Example #1
0
 def input_properties_changed(self,e):
     ind = self.ui.input_selector.currentIndex()
     if len(self.waterTableModel.waterData) == 0:
         water = iapws(P=0.1,T=300.14)
     else:
         water = self.waterTableModel.waterData[-1]
         
     if ind < 4:
         input1 = "Pressure"
         input1_unit = "[bar]"
         self.ui.input1.setText("%g" %(water.P*10))
         self.ui.input1.setValidator(self.positive_float_validator)
         if ind == 0:
             input2 = "Temperature"
             input2_unit = "[C]"
             self.ui.input2.setText("%g" %(water.T-273.14))
             self.ui.input2.setValidator(self.temperature_validator)
         elif ind == 1:
             input2 = "Enthalpy"
             input2_unit = "[kJ/kg]"
             self.ui.input2.setText("%g" %water.h)
             self.ui.input2.setValidator(self.positive_float_validator)
         elif ind == 2:
             input2 = "Enthropy"
             input2_unit = "[kJ/kg K]"
             self.ui.input2.setText("%g" %water.s)
             self.ui.input2.setValidator(self.positive_float_validator)
         elif ind == 3:
             input2 = "Quality"
             input2_unit = "[-]"
             self.ui.input2.setText("%g" %water.x)
             self.ui.input2.setValidator(self.unit_validator)
     elif ind == 4:
         input1 = "Temperature"
         input1_unit = "[C]"
         self.ui.input1.setText("%g" %(water.T-273.14))
         self.ui.input1.setValidator(self.temperature_validator)
         input2 = "Quality"
         input2_unit = "[-]"
         self.ui.input2.setText("%g" %water.x)
         self.ui.input2.setValidator(self.unit_validator)
     elif ind == 5:
         input1 = "Enthalpy"
         input1_unit = "[kJ/kg]"
         self.ui.input1.setText("%g" %water.h)
         self.ui.input1.setValidator(self.positive_float_validator)
         input2 = "Enthropy"
         input2_unit = "[kJ/kg K]"
         self.ui.input2.setText("%g" %water.s)
         self.ui.input2.setValidator(self.positive_float_validator)
     self.ui.label_input1.setText(input1)
     self.ui.label_input1_unit.setText(input1_unit)
     self.ui.label_input2.setText(input2)
     self.ui.label_input2_unit.setText(input2_unit)
Example #2
0
 def calculate_values_from_input(self,input1,input2):
     ind = self.ui.input_selector.currentIndex()
     try:
         if ind < 4:
             input1 /= 10.0 #convert bar to MPa
             if ind == 0:
                 water = iapws(P=input1,T=input2+273.14)
             elif ind == 1:
                 water = iapws(P=input1,h=input2)
             elif ind == 2:
                 water = iapws(P=input1,s=input2)
             elif ind == 3:
                 water = iapws(P=input1,x=input2)
         elif ind == 4:
             water = iapws(T=input1+273.14,x=input2)
         elif ind == 5:
             water = iapws(h=input1,s=input2)
     except NotImplementedError:
         QtGui.QMessageBox.warning(self,"Bad input",
         "You've input bad values either out of bounds or not yet implemented.",
                                   QtGui.QMessageBox.NoButton,
                                   QtGui.QMessageBox.Ok,
                                   QtGui.QMessageBox.NoButton)
     #Don't update if values are bad
     if not water.status:
         return
     self.waterTableModel.addWater(water)