def __init__(self, parent, case, default): """ Constructor """ QDialog.__init__(self, parent) Ui_ThermalRadiationAdvancedDialogForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.setWindowTitle(self.tr("Advanced options")) self.default = default self.result = self.default.copy() # Combo models self.modelTSRay = ComboModel(self.comboBoxTSRay, 3, 1) self.modelPrintT = ComboModel(self.comboBoxPrintT, 3, 1) self.modelPrintL = ComboModel(self.comboBoxPrintL, 3, 1) self.modelTSRay.addItem('0', '0') self.modelTSRay.addItem('1', '1') self.modelTSRay.addItem('2', '2') self.modelPrintT.addItem('0', '0') self.modelPrintT.addItem('1', '1') self.modelPrintT.addItem('2', '2') self.modelPrintL.addItem('0', '0') self.modelPrintL.addItem('1', '1') self.modelPrintL.addItem('2', '2') self.frequ = self.default['frequency'] self.tsr = self.default['idiver'] self.printTemp = self.default['tempP'] self.printLum = self.default['intensity'] model = self.default['model'] # Initialization self.lineEditFreq.setText(str(self.frequ)) self.modelTSRay.setItem(str_model=str(self.tsr)) self.modelPrintT.setItem(str_model=str(self.printTemp)) self.modelPrintL.setItem(str_model=str(self.printLum)) if model == 'dom': self.labelPrintL.show() self.comboBoxPrintL.show() else: self.labelPrintL.hide() self.comboBoxPrintL.hide() # Validator validatorFreq = IntValidator(self.lineEditFreq, min=1) self.lineEditFreq.setValidator(validatorFreq) self.case.undoStartGlobal()
def __init__(self, parent, case, default): """ Constructor """ QDialog.__init__(self, parent) Ui_TurbulenceAdvancedOptionsDialogForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() if default['model'] in ('k-epsilon', 'k-epsilon-PL'): title = self.tr("Options for k-epsilon model") elif default['model'] in ('Rij-epsilon', 'Rij-SSG', 'Rij-EBRSM'): title = self.tr("Options for Rij-epsilon model") elif default['model'] == 'k-omega-SST': title = self.tr("Options for k-omega-SST model") elif default['model'] == 'v2f-BL-v2/k': title = self.tr("Options for v2f-BL-v2/k model") elif default['model'] == 'Spalart-Allmaras': title = self.tr("Options for Spalart-Allmaras model") self.setWindowTitle(title) self.default = default self.result = self.default.copy() self.checkBoxGravity.setEnabled(True) self.comboBoxScales.setEnabled(True) if default['model'] == 'v2f-BL-v2/k' or \ default['model'] == 'Rij-EBRSM': self.modelScales = ComboModel(self.comboBoxScales, 1, 1) self.modelScales.addItem(self.tr("One scale model"), '0') self.comboBoxScales.setEnabled(False) elif default['model'] == 'Spalart-Allmaras': self.modelScales = ComboModel(self.comboBoxScales, 1, 1) self.modelScales.addItem(self.tr("One scale model"), '0') self.comboBoxScales.setEnabled(False) else: # Combo self.modelScales = ComboModel(self.comboBoxScales, 3, 1) self.modelScales.addItem(self.tr("One scale model"), '0') self.modelScales.addItem(self.tr("Two scale model"), '1') self.modelScales.addItem(self.tr("Scalable wall function"), '2') # Initialization of wall function model self.modelScales.setItem(str_model=str(self.result['scale_model'])) # Initialization of gravity terms if self.result['gravity_terms'] == 'on': self.checkBoxGravity.setChecked(True) else: self.checkBoxGravity.setChecked(False) self.case.undoStartGlobal()
def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.__model = MobileMeshModel(self.__case) self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1) self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary") self.__comboModel.addItem(self.tr("Sliding boundary"), "sliding_boundary") self.__comboModel.addItem(self.tr("Internal coupling"), "internal_coupling") self.__comboModel.addItem(self.tr("External coupling"), "external_coupling") self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity") self.__comboModel.addItem(self.tr("Fixed displacement"), "fixed_displacement") self.connect(self.comboMobilBoundary, SIGNAL("activated(const QString&)"), self.__slotCombo) self.connect(self.pushButtonMobilBoundary, SIGNAL("clicked(bool)"), self.__slotFormula) self.__case.undoStartGlobal()
def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.mdl = CompressibleModel(self.__case) # Connections self.connect(self.comboBoxTypeOutlet, SIGNAL("activated(const QString&)"), self.slotOutletType) self.connect(self.lineEditPressure, SIGNAL("textChanged(const QString &)"), self.slotPressureValue) # Combo models self.modelTypeOutlet = ComboModel(self.comboBoxTypeOutlet, 2, 1) self.modelTypeOutlet.addItem(self.tr("supersonic outlet"), 'supersonic_outlet') self.modelTypeOutlet.addItem(self.tr("subsonic outlet"), 'subsonic_outlet') # Validators validatorP = DoubleValidator(self.lineEditPressure, min = 0.0) # Apply validators self.lineEditPressure.setValidator(validatorP) self.__case.undoStartGlobal()
def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.connect(self.comboBoxTurbulence, SIGNAL("activated(const QString&)"), self.__slotChoiceTurbulence) self.__modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1) self.__modelTurbulence.addItem(self.tr("Calculation by hydraulic diameter"), 'hydraulic_diameter') self.__modelTurbulence.addItem(self.tr("Calculation by turbulent intensity"), 'turbulent_intensity') self.__modelTurbulence.addItem(self.tr("Calculation by formula"), 'formula') self.connect(self.lineEditDiameter, SIGNAL("textChanged(const QString &)"), self.__slotDiam) self.connect(self.lineEditIntensity, SIGNAL("textChanged(const QString &)"), self.__slotIntensity) self.connect(self.lineEditDiameterIntens, SIGNAL("textChanged(const QString &)"), self.__slotDiam) self.connect(self.pushButtonTurb, SIGNAL("clicked()"), self.__slotTurbulenceFormula) validatorDiam = DoubleValidator(self.lineEditDiameter, min=0.) validatorDiam.setExclusiveMin(True) validatorIntensity = DoubleValidator(self.lineEditIntensity, min=0.) self.lineEditDiameter.setValidator(validatorDiam) self.lineEditDiameterIntens.setValidator(validatorDiam) self.lineEditIntensity.setValidator(validatorIntensity) self.__case.undoStartGlobal()
def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() # Create the Page layout. # Combo self.modelRadiative = ComboModel(self.comboBoxRadiative,3,1) self.modelRadiative.addItem(self.tr("Gray or black wall\n"\ " and profile of fixed internal temperature"), 'itpimp') self.modelRadiative.addItem(self.tr("Gray or black wall\n"\ " and profile of fixed external temperature"), 'ipgrno') self.modelRadiative.addItem(self.tr("Gray or black wall\n"\ " and flux of fixed conduction"), 'ifgrno') # Validator validatorZone = IntValidator(self.lineEditZone, min=0) validatorZone.setExclusiveMin(True) self.lineEditZone.setValidator(validatorZone) # Connections self.connect(self.comboBoxRadiative, SIGNAL("activated(const QString&)"), self.slotRadiativeChoice) self.connect(self.lineEditZone, SIGNAL("textChanged(const QString &)"), self.slotZone) self.__case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DarcyForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DarcyModel(self.case) # ComboBox self.modelPermeability = ComboModel(self.comboBoxPermeability,2,1) self.modelDiffusion = ComboModel(self.comboBoxDiffusion,2,1) self.modelFlowType = ComboModel(self.comboBoxFlowType,2,1) self.modelCriterion = ComboModel(self.comboBoxCriterion,2,1) self.lineEditGx.setValidator(DoubleValidator(self.lineEditGx)) self.lineEditGy.setValidator(DoubleValidator(self.lineEditGy)) self.lineEditGz.setValidator(DoubleValidator(self.lineEditGz)) self.modelPermeability.addItem(self.tr("isotropic"), 'isotropic') self.modelPermeability.addItem(self.tr("anisotropic"), 'anisotropic') self.modelDiffusion.addItem(self.tr("isotropic"), 'isotropic') self.modelDiffusion.addItem(self.tr("anisotropic"), 'anisotropic') self.modelFlowType.addItem(self.tr("steady"), 'steady') self.modelFlowType.addItem(self.tr("unsteady"), 'unsteady') self.modelCriterion.addItem(self.tr("over pressure"), 'pressure') self.modelCriterion.addItem(self.tr("over velocity"), 'velocity') # Connections self.connect(self.comboBoxPermeability, SIGNAL("activated(const QString&)"), self.slotPermeabilityType) self.connect(self.comboBoxDiffusion, SIGNAL("activated(const QString&)"), self.slotDiffusionType) self.connect(self.comboBoxFlowType, SIGNAL("activated(const QString&)"), self.slotFlowType) self.connect(self.comboBoxCriterion, SIGNAL("activated(const QString&)"), self.slotCriterion) self.connect(self.checkBoxGravity, SIGNAL("clicked()"), self.slotGravity) self.connect(self.lineEditGx, SIGNAL("textChanged(const QString &)"), self.slotGravityX) self.connect(self.lineEditGy, SIGNAL("textChanged(const QString &)"), self.slotGravityY) self.connect(self.lineEditGz, SIGNAL("textChanged(const QString &)"), self.slotGravityZ) self.initializeWidget() self.case.undoStartGlobal()
def createEditor(self, parent, option, index): editor = QComboBox(parent) self.combo_mdl = ComboModel(editor,1,1) nature = index.model()._data[index.row()][1] self.dico = index.model().dicoM2V[nature] for k, v in list(self.dico.items()): self.combo_mdl.addItem(v, k) editor.installEventFilter(self) editor.setMinimumWidth(100) return editor
class ParticleBoundaryInteractionDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(ParticleBoundaryInteractionDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.combo_mdl = ComboModel(editor,1,1) nature = index.model()._data[index.row()][1] self.dico = index.model().dicoM2V[nature] for k, v in list(self.dico.items()): self.combo_mdl.addItem(v, k) editor.installEventFilter(self) editor.setMinimumWidth(100) return editor def setEditorData(self, comboBox, index): row = index.row() col = index.column() str_model = index.model()._data[row][col] self.combo_mdl.setItem(str_model=str_model) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.combo_mdl.dicoV2M[txt] selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole) def tr(self, text): return text
class VarianceDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(VarianceDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, editor, index): l1 = index.model().mdl.getScalarNameList() for label in index.model().mdl.getThermalScalarName(): l1.append(label) for s in index.model().mdl.getScalarsVarianceList(): if s in l1: l1.remove(s) for s in l1: self.modelCombo.addItem(s, s) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] model.setData(index, to_qvariant(value), Qt.DisplayRole) def tr(self, text): """ Translation """ return text
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_GasCombustionForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = GasCombustionModel(self.case) # Set models and number of elements for combo boxes self.modelGasCombustionOption = ComboModel(self.comboBoxGasCombustionOption,1,1) # Connections self.connect(self.comboBoxGasCombustionOption, SIGNAL("activated(const QString&)"), self.slotGasCombustionOption) self.connect(self.pushButtonThermochemistryData, SIGNAL("pressed()"), self.__slotSearchThermochemistryData) # Initialize Widgets model = self.mdl.getGasCombustionModel() if model == 'd3p': self.modelGasCombustionOption.addItem(self.tr("adiabatic model"), "adiabatic") self.modelGasCombustionOption.addItem(self.tr("non adiabatic model"), "extended") elif model == 'ebu': self.modelGasCombustionOption.addItem(self.tr("reference Spalding model"), "spalding") self.modelGasCombustionOption.addItem(self.tr("extended model with enthalpy source term"), "enthalpy_st") self.modelGasCombustionOption.addItem(self.tr("extended model with mixture fraction transport"), "mixture_st") self.modelGasCombustionOption.addItem(self.tr("extended model with enthalpy and mixture fraction transport"), "enthalpy_mixture_st") elif model == 'lwp': self.modelGasCombustionOption.addItem(self.tr("reference two-peak model with adiabatic condition"), "2-peak_adiabatic") self.modelGasCombustionOption.addItem(self.tr("reference two-peak model with enthalpy source term"), "2-peak_enthalpy") self.modelGasCombustionOption.addItem(self.tr("reference three-peak model with adiabatic condition"), "3-peak_adiabatic") self.modelGasCombustionOption.addItem(self.tr("reference three-peak model with enthalpy source term"), "3-peak_enthalpy") self.modelGasCombustionOption.addItem(self.tr("reference four-peak model with adiabatic condition"), "4-peak_adiabatic") self.modelGasCombustionOption.addItem(self.tr("reference four-peak model with enthalpy source term"), "4-peak_enthalpy") option = self.mdl.getGasCombustionOption() self.modelGasCombustionOption.setItem(str_model= option) name = self.mdl.getThermoChemistryDataFileName() if name != None: self.labelThermochemistryFile.setText(str(name)) setGreenColor(self.pushButtonThermochemistryData, False) else: setGreenColor(self.pushButtonThermochemistryData, True) self.case.undoStartGlobal()
def __init__(self, parent): """ Constructor """ QDialog.__init__(self, parent) Ui_BatchRunningAdvancedOptionsDialogForm.__init__(self) self.setupUi(self) self.setWindowTitle(self.tr("Advanced options")) self.parent = parent # Combo models self.modelCSOUT1 = ComboModel(self.comboBox_6, 2, 1) self.modelCSOUT2 = ComboModel(self.comboBox_7, 3, 1) # Combo items self.modelCSOUT1.addItem(self.tr("to standard output"), 'stdout') self.modelCSOUT1.addItem(self.tr("to listing"), 'listing') self.modelCSOUT2.addItem(self.tr("no output"), 'null') self.modelCSOUT2.addItem(self.tr("to standard output"), 'stdout') self.modelCSOUT2.addItem(self.tr("to listing_n<p>"), 'listing') # Connections self.connect(self.toolButton_2, SIGNAL("clicked()"), self.slotSearchFile) self.connect(self.lineEdit_3, SIGNAL("textChanged(const QString &)"), self.slotValgrind) self.connect(self.comboBox_6, SIGNAL("activated(const QString&)"), self.slotLogType) self.connect(self.comboBox_7, SIGNAL("activated(const QString&)"), self.slotLogType) # Previous values self.valgrind = self.parent.mdl.getString('valgrind') if self.valgrind is not None: self.lineEdit_3.setText(str(self.valgrind)) self.setLogType()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_PorosityForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = PorosityModel(self.case) # Create the Page layout. # Model and QTreeView for Head Losses self.modelPorosity = StandardItemModelPorosity() self.treeView.setModel(self.modelPorosity) # Combo model self.modelPorosityType = ComboModel(self.comboBoxType, 2, 1) self.modelPorosityType.addItem(self.tr("isotropic"), 'isotropic') self.modelPorosityType.addItem(self.tr("anisotropic"), 'anisotropic') # Connections self.connect(self.treeView, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectPorosityZones) self.connect(self.comboBoxType, SIGNAL("activated(const QString&)"), self.slotPorosity) self.connect(self.pushButtonPorosity, SIGNAL("clicked()"), self.slotFormulaPorosity) # Initialize Widgets self.entriesNumber = -1 d = self.mdl.getNameAndLocalizationZone() liste=[] liste=list(d.items()) t=[] for t in liste : NamLoc=t[1] Lab=t[0 ] self.modelPorosity.insertItem(Lab, NamLoc[0],NamLoc[1]) self.forgetStandardWindows() self.case.undoStartGlobal()
def __init__(self, parent, case, browser): """ Constructor """ QWidget.__init__(self, parent) Ui_MobileMeshForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = MobileMeshModel(self.case) self.browser = browser # Combo model VISCOSITY self.modelVISCOSITY = ComboModel(self.comboBoxVISCOSITY,2,1) self.modelVISCOSITY.addItem(self.tr("isotropic"), 'isotrop') self.modelVISCOSITY.addItem(self.tr("orthotropic"), 'orthotrop') # Connections self.connect(self.groupBoxALE, SIGNAL("clicked(bool)"), self.slotMethod) self.connect(self.lineEditNALINF, SIGNAL("textChanged(const QString &)"), self.slotNalinf) self.connect(self.comboBoxVISCOSITY, SIGNAL("activated(const QString&)"), self.slotViscosityType) self.connect(self.pushButtonFormula, SIGNAL("clicked(bool)"), self.slotFormula) # Validators validatorNALINF = IntValidator(self.lineEditNALINF, min=0) self.lineEditNALINF.setValidator(validatorNALINF) if self.mdl.getMethod() == 'on': self.groupBoxALE.setChecked(True) checked = True else: self.groupBoxALE.setChecked(False) checked = False self.slotMethod(checked) # Enable / disable formula state setGreenColor(self.pushButtonFormula, False) self.case.undoStartGlobal()
class GGDHDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, case): super(GGDHDelegate, self).__init__(parent) self.parent = parent self.case = case def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor def setEditorData(self, editor, index): self.modelCombo.addItem(self.tr("SGDH"), "SGDH") if TurbulenceModel(self.case).getTurbulenceModel() == "Rij-epsilon" or \ TurbulenceModel(self.case).getTurbulenceModel() == "Rij-SSG" or \ TurbulenceModel(self.case).getTurbulenceModel() == "Rij-EBRSM": self.modelCombo.addItem(self.tr("GGDH"), "GGDH") self.modelCombo.addItem(self.tr("AFM"), "AFM") self.modelCombo.addItem(self.tr("DFM"), "DFM") def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] model.setData(index, to_qvariant(value), Qt.DisplayRole) def tr(self, text): """ Translation """ return text
def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.mdl = CompressibleModel(self.__case) self.gas = GasCombustionModel(self.__case) # Connections self.connect(self.comboBoxVelocity, SIGNAL("activated(const QString&)"), self.__slotChoiceVelocity) self.connect(self.lineEditVelocity, SIGNAL("textChanged(const QString &)"), self.__slotVelocityValue) self.connect(self.comboBoxDirection, SIGNAL("activated(const QString&)"), self.__slotChoiceDirection) self.connect(self.lineEditDirectionX, SIGNAL("textChanged(const QString &)"), self.__slotDirX) self.connect(self.lineEditDirectionY, SIGNAL("textChanged(const QString &)"), self.__slotDirY) self.connect(self.lineEditDirectionZ, SIGNAL("textChanged(const QString &)"), self.__slotDirZ) self.connect(self.comboBoxTypeInlet, SIGNAL("activated(const QString&)"), self.__slotInletType) self.connect(self.checkBoxPressure, SIGNAL("clicked()"), self.__slotPressure) self.connect(self.checkBoxDensity, SIGNAL("clicked()"), self.__slotDensity) self.connect(self.checkBoxTemperature, SIGNAL("clicked()"), self.__slotTemperature) self.connect(self.checkBoxEnergy, SIGNAL("clicked()"), self.__slotEnergy) self.connect(self.lineEditPressure, SIGNAL("textChanged(const QString &)"), self.__slotPressureValue) self.connect(self.lineEditDensity, SIGNAL("textChanged(const QString &)"), self.__slotDensityValue) self.connect(self.lineEditTotalPressure, SIGNAL("textChanged(const QString &)"), self.__slotTotalPressure) self.connect(self.lineEditTotalEnthalpy, SIGNAL("textChanged(const QString &)"), self.__slotTotalEnthalpy) self.connect(self.lineEditTemperature, SIGNAL("textChanged(const QString &)"), self.__slotTemperatureValue) self.connect(self.lineEditEnergy, SIGNAL("textChanged(const QString &)"), self.__slotEnergyValue) self.connect(self.comboBoxTypeInletGasComb, SIGNAL("activated(const QString&)"), self.__slotInletTypeGasComb) self.connect(self.lineEditTemperatureGasComb, SIGNAL("textChanged(const QString &)"), self.__slotTemperatureGasComb) self.connect(self.lineEditFraction, SIGNAL("textChanged(const QString &)"), self.__slotMeanMixtureFraction) # Combo models self.modelVelocity = ComboModel(self.comboBoxVelocity, 6, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("volumic flow rate"), 'flow2') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelVelocity.addItem(self.tr("volumic flow rate (user law)"), 'flow2_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal direction to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("imposed inlet"), 'imposed_inlet') self.modelTypeInlet.addItem(self.tr("subsonic inlet (imposed total pressure and total enthalpy)"), 'subsonic_inlet_PH') self.modelTypeInletGasComb = ComboModel(self.comboBoxTypeInletGasComb, 2, 1) model = self.gas.getGasCombustionModel() if model == 'lwp' or model =='ebu': self.modelTypeInletGasComb.addItem(self.tr("Unburned gas"), 'unburned') self.modelTypeInletGasComb.addItem(self.tr("Burned gas"), 'burned') elif model == 'd3p': self.modelTypeInletGasComb.addItem(self.tr("Oxydant"), 'oxydant') self.modelTypeInletGasComb.addItem(self.tr("Fuel"), 'fuel') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorP = DoubleValidator(self.lineEditPressure, min = 0.0) validatorD = DoubleValidator(self.lineEditDensity, min = 0.0) validatorT = DoubleValidator(self.lineEditTemperature, min = 0.0) validatorE = DoubleValidator(self.lineEditEnergy, min = 0.0) validatorP2 = DoubleValidator(self.lineEditTotalPressure, min = 0.0) validatorH2 = DoubleValidator(self.lineEditTotalEnthalpy, min = 0.0) validatorTemp = DoubleValidator(self.lineEditTemperatureGasComb, min=0.) validatorFrac = DoubleValidator(self.lineEditFraction, min=0., max=1.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditPressure.setValidator(validatorP) self.lineEditDensity.setValidator(validatorD) self.lineEditTemperature.setValidator(validatorT) self.lineEditEnergy.setValidator(validatorE) self.lineEditTotalPressure.setValidator(validatorP2) self.lineEditTotalEnthalpy.setValidator(validatorH2) self.lineEditTemperatureGasComb.setValidator(validatorTemp) self.lineEditFraction.setValidator(validatorFrac) self.connect(self.pushButtonVelocityFormula, SIGNAL("clicked()"), self.__slotVelocityFormula) self.connect(self.pushButtonDirectionFormula, SIGNAL("clicked()"), self.__slotDirectionFormula) self.__case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundariesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.modelBoundaries = StandardItemModelBoundaries(self.case, self.model) self.tableViewBoundaries.setModel(self.modelBoundaries) self.tableViewBoundaries.setAlternatingRowColors(True) self.tableViewBoundaries.horizontalHeader().setResizeMode(QHeaderView.Stretch) delegateInteraction = ParticleBoundaryInteractionDelegate(self.tableViewBoundaries) delegateClassNumber = ValueDelegate(self.tableViewBoundaries) self.tableViewBoundaries.setItemDelegateForColumn(2,delegateInteraction) self.tableViewBoundaries.setItemDelegateForColumn(3,delegateClassNumber) self.modelIPOIT = ComboModel(self.comboBoxIPOIT,3,1) self.modelIPOIT.addItem(self.tr("Volumic flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIPOIT.addItem(self.tr("User defined statistical weight"), "subroutine") self.modelIJUVW = ComboModel(self.comboBoxIJUVW,4,1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJUVW.addItem(self.tr("User defined velocity"), "subroutine") self.modelIJRTP = ComboModel(self.comboBoxIJRTP,2,1) self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") self.modelIJRTP.addItem(self.tr("User defined temperature"), "subroutine") self.modelIJRDP = ComboModel(self.comboBoxIJRDP,2,1) self.modelIJRDP.addItem(self.tr("Diameter set by values"), "prescribed") self.modelIJRDP.addItem(self.tr("User defined diameter"), "subroutine") self.modelIRAWCL = ComboModel(self.comboBoxIRAWCL,2,1) self.modelIRAWCL.addItem(self.tr("Raw coal"), "raw_coal_as_received") self.modelIRAWCL.addItem(self.tr("User defined"), "subroutine") self.connect(self.tableViewBoundaries, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectBoundary) self.connect(self.modelBoundaries, SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), self.dataChanged) self.connect(self.spinBoxICLAS, SIGNAL("valueChanged(int)"), self.slotICLAS) self.connect(self.lineEditIJNBP, SIGNAL("textChanged(const QString &)"), self.slotIJNBP) self.connect(self.lineEditIJFRE, SIGNAL("textChanged(const QString &)"), self.slotIJFRE) self.connect(self.lineEditICLST, SIGNAL("textChanged(const QString &)"), self.slotICLST) self.connect(self.lineEditIDEBT, SIGNAL("textChanged(const QString &)"), self.slotIDEBT) self.connect(self.comboBoxIPOIT, SIGNAL("activated(const QString&)"), self.slotIPOITChoice) self.connect(self.lineEditIPOIT, SIGNAL("textChanged(const QString &)"), self.slotIPOIT) self.connect(self.lineEditIROPT, SIGNAL("textChanged(const QString &)"), self.slotIROPT) self.connect(self.comboBoxIJUVW, SIGNAL("activated(const QString&)"), self.slotIJUVW) self.connect(self.lineEditIUNO, SIGNAL("textChanged(const QString &)"), self.slotIUNO) self.connect(self.lineEditIUPT, SIGNAL("textChanged(const QString &)"), self.slotIUPT) self.connect(self.lineEditIVPT, SIGNAL("textChanged(const QString &)"), self.slotIVPT) self.connect(self.lineEditIWPT, SIGNAL("textChanged(const QString &)"), self.slotIWPT) self.connect(self.comboBoxIJRTP, SIGNAL("activated(const QString&)"), self.slotIJRTP) self.connect(self.lineEditITPT, SIGNAL("textChanged(const QString &)"), self.slotITPT) self.connect(self.lineEditICPT, SIGNAL("textChanged(const QString &)"), self.slotICPT) self.connect(self.lineEditIEPSI, SIGNAL("textChanged(const QString &)"), self.slotIEPSI) self.connect(self.comboBoxIJRDP, SIGNAL("activated(const QString&)"), self.slotIJRDP) self.connect(self.lineEditIDPT, SIGNAL("textChanged(const QString &)"), self.slotIDPT) self.connect(self.lineEditIVDPT, SIGNAL("textChanged(const QString &)"), self.slotIVDPT) self.connect(self.lineEditINUCHL, SIGNAL("textChanged(const QString &)"), self.slotINUCHL) self.connect(self.lineEditIHPT, SIGNAL("textChanged(const QString &)"), self.slotIHPT) self.connect(self.comboBoxIRAWCL, SIGNAL("activated(const QString&)"), self.slotIRAWCL) # Validators validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) self._hideAllWidgets() self.case.undoStartGlobal()
class LagrangianBoundariesView(QWidget, Ui_LagrangianBoundariesForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundariesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.modelBoundaries = StandardItemModelBoundaries( self.case, self.model) self.tableViewBoundaries.setModel(self.modelBoundaries) self.tableViewBoundaries.setAlternatingRowColors(True) if QT_API == "PYQT4": self.tableViewBoundaries.horizontalHeader().setResizeMode( QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewBoundaries.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) delegateInteraction = ParticleBoundaryInteractionDelegate( self.tableViewBoundaries) delegateSetNumber = ValueDelegate(self.tableViewBoundaries) self.tableViewBoundaries.setItemDelegateForColumn( 2, delegateInteraction) self.tableViewBoundaries.setItemDelegateForColumn(3, delegateSetNumber) self.modelIPOIT = ComboModel(self.comboBoxIPOIT, 2, 1) self.modelIPOIT.addItem(self.tr("Mass flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIJUVW = ComboModel(self.comboBoxIJUVW, 3, 1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJRTP = ComboModel(self.comboBoxIJRTP, 2, 1) self.modelIJRTP.addItem(self.tr("Fluid temperature"), "fluid") self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") self.tableViewBoundaries.clicked[QModelIndex].connect( self.slotSelectBoundary) self.modelBoundaries.dataChanged.connect(self.dataChanged) self.spinBoxICLAS.valueChanged[int].connect(self.slotICLAS) self.lineEditIJNBP.textChanged[str].connect(self.slotIJNBP) self.lineEditIJFRE.textChanged[str].connect(self.slotIJFRE) self.lineEditICLST.textChanged[str].connect(self.slotICLST) self.lineEditIDEBT.textChanged[str].connect(self.slotIDEBT) self.comboBoxIPOIT.activated[str].connect(self.slotIPOITChoice) self.lineEditIPOIT.textChanged[str].connect(self.slotIPOIT) self.lineEditIROPT.textChanged[str].connect(self.slotIROPT) self.lineEditIRCOLM.textChanged[str].connect(self.slotIRCOLM) self.comboBoxIJUVW.activated[str].connect(self.slotIJUVW) self.lineEditIUNO.textChanged[str].connect(self.slotIUNO) self.lineEditIUPT.textChanged[str].connect(self.slotIUPT) self.lineEditIVPT.textChanged[str].connect(self.slotIVPT) self.lineEditIWPT.textChanged[str].connect(self.slotIWPT) self.comboBoxIJRTP.activated[str].connect(self.slotIJRTP) self.lineEditITPT.textChanged[str].connect(self.slotITPT) self.lineEditICPT.textChanged[str].connect(self.slotICPT) self.lineEditIEPSI.textChanged[str].connect(self.slotIEPSI) self.lineEditIDPT.textChanged[str].connect(self.slotIDPT) self.lineEditIVDPT.textChanged[str].connect(self.slotIVDPT) self.lineEditINUCHL.textChanged[str].connect(self.slotINUCHL) self.lineEditIHPT.textChanged[str].connect(self.slotIHPT) # Validators validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIRCOLM = DoubleValidator(self.lineEditIRCOLM, min=0.) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIRCOLM.setValidator(validatorIRCOLM) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) self._hideAllWidgets() self.case.undoStartGlobal() def _hideAllWidgets(self): self.groupBoxSetNumber.hide() self.groupBoxMain.hide() self.groupBoxRate.hide() self.groupBoxVelocity.hide() self.groupBoxTemperature.hide() self.groupBoxDiameter.hide() self.groupBoxCoal.hide() @pyqtSlot("QModelIndex") def slotSelectBoundary(self, index): """ """ self._hideAllWidgets() label, nature, interaction, n_sets = self.modelBoundaries.getItem( index.row()) self.label = label if interaction != "inlet": return self.model.setCurrentBoundaryNode(nature, label) if n_sets > 0: self.groupBoxSetNumber.show() self.spinBoxICLAS.setMinimum(1) self.spinBoxICLAS.setMaximum(n_sets) self.spinBoxICLAS.setValue(1) self.slotICLAS(1) def dataChanged(self, topLeft, bottomRight): """ """ self.slotSelectBoundary(topLeft) @pyqtSlot(int) def slotICLAS(self, iset): """ Input ICLAS. """ self.iset = iset index = self.tableViewBoundaries.currentIndex() label, nature, interaction, n_sets = self.modelBoundaries.getItem( index.row()) if interaction == "inlet": self.model.setCurrentSetNode(self.label, iset) self.LM = LagrangianModel(self.case) part_model = self.LM.getParticlesModel() # Main variables self.groupBoxMain.show() npart = self.model.getNumberOfParticulesInSetValue( self.label, self.iset) self.lineEditIJNBP.setText(str(npart)) freq = self.model.getInjectionFrequencyValue(self.label, self.iset) self.lineEditIJFRE.setText(str(freq)) self.LSM = LagrangianStatisticsModel(self.case) if self.LSM.getGroupOfParticlesValue() > 0: igroup = self.model.getParticleGroupNumberValue( self.label, self.iset) self.lineEditICLST.setText(str(igroup)) self.labelICLST.show() self.lineEditICLST.show() else: self.labelICLST.hide() self.lineEditICLST.hide() # Rate / stat. weight self.groupBoxRate.show() choice = self.model.getStatisticalWeightChoice(self.label, self.iset) self.modelIPOIT.setItem(str_model=choice) text = self.modelIPOIT.dicoM2V[choice] self.slotIPOITChoice(text) # Velocity self.groupBoxVelocity.show() choice = self.model.getVelocityChoice(self.label, self.iset) self.modelIJUVW.setItem(str_model=choice) text = self.modelIJUVW.dicoM2V[choice] self.slotIJUVW(text) # Fouling colm = self.model.getFoulingIndexValue(self.label, self.iset) self.lineEditIRCOLM.setText(str(colm)) # Temperature status = self.LM.getHeating() if part_model == "thermal" and status == "on": self.groupBoxTemperature.show() choice = self.model.getTemperatureChoice(self.label, self.iset) self.modelIJRTP.setItem(str_model=choice) text = self.modelIJRTP.dicoM2V[choice] self.slotIJRTP(text) cp = self.model.getSpecificHeatValue(self.label, self.iset) self.lineEditICPT.setText(str(cp)) eps = self.model.getEmissivityValue(self.label, self.iset) self.lineEditIEPSI.setText(str(eps)) # Coals if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.groupBoxCoal.show() icoal = self.model.getCoalNumberValue(self.label, self.iset) self.lineEditINUCHL.setText(str(icoal)) temp = self.model.getCoalTemperatureValue(self.label, self.iset) self.lineEditIHPT.setText(str(temp)) # Diameter self.groupBoxDiameter.show() diam = self.model.getDiameterValue(self.label, self.iset) vdiam = self.model.getDiameterVarianceValue(self.label, self.iset) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) #Coal if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.labelIROPT.hide() self.labelUnitIROPT.hide() self.lineEditIROPT.hide()
class MainFieldsSourceTermsView(QWidget, Ui_MainFieldsSourceTerms): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_MainFieldsSourceTerms.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.parent = parent self.mdl = MainFieldsSourceTermsModel(self.case) self.mfm = MainFieldsModel(self.case) self.notebook = NotebookModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) # 0/ Read label names from XML file # Velocity # Thermal scalar self.th_sca_name = 'enthalpy' # 1/ Combo box models self.modelZone = ComboModel(self.comboBoxZone, 1, 1) self.zone = "" zones = self.volzone.getZones() for zone in zones: active = 0 if ('thermal_source_term' in zone.getNature().keys()): if (zone.getNature()['thermal_source_term'] == "on"): active = 1 if (active): label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelZone.setItem(str_model=self.zone) self.modelField = ComboModel(self.comboBoxField, 1, 1) for fieldId in self.mfm.getFieldIdList(): label = self.mfm.getLabel(fieldId) name = str(fieldId) self.modelField.addItem(self.tr(label), name) self.currentId = -1 if len(self.mfm.getFieldIdList()) > 0: self.currentId = self.mfm.getFieldIdList()[0] self.modelField.setItem(str_model=self.currentId) # 2/ Connections self.comboBoxZone.activated[str].connect(self.slotZone) self.comboBoxField.activated[str].connect(self.slotField) self.pushButtonThermal.clicked.connect(self.slotThermalFormula) # 3/ Initialize widget self.initialize(self.zone) self.case.undoStartGlobal()
class DarcyLawView(QWidget, Ui_DarcyLawForm): def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DarcyLawForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DarcyLawModel(self.case) self.list_scalars = [] self.m_sca = DefineUserScalarsModel(self.case) for s in self.m_sca.getUserScalarNameList(): self.list_scalars.append((s, self.tr("Additional scalar"))) # Create the Page layout. # Model and QTreeView for Head Losses self.modelDarcyLaw = StandardItemModelDarcyLaw() self.treeView.setModel(self.modelDarcyLaw) # Combo model self.modelDarcyLawType = ComboModel(self.comboBoxType, 2, 1) self.modelDarcyLawType.addItem(self.tr("User law"), 'user') self.modelDarcyLawType.addItem(self.tr("Van Genuchten law"), 'VanGenuchten') self.modelNameDiff = ComboModel(self.comboBoxNameDiff,1,1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('variable'), 'variable') # Set up validators self.lineEditKs.setValidator(DoubleValidator(self.lineEditKs)) self.lineEditThetas.setValidator(DoubleValidator(self.lineEditThetas)) self.lineEditThetar.setValidator(DoubleValidator(self.lineEditThetar)) self.lineEditN.setValidator(DoubleValidator(self.lineEditN)) self.lineEditL.setValidator(DoubleValidator(self.lineEditL)) self.lineEditAlpha.setValidator(DoubleValidator(self.lineEditAlpha)) self.lineEditLongitudinal.setValidator(DoubleValidator(self.lineEditLongitudinal)) self.lineEditTransverse.setValidator(DoubleValidator(self.lineEditTransverse)) self.scalar = "" scalar_list = self.m_sca.getUserScalarNameList() for s in self.m_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for scalar in scalar_list: self.modelNameDiff.addItem(scalar) # Connections self.connect(self.treeView, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectDarcyLawZones) self.connect(self.comboBoxType, SIGNAL("activated(const QString&)"), self.slotDarcyLaw) self.connect(self.lineEditKs, SIGNAL("textChanged(const QString &)"), self.slotKs) self.connect(self.lineEditThetas, SIGNAL("textChanged(const QString &)"), self.slotThetas) self.connect(self.lineEditThetar, SIGNAL("textChanged(const QString &)"), self.slotThetar) self.connect(self.lineEditN, SIGNAL("textChanged(const QString &)"), self.slotN) self.connect(self.lineEditL, SIGNAL("textChanged(const QString &)"), self.slotL) self.connect(self.lineEditAlpha, SIGNAL("textChanged(const QString &)"), self.slotAlpha) self.connect(self.lineEditLongitudinal, SIGNAL("textChanged(const QString &)"), self.slotLongitudinal) self.connect(self.lineEditTransverse, SIGNAL("textChanged(const QString &)"), self.slotTransverse) self.connect(self.pushButtonUserLaw, SIGNAL("clicked()"), self.slotFormula) self.connect(self.comboBoxNameDiff, SIGNAL("activated(const QString&)"), self.slotNameDiff) self.connect(self.comboBoxDiff, SIGNAL("activated(const QString&)"), self.slotStateDiff) self.connect(self.pushButtonDiff, SIGNAL("clicked()"), self.slotFormulaDiff) # Initialize Widgets self.entriesNumber = -1 d = self.mdl.getNameAndLocalizationZone() liste=[] liste=list(d.items()) t=[] for t in liste : NamLoc=t[1] Lab=t[0 ] self.modelDarcyLaw.insertItem(Lab, NamLoc[0],NamLoc[1]) self.forgetStandardWindows() self.case.undoStartGlobal() @pyqtSignature("const QModelIndex&") def slotSelectDarcyLawZones(self, index): label, name, local = self.modelDarcyLaw.getItem(index.row()) if hasattr(self, "modelScalars"): del self.modelScalars log.debug("slotSelectDarcyLawZones label %s " % label ) self.groupBoxType.show() choice = self.mdl.getDarcyLawModel(name) self.modelDarcyLawType.setItem(str_model=choice) if choice == "user": self.groupBoxVanGenuchten.hide() self.groupBoxUser.show() setGreenColor(self.pushButtonUserLaw, True) else: self.groupBoxVanGenuchten.show() self.groupBoxUser.hide() self.initializeVanGenuchten(name) if DarcyModel(self.case).getDiffusionType() == 'anisotropic': self.groupBoxAnisotropicDiffusion.show() value = self.mdl.getDiffusionCoefficient(name, "longitudinal") self.lineEditLongitudinal.setText(str(value)) value = self.mdl.getDiffusionCoefficient(name, "transverse") self.lineEditTransverse.setText(str(value)) if self.scalar == "": self.groupBoxDiff.hide() else : self.groupBoxDiff.show() diff_choice = self.mdl.getScalarDiffusivityChoice(self.scalar, name) self.modelDiff.setItem(str_model=diff_choice) self.modelNameDiff.setItem(str_model=str(self.scalar)) if diff_choice != 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) # force to variable property self.comboBoxDiff.setEnabled(False) self.entriesNumber = index.row() def initializeVanGenuchten(self, name): """ initialize variables for groupBoxVanGenuchten """ value = self.mdl.getValue(name, "ks") self.lineEditKs.setText(str(value)) value = self.mdl.getValue(name, "thetas") self.lineEditThetas.setText(str(value)) value = self.mdl.getValue(name, "thetar") self.lineEditThetar.setText(str(value)) value = self.mdl.getValue(name, "n") self.lineEditN.setText(str(value)) value = self.mdl.getValue(name, "l") self.lineEditL.setText(str(value)) value = self.mdl.getValue(name, "alpha") self.lineEditAlpha.setText(str(value)) def forgetStandardWindows(self): """ For forget standard windows """ self.groupBoxType.hide() self.groupBoxUser.hide() self.groupBoxVanGenuchten.hide() self.groupBoxAnisotropicDiffusion.hide() self.groupBoxDiff.hide() @pyqtSignature("const QString &") def slotDarcyLaw(self, text): """ Method to call 'getState' with correct arguements for 'rho' """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) choice = self.modelDarcyLawType.dicoV2M[str(text)] self.mdl.setDarcyLawModel(name, choice) if choice == "user": self.groupBoxVanGenuchten.hide() self.groupBoxUser.show() setGreenColor(self.pushButtonUserLaw, True) else: self.groupBoxVanGenuchten.show() self.groupBoxUser.hide() self.initializeVanGenuchten(name) @pyqtSignature("const QString&") def slotKs(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "ks", val) @pyqtSignature("const QString&") def slotThetas(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "thetas", val) @pyqtSignature("const QString&") def slotThetar(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "thetar", val) @pyqtSignature("const QString&") def slotN(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "n", val) @pyqtSignature("const QString&") def slotL(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "l", val) @pyqtSignature("const QString&") def slotAlpha(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setValue(name, "alpha", val) @pyqtSignature("const QString&") def slotLongitudinal(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setDiffusionCoefficient(name, "longitudinal", val) @pyqtSignature("const QString&") def slotTransverse(self, text): """ """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) if self.sender().validator().state == QValidator.Acceptable: val = float(text) self.mdl.setDiffusionCoefficient(name, "transverse", val) @pyqtSignature("") def slotFormula(self): """ User formula for darcy functions """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) exp = self.mdl.getDarcyLawFormula(name) if exp == None: exp = self.getDefaultDarcyLawFormula(choice) if DarcyModel(self.case).getPermeabilityType() == 'anisotropic': req = [('capacity', 'Capacity'), ('saturation', 'Saturation'), ('permeability[XX]', 'Permeability'), ('permeability[YY]', 'Permeability'), ('permeability[ZZ]', 'Permeability'), ('permeability[XY]', 'Permeability'), ('permeability[XZ]', 'Permeability'), ('permeability[YZ]', 'Permeability')] else: req = [('capacity', 'Capacity'), ('saturation', 'Saturation'), ('permeability', 'Permeability')] exa = """#example: \n""" + self.mdl.getDefaultDarcyLawFormula() sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormula -> %s" % str(result)) self.mdl.setDarcyLawFormula(name, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString &") def slotNameDiff(self, text): """ Method to set the variance scalar choosed """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) choice = self.modelNameDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) self.scalar = str(text) self.modelDiff.setItem(str_model=self.mdl.getScalarDiffusivityChoice(self.scalar, name)) setGreenColor(self.pushButtonDiff, True) @pyqtSignature("const QString &") def slotStateDiff(self, text): """ Method to set diffusion choice for the coefficient """ label, name, local = self.modelDarcyLaw.getItem(self.entriesNumber) choice = self.modelDiff.dicoV2M[str(text)] log.debug("slotStateDiff -> %s" % (text)) if choice != 'variable': self.pushButtonDiff.setEnabled(False) setGreenColor(self.pushButtonDiff, False) else: self.pushButtonDiff.setEnabled(True) setGreenColor(self.pushButtonDiff, True) self.mdl.setScalarDiffusivityChoice(self.scalar, name, choice) @pyqtSignature("") def slotFormulaDiff(self): """ User formula for the diffusion coefficient """ label, namesca, local = self.modelDarcyLaw.getItem(self.entriesNumber) name = self.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.getDiffFormula(self.scalar, namesca) delay_name = str(self.scalar) + "_delay" req = [(str(name), str(self.scalar) + ' diffusion coefficient'), (delay_name, str(self.scalar)+ ' delay')] exa = '' sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate'), ('saturation', 'saturation')] sym.append((str(self.scalar),str(self.scalar))) dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaDiff -> %s" % str(result)) self.mdl.setDiffFormula(self.scalar, namesca, result) setGreenColor(self.pushButtonDiff, False) def tr(self, text): """ Translation """ return text
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_GlobalNumericalParameters.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = GlobalNumericalParametersModel(self.case) # Combo model self.modelVelocityAlgorithm = ComboModel( self.comboBoxVelocityAlgorithm, 3, 1) self.modelVelocityAlgorithm.addItem(self.tr("Standard"), "standard_difvit") self.modelVelocityAlgorithm.addItem(self.tr("Coupled"), "coupled_difvitc") self.modelVelocityAlgorithm.addItem( self.tr("Mean velocity - relative velocity"), "mean_velocity_relative_velocity") mfm = MainFieldsModel(self.case) if len(mfm.getFieldIdList()) < 2: self.modelVelocityAlgorithm.disableItem(2) else: self.modelVelocityAlgorithm.enableItem(2) # Validator validatorMaxRestart = IntValidator(self.lineEditMaxRestart, min=0) validatorSplitting = DoubleValidator(self.lineEditTimeSplitting, min=0.) validatorPRelax = DoubleValidator(self.lineEditPressureRelaxation, min=0.) validatorMinP = DoubleValidator(self.lineEditMinimumPressure) validatorMaxP = DoubleValidator(self.lineEditMaximumPressure) validatorMaxRestart.setExclusiveMin(False) validatorSplitting.setExclusiveMin(True) validatorPRelax.setExclusiveMin(True) self.lineEditMaxRestart.setValidator(validatorMaxRestart) self.lineEditTimeSplitting.setValidator(validatorSplitting) self.lineEditPressureRelaxation.setValidator(validatorPRelax) self.lineEditMinimumPressure.setValidator(validatorMinP) self.lineEditMaximumPressure.setValidator(validatorMaxP) # Connections self.checkBoxRestart.clicked.connect(self.slotRestart) self.checkBoxPotentialState.clicked.connect(self.slotPotentialState) self.checkBoxFacesReconstruction.clicked.connect( self.slotFacesReconstruction) self.checkBoxMultigrid.clicked.connect(self.slotMultigrid) self.lineEditMinimumPressure.textChanged[str].connect( self.slotMinimumPressure) self.lineEditMaximumPressure.textChanged[str].connect( self.slotMaximumPressure) self.pushButtonAdvanced.clicked.connect(self.slotAdvancedOptions) self.lineEditMaxRestart.textChanged[str].connect(self.slotMaxRestart) self.lineEditTimeSplitting.textChanged[str].connect( self.slotTimeSplitting) self.lineEditPressureRelaxation.textChanged[str].connect( self.slotPressureRelaxation) self.checkBoxUpwindAlphaEnergy.clicked.connect( self.slotUpwindAlphaEnergy) self.checkBoxStopRestart.clicked.connect(self.slotStopRestart) self.comboBoxVelocityAlgorithm.activated[str].connect( self.slotVelocityAlgorithm) self.checkBoxRegulBadCells.clicked.connect(self.slotRegulateBadCells) # Initialize widget status = self.mdl.getRestartTimeStep() if status == 'on': self.checkBoxRestart.setChecked(1) self.groupBoxRestartOption.show() value = self.mdl.getMaxNumberOfRestart() self.lineEditMaxRestart.setText(str(value)) value = self.mdl.getTimeSplit() self.lineEditTimeSplitting.setText(str(value)) value = self.mdl.getPressureRelaxation() self.lineEditPressureRelaxation.setText(str(value)) status = self.mdl.getUpwindScheme() if status == 'on': self.checkBoxUpwindAlphaEnergy.setChecked(True) else: self.checkBoxUpwindAlphaEnergy.setChecked(False) status = self.mdl.getStopNoConvergence() if status == 'on': self.checkBoxStopRestart.setChecked(True) else: self.checkBoxStopRestart.setChecked(False) else: self.checkBoxRestart.setChecked(0) self.groupBoxRestartOption.hide() is_compressible = False for fid in mfm.getFieldIdList(): if mfm.getCompressibleStatus(int(fid)) == 'on': is_compressible = True break if is_compressible: self.mdl.setPotentielState('off') self.checkBoxPotentialState.setChecked(0) self.checkBoxPotentialState.setEnabled(False) else: status = self.mdl.getPotentielState() if status == 'on': self.checkBoxPotentialState.setChecked(1) else: self.checkBoxPotentialState.setChecked(0) status = self.mdl.getFacesReconstruction() if status == 'on': self.checkBoxFacesReconstruction.setChecked(1) else: self.checkBoxFacesReconstruction.setChecked(0) status = self.mdl.getRegulateBadCElls() self.checkBoxRegulBadCells.setChecked(status == 'on') status = self.mdl.getMultigridStatus() if status == 'on': self.checkBoxMultigrid.setChecked(1) else: self.checkBoxMultigrid.setChecked(0) value = self.mdl.getMinPressure() self.lineEditMinimumPressure.setText(str(value)) value = self.mdl.getMaxPressure() self.lineEditMaximumPressure.setText(str(value)) model = self.mdl.getVelocityPredictorAlgo() self.modelVelocityAlgorithm.setItem(str_model=model) self.case.undoStartGlobal()
class ElectricalView(QWidget, Ui_ElectricalForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_ElectricalForm.__init__(self) self.setupUi(self) self.case = case self.stbar = stbar self.case.undoStopGlobal() self.model = ElectricalModel(self.case) # Combo model self.modelJoule = ComboModel(self.comboBoxJouleModel, 4, 1) self.modelJoule.addItem(self.tr("AC/DC"), "AC/DC") self.modelJoule.addItem(self.tr("three-phase"), "three-phase") self.modelJoule.addItem(self.tr("AC/DC with Transformer coupling"), "AC/DC+Transformer") self.modelJoule.addItem(self.tr("three-phase with Transformer coupling"), "three-phase+Transformer") self.modelJoule.disableItem(str_model="AC/DC+Transformer") self.modelJoule.disableItem(str_model="three-phase+Transformer") self.modelScaling = ComboModel(self.comboBoxScalingModel, 3, 1) self.modelScaling.addItem(self.tr("general case"), "general_case") self.modelScaling.addItem(self.tr("plane define"), "plane_define") self.modelScaling.addItem(self.tr("user define"), "user") self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("X"), "X") self.modelDirection.addItem(self.tr("Y"), "Y") self.modelDirection.addItem(self.tr("Z"), "Z") # Connections self.lineEditPower.textChanged[str].connect(self.slotPower) self.lineEditCurrent.textChanged[str].connect(self.slotCurrent) self.checkBoxScaling.clicked.connect(self.slotScaling) self.comboBoxJouleModel.activated[str].connect(self.slotJouleModel) self.comboBoxScalingModel.activated[str].connect(self.slotScalingModel) self.comboBoxDirection.activated[str].connect(self.slotDirection) self.lineEditPlaneDefinitionA.textChanged[str].connect(self.slotPlaneDefA) self.lineEditPlaneDefinitionB.textChanged[str].connect(self.slotPlaneDefB) self.lineEditPlaneDefinitionC.textChanged[str].connect(self.slotPlaneDefC) self.lineEditPlaneDefinitionD.textChanged[str].connect(self.slotPlaneDefD) self.lineEditEpsilon.textChanged[str].connect(self.slotPlaneDefEpsilon) # Validators validatorPower = DoubleValidator(self.lineEditPower, min=0.0) validatorPower.setExclusiveMin(False) validatorCurrent = DoubleValidator(self.lineEditCurrent, min=0.0) validatorCurrent.setExclusiveMin(False) validatorDefinitionA = DoubleValidator(self.lineEditPlaneDefinitionA) validatorDefinitionB = DoubleValidator(self.lineEditPlaneDefinitionB) validatorDefinitionC = DoubleValidator(self.lineEditPlaneDefinitionC) validatorDefinitionD = DoubleValidator(self.lineEditPlaneDefinitionD) validatorEpsilon = DoubleValidator(self.lineEditEpsilon) self.lineEditPower.setValidator(validatorPower) self.lineEditCurrent.setValidator(validatorCurrent) self.lineEditPlaneDefinitionA.setValidator(validatorDefinitionA) self.lineEditPlaneDefinitionB.setValidator(validatorDefinitionB) self.lineEditPlaneDefinitionC.setValidator(validatorDefinitionC) self.lineEditPlaneDefinitionD.setValidator(validatorDefinitionD) self.lineEditEpsilon.setValidator(validatorEpsilon) # Initialize widget self.__initializeWidget() self.case.undoStartGlobal()
def __setBoundary(self, boundary): """ Set the current boundary """ self.__boundary = boundary self.nature = boundary.getNature() self.groupBoxPotElecIm.hide() self.groupBoxPotVector.hide() self.groupBoxMixture.hide() self.modelPotElec = ComboModel(self.comboBoxTypePotElec, 1, 1) self.modelPotElecIm = ComboModel(self.comboBoxTypePotElecIm, 1, 1) self.modelPotVector = ComboModel(self.comboBoxTypePotVector, 1, 1) self.modelPotElec.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElec.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElec.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElec.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') if self.__model.getScaling() == 'on': self.modelPotElec.addItem(self.tr("Implicit value (dpot)"), 'dirichlet_implicit') #TODO self.modelPotElec.disableItem(1) self.modelPotElec.disableItem(3) self.potElec = "elec_pot_r" self.modelPotElecLabel = ComboModel(self.comboBoxPotElec, 1, 1) self.modelPotElecLabel.addItem(self.tr(self.potElec), self.potElec) self.modelPotElecLabel.setItem(str_model=self.potElec) self.modelPotElecIm.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElecIm.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElecIm.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElecIm.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') #TODO self.modelPotElecIm.disableItem(1) self.modelPotElecIm.disableItem(3) self.potElecIm = 'elec_pot_i' self.modelPotElecImLabel = ComboModel(self.comboBoxPotElecIm, 1, 1) self.modelPotElecImLabel.addItem(self.tr(self.potElecIm), self.potElecIm) self.modelPotElecImLabel.setItem(str_model=self.potElecIm) self.modelPotVector.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotVector.addItem(self.tr("Null flux"), 'neumann') self.modelPotVector.addItem(self.tr("Implicit flux"), 'neumann_implicit') self.modelPotVector.disableItem(0) self.potVect = 'vec_potential' self.modelPotVectLabel = ComboModel(self.comboBoxPotVector, 1, 1) self.modelPotVectLabel.addItem(self.tr('vec_potential'), 'vec_potential') self.modelPotVectLabel.setItem(str_model=self.potVect) if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.groupBoxPotElecIm.show() elif self.__model.getElectricalModel() == 'arc': self.groupBoxPotVector.show() self.species = "" if self.nature == 'inlet': if self.__model.getGasNumber() > 1: self.groupBoxMixture.show() self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.species_list = self.__model.getSpeciesLabelsList() for species in self.species_list: self.modelSpecies.addItem(self.tr(species), species) self.species = self.species_list[0] self.modelSpecies.setItem(str_model=self.species) self.initializeVariables()
class LagrangianView(QWidget, Ui_LagrangianForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianModel(self.case) # Combo model self.modelIPHYLA = ComboModel(self.comboBoxIPHYLA, 2, 1) self.modelIPHYLA.addItem(self.tr("No model"), 'off') self.modelIPHYLA.addItem(self.tr("Heat transfer and evaporation"), 'thermal') if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.modelIPHYLA.addItem(self.tr("Pulverised coal model"), 'coal') # Connections self.checkBoxISUILA.clicked.connect(self.slotISUILA) self.checkBoxISTTIO.clicked.connect(self.slotISTTIO) self.checkBoxIDEPST.clicked.connect(self.slotIDEPST) self.comboBoxIPHYLA.activated[str].connect(self.slotIPHYLA) self.checkBoxITPVAR.clicked.connect(self.slotITPVAR) self.checkBoxIMPVAR.clicked.connect(self.slotIMPVAR) self.checkBoxIENCRA.clicked.connect(self.slotIENCRA) # self.lineEditNSTITS.textChanged[str].connect(self.slotNSTITS) self.checkBoxLTSDYN.clicked.connect(self.slotLTSDYN) self.checkBoxLTSMAS.clicked.connect(self.slotLTSMAS) self.checkBoxLTSTHE.clicked.connect(self.slotLTSTHE) self.toolButtonAdvanced.clicked.connect(self.slotAdvancedOptions) # Validators validatorNSTITS = IntValidator(self.lineEditNSTITS) self.lineEditNSTITS.setValidator(validatorNSTITS) # initialize Widgets model = self.model.getLagrangianModel() status = self.model.getRestart() if status == "on": self.checkBoxISUILA.setChecked(True) else: self.checkBoxISUILA.setChecked(False) status = self.model.getCarrierFlowStationary() if status == "on": self.checkBoxISTTIO.setChecked(True) else: self.checkBoxISTTIO.setChecked(False) status = self.model.getDepositionSubmodel() if status == "on": self.checkBoxIDEPST.setChecked(True) else: self.checkBoxIDEPST.setChecked(False) if (model == "frozen"): self.labelISTTIO.setDisabled(True) self.checkBoxISTTIO.setChecked(True) self.checkBoxISTTIO.setDisabled(True) self.groupBox2way.hide() self.labelISTTIO.setDisabled(False) self.checkBoxISTTIO.setDisabled(False) if model == "one_way": pass elif model == "two_way": self.groupBox2way.show() start_it = self.model.get2WayCouplingStartIteration() self.lineEditNSTITS.setText(str(start_it)) status = self.model.get2WayCouplingDynamic() if status == "on": self.checkBoxLTSDYN.setChecked(True) else: self.checkBoxLTSDYN.setChecked(False) status = self.model.get2WayCouplingMass() if status == "on": self.checkBoxLTSMAS.setChecked(True) else: self.checkBoxLTSMAS.setChecked(False) status = self.model.get2WayCouplingTemperature() if status == "on": self.checkBoxLTSTHE.setChecked(True) else: self.checkBoxLTSTHE.setChecked(False) elif model == "frozen": self.labelISTTIO.setDisabled(True) self.checkBoxISTTIO.setDisabled(True) part_model = self.model.getParticlesModel() self.modelIPHYLA.setItem(str_model=part_model) self.slotIPHYLA(self.modelIPHYLA.dicoM2V[part_model]) self.case.undoStartGlobal()
class LagrangianAdvancedOptionsDialogView( QDialog, Ui_LagrangianAdvancedOptionsDialogForm): """ Advanced dialog """ def __init__(self, parent, case, default): """ Constructor """ QDialog.__init__(self, parent) Ui_LagrangianAdvancedOptionsDialogForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.setWindowTitle(self.tr("Advanced options")) self.default = default self.result = self.default.copy() # Combo model self.modelNORDRE = ComboModel(self.comboBoxNORDRE, 2, 1) self.modelNORDRE.addItem(self.tr("first-order scheme"), "1") self.modelNORDRE.addItem(self.tr("second-order scheme"), "2") self.modelIDIRLA = ComboModel(self.comboBoxIDIRLA, 3, 1) self.modelIDIRLA.addItem(self.tr("X"), "1") self.modelIDIRLA.addItem(self.tr("Y"), "2") self.modelIDIRLA.addItem(self.tr("Z"), "3") # Connections self.comboBoxNORDRE.activated[str].connect(self.slotNORDRE) self.checkBoxIDISTU.clicked.connect(self.slotIDISTU) self.checkBoxIDIFFL.clicked.connect(self.slotIDIFFL) self.groupBoxModel.clicked[bool].connect(self.slotModel) self.lineEditMODCPL.textChanged[str].connect(self.slotMODCPL) self.comboBoxIDIRLA.activated[str].connect(self.slotIDIRLA) validatorMODCPL = IntValidator(self.lineEditMODCPL, min=1) self.lineEditMODCPL.setValidator(validatorMODCPL) # initialize Widgets order = str(self.result['scheme_order']) self.modelNORDRE.setItem(str_model=order) if self.result['turbulent_dispertion'] == "on": self.checkBoxIDISTU.setChecked(True) else: self.checkBoxIDISTU.setChecked(False) if self.result['fluid_particles_turbulent_diffusion'] == "on": self.checkBoxIDIFFL.setChecked(True) else: self.checkBoxIDIFFL.setChecked(False) value = self.result['complete_model_iteration'] if value > 0: self.lineEditMODCPL.setText(str(value)) direction = self.result['complete_model_direction'] self.modelIDIRLA.setItem(str_model=str(direction)) else: self.groupBoxModel.setChecked(False) self.case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_SolutionVerifForm.__init__(self) self.setupUi(self) self.parent = parent self.case = case self.case.undoStopGlobal() self.mdl = SolutionDomainModel(self.case) self.out = OutputControlModel(self.case) self.case2 = Case(package = self.case['package'], file_name = None) XMLinit(self.case2).initialize() self.case2['xmlfile'] = 'cs_cmd' self.case2['salome'] = self.case['salome'] self.node_domain = self.case.xmlGetNode('solution_domain') faces_cutting = self.node_domain.xmlGetNode('faces_cutting') joining = self.node_domain.xmlGetNode('joining') periodicity = self.node_domain.xmlGetNode('periodicity') sd_node = self.case2.xmlGetNode('solution_domain') if faces_cutting != None: if (faces_cutting)['status'] == 'on': sd_node.xmlInitNode('faces_cutting', status='on').xmlChildsCopy(faces_cutting) if joining != None: sd_node.xmlInitNode('joining').xmlChildsCopy(joining) if periodicity != None: sd_node.xmlInitNode('periodicity').xmlChildsCopy(periodicity) self.out2 = OutputControlModel(self.case2) # combo models self.modelFMTCHR = ComboModel(self.comboBoxFMTCHR, 3, 1) self.modelFormat = ComboModel(self.comboBoxFormat, 2, 1) self.modelPolygon = ComboModel(self.comboBoxPolygon, 3, 1) self.modelPolyhedra = ComboModel(self.comboBoxPolyhedra, 3, 1) self.modelFMTCHR.addItem(self.tr("EnSight Gold"), 'ensight') self.modelFMTCHR.addItem(self.tr("MED"), 'med') self.modelFMTCHR.addItem(self.tr("CGNS"), 'cgns') self.modelFMTCHR.addItem(self.tr("Catalyst"), 'catalyst') self.modelFMTCHR.addItem(self.tr("CCM-IO"), 'ccm') import cs_config cfg = cs_config.config() if cfg.libs['med'].have == "no": self.comboBoxFMTCHR.setItemData(1, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['cgns'].have == "no": self.comboBoxFMTCHR.setItemData(2, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['catalyst'].have == "no": self.comboBoxFMTCHR.setItemData(3, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['ccm'].have == "no": self.comboBoxFMTCHR.setItemData(4, QColor(Qt.red), Qt.TextColorRole); self.modelFormat.addItem(self.tr("binary"), 'binary') self.modelFormat.addItem(self.tr("text"), 'text') self.modelPolygon.addItem(self.tr("display"), 'display') self.modelPolygon.addItem(self.tr("discard"), 'discard_polygons') self.modelPolygon.addItem(self.tr("subdivide"), 'divide_polygons') self.modelPolyhedra.addItem(self.tr("display"), 'display') self.modelPolyhedra.addItem(self.tr("discard"), 'discard_polyhedra') self.modelPolyhedra.addItem(self.tr("subdivide"), 'divide_polyhedra') # connections self.connect(self.comboBoxFMTCHR, SIGNAL("activated(const QString&)"), self.slotOutputFormat) self.connect(self.comboBoxFormat, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.comboBoxPolygon, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.comboBoxPolyhedra, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.checkBoxBigEndian, SIGNAL("clicked()"), self.slotOutputOptions) self.connect(self.toolButtonBatch, SIGNAL("clicked()"), self.slotMeshChecking) # INITIALISATIONS # 1 - Values of post processing's format fmt = self.out.getWriterFormat("-1") self.modelFMTCHR.setItem(str_model=fmt) line = self.out.getWriterOptions("-1") self.__updateOptionsFormat(line) if not (self.mdl.getMeshList() or self.mdl.getMeshInput()): self.toolButtonBatch.setEnabled(False) self.case.undoStartGlobal()
class SolutionVerifView(QWidget, Ui_SolutionVerifForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_SolutionVerifForm.__init__(self) self.setupUi(self) self.parent = parent self.case = case self.case.undoStopGlobal() self.mdl = SolutionDomainModel(self.case) self.out = OutputControlModel(self.case) self.case2 = Case(package = self.case['package'], file_name = None) XMLinit(self.case2).initialize() self.case2['xmlfile'] = 'cs_cmd' self.case2['salome'] = self.case['salome'] self.node_domain = self.case.xmlGetNode('solution_domain') faces_cutting = self.node_domain.xmlGetNode('faces_cutting') joining = self.node_domain.xmlGetNode('joining') periodicity = self.node_domain.xmlGetNode('periodicity') sd_node = self.case2.xmlGetNode('solution_domain') if faces_cutting != None: if (faces_cutting)['status'] == 'on': sd_node.xmlInitNode('faces_cutting', status='on').xmlChildsCopy(faces_cutting) if joining != None: sd_node.xmlInitNode('joining').xmlChildsCopy(joining) if periodicity != None: sd_node.xmlInitNode('periodicity').xmlChildsCopy(periodicity) self.out2 = OutputControlModel(self.case2) # combo models self.modelFMTCHR = ComboModel(self.comboBoxFMTCHR, 3, 1) self.modelFormat = ComboModel(self.comboBoxFormat, 2, 1) self.modelPolygon = ComboModel(self.comboBoxPolygon, 3, 1) self.modelPolyhedra = ComboModel(self.comboBoxPolyhedra, 3, 1) self.modelFMTCHR.addItem(self.tr("EnSight Gold"), 'ensight') self.modelFMTCHR.addItem(self.tr("MED"), 'med') self.modelFMTCHR.addItem(self.tr("CGNS"), 'cgns') self.modelFMTCHR.addItem(self.tr("Catalyst"), 'catalyst') self.modelFMTCHR.addItem(self.tr("CCM-IO"), 'ccm') import cs_config cfg = cs_config.config() if cfg.libs['med'].have == "no": self.comboBoxFMTCHR.setItemData(1, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['cgns'].have == "no": self.comboBoxFMTCHR.setItemData(2, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['catalyst'].have == "no": self.comboBoxFMTCHR.setItemData(3, QColor(Qt.red), Qt.TextColorRole); if cfg.libs['ccm'].have == "no": self.comboBoxFMTCHR.setItemData(4, QColor(Qt.red), Qt.TextColorRole); self.modelFormat.addItem(self.tr("binary"), 'binary') self.modelFormat.addItem(self.tr("text"), 'text') self.modelPolygon.addItem(self.tr("display"), 'display') self.modelPolygon.addItem(self.tr("discard"), 'discard_polygons') self.modelPolygon.addItem(self.tr("subdivide"), 'divide_polygons') self.modelPolyhedra.addItem(self.tr("display"), 'display') self.modelPolyhedra.addItem(self.tr("discard"), 'discard_polyhedra') self.modelPolyhedra.addItem(self.tr("subdivide"), 'divide_polyhedra') # connections self.connect(self.comboBoxFMTCHR, SIGNAL("activated(const QString&)"), self.slotOutputFormat) self.connect(self.comboBoxFormat, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.comboBoxPolygon, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.comboBoxPolyhedra, SIGNAL("activated(const QString&)"), self.slotOutputOptions) self.connect(self.checkBoxBigEndian, SIGNAL("clicked()"), self.slotOutputOptions) self.connect(self.toolButtonBatch, SIGNAL("clicked()"), self.slotMeshChecking) # INITIALISATIONS # 1 - Values of post processing's format fmt = self.out.getWriterFormat("-1") self.modelFMTCHR.setItem(str_model=fmt) line = self.out.getWriterOptions("-1") self.__updateOptionsFormat(line) if not (self.mdl.getMeshList() or self.mdl.getMeshInput()): self.toolButtonBatch.setEnabled(False) self.case.undoStartGlobal() @pyqtSignature("const QString &") def slotOutputFormat(self, text): """ Input format of post-processing """ format = self.modelFMTCHR.dicoV2M[str(text)] if self.out.getWriterFormat("-1") != format: self.out.setWriterFormat("-1",format) l = self.out.defaultWriterValues()['options'] self.out.setWriterOptions("-1",l) if self.out2.getWriterFormat("-1") != format: self.out2.setWriterFormat("-1",format) l = self.out2.defaultWriterValues()['options'] self.out2.setWriterOptions("-1",l) self.__updateOptionsFormat(l) @pyqtSignature("") def slotOutputOptions(self): """ Create format's command line options """ line = [] opt_format = self.modelFormat.dicoV2M[str(self.comboBoxFormat.currentText())] line.append(opt_format) if self.checkBoxBigEndian.isChecked(): line.append('big_endian') opt_polygon = self.modelPolygon.dicoV2M[str(self.comboBoxPolygon.currentText())] opt_polyhed = self.modelPolyhedra.dicoV2M[str(self.comboBoxPolyhedra.currentText())] if opt_polygon != 'display': line.append(opt_polygon) if opt_polyhed != 'display': line.append(opt_polyhed) l = string.join(line, ',') log.debug("slotOutputOptions-> OPTCHR = %s" % l) self.out.setWriterOptions("-1",l) self.out2.setWriterOptions("-1",l) def __updateOptionsFormat(self, line): """ Update command-line options at each modification of post processing format """ lst = line.split(',') format = self.modelFMTCHR.dicoV2M[str(self.comboBoxFMTCHR.currentText())] log.debug("__updateOptionsFormat-> FMTCHR = %s" % format) log.debug("__updateOptionsFormat-> OPTCHR = %s" % line) # update widgets from the options list for opt in lst: if opt == 'binary' or opt == 'text' : self.modelFormat.setItem(str_model=opt) if opt == 'discard_polygons' or opt == 'divide_polygons': self.modelPolygon.setItem(str_model=opt) if opt == 'discard_polyhedra' or opt == 'divide_polyhedra': self.modelPolyhedra.setItem(str_model=opt) if format == 'ensight': if opt == 'big_endian': self.checkBoxBigEndian.setChecked(True) if 'discard_polygons' not in lst and 'divide_polygons' not in lst: self.modelPolygon.setItem(str_model="display") if 'discard_polyhedra' not in lst and 'divide_polyhedra' not in lst: self.modelPolyhedra.setItem(str_model="display") if 'big_endian' not in lst: self.checkBoxBigEndian.setChecked(False) # enable and disable options related to the format self.modelPolygon.enableItem(str_model='discard_polygons') self.modelPolygon.enableItem(str_model='divide_polygons') self.modelPolyhedra.enableItem(str_model='discard_polyhedra') self.modelPolyhedra.enableItem(str_model='divide_polyhedra') self.comboBoxPolygon.setEnabled(True) self.comboBoxPolyhedra.setEnabled(True) if format != "ensight": if format == "cgns": self.modelPolyhedra.setItem(str_model='divide_polyhedra') self.modelPolyhedra.disableItem(str_model='display') elif format in ["catalyst", "ccm"]: self.modelPolyhedra.setItem(str_model='display') self.modelPolygon.setItem(str_model='display') self.comboBoxPolygon.setEnabled(False) self.comboBoxPolyhedra.setEnabled(False) self.modelFormat.setItem(str_model="binary") self.modelFormat.disableItem(str_model='text') self.labelBigEndian.setEnabled(False) self.checkBoxBigEndian.setEnabled(False) else: self.modelFormat.enableItem(str_model='text') self.comboBoxFormat.setEnabled(True) self.labelBigEndian.setEnabled(True) self.checkBoxBigEndian.setEnabled(True) def __setButtonEnabled(self): """ Block the QButton during the display of the dialog. """ try: self.toolButtonBatch.setEnabled(not self.toolButtonBatch.isEnabled()) except: pass def slotMeshChecking(self): """ """ self.__setButtonEnabled() dialog = MeshQualityCriteriaLogDialogView(self.parent, self.case, self.case2) dialog.show() self.connect(dialog, SIGNAL("accepted()"), self.__setButtonEnabled) self.connect(dialog, SIGNAL("rejected()"), self.__setButtonEnabled) def tr(self, text): """ Translation """ return text
def __init__(self, parent, case, tree): """ Constructor """ QWidget.__init__(self, parent) Ui_NumericalParamGlobalForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = NumericalParamGlobalModel(self.case) self.browser = tree self.labelSRROM.hide() self.lineEditSRROM.hide() self.line_5.hide() # Combo models self.modelEXTRAG = ComboModel(self.comboBoxEXTRAG,2,1) self.modelIMRGRA = ComboModel(self.comboBoxIMRGRA,5,1) self.modelNTERUP = ComboModel(self.comboBoxNTERUP,3,1) self.modelEXTRAG.addItem(self.tr("Neumann 1st order"), 'neumann') self.modelEXTRAG.addItem(self.tr("Extrapolation"), 'extrapolation') self.modelIMRGRA.addItem(self.tr("Iterative handling of non-orthogonalities"),'0') self.modelIMRGRA.addItem(self.tr("Least squares method over neighboring cells"),'1') self.modelIMRGRA.addItem(self.tr("Least squares method over extended cell neighborhood"),'2') self.modelIMRGRA.addItem(self.tr("Least squares method over partial extended cell neighborhood"),'3') self.modelIMRGRA.addItem(self.tr("Iterative method with least squares initialization"),'4') self.modelNTERUP.addItem(self.tr("SIMPLE"), 'simple') self.modelNTERUP.addItem(self.tr("SIMPLEC"),'simplec') self.modelNTERUP.addItem(self.tr("PISO"),'piso') self.comboBoxEXTRAG.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.comboBoxNTERUP.setSizeAdjustPolicy(QComboBox.AdjustToContents) # Connections self.connect(self.checkBoxIVISSE, SIGNAL("clicked()"), self.slotIVISSE) self.connect(self.checkBoxIPUCOU, SIGNAL("clicked()"), self.slotIPUCOU) self.connect(self.checkBoxICFGRP, SIGNAL("clicked()"), self.slotICFGRP) self.connect(self.checkBoxImprovedPressure, SIGNAL("clicked()"), self.slotImprovedPressure) self.connect(self.comboBoxEXTRAG, SIGNAL("activated(const QString&)"), self.slotEXTRAG) self.connect(self.lineEditRELAXP, SIGNAL("textChanged(const QString &)"), self.slotRELAXP) self.connect(self.comboBoxIMRGRA, SIGNAL("activated(const QString&)"), self.slotIMRGRA) self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM) self.connect(self.comboBoxNTERUP, SIGNAL("activated(const QString&)"), self.slotNTERUP) self.connect(self.spinBoxNTERUP, SIGNAL("valueChanged(int)"), self.slotNTERUP2) # Validators validatorRELAXP = DoubleValidator(self.lineEditRELAXP, min=0., max=1.) validatorRELAXP.setExclusiveMin(True) validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0., max=1.) validatorSRROM.setExclusiveMin(True) self.lineEditRELAXP.setValidator(validatorRELAXP) self.lineEditSRROM.setValidator(validatorSRROM) if self.model.getTransposedGradient() == 'on': self.checkBoxIVISSE.setChecked(True) else: self.checkBoxIVISSE.setChecked(False) if self.model.getVelocityPressureCoupling() == 'on': self.checkBoxIPUCOU.setChecked(True) else: self.checkBoxIPUCOU.setChecked(False) import code_saturne.Pages.FluidCharacteristicsModel as FluidCharacteristics fluid = FluidCharacteristics.FluidCharacteristicsModel(self.case) modl_atmo, modl_joul, modl_thermo, modl_gas, modl_coal, modl_comp = fluid.getThermoPhysicalModel() if self.model.getHydrostaticPressure() == 'on': self.checkBoxImprovedPressure.setChecked(True) else: self.checkBoxImprovedPressure.setChecked(False) self.lineEditRELAXP.setText(str(self.model.getPressureRelaxation())) self.modelEXTRAG.setItem(str_model=self.model.getWallPressureExtrapolation()) self.modelIMRGRA.setItem(str_model=str(self.model.getGradientReconstruction())) if modl_joul != 'off' or modl_gas != 'off' or modl_coal != 'off': self.labelSRROM.show() self.lineEditSRROM.show() self.lineEditSRROM.setText(str(self.model.getDensityRelaxation())) self.line_5.show() algo = self.model.getVelocityPressureAlgorithm() status = SteadyManagementModel(self.case).getSteadyFlowManagement() if status == 'on': self.modelNTERUP.enableItem(str_model = 'simple') self.modelNTERUP.disableItem(str_model = 'piso') else: self.modelNTERUP.disableItem(str_model = 'simple') self.modelNTERUP.enableItem(str_model = 'piso') self.modelNTERUP.setItem(str_model=algo) if algo == 'piso': self.spinBoxNTERUP.show() else: self.spinBoxNTERUP.hide() if modl_comp != 'off': self.labelICFGRP.show() self.checkBoxICFGRP.show() self.line_4.show() if self.model.getHydrostaticEquilibrium() == 'on': self.checkBoxICFGRP.setChecked(True) else: self.checkBoxICFGRP.setChecked(False) self.checkBoxIPUCOU.hide() self.labelIPUCOU.hide() self.lineEditRELAXP.hide() self.labelRELAXP.hide() self.checkBoxImprovedPressure.hide() self.labelImprovedPressure.hide() self.line_2.hide() self.line_5.hide() self.line_7.hide() self.line_8.hide() self.labelNTERUP.setText("Velocity-Pressure algorithm\nsub-iterations on Navier-Stokes") self.comboBoxNTERUP.hide() self.spinBoxNTERUP.show() else: self.labelICFGRP.hide() self.checkBoxICFGRP.hide() self.line_4.hide() self.checkBoxIPUCOU.show() self.labelIPUCOU.show() self.lineEditRELAXP.show() self.labelRELAXP.show() self.checkBoxImprovedPressure.show() self.labelImprovedPressure.show() self.line_2.show() self.line_5.show() self.line_7.show() self.line_8.show() value = self.model.getPisoSweepNumber() self.spinBoxNTERUP.setValue(value) # Update the Tree files and folders self.browser.configureTree(self.case) self.case.undoStartGlobal()
class OpenTurnsView(QWidget, Ui_OpenTurnsForm): """ OpenTurns Page viewer class """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_OpenTurnsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = OpenTurnsModel(case) if not self.mdl.getHostName(): self.mdl.setDefaultOptions() # Combo model config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) self.nmodes = 1 dist_hosts = None if config.has_section('distant_hosts'): if len(config.options('distant_hosts')) != 0: dist_hosts = config.options('distant_hosts') self.nmodes += len(dist_hosts) self.modelOtStudyHosts = ComboModel(self.comboBoxStudyMode, self.nmodes, 1) self.modelOtStudyHosts.addItem(self.tr("Localhost"), 'localhost') self.hosts_bmgr = {} if config.has_option('install', 'batch'): self.hosts_bmgr['localhost'] = (config.get('install', 'batch')).lower() else: self.hosts_bmgr['localhost'] = 'none' # Check for distant builds: # Hosts are stored in the form <batch_rm>_<host_name> hence the split # used hereafter to determine the "real" host name self.hosts_binpath = {} self.hosts_binpath['localhost'] = 'default' self.distant_host_builds = None if dist_hosts != None: self.distant_host_builds = {} for key in dist_hosts: host_name = key.split('_')[1] self.hosts_bmgr[host_name] = key.split('_')[0] self.hosts_binpath[host_name] = config.get( 'distant_hosts', key) self.addDistantBuilds(host_name) dh_not_found = False if self.distant_host_builds[host_name] == None: self.distant_host_builds[host_name] = ['none found'] dh_not_found = True host_tag = 'distant : ' + host_name self.modelOtStudyHosts.addItem(self.tr(host_tag), host_name, warn=dh_not_found) if dh_not_found: self.modelOtStudyHosts.disableItem(str_model=host_name) # --------------------------------------- # Connections: self.comboBoxStudyMode.activated[str].connect(self.slotOtStudyMode) self.comboBoxDistantBuilds.activated[str].connect(self.slotBuildChoice) self.lineEditDistWorkDir.textChanged[str].connect(self.slotOtDistWdir) self.spinBoxNumberNodes.valueChanged[int].connect( self.slotUpdateNodesNumber) self.spinBoxNumberTasks.valueChanged[int].connect( self.slotUpdateTasksNumber) self.spinBoxNumberThreads.valueChanged[int].connect( self.slotUpdateThreadsNumber) self.spinBoxNumberDays.valueChanged[int].connect(self.slotUpdateWCDays) self.spinBoxNumberHours.valueChanged[int].connect( self.slotUpdateWCHours) self.spinBoxNumberMinutes.valueChanged[int].connect( self.slotUpdateWCMinutes) self.spinBoxNumberSeconds.valueChanged[int].connect( self.slotUpdateWCSeconds) self.lineEditWCKEY.textChanged[str].connect(self.slotUpdateWckey) self.pushButtonLaunchOT.clicked.connect(self.slotLaunchCsOt) # --------------------------------------- # Hide/Show initial elements if self.nmodes == 1: self.groupBoxLocalLaunch.show() self.groupBoxDistantLaunch.hide() self.setAvailableBuildsList('localhost') else: self.setAvailableBuildsList(self.mdl.getHostName()) if self.mdl.getHostName() == "localhost": self.groupBoxLocalLaunch.show() self.groupBoxDistantLaunch.hide() else: self.groupBoxLocalLaunch.hide() self.groupBoxDistantLaunch.show() # --------------------------------------- # Initial values if dist_hosts != None: self.modelOtStudyHosts.setItem(str_model=self.mdl.host_name) else: self.modelOtStudyHosts.setItem(str_model='localhost') self.spinBoxLocalProcs.setValue(int(self.mdl.nprocs)) self.spinBoxLocalThreads.setValue(1) self.spinBoxNumberNodes.setValue(int(self.mdl.nnodes)) self.spinBoxNumberTasks.setValue(int(self.mdl.ntasks)) self.spinBoxNumberThreads.setValue(int(self.mdl.nthreads)) wct = self.mdl.getWallClockTime() self.spinBoxNumberDays.setValue(int(wct[0])) self.spinBoxNumberHours.setValue(int(wct[1])) self.spinBoxNumberMinutes.setValue(int(wct[2])) self.spinBoxNumberSeconds.setValue(int(wct[3])) self.lineEditWCKEY.setText(self.mdl.getWCKEY()) @pyqtSlot(str) def slotOtStudyMode(self, text): """ Host type: localhost or a distant one (defined in code_saturne.cfg). """ host_name = self.modelOtStudyHosts.dicoV2M[str(text)] self.mdl.setHostName(host_name) self.mdl.setBatchManager(self.hosts_bmgr[host_name]) if host_name != 'localhost': self.groupBoxDistantLaunch.show() else: self.groupBoxDistantLaunch.hide() self.setAvailableBuildsList(host_name) self.mdl.arch_path = self.hosts_binpath[host_name] @pyqtSlot(str) def slotBuildChoice(self, text): """ Sets the hostname """ self.mdl.setBuildName(text) @pyqtSlot(str) def slotOtDistWdir(self, text): """ Set the distant workdir path """ self.mdl.setDistWorkdir(text) @pyqtSlot(int) def slotUpdateNodesNumber(self, v): """ Update the number of required computation nodes """ n = int(self.spinBoxNumberNodes.text()) self.mdl.setClusterParams(nnodes=n) @pyqtSlot(int) def slotUpdateNprocs(self, v): """ Update the number of required processes """ n = int(self.spinBoxLocalProcs.text()) self.mdl.setNprocs(n) @pyqtSlot(int) def slotUpdateTasksNumber(self, v): """ Update the number of required mpi tasks per node """ n = int(self.spinBoxNumberTasks.text()) self.mdl.setClusterParams(ntasks=n) @pyqtSlot(int) def slotUpdateThreadsNumber(self, v): """ Update the number of required threads per processor """ n = int(self.spinBoxNumberThreads.text()) self.mdl.setClusterParams(nthreads=n) @pyqtSlot(int) def slotUpdateWCDays(self, v): """ Update the wall clock days value """ d, h, m, s = self.mdl.getWallClockTime() d = str(int(self.spinBoxNumberDays.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(int) def slotUpdateWCHours(self, v): """ Update the wall clock hours value """ d, h, m, s = self.mdl.getWallClockTime() h = str(int(self.spinBoxNumberHours.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(int) def slotUpdateWCMinutes(self, v): """ Update the wall clock minutes value """ d, h, m, s = self.mdl.getWallClockTime() m = str(int(self.spinBoxNumberMinutes.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(int) def slotUpdateWCSeconds(self, v): """ Update the wall clock seconds value """ d, h, m, s = self.mdl.getWallClockTime() s = str(int(self.spinBoxNumberSeconds.text())) self.mdl.setWallClockTime(d, h, m, s) @pyqtSlot(str) def slotUpdateWckey(self, text): """ Update the WCKEY variable """ self.mdl.setWCKEY(text) @pyqtSlot() def slotLaunchCsOt(self): """ Translate the Code_Sature reference case and study into an OpenTurs physical model and study """ if self.case['salome']: import salome_ot # Update the study cfg file self.mdl.update_cfg_file() # Generating OpenTurns _exec function self.create_cs_exec_function() # Load the Code_Saturne cas as Physical model and launch # OpenTurns GUI cs_exec_script_name = os.path.join(self.mdl.otstudy_path, 'cs_execute_job.py') salome_ot.loadYacsPyStudy(cs_exec_script_name) else: print( "This option is only available within the SALOME_CFD platform") def tr(self, text): """ Translation """ return text def addDistantBuilds(self, host_name): """ Search for the distant builds of Code_Saturne for the given distant host. """ host_path = self.hosts_binpath[host_name] builds_list = __getListOfDistantBuilds__(host_name, host_path) self.distant_host_builds[host_name] = builds_list def setAvailableBuildsList(self, host_name): """ Set the list of available builds per host """ if host_name == 'localhost': self.groupBoxDistantLaunch.hide() self.groupBoxLocalLaunch.show() self.comboBoxDistantBuilds.hide() self.labelDistantBuilds.hide() return else: self.groupBoxDistantLaunch.show() self.groupBoxLocalLaunch.hide() self.comboBoxDistantBuilds.show() self.labelDistantBuilds.show() dist_builds_list = self.distant_host_builds[host_name] self.modelOtDistantBuilds = ComboModel(self.comboBoxDistantBuilds, len(dist_builds_list), 1) for db in dist_builds_list: self.modelOtDistantBuilds.addItem(self.tr(db), db) def create_cs_exec_function(self): """ This function generates the _exec function needed by OpenTurns for a study using distant launching on clusters. Takes as input: - Code_Saturne study path - OT_params.cfg name - list of OTurns input variables - list of OTurns output variables - the requested cluster name - the result file name which contains the output values """ cluster = self.mdl.host_name exec_file_name = os.path.join(self.mdl.otstudy_path, 'cs_execute_job.py') f = open(exec_file_name, 'w') script_cmd = "\n" script_cmd += "# ============================================================================== \n" script_cmd += "# OPENTURNS EXEC FUNCTION WHICH LAUNCHES CODE_SATURNE ON A DISTANT CLUSTER \n" script_cmd += "# ============================================================================== \n" script_cmd += "\n\n" nvars = len(self.mdl.input_variables) script_cmd = 'def _exec(' vars_dict = '{' toffset = ' ' cmd1 = 'cfd_eval = cfd_openturns_study(' loffset1 = toffset for i in range(len(cmd1)): loffset1 += ' ' loffset2 = ' ' iv = -1 for i in range(nvars): if i == 0: script_cmd += self.mdl.input_variables[i] vars_dict += '"' + self.mdl.input_variables[i] + '":' vars_dict += self.mdl.input_variables[i] else: script_cmd += ", " + self.mdl.input_variables[i] vars_dict += ', \n' vars_dict += loffset1 + loffset2 + ' ' vars_dict += '"' + self.mdl.input_variables[i] + '":' vars_dict += self.mdl.input_variables[i] script_cmd += '):\n\n' vars_dict += '}' script_cmd += toffset + "import sys\n" salome_pydir = os.path.join(self.case['package'].dirs['pythondir'][1], 'salome') script_cmd += toffset script_cmd += "sys.path.insert(-1, '%s')\n\n" % salome_pydir script_cmd += toffset + "from CFDSTUDYOTURNS_StudyInterface import cfd_openturns_study" script_cmd += "\n\n" script_cmd += toffset + cmd1 + 'study_path = "' + self.mdl.otstudy_path + '",\n' script_cmd += loffset1 + 'study_cfg = "openturns_study.cfg",\n' script_cmd += loffset1 + 'vars_dico = ' + vars_dict + ')\n\n' script_cmd += toffset + 'cfd_eval.study2code() \n\n' script_cmd += toffset + 'cfd_eval.run() \n\n' n_vals = len(self.mdl.output_variables) vals_list = "" for i in range(n_vals): if i != 0: vals_list += ', ' vals_list += self.mdl.output_variables[i] cmd_m1 = '(%s,) = cfd_eval.code2study(n_values=%d)\n' % (vals_list, n_vals) script_cmd += toffset + cmd_m1 script_cmd += '\n' script_cmd += toffset + 'return ' script_cmd += vals_list + '\n' f.write(script_cmd) f.close()
class InterfacialForcesView(QWidget, Ui_InterfacialForces): """ Main fields layout. """ def __init__(self, parent, case, tree): """ Constructor """ QWidget.__init__(self, parent) Ui_InterfacialForces.__init__(self) self.setupUi(self) self.case = case self.browser = tree self.case.undoStopGlobal() self.mdl = InterfacialForcesModel(self.case) self.field_id_a = None self.field_id_b = None # Dico self.dicoM2V = {"none": 'None', "LLB_model": 'LLB model', "GTD_model": 'GTD model', "antal": 'Antal', "tomiyama": 'Tomiyama', "ishii": 'Ishii', "inclusions": 'Gobin et al.', "Wen_Yu": 'Wen and Yu', "standard": 'Standard', "zuber": 'Zuber', "coef_cst": 'Constant coefficient', "Tomiyama_SMD": 'Tomiyama SMD', "Zeng_Baalbaki": "Zeng and Baalbaki", "Large_Interface_Model": "Large Interface Model", "Large_Bubble_Model": "Large Bubble Model", "G_Large_Interface_Model": "Generalized Large Interface Model"} self.dicoV2M = {value: key for key, value in self.dicoM2V.items()} allCouples = self.mdl.getAllCouples() self.groupBoxDispersedMomentumTransfer.hide() self.groupBoxContinuousMomentumTransfer.hide() self.tableModelInteractions = InteractionsTableModel(self, allCouples, self.mdl) # Dispersed models self.modelDispersedDrag = ComboModel(self.comboBoxDispersedDrag, 1, 1) self.modelLift = ComboModel(self.comboBoxLift, 1, 1) self.modelAddedMass = ComboModel(self.comboBoxAddedMass, 1, 1) self.modelTurbulenceDispersion = ComboModel(self.comboBoxTurbulenceDispersion, 1, 1) self.modelWallForce = ComboModel(self.comboBoxWallForce, 1, 1) # Continuous models self.modelContinuousMomentumTransfer = ComboModel(self.comboBoxContinuousMomentumTransfer, 3, 1) self.modelInterfaceSharpening = ComboModel(self.comboBoxInterfaceSharpening, 1, 1) self.modelSurfaceTension = ComboModel(self.comboBoxSurfaceTension, 1, 1) self._fillContinuousComboBoxes() self._connectSignalsToSlots() self._initializeInteractionsTable() self.case.undoStartGlobal()
class InterfacialAreaView(QWidget, Ui_InterfacialArea): """ InterfacialAreaView layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_InterfacialArea.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = InterfacialAreaModel(self.case) dispersed_fields = self.mdl.getDispersedFieldList( ) + InterfacialForcesModel(self.case).getGLIMfields() if dispersed_fields == []: self.groupBoxField.hide() self.groupBoxMinMaxDiameter.hide() self.groupBoxModel.hide() self.labelNoDispersedPhase.show() self.mdl.remove() return # Combo box models id_to_set = -1 self.modelField = ComboModel(self.comboBoxField, 1, 1) # For consistency with the previous pages, the second phase of the # Large Interface Model is set before the dispersed fields for fieldId in dispersed_fields: label = self.mdl.getLabel(fieldId) name = str(fieldId) self.modelField.addItem(self.tr(label), name) if len(dispersed_fields) > 0 and id_to_set == -1: id_to_set = dispersed_fields[0] self.modelField.setItem(str_model=id_to_set) # case no field self.currentid = id_to_set self.modelModel = ComboModel(self.comboBoxModel, 2, 1) self.modelModel.addItem(self.tr("constant"), "constant") self.modelModel.addItem(self.tr("interfacial area transport"), "interfacial_area_transport") self.modelSourceTerm = ComboModel(self.comboBoxSourceTerm, 4, 1) self.modelSourceTerm.addItem( self.tr("No coalescence, no fragmentation"), "no_coalescence_no_fragmentation") self.modelSourceTerm.addItem(self.tr("Yao & Morel"), "wei_yao") self.modelSourceTerm.addItem(self.tr("Kamp & Colin"), "kamp_colin") self.modelSourceTerm.addItem(self.tr("Ruyer & Seiler"), "ruyer_seiler") self.modelSourceTerm.disableItem(2) # Why ? # Validators validatorDefDiam = DoubleValidator(self.lineEditDefaultDiameter, min=0.0) validatorMinDiam = DoubleValidator(self.lineEditMinDiameter, min=0.0) validatorMaxDiam = DoubleValidator(self.lineEditMaxDiameter, min=0.0) validatorDefDiam.setExclusiveMin(True) validatorMinDiam.setExclusiveMin(True) validatorMaxDiam.setExclusiveMin(True) self.lineEditDefaultDiameter.setValidator(validatorDefDiam) self.lineEditMinDiameter.setValidator(validatorMinDiam) self.lineEditMaxDiameter.setValidator(validatorMaxDiam) # Connect signals to slots self.comboBoxField.activated[str].connect(self.slotField) self.comboBoxModel.activated[str].connect(self.slotModel) self.comboBoxSourceTerm.activated[str].connect(self.slotSourceTerm) self.lineEditDefaultDiameter.textChanged[str].connect( self.slotDefaultDiameter) self.lineEditMinDiameter.textChanged[str].connect(self.slotMinDiameter) self.lineEditMaxDiameter.textChanged[str].connect(self.slotMaxDiameter) # Initialize widget self.initializeVariables(self.currentid) self.case.undoStartGlobal() @pyqtSlot(str) def slotField(self, text): """ INPUT label for choice of field """ self.currentid = self.modelField.dicoV2M[text] self.initializeVariables(self.currentid) if self.mdl.getFieldNature(self.currentid) == "gas": self.modelSourceTerm.enableItem(0) else: self.modelSourceTerm.disableItem(0) @pyqtSlot(str) def slotModel(self, text): """ INPUT type for choice of model """ model = self.modelModel.dicoV2M[text] self.mdl.setAreaModel(self.currentid, model) self.initializeVariables(self.currentid) @pyqtSlot(str) def slotSourceTerm(self, text): """ INPUT type for choice of model source term """ model = self.modelSourceTerm.dicoV2M[text] self.mdl.setSourceTerm(self.currentid, model) @pyqtSlot(str) def slotDefaultDiameter(self, var): """ """ if self.lineEditDefaultDiameter.validator( ).state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setInitialDiameter(self.currentid, value) @pyqtSlot(str) def slotMinDiameter(self, var): """ """ if self.lineEditMinDiameter.validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setMinDiameter(self.currentid, value) @pyqtSlot(str) def slotMaxDiameter(self, var): """ """ if self.lineEditMaxDiameter.validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.mdl.setMaxDiameter(self.currentid, value) def initializeVariables(self, fieldId): """ Initialize variables when a new fieldId is choosen """ self.labelNoDispersedPhase.hide() model = self.mdl.getAreaModel(fieldId) self.modelModel.setItem(str_model=model) value = self.mdl.getInitialDiameter(self.currentid) self.lineEditDefaultDiameter.setText(str(value)) if self.mdl.getAreaModel(fieldId) == "constant": self.groupBoxAreaTransport.hide() self.groupBoxMinMaxDiameter.hide() else: self.groupBoxAreaTransport.show() model = self.mdl.getSourceTerm(fieldId) self.modelSourceTerm.setItem(str_model=model) self.groupBoxMinMaxDiameter.show() value = self.mdl.getMinDiameter(self.currentid) self.lineEditMinDiameter.setText(str(value)) value = self.mdl.getMaxDiameter(self.currentid) self.lineEditMaxDiameter.setText(str(value)) if MainFieldsModel(self.case).getFieldNature(fieldId) != 'gas': self.modelSourceTerm.disableItem(1) self.modelSourceTerm.disableItem(2) self.modelSourceTerm.disableItem(3) else:
class NatureDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent): super(NatureDelegate, self).__init__(parent) self.parent = parent def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 3, 1) self.modelCombo.addItem(self.tr("liquid"), 'liquid') self.modelCombo.addItem(self.tr("gas"), 'gas') self.modelCombo.addItem(self.tr("solid"), 'solid') row = index.row() if (row == 0): self.modelCombo.disableItem(2) else: self.modelCombo.enableItem(2) editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): col = index.column() string = index.model().getData(index)[col] self.modelCombo.setItem(str_model=string) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] log.debug("NatureDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole) def tr(self, text): return text
class NucleateBoilingView(QWidget, Ui_NucleateBoiling): """ Nucleate boiling model layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_NucleateBoiling.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = NucleateBoilingModel(self.case) self.modelHeatTransferModel = ComboModel( self.comboBoxHeatTransferModel, 2, 1) self.modelHeatTransferModel.addItem( self.tr("Extended Kurul-Podowski model"), "extended_kurul-podowski") self.modelHeatTransferModel.addItem( self.tr("Standard Kurul-Podowski model"), "standard_kurul-podowski") self.modelWallFunctionModel = ComboModel( self.comboBoxWallFunctionModel, 3, 1) self.modelWallFunctionModel.addItem( self.tr("standard (single phase wall function)"), "standard") self.modelWallFunctionModel.addItem(self.tr("Koncar Tiselj-NED 2008"), "koncar") self.modelWallFunctionModel.addItem(self.tr("Mimouni et al-NED 2008"), "mimouni") self.modelYPlus = ComboModel(self.comboBoxYPlus, 3, 1) self.modelYPlus.addItem(self.tr("Boundary cell center"), "center") self.modelYPlus.addItem(self.tr("Y+ = "), "Yplus_value") self.modelYPlus.addItem(self.tr("Nucleate bubble diameter"), "diameter") # Validators validatorYplus = DoubleValidator(self.lineEditYPlus, min=0.0) validatorRad = DoubleValidator(self.lineEditMaxRadius, min=0.0) validatorDiam = DoubleValidator(self.lineEditMaxDiam, min=0.0) validatorSat = DoubleValidator(self.lineEditMaxOverSaturation, min=0.0) validatorLam = DoubleValidator(self.lineEditThermalConductivity, min=0.0) validatorRho = DoubleValidator(self.lineEditDensity, min=0.0) validatorCp = DoubleValidator(self.lineEditSpecificHeat, min=0.0) validatorTh = DoubleValidator(self.lineEditThickness, min=0.0) validatorYplus.setExclusiveMin(True) validatorRad.setExclusiveMin(True) validatorDiam.setExclusiveMin(True) validatorSat.setExclusiveMin(True) validatorLam.setExclusiveMin(True) validatorRho.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorTh.setExclusiveMin(True) self.lineEditYPlus.setValidator(validatorYplus) self.lineEditMaxRadius.setValidator(validatorRad) self.lineEditMaxDiam.setValidator(validatorDiam) self.lineEditMaxOverSaturation.setValidator(validatorSat) self.lineEditThermalConductivity.setValidator(validatorLam) self.lineEditDensity.setValidator(validatorRho) self.lineEditSpecificHeat.setValidator(validatorCp) self.lineEditThickness.setValidator(validatorTh) # Connect signals to slots self.comboBoxHeatTransferModel.activated[str].connect( self.slotHeatTransferModel) self.comboBoxWallFunctionModel.activated[str].connect( self.slotWallFunctionModel) self.comboBoxYPlus.activated[str].connect(self.slotYPlus) self.checkBoxThickness.clicked.connect(self.slotThickness) self.lineEditYPlus.textChanged[str].connect(self.slotYPlusValue) self.lineEditMaxRadius.textChanged[str].connect(self.slotMaxRadius) self.lineEditMaxDiam.textChanged[str].connect(self.slotMaxDiam) self.lineEditMaxOverSaturation.textChanged[str].connect( self.slotMaxOverSaturation) self.lineEditThermalConductivity.textChanged[str].connect( self.slotThermalConductivity) self.lineEditDensity.textChanged[str].connect(self.slotDensity) self.lineEditSpecificHeat.textChanged[str].connect( self.slotSpecificHeat) self.lineEditThickness.textChanged[str].connect( self.slotThicknessValue) # load values isYPlus = self.mdl.getYPlusModel() self.modelYPlus.setItem(str_model=isYPlus) if isYPlus == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() self.lineEditMaxRadius.setText(str(self.mdl.getMaxRadius())) self.lineEditMaxDiam.setText(str(self.mdl.getMaxDiameter())) self.lineEditMaxOverSaturation.setText( str(self.mdl.getMaxOverSaturation())) self.lineEditThermalConductivity.setText( str(self.mdl.getThermalConductivity())) self.lineEditDensity.setText(str(self.mdl.getDensity())) self.lineEditSpecificHeat.setText(str(self.mdl.getSpecificHeat())) model = self.mdl.getHeatTransferModel() self.modelHeatTransferModel.setItem(str_model=model) if model == "standard_kurul-podowski": self.labelMaxRadius.setEnabled(0) self.lineEditMaxRadius.setEnabled(0) self.labelMaxRadiusUnit.setEnabled(0) self.labelMaxDiam.setEnabled(0) self.lineEditMaxDiam.setEnabled(0) self.labelMaxDiamUnit.setEnabled(0) else: self.labelMaxRadius.setEnabled(1) self.lineEditMaxRadius.setEnabled(1) self.labelMaxRadiusUnit.setEnabled(1) self.labelMaxDiam.setEnabled(1) self.lineEditMaxDiam.setEnabled(1) self.labelMaxDiamUnit.setEnabled(1) isThickness = self.mdl.getThicknessStatus() == "on" self.checkBoxThickness.setChecked(isThickness) if isThickness: self.lineEditThickness.show() self.labelThickness1.show() self.labelThickness2.show() self.lineEditThickness.setText(str(self.mdl.getThicknessValue())) else: self.lineEditThickness.hide() self.labelThickness1.hide() self.labelThickness2.hide() model = self.mdl.getWallFunctionModel() self.modelWallFunctionModel.setItem(str_model=model) self.case.undoStartGlobal() @pyqtSlot(str) def slotHeatTransferModel(self, text): """ configure standard or extend kurul-podowski model """ value = self.modelHeatTransferModel.dicoV2M[text] log.debug("slotHeatTransferModel -> %s" % value) self.mdl.setHeatTransferModel(value) if value == "standard_kurul-podowski": self.labelMaxRadius.setEnabled(0) self.lineEditMaxRadius.setEnabled(0) self.labelMaxRadiusUnit.setEnabled(0) self.labelMaxDiam.setEnabled(0) self.lineEditMaxDiam.setEnabled(0) self.labelMaxDiamUnit.setEnabled(0) else: self.labelMaxRadius.setEnabled(1) self.lineEditMaxRadius.setEnabled(1) self.labelMaxRadiusUnit.setEnabled(1) self.labelMaxDiam.setEnabled(1) self.lineEditMaxDiam.setEnabled(1) self.labelMaxDiamUnit.setEnabled(1) self.lineEditMaxRadius.setText(str(self.mdl.getMaxRadius())) self.lineEditMaxDiam.setText(str(self.mdl.getMaxDiameter())) @pyqtSlot(str) def slotWallFunctionModel(self, text): """ configure wall function model """ value = self.modelWallFunctionModel.dicoV2M[text] log.debug("slotWallFunctionModel -> %s" % value) self.mdl.setWallFunctionModel(value) @pyqtSlot(str) def slotYPlus(self, text): """ configure Y Plus model """ value = self.modelYPlus.dicoV2M[text] log.debug("slotYPlus -> %s" % value) self.mdl.setYPlusModel(value) if value == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() @pyqtSlot(str) def slotYPlusValue(self, text): """ Update the Yplus value """ if self.lineEditYPlus.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setYPlusValue(value) @pyqtSlot(str) def slotMaxRadius(self, text): """ Update the max radius """ if self.lineEditMaxRadius.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxRadius(value) @pyqtSlot(str) def slotMaxDiam(self, text): """ Update the max diameter """ if self.lineEditMaxDiam.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxDiameter(value) @pyqtSlot(str) def slotMaxOverSaturation(self, text): """ Update the maximum oversaturation temperature """ if self.lineEditMaxOverSaturation.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxOverSaturation(value) @pyqtSlot(str) def slotThermalConductivity(self, text): """ Update the thermal conductivity """ if self.lineEditThermalConductivity.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setThermalConductivity(value) @pyqtSlot(str) def slotDensity(self, text): """ Update the density """ if self.lineEditDensity.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setDensity(value) @pyqtSlot(str) def slotSpecificHeat(self, text): """ Update the specific heat """ if self.lineEditSpecificHeat.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setSpecificHeat(value) @pyqtSlot(bool) def slotThickness(self, checked): """ check box for Y Plus """ status = 'off' if checked: status = 'on' self.mdl.setThicknessStatus(status) if status == 'on': self.lineEditThickness.show() self.labelThickness1.show() self.labelThickness2.show() self.lineEditThickness.setText(str(self.mdl.getThicknessValue())) else: self.lineEditThickness.hide() self.labelThickness1.hide() self.labelThickness2.hide() @pyqtSlot(str) def slotThicknessValue(self, text): """ Update the thickness value """ if self.lineEditThickness.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setThicknessValue(value)
class EnthalpyDelegate(QItemDelegate): """ Use of a combo box in the table. """ def __init__(self, parent, mdl): super(EnthalpyDelegate, self).__init__(parent) self.parent = parent self.mdl = mdl def createEditor(self, parent, option, index): editor = QComboBox(parent) if self.mdl.getPredefinedFlow() == "free_surface" or \ self.mdl.getPredefinedFlow() == "boiling_flow" or \ self.mdl.getPredefinedFlow() == "droplet_flow": self.modelCombo = ComboModel(editor, 2, 1) self.modelCombo.addItem(self.tr("off"), 'off') self.modelCombo.addItem(self.tr("total enthalpy"), 'total_enthalpy') else: self.modelCombo = ComboModel(editor, 3, 1) self.modelCombo.addItem(self.tr("off"), 'off') self.modelCombo.addItem(self.tr("total enthalpy"), 'total_enthalpy') self.modelCombo.addItem(self.tr("specific enthalpy"), 'specific_enthalpy') editor.installEventFilter(self) return editor def setEditorData(self, comboBox, index): col = index.column() string = index.model().getData(index)[col] self.modelCombo.setItem(str_model=string) def setModelData(self, comboBox, model, index): txt = str(comboBox.currentText()) value = self.modelCombo.dicoV2M[txt] log.debug("EnthalpyDelegate value = %s" % value) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, to_qvariant(value), Qt.DisplayRole) def tr(self, text): return text
class NumericalParamGlobalView(QWidget, Ui_NumericalParamGlobalForm): """ """ def __init__(self, parent, case, tree): """ Constructor """ QWidget.__init__(self, parent) Ui_NumericalParamGlobalForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = NumericalParamGlobalModel(self.case) self.browser = tree self.labelSRROM.hide() self.lineEditSRROM.hide() self.line_5.hide() # Combo models self.modelEXTRAG = ComboModel(self.comboBoxEXTRAG,2,1) self.modelIMRGRA = ComboModel(self.comboBoxIMRGRA,5,1) self.modelNTERUP = ComboModel(self.comboBoxNTERUP,3,1) self.modelEXTRAG.addItem(self.tr("Neumann 1st order"), 'neumann') self.modelEXTRAG.addItem(self.tr("Extrapolation"), 'extrapolation') self.modelIMRGRA.addItem(self.tr("Iterative handling of non-orthogonalities"),'0') self.modelIMRGRA.addItem(self.tr("Least squares method over neighboring cells"),'1') self.modelIMRGRA.addItem(self.tr("Least squares method over extended cell neighborhood"),'2') self.modelIMRGRA.addItem(self.tr("Least squares method over partial extended cell neighborhood"),'3') self.modelIMRGRA.addItem(self.tr("Iterative method with least squares initialization"),'4') self.modelNTERUP.addItem(self.tr("SIMPLE"), 'simple') self.modelNTERUP.addItem(self.tr("SIMPLEC"),'simplec') self.modelNTERUP.addItem(self.tr("PISO"),'piso') self.comboBoxEXTRAG.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.comboBoxNTERUP.setSizeAdjustPolicy(QComboBox.AdjustToContents) # Connections self.connect(self.checkBoxIVISSE, SIGNAL("clicked()"), self.slotIVISSE) self.connect(self.checkBoxIPUCOU, SIGNAL("clicked()"), self.slotIPUCOU) self.connect(self.checkBoxICFGRP, SIGNAL("clicked()"), self.slotICFGRP) self.connect(self.checkBoxImprovedPressure, SIGNAL("clicked()"), self.slotImprovedPressure) self.connect(self.comboBoxEXTRAG, SIGNAL("activated(const QString&)"), self.slotEXTRAG) self.connect(self.lineEditRELAXP, SIGNAL("textChanged(const QString &)"), self.slotRELAXP) self.connect(self.comboBoxIMRGRA, SIGNAL("activated(const QString&)"), self.slotIMRGRA) self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM) self.connect(self.comboBoxNTERUP, SIGNAL("activated(const QString&)"), self.slotNTERUP) self.connect(self.spinBoxNTERUP, SIGNAL("valueChanged(int)"), self.slotNTERUP2) # Validators validatorRELAXP = DoubleValidator(self.lineEditRELAXP, min=0., max=1.) validatorRELAXP.setExclusiveMin(True) validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0., max=1.) validatorSRROM.setExclusiveMin(True) self.lineEditRELAXP.setValidator(validatorRELAXP) self.lineEditSRROM.setValidator(validatorSRROM) if self.model.getTransposedGradient() == 'on': self.checkBoxIVISSE.setChecked(True) else: self.checkBoxIVISSE.setChecked(False) if self.model.getVelocityPressureCoupling() == 'on': self.checkBoxIPUCOU.setChecked(True) else: self.checkBoxIPUCOU.setChecked(False) import code_saturne.Pages.FluidCharacteristicsModel as FluidCharacteristics fluid = FluidCharacteristics.FluidCharacteristicsModel(self.case) modl_atmo, modl_joul, modl_thermo, modl_gas, modl_coal, modl_comp = fluid.getThermoPhysicalModel() if self.model.getHydrostaticPressure() == 'on': self.checkBoxImprovedPressure.setChecked(True) else: self.checkBoxImprovedPressure.setChecked(False) self.lineEditRELAXP.setText(str(self.model.getPressureRelaxation())) self.modelEXTRAG.setItem(str_model=self.model.getWallPressureExtrapolation()) self.modelIMRGRA.setItem(str_model=str(self.model.getGradientReconstruction())) if modl_joul != 'off' or modl_gas != 'off' or modl_coal != 'off': self.labelSRROM.show() self.lineEditSRROM.show() self.lineEditSRROM.setText(str(self.model.getDensityRelaxation())) self.line_5.show() algo = self.model.getVelocityPressureAlgorithm() status = SteadyManagementModel(self.case).getSteadyFlowManagement() if status == 'on': self.modelNTERUP.enableItem(str_model = 'simple') self.modelNTERUP.disableItem(str_model = 'piso') else: self.modelNTERUP.disableItem(str_model = 'simple') self.modelNTERUP.enableItem(str_model = 'piso') self.modelNTERUP.setItem(str_model=algo) if algo == 'piso': self.spinBoxNTERUP.show() else: self.spinBoxNTERUP.hide() if modl_comp != 'off': self.labelICFGRP.show() self.checkBoxICFGRP.show() self.line_4.show() if self.model.getHydrostaticEquilibrium() == 'on': self.checkBoxICFGRP.setChecked(True) else: self.checkBoxICFGRP.setChecked(False) self.checkBoxIPUCOU.hide() self.labelIPUCOU.hide() self.lineEditRELAXP.hide() self.labelRELAXP.hide() self.checkBoxImprovedPressure.hide() self.labelImprovedPressure.hide() self.line_2.hide() self.line_5.hide() self.line_7.hide() self.line_8.hide() self.labelNTERUP.setText("Velocity-Pressure algorithm\nsub-iterations on Navier-Stokes") self.comboBoxNTERUP.hide() self.spinBoxNTERUP.show() else: self.labelICFGRP.hide() self.checkBoxICFGRP.hide() self.line_4.hide() self.checkBoxIPUCOU.show() self.labelIPUCOU.show() self.lineEditRELAXP.show() self.labelRELAXP.show() self.checkBoxImprovedPressure.show() self.labelImprovedPressure.show() self.line_2.show() self.line_5.show() self.line_7.show() self.line_8.show() value = self.model.getPisoSweepNumber() self.spinBoxNTERUP.setValue(value) # Update the Tree files and folders self.browser.configureTree(self.case) self.case.undoStartGlobal() @pyqtSignature("") def slotIVISSE(self): """ Set value for parameter IVISSE """ if self.checkBoxIVISSE.isChecked(): self.model.setTransposedGradient("on") else: self.model.setTransposedGradient("off") @pyqtSignature("") def slotIPUCOU(self): """ Set value for parameter IPUCOU """ if self.checkBoxIPUCOU.isChecked(): self.model.setVelocityPressureCoupling("on") else: self.model.setVelocityPressureCoupling("off") @pyqtSignature("") def slotICFGRP(self): """ Set value for parameter IPUCOU """ if self.checkBoxICFGRP.isChecked(): self.model.setHydrostaticEquilibrium("on") else: self.model.setHydrostaticEquilibrium("off") @pyqtSignature("") def slotImprovedPressure(self): """ Input IHYDPR. """ if self.checkBoxImprovedPressure.isChecked(): self.model.setHydrostaticPressure("on") else: self.model.setHydrostaticPressure("off") @pyqtSignature("const QString &") def slotEXTRAG(self, text): """ Set value for parameter EXTRAG """ extrag = self.modelEXTRAG.dicoV2M[str(text)] self.model.setWallPressureExtrapolation(extrag) log.debug("slotEXTRAG-> %s" % extrag) @pyqtSignature("const QString &") def slotRELAXP(self, text): """ Set value for parameter RELAXP """ if self.sender().validator().state == QValidator.Acceptable: relaxp = from_qvariant(text, float) self.model.setPressureRelaxation(relaxp) log.debug("slotRELAXP-> %s" % relaxp) @pyqtSignature("const QString &") def slotSRROM(self, text): """ Set value for parameter SRROM """ if self.sender().validator().state == QValidator.Acceptable: srrom = from_qvariant(text, float) self.model.setDensityRelaxation(srrom) log.debug("slotSRROM-> %s" % srrom) @pyqtSignature("const QString &") def slotIMRGRA(self, text): """ Set value for parameter IMRGRA """ imrgra = self.modelIMRGRA.getIndex(str_view=str(text)) self.model.setGradientReconstruction(imrgra) log.debug("slotIMRGRA-> %s" % imrgra) @pyqtSignature("const QString &") def slotNTERUP(self,text): """ Set value for parameterNTERUP """ NTERUP = self.modelNTERUP.dicoV2M[str(text)] self.model.setVelocityPressureAlgorithm(NTERUP) if NTERUP == 'piso': self.spinBoxNTERUP.show() value = self.model.getPisoSweepNumber() self.spinBoxNTERUP.setValue(value) else: self.spinBoxNTERUP.hide() self.browser.configureTree(self.case) log.debug("slotNTERUP-> %s" % NTERUP) @pyqtSignature("const QString &") def slotNTERUP2(self, var): """ Set value for parameter piso sweep number """ self.model.setPisoSweepNumber(var) log.debug("slotNTERUP2-> %s" % var) def tr(self, text): """ Translation """ return text
class DropletCondensationEvaporationView(QWidget, Ui_DropletCondensationEvaporation): """ Droplet Condensation-Evaporation model layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DropletCondensationEvaporation.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DropletCondensationEvaporationModel(self.case) self.modelYPlus = ComboModel(self.comboBoxYPlus, 3, 1) self.modelYPlus.addItem(self.tr("Boundary cell center"), "center") self.modelYPlus.addItem(self.tr("Y+ = "), "Yplus_value") self.modelYPlus.addItem(self.tr("Droplets diameter"), "diameter") # Validators validatorYplus = DoubleValidator(self.lineEditYPlus, min=0.0) validatorYplus.setExclusiveMin(True) self.lineEditYPlus.setValidator(validatorYplus) # Connect signals to slots self.comboBoxYPlus.activated[str].connect(self.slotYPlus) self.lineEditYPlus.textChanged[str].connect(self.slotYPlusValue) isYPlus = self.mdl.getYPlusModel() self.modelYPlus.setItem(str_model=isYPlus) if isYPlus == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() self.case.undoStartGlobal() @pyqtSlot(str) def slotYPlus(self, text): """ configure Y Plus model """ value = self.modelYPlus.dicoV2M[text] log.debug("slotYPlus -> %s" % value) self.mdl.setYPlusModel(value) if value == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() @pyqtSlot(str) def slotYPlusValue(self, text): """ Update the Yplus value """ if self.lineEditYPlus.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setYPlusValue(value)
class GlobalNumericalParametersAdvancedOptionsDialogView( QDialog, Ui_GlobalNumericalParametersAdvancedOptionsDialog): """ Advanced global numerical parameters layout. """ def __init__(self, parent, case, default): """ Constructor """ QDialog.__init__(self, parent) Ui_GlobalNumericalParametersAdvancedOptionsDialog.__init__(self) self.setupUi(self) title = self.tr("Advanced options for Global Numerical Parameters") self.setWindowTitle(title) self.default = default self.result = self.default.copy() self.case = case self.case.undoStopGlobal() # Combo model self.modelVelocityUpdate = ComboModel(self.comboBoxVelocityUpdate, 4, 1) self.modelVelocityUpdate.addItem( self.tr("By the pressure gradient increment"), "pressure_gradient_increment") self.modelVelocityUpdate.addItem( self.tr("RT0 by flow rate (internal+boundary)"), "flow_rate") self.modelVelocityUpdate.addItem(self.tr("RT0 by flumas(b) increment"), "flumas_increment") self.modelVelocityUpdate.addItem( self.tr("By means of Conv+Diff+ST equation"), "conv_diff_equation") self.modelGradientPressure = ComboModel(self.comboBoxGradientPressure, 5, 1) self.modelGradientPressure.addItem(self.tr("Mass ponderation"), "mass_ponderation") self.modelGradientPressure.addItem(self.tr("Standard"), "standard") self.modelGradientPressure.addItem( self.tr("Controlled mass ponderation"), "controlled_mass_pound") self.modelGradientPressure.addItem(self.tr("Momentum ponderation"), "momentum_pound") self.modelGradientPressure.addItem(self.tr("Gravity+HL+ST momentum"), "gravity_momentum") # Validator validatorSumAlpha = DoubleValidator(self.lineEditMaxSumAlpha, min=0., max=1.) validatorAlphaP = IntValidator(self.lineEditNumberAlphaPCycle, min=1) validatorSumAlpha.setExclusiveMin(False) validatorAlphaP.setExclusiveMin(False) self.lineEditMaxSumAlpha.setValidator(validatorSumAlpha) self.lineEditNumberAlphaPCycle.setValidator(validatorAlphaP) # Initialization if self.result['pressure_symetrisation'] == 'on': self.checkBoxSymetPressure.setChecked(True) else: self.checkBoxSymetPressure.setChecked(False) self.modelVelocityUpdate.setItem( str_model=self.result['velocity_update']) self.modelGradientPressure.setItem( str_model=self.result['pressure_gradient']) self.lineEditMaxSumAlpha.setText(str(self.result['max_sum_alpha'])) self.lineEditNumberAlphaPCycle.setText( str(self.result['alpha_p_cycle'])) self.case.undoStartGlobal()
class BoundaryConditionsCoalInletView(QWidget, Ui_BoundaryConditionsCoalInletForm): def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsCoalInletForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.case = case self.__boundary = None self.case.undoStopGlobal() self.notebook = NotebookModel(self.case) # Connections self.comboBoxTypeInlet.activated[str].connect(self.__slotInletType) self.comboBoxVelocity.activated[str].connect(self.__slotChoiceVelocity) self.lineEditVelocity.textChanged[str].connect( self.__slotVelocityValue) self.lineEditTemperature.textChanged[str].connect( self.__slotTemperature) self.spinBoxOxydantNumber.valueChanged[int].connect( self.__slotOxydantNumber) self.comboBoxDirection.activated[str].connect( self.__slotChoiceDirection) self.lineEditDirectionX.textChanged[str].connect(self.__slotDirX) self.lineEditDirectionY.textChanged[str].connect(self.__slotDirY) self.lineEditDirectionZ.textChanged[str].connect(self.__slotDirZ) # Combo models self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("only oxydant"), 'oxydantFlow') self.modelTypeInlet.addItem(self.tr("oxydant and coal"), 'coalFlow') self.modelVelocity = ComboModel(self.comboBoxVelocity, 4, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorTemp = DoubleValidator(self.lineEditTemperature, min=0.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditTemperature.setValidator(validatorTemp) self.pushButtonVelocityFormula.clicked.connect( self.__slotVelocityFormula) self.pushButtonDirectionFormula.clicked.connect( self.__slotDirectionFormula) # Useful information about coals, classes, and ratios mdl = CoalCombustion.CoalCombustionModel(self.case) if mdl.getCoalCombustionModel() != "off": self.__coalNumber = mdl.getCoalNumber() self.__coalClassesNumber = [] for coal in range(0, self.__coalNumber): self.__coalClassesNumber.append( mdl.getClassNumber(str(coal + 1))) self.__maxOxydantNumber = mdl.getOxidantNumber() else: self.__coalNumber = 0 self.__coalClassesNumber = [0] self.__maxOxydantNumber = 1 self.__ratio = self.__coalNumber * [0] for i in range(0, self.__coalNumber): self.__ratio[i] = self.__coalClassesNumber[i] * [0] # Coal table self.__modelCoal = StandardItemModelCoal(self.case) self.tableViewCoal.setModel(self.__modelCoal) delegateValue = FloatDelegate(self.tableViewCoal, minVal=0.) self.tableViewCoal.setItemDelegateForColumn(1, delegateValue) self.tableViewCoal.setItemDelegateForColumn(2, delegateValue) # Coal mass ratio table self.__modelCoalMass = StandardItemModelCoalMass( self.case, self.__coalNumber, self.__coalClassesNumber) self.tableViewCoalMass.setModel(self.__modelCoalMass) delegateValueMass = FloatDelegate(self.tableViewCoalMass, minVal=0.) for c in range(self.__modelCoalMass.columnCount()): self.tableViewCoalMass.setItemDelegateForColumn( c, delegateValueMass) self.case.undoStartGlobal() def showWidget(self, b): """ Show the widget """ label = b.getLabel() self.__boundary = Boundary('coal_inlet', label, self.case) # Initialize velocity choice = self.__boundary.getVelocityChoice() self.modelVelocity.setItem(str_model=choice) self.__updateLabel() if choice[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) self.lineEditVelocity.setEnabled(False) else: self.pushButtonVelocityFormula.setEnabled(False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) # Initialize oxydant and temperature self.spinBoxOxydantNumber.setMaximum(self.__maxOxydantNumber) o = self.__boundary.getOxydantNumber() self.spinBoxOxydantNumber.setValue(o) t = self.__boundary.getOxydantTemperature() self.lineEditTemperature.setText(str(t)) # Initialize direction choice = self.__boundary.getDirectionChoice() self.modelDirection.setItem(str_model=choice) text = self.modelDirection.dicoM2V[choice] if choice == "formula": self.pushButtonDirectionFormula.setEnabled(True) self.frameDirectionCoordinates.hide() elif choice == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif choice == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.hide() log.debug("showWidget:inlet type: %s " % self.__boundary.getInletType()) if self.__boundary.getInletType() == "coalFlow": self.modelTypeInlet.setItem(str_model="coalFlow") self.groupBoxCoal.show() self.groupBoxCoalMass.show() self.__updateTables() self.__boundary.setInletType("coalFlow") else: self.__boundary.setInletType("oxydantFlow") self.modelTypeInlet.setItem(str_model="oxydantFlow") self.groupBoxCoal.hide() self.groupBoxCoalMass.hide() self.show() def hideWidget(self): """ Hide all """ self.hide() def __updateTables(self): """ Insert rows in the two QTableView. """ # clean the QTableView self.__modelCoal.deleteAll() self.__modelCoalMass.deleteAll() label = self.__boundary.getLabel() self.__modelCoalMass.setBoundaryFromLabel(label) self.__modelCoal.setBoundaryFromLabel(label) # fill the flow and temperature of the coal for coal in range(0, self.__coalNumber): self.__modelCoal.insertItem( self.tr("Coal ") + " " + str(coal + 1), self.__boundary.getCoalFlow(coal), self.__boundary.getCoalTemperature(coal)) # fill the ratio of mass for each class for each coal for coal in range(0, self.__coalNumber): lastValue = 0. for coalClass in range(0, self.__coalClassesNumber[coal] - 1): lst = self.__boundary.getCoalRatios(coal) lastValue += lst[coalClass] self.__ratio[coal][coalClass] = lst[coalClass] # last class is computed in order to assure that sum is egal to 100% coalClass = self.__coalClassesNumber[coal] - 1 lastValue = 100 - lastValue self.__ratio[coal][coalClass] = lastValue self.__modelCoalMass.setRatio(self.__ratio) @pyqtSlot(str) def __slotChoiceVelocity(self, text): """ Private slot. Input the velocity boundary type choice (norm, ). @type text: C{QString} @param text: velocity boundary type choice. """ c = self.modelVelocity.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setVelocityChoice(c) if c[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) exp = self.__boundary.getVelocity() if exp: self.pushButtonVelocityFormula.setStyleSheet( "background-color: green") self.pushButtonVelocityFormula.setToolTip(exp) else: self.pushButtonVelocityFormula.setStyleSheet( "background-color: red") self.lineEditVelocity.setEnabled(False) self.lineEditVelocity.setText("") else: self.pushButtonVelocityFormula.setEnabled(False) self.pushButtonVelocityFormula.setStyleSheet( "background-color: None") self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) self.__updateLabel() def __updateLabel(self): """ Update the unit for the velocity specification. """ c = self.__boundary.getVelocityChoice() if c in ('norm', 'norm_formula'): self.labelUnitVelocity.setText(str('m/s')) elif c in ('flow1', 'flow1_formula'): self.labelUnitVelocity.setText(str('kg/s')) elif c in ('flow2', 'flow2_formula'): self.labelUnitVelocity.setText(str('m<sup>3</sup>/s')) @pyqtSlot(str) def __slotVelocityValue(self, text): """ Private slot. New value associated to the velocity boundary type. @type text: C{QString} @param text: value """ if self.sender().validator().state == QValidator.Acceptable: v = from_qvariant(text, float) self.__boundary.setVelocity(v) @pyqtSlot() def __slotVelocityFormula(self): """ """ exp = self.__boundary.getVelocity() c = self.__boundary.getVelocityChoice() if c == 'norm_formula': exa = "u_norm = 1.0;" req = [('u_norm', 'Norm of the velocity')] elif c == 'flow1_formula': exa = "q_m = 1.0;" req = [('q_m', 'mass flow rate')] elif c == 'flow2_formula': exa = "q_v = 1.0;" req = [('q_v', 'volumic flow rate')] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration'), ('surface', 'Boundary zone surface')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(parent=self, function_type='bnd', zone_name=self.__boundary._label, variable_name='velocity', expression=exp, required=req, symbols=sym, condition=c, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaVelocity -> %s" % str(result)) self.__boundary.setVelocity(str(result)) self.pushButtonVelocityFormula.setToolTip(result) self.pushButtonVelocityFormula.setStyleSheet( "background-color: green") @pyqtSlot(str) def __slotChoiceDirection(self, text): """ Input the direction type choice. """ c = self.modelDirection.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setDirectionChoice(c) if c == "formula": self.pushButtonDirectionFormula.setEnabled(True) exp = self.__boundary.getDirection('direction_formula') if exp: self.pushButtonDirectionFormula.setStyleSheet( "background-color: green") self.pushButtonDirectionFormula.setToolTip(exp) else: self.pushButtonDirectionFormula.setStyleSheet( "background-color: red") self.frameDirectionCoordinates.hide() elif c == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.pushButtonDirectionFormula.setStyleSheet( "background-color: None") self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif c == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.pushButtonDirectionFormula.setStyleSheet( "background-color: None") self.frameDirectionCoordinates.hide() @pyqtSlot(str) def __slotDirX(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_x', value) @pyqtSlot(str) def __slotDirY(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_y', value) @pyqtSlot(str) def __slotDirZ(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_z', value) @pyqtSlot() def __slotDirectionFormula(self): """ """ exp = self.__boundary.getDirection('direction_formula') req = [('dir_x', 'Direction of the flow along X'), ('dir_y', 'Direction of the flow along Y'), ('dir_z', 'Direction of the flow along Z')] exa = "dir_x = 3.0;\ndir_y = 1.0;\ndir_z = 0.0;\n" sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration'), ('surface', 'Boundary zone surface')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(parent=self, function_type='bnd', zone_name=self.__boundary._label, variable_name='direction', expression=exp, required=req, symbols=sym, condition='formula', examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaDirection -> %s" % str(result)) self.__boundary.setDirection('direction_formula', str(result)) self.pushButtonDirectionFormula.setToolTip(result) self.pushButtonDirectionFormula.setStyleSheet( "background-color: green") @pyqtSlot(str) def __slotInletType(self, text): """ INPUT inlet type : 'oxydant' or 'oxydant + coal' """ value = self.modelTypeInlet.dicoV2M[str(text)] log.debug("__slotInletType value = %s " % value) self.__boundary.setInletType(value) if value == 'oxydantFlow': self.groupBoxCoal.hide() self.groupBoxCoalMass.hide() else: self.groupBoxCoal.show() self.groupBoxCoalMass.show() self.__updateTables() @pyqtSlot(str) def __slotTemperature(self, text): if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setOxydantTemperature(t) @pyqtSlot(int) def __slotOxydantNumber(self, i): self.__boundary.setOxydantNumber(i) def getCoalNumber(self): """ Return the coal number """ return self.__coalNumber
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundariesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.modelBoundaries = StandardItemModelBoundaries( self.case, self.model) self.tableViewBoundaries.setModel(self.modelBoundaries) self.tableViewBoundaries.setAlternatingRowColors(True) if QT_API == "PYQT4": self.tableViewBoundaries.horizontalHeader().setResizeMode( QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewBoundaries.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) delegateInteraction = ParticleBoundaryInteractionDelegate( self.tableViewBoundaries) delegateSetNumber = ValueDelegate(self.tableViewBoundaries) self.tableViewBoundaries.setItemDelegateForColumn( 2, delegateInteraction) self.tableViewBoundaries.setItemDelegateForColumn(3, delegateSetNumber) self.modelIPOIT = ComboModel(self.comboBoxIPOIT, 2, 1) self.modelIPOIT.addItem(self.tr("Mass flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIJUVW = ComboModel(self.comboBoxIJUVW, 3, 1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJRTP = ComboModel(self.comboBoxIJRTP, 2, 1) self.modelIJRTP.addItem(self.tr("Fluid temperature"), "fluid") self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") self.tableViewBoundaries.clicked[QModelIndex].connect( self.slotSelectBoundary) self.modelBoundaries.dataChanged.connect(self.dataChanged) self.spinBoxICLAS.valueChanged[int].connect(self.slotICLAS) self.lineEditIJNBP.textChanged[str].connect(self.slotIJNBP) self.lineEditIJFRE.textChanged[str].connect(self.slotIJFRE) self.lineEditICLST.textChanged[str].connect(self.slotICLST) self.lineEditIDEBT.textChanged[str].connect(self.slotIDEBT) self.comboBoxIPOIT.activated[str].connect(self.slotIPOITChoice) self.lineEditIPOIT.textChanged[str].connect(self.slotIPOIT) self.lineEditIROPT.textChanged[str].connect(self.slotIROPT) self.lineEditIRCOLM.textChanged[str].connect(self.slotIRCOLM) self.comboBoxIJUVW.activated[str].connect(self.slotIJUVW) self.lineEditIUNO.textChanged[str].connect(self.slotIUNO) self.lineEditIUPT.textChanged[str].connect(self.slotIUPT) self.lineEditIVPT.textChanged[str].connect(self.slotIVPT) self.lineEditIWPT.textChanged[str].connect(self.slotIWPT) self.comboBoxIJRTP.activated[str].connect(self.slotIJRTP) self.lineEditITPT.textChanged[str].connect(self.slotITPT) self.lineEditICPT.textChanged[str].connect(self.slotICPT) self.lineEditIEPSI.textChanged[str].connect(self.slotIEPSI) self.lineEditIDPT.textChanged[str].connect(self.slotIDPT) self.lineEditIVDPT.textChanged[str].connect(self.slotIVDPT) self.lineEditINUCHL.textChanged[str].connect(self.slotINUCHL) self.lineEditIHPT.textChanged[str].connect(self.slotIHPT) # Validators validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIRCOLM = DoubleValidator(self.lineEditIRCOLM, min=0.) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIRCOLM.setValidator(validatorIRCOLM) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) self._hideAllWidgets() self.case.undoStartGlobal()
def setup(self, case): """ Setup the widget """ self.case = case self.__boundary = None self.case.undoStopGlobal() self.notebook = NotebookModel(self.case) # Connections self.comboBoxTypeInlet.activated[str].connect(self.__slotInletType) self.comboBoxVelocity.activated[str].connect(self.__slotChoiceVelocity) self.lineEditVelocity.textChanged[str].connect( self.__slotVelocityValue) self.lineEditTemperature.textChanged[str].connect( self.__slotTemperature) self.spinBoxOxydantNumber.valueChanged[int].connect( self.__slotOxydantNumber) self.comboBoxDirection.activated[str].connect( self.__slotChoiceDirection) self.lineEditDirectionX.textChanged[str].connect(self.__slotDirX) self.lineEditDirectionY.textChanged[str].connect(self.__slotDirY) self.lineEditDirectionZ.textChanged[str].connect(self.__slotDirZ) # Combo models self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("only oxydant"), 'oxydantFlow') self.modelTypeInlet.addItem(self.tr("oxydant and coal"), 'coalFlow') self.modelVelocity = ComboModel(self.comboBoxVelocity, 4, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorTemp = DoubleValidator(self.lineEditTemperature, min=0.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditTemperature.setValidator(validatorTemp) self.pushButtonVelocityFormula.clicked.connect( self.__slotVelocityFormula) self.pushButtonDirectionFormula.clicked.connect( self.__slotDirectionFormula) # Useful information about coals, classes, and ratios mdl = CoalCombustion.CoalCombustionModel(self.case) if mdl.getCoalCombustionModel() != "off": self.__coalNumber = mdl.getCoalNumber() self.__coalClassesNumber = [] for coal in range(0, self.__coalNumber): self.__coalClassesNumber.append( mdl.getClassNumber(str(coal + 1))) self.__maxOxydantNumber = mdl.getOxidantNumber() else: self.__coalNumber = 0 self.__coalClassesNumber = [0] self.__maxOxydantNumber = 1 self.__ratio = self.__coalNumber * [0] for i in range(0, self.__coalNumber): self.__ratio[i] = self.__coalClassesNumber[i] * [0] # Coal table self.__modelCoal = StandardItemModelCoal(self.case) self.tableViewCoal.setModel(self.__modelCoal) delegateValue = FloatDelegate(self.tableViewCoal, minVal=0.) self.tableViewCoal.setItemDelegateForColumn(1, delegateValue) self.tableViewCoal.setItemDelegateForColumn(2, delegateValue) # Coal mass ratio table self.__modelCoalMass = StandardItemModelCoalMass( self.case, self.__coalNumber, self.__coalClassesNumber) self.tableViewCoalMass.setModel(self.__modelCoalMass) delegateValueMass = FloatDelegate(self.tableViewCoalMass, minVal=0.) for c in range(self.__modelCoalMass.columnCount()): self.tableViewCoalMass.setItemDelegateForColumn( c, delegateValueMass) self.case.undoStartGlobal()
class BoundaryConditionsWallRadiativeTransferView( QWidget, Ui_BoundaryConditionsWallRadiativeTransferForm): """ """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsWallRadiativeTransferForm.__init__(self) self.setupUi(self) validatorEmissivity = DoubleValidator(self.lineEditEmissivity, min=0.0) self.lineEditEmissivity.setValidator(validatorEmissivity) validatorConductivity = DoubleValidator(self.lineEditConductivity, min=0.0) self.lineEditConductivity.setValidator(validatorConductivity) validatorThickness = DoubleValidator(self.lineEditThickness, min=0.0) self.lineEditThickness.setValidator(validatorThickness) validatorExtTemperature = DoubleValidator(self.lineEditExtTemperature, min=0.0) self.lineEditExtTemperature.setValidator(validatorExtTemperature) validatorIntTemperature = DoubleValidator(self.lineEditIntTemperature, min=0.0) self.lineEditIntTemperature.setValidator(validatorIntTemperature) validatorConductionFlux = DoubleValidator(self.lineEditConductionFlux, min=0.0) self.lineEditConductionFlux.setValidator(validatorConductionFlux) def __updateView__(self): cond = self.__boundary.getRadiativeChoice() #self.labelEmissivity.show() #self.lineEditEmissivity.show() self.lineEditEmissivity.setText(str(self.__boundary.getEmissivity())) #self.labelIntTemperature.hide() #self.lineEditIntTemperature.hide() #self.labelIntTemperatureUnit.hide() self.lineEditIntTemperature.setText( str(self.__boundary.getInternalTemperatureProfile())) self.labelConductivity.hide() self.lineEditConductivity.hide() self.labelConductivityUnit.hide() self.lineEditConductivity.setText( str(self.__boundary.getThermalConductivity())) self.labelThickness.hide() self.lineEditThickness.hide() self.labelThicknessUnit.hide() self.lineEditThickness.setText(str(self.__boundary.getThickness())) self.labelExtTemperature.hide() self.lineEditExtTemperature.hide() self.labelExtTemperatureUnit.hide() self.lineEditExtTemperature.setText( str(self.__boundary.getExternalTemperatureProfile())) self.labelConductionFlux.hide() self.lineEditConductionFlux.hide() self.labelConductionFluxUnit.hide() self.lineEditConductionFlux.setText(str(self.__boundary.getFlux())) if cond == 'ipgrno': self.labelConductivity.show() self.lineEditConductivity.show() self.labelConductivityUnit.show() self.labelThickness.show() self.lineEditThickness.show() self.labelThicknessUnit.show() self.labelExtTemperature.show() self.lineEditExtTemperature.show() self.labelExtTemperatureUnit.show() elif cond == 'ifgrno': self.labelConductionFlux.show() self.lineEditConductionFlux.show() self.labelConductionFluxUnit.show() def setup(self, case): """ Setup the widget """ self.case = case self.__boundary = None self.case.undoStopGlobal() # Create the Page layout. # Combo self.modelRadiative = ComboModel(self.comboBoxRadiative, 3, 1) self.modelRadiative.addItem(self.tr("Fixed interior temperature"), 'itpimp') self.modelRadiative.addItem(self.tr("Fixed exterior temperature"), 'ipgrno') self.modelRadiative.addItem(self.tr("Fixed conduction flux"), 'ifgrno') # Connections self.comboBoxRadiative.activated[str].connect(self.slotRadiativeChoice) self.lineEditEmissivity.textChanged[str].connect(self.slotEmissivity) self.lineEditConductivity.textChanged[str].connect( self.slotConductivity) self.lineEditThickness.textChanged[str].connect(self.slotThickness) self.lineEditExtTemperature.textChanged[str].connect( self.slotExtTemperature) self.lineEditIntTemperature.textChanged[str].connect( self.slotIntTemperature) self.lineEditConductionFlux.textChanged[str].connect( self.slotConductionFlux) self.case.undoStartGlobal() def showWidget(self, b): """ Show the widget """ if ThermalRadiationModel(self.case).getRadiativeModel() != "off": label = b.getLabel() self.__boundary = Boundary('radiative_wall', label, self.case) choice = self.__boundary.getRadiativeChoice() self.modelRadiative.setItem(str_model=choice) self.__updateView__() self.show() else:
class ElectricalView(QWidget, Ui_ElectricalForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_ElectricalForm.__init__(self) self.setupUi(self) self.case = case self.stbar = stbar self.case.undoStopGlobal() self.model = ElectricalModel(self.case) # Combo model self.modelJoule = ComboModel(self.comboBoxJouleModel, 4, 1) self.modelJoule.addItem(self.tr("AC/DC"), "AC/DC") self.modelJoule.addItem(self.tr("three-phase"), "three-phase") self.modelJoule.addItem(self.tr("AC/DC with Transformer coupling"), "AC/DC+Transformer") self.modelJoule.addItem(self.tr("three-phase with Transformer coupling"), "three-phase+Transformer") self.modelJoule.disableItem(str_model="AC/DC+Transformer") self.modelJoule.disableItem(str_model="three-phase+Transformer") self.modelScaling = ComboModel(self.comboBoxScalingModel, 3, 1) self.modelScaling.addItem(self.tr("general case"), "general_case") self.modelScaling.addItem(self.tr("plane define"), "plane_define") self.modelScaling.addItem(self.tr("user define"), "user") self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("X"), "X") self.modelDirection.addItem(self.tr("Y"), "Y") self.modelDirection.addItem(self.tr("Z"), "Z") # Connections self.connect(self.pushButtonPropertiesData, SIGNAL("pressed()"), self.__slotSearchPropertiesData) self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM) self.connect(self.lineEditPower, SIGNAL("textChanged(const QString &)"), self.slotPower) self.connect(self.lineEditCurrent, SIGNAL("textChanged(const QString &)"), self.slotCurrent) self.connect(self.checkBoxScaling, SIGNAL("clicked()"), self.slotScaling) self.connect(self.comboBoxJouleModel, SIGNAL("activated(const QString&)"), self.slotJouleModel) self.connect(self.comboBoxScalingModel, SIGNAL("activated(const QString&)"), self.slotScalingModel) self.connect(self.comboBoxDirection, SIGNAL("clicked()"), self.slotDirection) self.connect(self.lineEditPlaneDefinitionA, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefA) self.connect(self.lineEditPlaneDefinitionB, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefB) self.connect(self.lineEditPlaneDefinitionC, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefC) self.connect(self.lineEditPlaneDefinitionD, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefD) self.connect(self.lineEditEpsilon, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefEpsilon) # Validators validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0.0, max=1.0) validatorSRROM.setExclusiveMin(False) validatorPower = DoubleValidator(self.lineEditPower, min=0.0) validatorPower.setExclusiveMin(False) validatorCurrent = DoubleValidator(self.lineEditCurrent, min=0.0) validatorCurrent.setExclusiveMin(False) validatorDefinitionA = DoubleValidator(self.lineEditPlaneDefinitionA) validatorDefinitionB = DoubleValidator(self.lineEditPlaneDefinitionB) validatorDefinitionC = DoubleValidator(self.lineEditPlaneDefinitionC) validatorDefinitionD = DoubleValidator(self.lineEditPlaneDefinitionD) validatorEpsilon = DoubleValidator(self.lineEditEpsilon) self.lineEditSRROM.setValidator(validatorSRROM) self.lineEditPower.setValidator(validatorPower) self.lineEditCurrent.setValidator(validatorCurrent) self.lineEditPlaneDefinitionA.setValidator(validatorDefinitionA) self.lineEditPlaneDefinitionB.setValidator(validatorDefinitionB) self.lineEditPlaneDefinitionC.setValidator(validatorDefinitionC) self.lineEditPlaneDefinitionD.setValidator(validatorDefinitionD) self.lineEditEpsilon.setValidator(validatorEpsilon) # Initialize widget self.__initializeWidget() self.case.undoStartGlobal() @pyqtSignature("") def __initializeWidget(self): """ Initialize widget """ name = self.model.getPropertiesDataFileName() if name != None: self.labelPropertiesFile.setText(str(name)) setGreenColor(self.pushButtonPropertiesData, False) else: setGreenColor(self.pushButtonPropertiesData, True) srrom = self.model.getSRROM() self.lineEditSRROM.setText(str(srrom)) self.groupBoxRecalage.hide() if self.model.getScaling() == 'on': self.checkBoxScaling.setChecked(True) self.labelScalingModel.show() self.comboBoxScalingModel.show() else: self.checkBoxScaling.setChecked(False) self.labelScalingModel.hide() self.comboBoxScalingModel.hide() if self.model.getElectricalModel() == "joule": self.groupBoxJoule.show() self.groupBoxElectricArc.hide() model = self.model.getJouleModel() self.modelJoule.setItem(str_model=str(model)) power = self.model.getPower() self.lineEditPower.setText(str(power)) self.labelPropertiesData.hide() self.pushButtonPropertiesData.hide() self.labelPropertiesFile.hide() self.pushButtonPropertiesData.hide() self.labelPropertiesData.hide() self.labelPropertiesFile.hide() elif self.model.getElectricalModel() == "arc": self.groupBoxJoule.hide() self.groupBoxElectricArc.show() current = self.model.getCurrent() self.lineEditCurrent.setText(str(current)) if self.model.getScaling() == 'on': model = self.model.getScalingModel() self.modelScaling.setItem(str_model=str(model)) if model == 'plane_define': self.groupBoxRecalage.show() direction = self.model.getDirection() self.modelDirection.setItem(str_model=str(direction)) definition = self.model.getPlaneDefinition("A") self.lineEditPlaneDefinitionA.setText(str(definition)) definition = self.model.getPlaneDefinition("B") self.lineEditPlaneDefinitionB.setText(str(definition)) definition = self.model.getPlaneDefinition("C") self.lineEditPlaneDefinitionC.setText(str(definition)) definition = self.model.getPlaneDefinition("D") self.lineEditPlaneDefinitionD.setText(str(definition)) definition = self.model.getPlaneDefinition("epsilon") self.lineEditEpsilon.setText(str(definition)) @pyqtSignature("") def __slotSearchPropertiesData(self): """ Select a properties file of data for electric arc """ data = self.case['data_path'] title = self.tr("Properties file of data.") filetypes = self.tr("Properties data (*dp_ELE*);;All Files (*)") file = QFileDialog.getOpenFileName(self, title, data, filetypes) file = str(file) if not file: return file = os.path.basename(file) if file not in os.listdir(data): title = self.tr("WARNING") msg = self.tr("This selected file is not in the DATA directory") QMessageBox.information(self, title, msg) else: self.labelPropertiesFile.setText(str(file)) self.model.setPropertiesDataFileName(file) setGreenColor(self.pushButtonPropertiesData, False) @pyqtSignature("const QString &") def slotSRROM(self, text): """ Input Relaxation coefficient for mass density """ if self.sender().validator().state == QValidator.Acceptable: srrom = from_qvariant(text, float) self.model.setSRROM(srrom) @pyqtSignature("const QString &") def slotPower(self, text): """ Input Imposed Power """ if self.sender().validator().state == QValidator.Acceptable: power = from_qvariant(text, float) self.model.setPower(power) @pyqtSignature("const QString &") def slotCurrent(self, text): """ Input Imposed current intensity """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setCurrent(current) @pyqtSignature("") def slotJouleModel(self, text): """ Input Joule model. """ model = self.modelJoule.dicoV2M[str(text)] self.model.setJouleModel(model) @pyqtSignature("") def slotScaling(self): """ Input "Electric variables" scaling. """ if self.checkBoxScaling.isChecked(): self.model.setScaling("on") else: self.model.setScaling("off") self.__initializeWidget() @pyqtSignature("") def slotScalingModel(self, text): """ Input scaling model. """ model = self.modelScaling.dicoV2M[str(text)] self.model.setScalingModel(model) self.__initializeWidget() @pyqtSignature("") def slotDirection(self, text): """ Input current density direction for scaling. """ direction = self.modelDirection.dicoV2M[str(text)] self.model.setDirection(direction) @pyqtSignature("const QString &") def slotPlaneDefA(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("A", current) @pyqtSignature("const QString &") def slotPlaneDefB(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("B", current) @pyqtSignature("const QString &") def slotPlaneDefC(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("C", current) @pyqtSignature("const QString &") def slotPlaneDefD(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("D", current) @pyqtSignature("const QString &") def slotPlaneDefEpsilon(self, text): """ Input define plane """ if self.sender().validator().state == QValidator.Acceptable: current = from_qvariant(text, float) self.model.setPlaneDefinition("epsilon", current) def tr(self, text): """ Translation. """ return text
class LagrangianBoundariesView(QWidget, Ui_LagrangianBoundariesForm): """ """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundariesForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.modelBoundaries = StandardItemModelBoundaries(self.case, self.model) self.tableViewBoundaries.setModel(self.modelBoundaries) self.tableViewBoundaries.setAlternatingRowColors(True) self.tableViewBoundaries.horizontalHeader().setResizeMode(QHeaderView.Stretch) delegateInteraction = ParticleBoundaryInteractionDelegate(self.tableViewBoundaries) delegateClassNumber = ValueDelegate(self.tableViewBoundaries) self.tableViewBoundaries.setItemDelegateForColumn(2,delegateInteraction) self.tableViewBoundaries.setItemDelegateForColumn(3,delegateClassNumber) self.modelIPOIT = ComboModel(self.comboBoxIPOIT,3,1) self.modelIPOIT.addItem(self.tr("Volumic flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIPOIT.addItem(self.tr("User defined statistical weight"), "subroutine") self.modelIJUVW = ComboModel(self.comboBoxIJUVW,4,1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJUVW.addItem(self.tr("User defined velocity"), "subroutine") self.modelIJRTP = ComboModel(self.comboBoxIJRTP,2,1) self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") self.modelIJRTP.addItem(self.tr("User defined temperature"), "subroutine") self.modelIJRDP = ComboModel(self.comboBoxIJRDP,2,1) self.modelIJRDP.addItem(self.tr("Diameter set by values"), "prescribed") self.modelIJRDP.addItem(self.tr("User defined diameter"), "subroutine") self.modelIRAWCL = ComboModel(self.comboBoxIRAWCL,2,1) self.modelIRAWCL.addItem(self.tr("Raw coal"), "raw_coal_as_received") self.modelIRAWCL.addItem(self.tr("User defined"), "subroutine") self.connect(self.tableViewBoundaries, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectBoundary) self.connect(self.modelBoundaries, SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), self.dataChanged) self.connect(self.spinBoxICLAS, SIGNAL("valueChanged(int)"), self.slotICLAS) self.connect(self.lineEditIJNBP, SIGNAL("textChanged(const QString &)"), self.slotIJNBP) self.connect(self.lineEditIJFRE, SIGNAL("textChanged(const QString &)"), self.slotIJFRE) self.connect(self.lineEditICLST, SIGNAL("textChanged(const QString &)"), self.slotICLST) self.connect(self.lineEditIDEBT, SIGNAL("textChanged(const QString &)"), self.slotIDEBT) self.connect(self.comboBoxIPOIT, SIGNAL("activated(const QString&)"), self.slotIPOITChoice) self.connect(self.lineEditIPOIT, SIGNAL("textChanged(const QString &)"), self.slotIPOIT) self.connect(self.lineEditIROPT, SIGNAL("textChanged(const QString &)"), self.slotIROPT) self.connect(self.comboBoxIJUVW, SIGNAL("activated(const QString&)"), self.slotIJUVW) self.connect(self.lineEditIUNO, SIGNAL("textChanged(const QString &)"), self.slotIUNO) self.connect(self.lineEditIUPT, SIGNAL("textChanged(const QString &)"), self.slotIUPT) self.connect(self.lineEditIVPT, SIGNAL("textChanged(const QString &)"), self.slotIVPT) self.connect(self.lineEditIWPT, SIGNAL("textChanged(const QString &)"), self.slotIWPT) self.connect(self.comboBoxIJRTP, SIGNAL("activated(const QString&)"), self.slotIJRTP) self.connect(self.lineEditITPT, SIGNAL("textChanged(const QString &)"), self.slotITPT) self.connect(self.lineEditICPT, SIGNAL("textChanged(const QString &)"), self.slotICPT) self.connect(self.lineEditIEPSI, SIGNAL("textChanged(const QString &)"), self.slotIEPSI) self.connect(self.comboBoxIJRDP, SIGNAL("activated(const QString&)"), self.slotIJRDP) self.connect(self.lineEditIDPT, SIGNAL("textChanged(const QString &)"), self.slotIDPT) self.connect(self.lineEditIVDPT, SIGNAL("textChanged(const QString &)"), self.slotIVDPT) self.connect(self.lineEditINUCHL, SIGNAL("textChanged(const QString &)"), self.slotINUCHL) self.connect(self.lineEditIHPT, SIGNAL("textChanged(const QString &)"), self.slotIHPT) self.connect(self.comboBoxIRAWCL, SIGNAL("activated(const QString&)"), self.slotIRAWCL) # Validators validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) self._hideAllWidgets() self.case.undoStartGlobal() def _hideAllWidgets(self): self.groupBoxClassNumber.hide() self.groupBoxMain.hide() self.groupBoxRate.hide() self.groupBoxVelocity.hide() self.groupBoxTemperature.hide() self.groupBoxDiameter.hide() self.groupBoxCoal.hide() @pyqtSignature("const QModelIndex&") def slotSelectBoundary(self, index): """ """ self._hideAllWidgets() label, nature, interaction, nclasses = self.modelBoundaries.getItem(index.row()) self.label = label if interaction != "inlet": return self.model.setCurrentBoundaryNode(nature, label) if nclasses > 0: self.groupBoxClassNumber.show() self.spinBoxICLAS.setMinimum(1) self.spinBoxICLAS.setMaximum(nclasses) self.spinBoxICLAS.setValue(1) self.slotICLAS(1) @pyqtSignature("const QModelIndex &, const QModelIndex &") def dataChanged(self, topLeft, bottomRight): """ """ self.slotSelectBoundary(topLeft) @pyqtSignature("int") def slotICLAS(self, iclass): """ Input ICLAS. """ self.iclass = iclass index = self.tableViewBoundaries.currentIndex() label, nature, interaction, nclasses = self.modelBoundaries.getItem(index.row()) if interaction == "inlet": self.model.setCurrentClassNode(self.label, iclass) self.LM = LagrangianModel(self.case) part_model = self.LM.getParticlesModel() # Main variables self.groupBoxMain.show() npart = self.model.getNumberOfParticulesInClassValue(self.label, self.iclass) self.lineEditIJNBP.setText(str(npart)) freq = self.model.getInjectionFrequencyValue(self.label, self.iclass) self.lineEditIJFRE.setText(str(freq)) self.LSM = LagrangianStatisticsModel(self.case) if self.LSM.getGroupOfParticlesValue() > 0: igroup = self.model.getParticleGroupNumberValue(self.label, self.iclass) self.lineEditICLST.setText(str(igroup)) else: self.labelICLST.setDisabled(True) self.lineEditICLST.setDisabled(True) # Rate / stat. weight self.groupBoxRate.show() choice = self.model.getStatisticalWeightChoice(self.label, self.iclass) self.modelIPOIT.setItem(str_model=choice) text = self.modelIPOIT.dicoM2V[choice] self.slotIPOITChoice(text) # Velocity self.groupBoxVelocity.show() choice = self.model.getVelocityChoice(self.label, self.iclass) self.modelIJUVW.setItem(str_model=choice) text = self.modelIJUVW.dicoM2V[choice] self.slotIJUVW(text) # Temperature status = self.LM.getHeating() if part_model == "thermal" and status == "on": self.groupBoxTemperature.show() choice = self.model.getTemperatureChoice(self.label, self.iclass) self.modelIJRTP.setItem(str_model=choice) text = self.modelIJRTP.dicoM2V[choice] self.slotIJRTP(text) cp = self.model.getSpecificHeatValue(self.label, self.iclass) self.lineEditICPT.setText(str(cp)) eps = self.model.getEmissivityValue(self.label, self.iclass) self.lineEditIEPSI.setText(str(eps)) # Coals if CoalCombustionModel(self.case).getCoalCombustionModel() != 'off': self.groupBoxCoal.show() icoal = self.model.getCoalNumberValue(self.label, self.iclass) self.lineEditINUCHL.setText(str(icoal)) temp = self.model.getCoalTemperatureValue(self.label, self.iclass) self.lineEditIHPT.setText(str(temp)) choice = self.model.getCoalCompositionChoice(self.label, self.iclass) self.modelIRAWCL.setItem(str_model=choice) # Diameter self.groupBoxDiameter.show() choice = self.model.getDiameterChoice(self.label, self.iclass) if part_model == "coal": self.modelIJRDP.setItem(str_model="prescribed") else: self.modelIJRDP.setItem(str_model=choice) text = self.modelIJRDP.dicoM2V[choice] self.slotIJRDP(text) if choice == "prescribed": self.frameDiameter.show() diam = self.model.getDiameterValue(self.label, self.iclass) vdiam = self.model.getDiameterVarianceValue(self.label, self.iclass) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) elif choice == "subroutine": self.frameDiameter.hide() #Coal if CoalCombustionModel(self.case).getCoalCombustionModel() != 'off': self.labelIROPT.hide() self.labelUnitIROPT.hide() self.lineEditIROPT.hide() else: self.labelIROPT.show() self.labelUnitIROPT.show() self.lineEditIROPT.show() rho = self.model.getDensityValue(self.label, self.iclass) self.lineEditIROPT.setText(str(rho)) @pyqtSignature("const QString&") def slotIJNBP(self, text): """ Input IJNBP. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setNumberOfParticulesInClassValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIJFRE(self, text): """ Input IJFRE. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setInjectionFrequencyValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotICLST(self, text): """ Input ICLST. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setParticleGroupNumberValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIDEBT(self, text): """ Input IDEBT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setMassFlowRateValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIPOITChoice(self, text): """ Input IPOIT. """ choice = self.modelIPOIT.dicoV2M[str(text)] self.model.setStatisticalWeightChoice(self.label, self.iclass, choice) self.frameVolumicRate.hide() self.frameStatisticalWeight.hide() if choice == "rate": self.frameVolumicRate.show() rate = self.model.getMassFlowRateValue(self.label, self.iclass) self.lineEditIDEBT.setText(str(rate)) self.model.setStatisticalWeightValue(self.label, self.iclass, 1) elif choice == "prescribed": self.frameStatisticalWeight.show() weight = self.model.getStatisticalWeightValue(self.label, self.iclass) self.lineEditIPOIT.setText(str(weight)) elif choice == "subroutine": pass @pyqtSignature("const QString&") def slotIPOIT(self, text): """ Input IPOIT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setStatisticalWeightValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIROPT(self, text): """ Input IROPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDensityValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIJUVW(self, text): """ Input IJUVW. """ choice = self.modelIJUVW.dicoV2M[str(text)] self.model.setVelocityChoice(self.label, self.iclass, choice) self.frameVelocityNorm.hide() self.frameVelocityValues.hide() if choice == "norm": self.frameVelocityNorm.show() norm = self.model.getVelocityNormValue(self.label, self.iclass) self.lineEditIUNO.setText(str(norm)) elif choice == "components": self.frameVelocityValues.show() vu = self.model.getVelocityDirectionValue(self.label, self.iclass, "u") vv = self.model.getVelocityDirectionValue(self.label, self.iclass, "v") vw = self.model.getVelocityDirectionValue(self.label, self.iclass, "w") self.lineEditIUPT.setText(str(vu)) self.lineEditIVPT.setText(str(vv)) self.lineEditIWPT.setText(str(vw)) @pyqtSignature("const QString&") def slotIUNO(self, text): """ Input IUNO. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityNormValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIUPT(self, text): """ Input IUPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityDirectionValue(self.label, self.iclass, "u", value) @pyqtSignature("const QString&") def slotIVPT(self, text): """ Input IVPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityDirectionValue(self.label, self.iclass, "v", value) @pyqtSignature("const QString&") def slotIWPT(self, text): """ Input IWPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setVelocityDirectionValue(self.label, self.iclass, "w", value) @pyqtSignature("const QString&") def slotIJRTP(self, text): """ Input IJRTP. """ choice = self.modelIJRTP.dicoV2M[str(text)] self.model.setTemperatureChoice(self.label, self.iclass, choice) if choice == "prescribed": self.frameTemperature.show() temp = self.model.getTemperatureValue(self.label, self.iclass) self.lineEditITPT.setText(str(temp)) elif choice == "subroutine": self.frameTemperature.hide() @pyqtSignature("const QString&") def slotITPT(self, text): """ Input ITPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setTemperatureValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotICPT(self, text): """ Input ICPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setSpecificHeatValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIEPSI(self, text): """ Input IEPSI. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setEmissivityValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIJRDP(self, text): """ Input IJRDP. """ choice = self.modelIJRDP.dicoV2M[str(text)] self.model.setDiameterChoice(self.label, self.iclass, choice) if choice == "prescribed": self.frameDiameter.show() diam = self.model.getDiameterValue(self.label, self.iclass) vdiam = self.model.getDiameterVarianceValue(self.label, self.iclass) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) elif choice == "subroutine": self.frameDiameter.hide() @pyqtSignature("const QString&") def slotIDPT(self, text): """ Input IDPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDiameterValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIVDPT(self, text): """ Input IVDPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDiameterVarianceValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotINUCHL(self, text): """ Input IHPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.setCoalNumberValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIHPT(self, text): """ Input IHPT. """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setCoalTemperatureValue(self.label, self.iclass, value) @pyqtSignature("const QString&") def slotIRAWCL(self, text): """ Input IJRDP. """ choice = self.modelIRAWCL.dicoV2M[str(text)] self.model.setCoalCompositionChoice(self.label, self.iclass, choice) def tr(self, text): """ Translation """ return text
class BoundaryConditionsMobileMeshView(QWidget, Ui_BoundaryConditionsMobileMeshForm): """ Boundary condifition for mobil mesh (ALE and/or Fluid-interaction) """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsMobileMeshForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.__model = MobileMeshModel(self.__case) self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1) self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary") self.__comboModel.addItem(self.tr("Sliding boundary"), "sliding_boundary") self.__comboModel.addItem(self.tr("Internal coupling"), "internal_coupling") self.__comboModel.addItem(self.tr("External coupling"), "external_coupling") self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity") self.__comboModel.addItem(self.tr("Fixed displacement"), "fixed_displacement") self.connect(self.comboMobilBoundary, SIGNAL("activated(const QString&)"), self.__slotCombo) self.connect(self.pushButtonMobilBoundary, SIGNAL("clicked(bool)"), self.__slotFormula) self.__case.undoStartGlobal() @pyqtSignature("const QString&") def __slotFormula(self, text): """ Run formula editor. """ exp = self.__boundary.getFormula() aleChoice = self.__boundary.getALEChoice(); if aleChoice == "fixed_velocity": if not exp: exp = 'mesh_velocity_U =' req = [('mesh_velocity_U', 'Fixed velocity of the mesh'), ('mesh_velocity_V', 'Fixed velocity of the mesh'), ('mesh_velocity_W', 'Fixed velocity of the mesh')] exa = 'mesh_velocity_U = 1000;\nmesh_velocity_V = 1000;\nmesh_velocity_W = 1000;' elif aleChoice == "fixed_displacement": if not exp: exp = 'mesh_x =' req = [('mesh_x', 'Fixed displacement of the mesh'), ('mesh_y', 'Fixed displacement of the mesh'), ('mesh_z', 'Fixed displacement of the mesh')] exa = 'mesh_x = 1000;\nmesh_y = 1000;\nmesh_z = 1000;' symbs = [('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] dialog = QMeiEditorView(self, check_syntax = self.__case['package'].get_check_syntax(), expression = exp, required = req, symbols = symbs, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMobileMeshBoundary -> %s" % str(result)) self.__boundary.setFormula(result) setGreenColor(self.pushButtonMobilBoundary, False) @pyqtSignature("const QString&") def __slotCombo(self, text): """ Called when the combobox changed. """ modelData = self.__comboModel.dicoV2M[str(text)] # Enable/disable formula button. isFormulaEnabled = modelData in ["fixed_velocity", "fixed_displacement"] self.pushButtonMobilBoundary.setEnabled(isFormulaEnabled) setGreenColor(self.pushButtonMobilBoundary, isFormulaEnabled) self.__boundary.setALEChoice(modelData) def showWidget(self, b): """ Show the widget """ if self.__model.getMethod() != "off": self.__boundary = Boundary("mobile_boundary", b.getLabel(), self.__case) modelData = self.__boundary.getALEChoice() self.__comboModel.setItem(str_model=modelData) isFormulaEnabled = modelData in ["fixed_velocity", "fixed_displacement"] self.pushButtonMobilBoundary.setEnabled(isFormulaEnabled) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all """ self.hide() def tr(self, text): """ Translation """ return text
class BoundaryConditionsVelocityInletView(QWidget, Ui_BoundaryConditionsVelocityInletForm): """ Boundary condition for velocity in inlet, without particular physics. """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsVelocityInletForm.__init__(self) self.setupUi(self) self.thermodynamic_list = ['Pressure', 'Density', 'Temperature', 'Energy'] def setup(self, case): """ Setup the widget """ self.__case = case self.__boundary = None self.__case.undoStopGlobal() self.mdl = CompressibleModel(self.__case) self.gas = GasCombustionModel(self.__case) # Connections self.connect(self.comboBoxVelocity, SIGNAL("activated(const QString&)"), self.__slotChoiceVelocity) self.connect(self.lineEditVelocity, SIGNAL("textChanged(const QString &)"), self.__slotVelocityValue) self.connect(self.comboBoxDirection, SIGNAL("activated(const QString&)"), self.__slotChoiceDirection) self.connect(self.lineEditDirectionX, SIGNAL("textChanged(const QString &)"), self.__slotDirX) self.connect(self.lineEditDirectionY, SIGNAL("textChanged(const QString &)"), self.__slotDirY) self.connect(self.lineEditDirectionZ, SIGNAL("textChanged(const QString &)"), self.__slotDirZ) self.connect(self.comboBoxTypeInlet, SIGNAL("activated(const QString&)"), self.__slotInletType) self.connect(self.checkBoxPressure, SIGNAL("clicked()"), self.__slotPressure) self.connect(self.checkBoxDensity, SIGNAL("clicked()"), self.__slotDensity) self.connect(self.checkBoxTemperature, SIGNAL("clicked()"), self.__slotTemperature) self.connect(self.checkBoxEnergy, SIGNAL("clicked()"), self.__slotEnergy) self.connect(self.lineEditPressure, SIGNAL("textChanged(const QString &)"), self.__slotPressureValue) self.connect(self.lineEditDensity, SIGNAL("textChanged(const QString &)"), self.__slotDensityValue) self.connect(self.lineEditTotalPressure, SIGNAL("textChanged(const QString &)"), self.__slotTotalPressure) self.connect(self.lineEditTotalEnthalpy, SIGNAL("textChanged(const QString &)"), self.__slotTotalEnthalpy) self.connect(self.lineEditTemperature, SIGNAL("textChanged(const QString &)"), self.__slotTemperatureValue) self.connect(self.lineEditEnergy, SIGNAL("textChanged(const QString &)"), self.__slotEnergyValue) self.connect(self.comboBoxTypeInletGasComb, SIGNAL("activated(const QString&)"), self.__slotInletTypeGasComb) self.connect(self.lineEditTemperatureGasComb, SIGNAL("textChanged(const QString &)"), self.__slotTemperatureGasComb) self.connect(self.lineEditFraction, SIGNAL("textChanged(const QString &)"), self.__slotMeanMixtureFraction) # Combo models self.modelVelocity = ComboModel(self.comboBoxVelocity, 6, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("volumic flow rate"), 'flow2') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelVelocity.addItem(self.tr("volumic flow rate (user law)"), 'flow2_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal direction to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("imposed inlet"), 'imposed_inlet') self.modelTypeInlet.addItem(self.tr("subsonic inlet (imposed total pressure and total enthalpy)"), 'subsonic_inlet_PH') self.modelTypeInletGasComb = ComboModel(self.comboBoxTypeInletGasComb, 2, 1) model = self.gas.getGasCombustionModel() if model == 'lwp' or model =='ebu': self.modelTypeInletGasComb.addItem(self.tr("Unburned gas"), 'unburned') self.modelTypeInletGasComb.addItem(self.tr("Burned gas"), 'burned') elif model == 'd3p': self.modelTypeInletGasComb.addItem(self.tr("Oxydant"), 'oxydant') self.modelTypeInletGasComb.addItem(self.tr("Fuel"), 'fuel') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorP = DoubleValidator(self.lineEditPressure, min = 0.0) validatorD = DoubleValidator(self.lineEditDensity, min = 0.0) validatorT = DoubleValidator(self.lineEditTemperature, min = 0.0) validatorE = DoubleValidator(self.lineEditEnergy, min = 0.0) validatorP2 = DoubleValidator(self.lineEditTotalPressure, min = 0.0) validatorH2 = DoubleValidator(self.lineEditTotalEnthalpy, min = 0.0) validatorTemp = DoubleValidator(self.lineEditTemperatureGasComb, min=0.) validatorFrac = DoubleValidator(self.lineEditFraction, min=0., max=1.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditPressure.setValidator(validatorP) self.lineEditDensity.setValidator(validatorD) self.lineEditTemperature.setValidator(validatorT) self.lineEditEnergy.setValidator(validatorE) self.lineEditTotalPressure.setValidator(validatorP2) self.lineEditTotalEnthalpy.setValidator(validatorH2) self.lineEditTemperatureGasComb.setValidator(validatorTemp) self.lineEditFraction.setValidator(validatorFrac) self.connect(self.pushButtonVelocityFormula, SIGNAL("clicked()"), self.__slotVelocityFormula) self.connect(self.pushButtonDirectionFormula, SIGNAL("clicked()"), self.__slotDirectionFormula) self.__case.undoStartGlobal() def showWidget(self, boundary): """ Show the widget """ self.__boundary = boundary # Initialize velocity choice = self.__boundary.getVelocityChoice() self.modelVelocity.setItem(str_model=choice) self.__updateLabel() if choice[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) self.lineEditVelocity.setEnabled(False) else: self.pushButtonVelocityFormula.setEnabled(False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) # Initialize direction choice = self.__boundary.getDirectionChoice() self.modelDirection.setItem(str_model=choice) text = self.modelDirection.dicoM2V[choice] if choice == "formula": self.pushButtonDirectionFormula.setEnabled(True) self.frameDirectionCoordinates.hide() elif choice == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif choice == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.hide() self.initialize() def initialize(self): """ Initialize widget for compressible """ self.comboBoxVelocity.show() self.lineEditVelocity.show() self.labelUnitVelocity.show() self.pushButtonVelocityFormula.show() # Initialize thermodynamic value if self.mdl.getCompressibleModel() != 'off': inlet_type = self.__boundary.getInletType() self.modelTypeInlet.setItem(str_model = inlet_type) self.__boundary.setInletType(inlet_type) if inlet_type == 'imposed_inlet': self.groupBoxThermodynamic.show() self.frameDensity.hide() for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setChecked(False) __checkBox.setEnabled(False) __lineEdit.setEnabled(False) __lineEdit.clear() box_list = self.__boundary.getCheckedBoxList() if len(box_list) == 0: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) elif len(box_list) == 1: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) box = box_list[0] if box == 'Temperature': self.checkBoxEnergy.setEnabled(False) elif box == 'Energy': self.checkBoxTemperature.setEnabled(False) __checkBox = getattr(self, "checkBox" + box) __checkBox.setChecked(True) __lineEdit = getattr(self, "lineEdit" + box) __lineEdit.setEnabled(True) v1 = self.__boundary.getListValue()[0] __lineEdit.setText(str(v1)) elif len(box_list) == 2: v1,v2 = self.__boundary.getListValue() for name in box_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) __checkBox.setChecked(True) __lineEdit.setEnabled(True) if v1 >= 0.: __lineEdit.setText(str(v1)) else: __lineEdit.setText(str(v2)) v1 = -1. elif inlet_type == 'subsonic_inlet_PH': self.comboBoxVelocity.hide() self.lineEditVelocity.hide() self.labelUnitVelocity.hide() self.pushButtonVelocityFormula.hide() self.groupBoxThermodynamic.hide() self.frameDensity.show() pressure = self.__boundary.getThermoValue('total_pressure') self.lineEditTotalPressure.setText(str(pressure)) enthalpy = self.__boundary.getThermoValue('enthalpy') self.lineEditTotalEnthalpy.setText(str(enthalpy)) else: self.groupBoxCompressible.hide() # Initialize temperature and mean mixture fraction model = self.gas.getGasCombustionModel() if model != 'off': self.groupBoxGasCombustion.show() inlet_type = self.__boundary.getInletGasCombustionType() self.modelTypeInletGasComb.setItem(str_model = inlet_type) if model == 'd3p': self.lineEditTemperatureGasComb.hide() self.labelTemperature_2.hide() self.labelUnitTemp.hide() self.lineEditFraction.setEnabled(False) f = self.__boundary.setMeanMixtureFraction(1) self.lineEditFraction.setText(str(1) if inlet_type == 'oxydant' else str(0)) else : self.lineEditTemperatureGasComb.show() self.labelTemperature_2.show() self.labelUnitTemp.show() t = self.__boundary.getGasCombustionTemperature() self.lineEditTemperatureGasComb.setText(str(t)) self.lineEditFraction.setEnabled(True) f = self.__boundary.getMeanMixtureFraction() self.lineEditFraction.setText(str(f)) else: self.groupBoxGasCombustion.hide() self.show() def hideWidget(self): """ Hide all """ self.hide() @pyqtSignature("const QString&") def __slotChoiceVelocity(self, text): """ Private slot. Input the velocity boundary type choice (norm, ). @type text: C{QString} @param text: velocity boundary type choice. """ c = self.modelVelocity.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setVelocityChoice(c) if c[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) setGreenColor(self.pushButtonVelocityFormula, True) self.lineEditVelocity.setEnabled(False) self.lineEditVelocity.setText("") else: self.pushButtonVelocityFormula.setEnabled(False) setGreenColor(self.pushButtonVelocityFormula, False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) self.__updateLabel() def __updateLabel(self): """ Update the unit for the velocity specification. """ c = self.__boundary.getVelocityChoice() if c in ('norm', 'norm_formula'): self.labelUnitVelocity.setText(str('m/s')) elif c in ('flow1', 'flow1_formula'): self.labelUnitVelocity.setText(str('kg/s')) elif c in ('flow2', 'flow2_formula'): self.labelUnitVelocity.setText(str('m<sup>3</sup>/s')) @pyqtSignature("const QString&") def __slotVelocityValue(self, text): """ Private slot. New value associated to the velocity boundary type. @type text: C{QString} @param text: value """ if self.sender().validator().state == QValidator.Acceptable: v = from_qvariant(text, float) self.__boundary.setVelocity(v) @pyqtSignature("") def __slotVelocityFormula(self): """ """ exp = self.__boundary.getVelocity() c = self.__boundary.getVelocityChoice() if c == 'norm_formula': exa = "u_norm = 1.0;" req = [('u_norm', 'Norm of the velocity')] elif c == 'flow1_formula': exa = "q_m = 1.0;" req = [('q_m', 'mass flow rate')] elif c == 'flow2_formula': exa = "q_v = 1.0;" req = [('q_v', 'volumic flow rate')] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] dialog = QMeiEditorView(self, check_syntax = self.__case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaVelocity -> %s" % str(result)) self.__boundary.setVelocity(result) setGreenColor(self.pushButtonVelocityFormula, False) @pyqtSignature("const QString&") def __slotChoiceDirection(self, text): """ Input the direction type choice. """ c = self.modelDirection.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setDirectionChoice(c) if c == "formula": self.pushButtonDirectionFormula.setEnabled(True) setGreenColor(self.pushButtonDirectionFormula, True) self.frameDirectionCoordinates.hide() elif c == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) setGreenColor(self.pushButtonDirectionFormula, False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif c == "normal": self.pushButtonDirectionFormula.setEnabled(False) setGreenColor(self.pushButtonDirectionFormula, False) self.frameDirectionCoordinates.hide() @pyqtSignature("const QString&") def __slotDirX(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_x', value) @pyqtSignature("const QString&") def __slotDirY(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_y', value) @pyqtSignature("const QString&") def __slotDirZ(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_z', value) @pyqtSignature("") def __slotDirectionFormula(self): """ """ exp = self.__boundary.getDirection('direction_formula') req = [('dir_x', 'Direction of the flow along X'), ('dir_y', 'Direction of the flow along Y'), ('dir_z', 'Direction of the flow along Z')] exa = "dir_x = 3.0;\ndir_y = 1.0;\ndir_z = 0.0;\n" sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] dialog = QMeiEditorView(self, check_syntax = self.__case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaDirection -> %s" % str(result)) self.__boundary.setDirection('direction_formula', result) setGreenColor(self.pushButtonDirectionFormula, False) @pyqtSignature("const QString&") def __slotInletType(self, text): """ INPUT inlet type : 'oxydant'/'fuel' or 'burned'/'unburned' """ value = self.modelTypeInlet.dicoV2M[str(text)] log.debug("__slotInletType value = %s " % value) self.__boundary.setInletType(value) self.initialize() @pyqtSignature("") def __slotPressure(self): """ Pressure selected or not for the initialisation. """ if self.checkBoxPressure.isChecked(): self.__boundary.setThermoStatus('pressure', "on") else: self.__boundary.setThermoStatus('pressure', "off") self.initialize() @pyqtSignature("") def __slotDensity(self): """ Density selected or not for the initialisation. """ if self.checkBoxDensity.isChecked(): self.__boundary.setThermoStatus('density', "on") else: self.__boundary.setThermoStatus('density', "off") self.initialize() @pyqtSignature("") def __slotTemperature(self): """ Temperature selected or not for the initialisation. """ if self.checkBoxTemperature.isChecked(): self.__boundary.setThermoStatus('temperature', "on") else: self.__boundary.setThermoStatus('temperature', "off") self.initialize() @pyqtSignature("") def __slotEnergy(self): """ Energy selected or not for the initialisation. """ if self.checkBoxEnergy.isChecked(): self.__boundary.setThermoStatus('energy', "on") else: self.__boundary.setThermoStatus('energy', "off") self.initialize() @pyqtSignature("const QString&") def __slotPressureValue(self, text): """ INPUT inlet Pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('pressure', t) @pyqtSignature("const QString&") def __slotDensityValue(self, text): """ INPUT inlet Density """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('density', t) @pyqtSignature("const QString&") def __slotTemperatureValue(self, text): """ INPUT inlet Temperature """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('temperature', t) @pyqtSignature("const QString&") def __slotEnergyValue(self, text): """ INPUT inlet Energy """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('energy', t) @pyqtSignature("const QString&") def __slotTotalPressure(self, text): """ INPUT inlet total pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('total_pressure', t) @pyqtSignature("const QString&") def __slotTotalEnthalpy(self, text): """ INPUT inlet total enthalpy """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('enthalpy', t) @pyqtSignature("const QString&") def __slotTemperatureGasComb(self, text): """ INPUT inlet temperature """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setGasCombustionTemperature(t) @pyqtSignature("const QString&") def __slotMeanMixtureFraction(self, text): """ INPUT inlet mean mixutre fraction """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setMeanMixtureFraction(f) @pyqtSignature("const QString&") def __slotInletTypeGasComb(self, text): """ INPUT inlet type : 'oxydant'/'fuel' or 'burned'/'unburned' """ value = self.modelTypeInletGasComb.dicoV2M[str(text)] log.debug("__slotInletTypeGasComb value = %s " % value) self.__boundary.setInletGasCombustionType(value) self.initialize() def tr(self, text): """ Translation """ return text
class InitializationView(QWidget, Ui_InitializationForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_InitializationForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.init = InitializationModel(self.case) self.turb = TurbulenceModel(self.case) self.therm = ThermalScalarModel(self.case) self.th_sca = DefineUserScalarsModel(self.case) self.comp = CompressibleModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) # create group to control hide/show options self.turb_group = [self.labelTurbulence, self.pushButtonTurbulence, self.comboBoxTurbulence] self.thermal_group = [self.labelThermal, self.pushButtonThermal] self.species_group = [self.labelSpecies, self.comboBoxSpecies, self.pushButtonSpecies] self.meteo_group = [self.labelMeteo, self.comboBoxMeteo, self.pushButtonMeteo] self.thermodynamic_list = ['Pressure', 'Density', 'Temperature', 'Energy'] # 1/ Combo box models self.modelZone = ComboModel(self.comboBoxZone, 1, 1) if self.comp.getCompressibleModel() != 'off': self.groupBoxThermodynamic.show() else: self.groupBoxThermodynamic.hide() self.zone = "" zones = self.volzone.getZones() for zone in zones: if zone.getNature()['initialization'] == "on": label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelZone.setItem(str_model = self.zone) self.modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1) self.modelTurbulence.addItem(self.tr("Initialization by formula"), 'formula') self.modelTurbulence.addItem(self.tr("Initialization by reference value(s)"), 'reference_value') # 2/ Connections self.connect(self.comboBoxZone, SIGNAL("activated(const QString&)"), self.slotZone) self.connect(self.comboBoxTurbulence, SIGNAL("activated(const QString&)"), self.slotChoice) self.connect(self.comboBoxSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesChoice) self.connect(self.comboBoxMeteo, SIGNAL("activated(const QString&)"), self.slotMeteoChoice) self.connect(self.checkBoxPressure, SIGNAL("clicked()"), self.slotPressure) self.connect(self.checkBoxDensity, SIGNAL("clicked()"), self.slotDensity) self.connect(self.checkBoxTemperature, SIGNAL("clicked()"), self.slotTemperature) self.connect(self.checkBoxEnergy, SIGNAL("clicked()"), self.slotEnergy) self.connect(self.pushButtonVelocity, SIGNAL("clicked()"), self.slotVelocityFormula) self.connect(self.pushButtonThermal, SIGNAL("clicked()"), self.slotThermalFormula) self.connect(self.pushButtonTurbulence, SIGNAL("clicked()"), self.slotTurbulenceFormula) self.connect(self.pushButtonSpecies, SIGNAL("clicked()"), self.slotSpeciesFormula) self.connect(self.pushButtonMeteo, SIGNAL("clicked()"), self.slotMeteoFormula) self.connect(self.pushButtonPressure, SIGNAL("clicked()"), self.slotPressureFormula) self.connect(self.pushButtonDensity, SIGNAL("clicked()"), self.slotDensityFormula) self.connect(self.pushButtonTemperature,SIGNAL("clicked()"), self.slotTemperatureFormula) self.connect(self.pushButtonEnergy, SIGNAL("clicked()"), self.slotEnergyFormula) self.connect(self.pushButtonPressure_2, SIGNAL("clicked()"), self.slotPressureFormula) choice = self.init.getInitialTurbulenceChoice(self.zone) self.modelTurbulence.setItem(str_model = choice) # species treatment self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.scalar = "" scalar_list = self.th_sca.getUserScalarNameList() for s in self.th_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for item in self.species_group: item.show() for scalar in scalar_list: self.modelSpecies.addItem(self.tr(scalar), scalar) self.modelSpecies.setItem(str_model = self.scalar) setGreenColor(self.pushButtonSpecies, True) else: for item in self.species_group: item.hide() # meteo self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1) self.scalar_meteo = "" scalar_meteo_list = DefineUserScalarsModel( self.case).getMeteoScalarsNameList() if scalar_meteo_list != None and scalar_meteo_list != []: self.scalar_meteo = scalar_meteo_list[0] for item in self.meteo_group: item.show() for scalar in scalar_meteo_list: self.modelMeteo.addItem(self.tr(scalar), scalar) self.modelMeteo.setItem(str_model = self.scalar_meteo) setGreenColor(self.pushButtonMeteo, True) else: for item in self.meteo_group: item.hide() if DarcyModel(self.case).getDarcyModel() == "off": self.labelpressure.hide() self.pushButtonPressure_2.hide() else: setGreenColor(self.pushButtonPressure_2, True) # Initialize widget self.initializeVariables(self.zone) self.case.undoStartGlobal() @pyqtSignature("const QString&") def slotZone(self, text): """ INPUT label for choice of zone """ self.zone = self.modelZone.dicoV2M[str(text)] self.initializeVariables(self.zone) @pyqtSignature("const QString&") def slotChoice(self, text): """ INPUT choice of method of initialization """ choice = self.modelTurbulence.dicoV2M[str(text)] log.debug("slotChoice choice = %s "%str(choice)) self.init.setInitialTurbulenceChoice(self.zone, choice) turb_model = self.turb.getTurbulenceModel() self.initializeVariables(self.zone) @pyqtSignature("const QString&") def slotMeteoChoice(self, text): """ INPUT label for choice of zone """ self.scalar_meteo= self.modelMeteo.dicoV2M[str(text)] self.initializeVariables(self.zone) setGreenColor(self.pushButtonMeteo, True) @pyqtSignature("const QString&") def slotSpeciesChoice(self, text): """ INPUT label for choice of zone """ self.scalar= self.modelSpecies.dicoV2M[str(text)] self.initializeVariables(self.zone) setGreenColor(self.pushButtonSpecies, True) @pyqtSignature("const QString&") def slotVelocityFormula(self): """ """ exp = self.init.getVelocityFormula(self.zone) if not exp: exp = self.init.getDefaultVelocityFormula() exa = """#example: \n""" + self.init.getDefaultVelocityFormula() req = [('velocity[0]', "velocity"), ('velocity[1]', "velocity"), ('velocity[2]', "velocity")] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaVelocity -> %s" % str(result)) self.init.setVelocityFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotTurbulenceFormula(self): """ INPUT user formula """ turb_model = self.turb.getTurbulenceModel() exa = """#example \n""" + self.init.getDefaultTurbFormula(turb_model) exp = self.init.getTurbFormula(self.zone, turb_model) sym = [('rho0', 'density (reference value)'), ('mu0', 'viscosity (reference value)'), ('cp0', 'specific heat (reference value)'), ('lambda0', 'thermal conductivity (reference value)'), ('x','cell center coordinate'), ('y','cell center coordinate'), ('z','cell center coordinate'), ('uref','reference velocity'), ('almax','reference length')] if turb_model in ('k-epsilon', 'k-epsilon-PL'): req = [('k', "turbulent energy"), ('epsilon', "turbulent dissipation")] elif turb_model in ('Rij-epsilon', 'Rij-SSG'): req = [('r11', "Reynolds stress R11"), ('r22', "Reynolds stress R22"), ('r33', "Reynolds stress R33"), ('r12', "Reynolds stress R12"), ('r23', "Reynolds stress R23"), ('r13', "Reynolds stress R13"), ('epsilon', "turbulent dissipation")] elif turb_model == 'Rij-EBRSM': req = [('r11', "Reynolds stress R11"), ('r22', "Reynolds stress R22"), ('r33', "Reynolds stress R33"), ('r12', "Reynolds stress R12"), ('r23', "Reynolds stress R23"), ('r13', "Reynolds stress R13"), ('epsilon', "turbulent dissipation"), ('alpha', "alpha")] elif turb_model == 'v2f-BL-v2/k': req = [('k', "turbulent energy"), ('epsilon', "turbulent dissipation"), ('phi', "variable phi in v2f model"), ('alpha', "variable alpha in v2f model")] elif turb_model == 'k-omega-SST': req = [('k', "turbulent energy"), ('omega', "specific dissipation rate")] elif turb_model == 'Spalart-Allmaras': req = [('nu_tilda', "nusa")] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaTurb -> %s" % str(result)) self.init.setTurbFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotThermalFormula(self): """ Input the initial formula of thermal scalar """ exp = self.init.getThermalFormula(self.zone) if not exp: exp = self.init.getDefaultThermalFormula() exa = """#example \n""" + self.init.getDefaultThermalFormula() if self.therm.getThermalScalarModel() == "enthalpy": req = [('enthalpy', 'enthalpy')] elif self.therm.getThermalScalarModel() == "total_energy": req = [('total_energy', 'total energy')] else: req = [('temperature', 'temperature')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaThermal -> %s" % str(result)) self.init.setThermalFormula(self.zone, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotSpeciesFormula(self): """ Input the initial formula of species """ exp = self.init.getSpeciesFormula(self.zone, self.scalar) name = self.th_sca.getScalarName(self.scalar) if not exp: exp = str(name)+""" = 0;\n""" exa = """#example: \n""" + str(name)+""" = 0;\n""" req = [(str(name), str(name))] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaSpecies -> %s" % str(result)) self.init.setSpeciesFormula(self.zone, self.scalar, result) setGreenColor(self.sender(), False) @pyqtSignature("const QString&") def slotMeteoFormula(self): """ """ exp = self.init.getMeteoFormula(self.zone, self.scalar_meteo) name = self.scalar_meteo if not exp: exp = str(name)+""" = 0;\n""" exa = """#example: \n""" + str(name)+""" = 0;\n""" req = [(str(name), str(name))] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMeteo -> %s" % str(result)) self.init.setMeteoFormula(self.zone, self.scalar_meteo, result) setGreenColor(self.sender(), False) @pyqtSignature("") def slotPressure(self): """ Pressure selected or not for the initialisation. """ if self.checkBoxPressure.isChecked(): self.init.setPressureStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonPressure.setEnabled(True) setGreenColor(self.pushButtonPressure,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(False) else: self.init.setPressureStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonPressure.setEnabled(False) setGreenColor(self.pushButtonPressure,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Pressure': __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(True) if box_list[0] =='Energy': self.checkBoxTemperature.setEnabled(False) if box_list[0] =='Temperature': self.checkBoxEnergy.setEnabled(False) @pyqtSignature("") def slotDensity(self): """ Density selected or not for the initialisation. """ if self.checkBoxDensity.isChecked(): self.init.setDensityStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonDensity.setEnabled(True) setGreenColor(self.pushButtonDensity,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(False) else: self.init.setDensityStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonDensity.setEnabled(False) setGreenColor(self.pushButtonDensity,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Density': __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(True) if box_list[0] =='Energy': self.checkBoxTemperature.setEnabled(False) if box_list[0] =='Temperature': self.checkBoxEnergy.setEnabled(False) @pyqtSignature("") def slotTemperature(self): """ Temperature selected or not for the initialisation. """ if self.checkBoxTemperature.isChecked(): self.init.setTemperatureStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonTemperature.setEnabled(True) setGreenColor(self.pushButtonTemperature,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(False) self.checkBoxEnergy.setEnabled(False) else: self.init.setTemperatureStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonTemperature.setEnabled(False) setGreenColor(self.pushButtonTemperature,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Temperature': __checkBox = getattr(self, "checkBox" + name) __checkBox.setEnabled(True) self.checkBoxEnergy.setEnabled(True) @pyqtSignature("") def slotEnergy(self): """ Energy selected or not for the initialisation. """ if self.checkBoxEnergy.isChecked(): self.init.setEnergyStatus(self.zone,"on") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonEnergy.setEnabled(True) setGreenColor(self.pushButtonEnergy,True) if len(box_list) == 2: for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setEnabled(False) __Button.setEnabled(False) setGreenColor(__Button,False) if len(box_list) == 1: self.checkBoxTemperature.setEnabled(False) else: self.init.setEnergyStatus(self.zone,"off") box_list = self.init.getCheckedBoxList(self.zone) self.pushButtonEnergy.setEnabled(False) setGreenColor(self.pushButtonEnergy,False) if len(box_list) == 1: for name in self.thermodynamic_list: if name != 'Energy': __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setEnabled(True) __Button.setEnabled(False) setGreenColor(__Button,False) self.checkBoxTemperature.setEnabled(True) @pyqtSignature("const QString&") def slotPressureFormula(self): """ Input the initial Pressure formula """ exp = self.init.getPressureFormula(self.zone) if not exp: exp = """p0 = 0.; g = 9.81; ro = 1.17862; pressure = p0 + g * ro * z;\n""" exa = """#example: """ req = [('pressure', 'pressure')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotPressureFormula -> %s" % str(result)) self.init.setPressureFormula(self.zone, result) setGreenColor(self.pushButtonPressure_2, False) @pyqtSignature("const QString&") def slotDensityFormula(self): """ Input the initial Density formula """ exp = self.init.getDensityFormula(self.zone) if not exp: exp = """density = 0;\n""" exa = """#example: """ req = [('density', 'density')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotDensityFormula -> %s" % str(result)) self.init.setDensityFormula(self.zone, result) setGreenColor(self.pushButtonDensity, False) @pyqtSignature("const QString&") def slotTemperatureFormula(self): """ Input the initial Temperature formula """ exp = self.init.getTemperatureFormula(self.zone) if not exp: exp = """temperature = 0;\n""" exa = """#example: """ req = [('temperature', 'temperature')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotTemperatureFormula -> %s" % str(result)) self.init.setTemperatureFormula(self.zone, result) setGreenColor(self.pushButtonTemperature, False) @pyqtSignature("const QString&") def slotEnergyFormula(self): """ Input the initial Energy formula """ exp = self.init.getEnergyFormula(self.zone) if not exp: exp = """total_energy = 0;\n""" exa = """#example: """ req = [('total_energy', 'Energy')] sym = [('x', 'cell center coordinate'), ('y', 'cell center coordinate'), ('z', 'cell center coordinate')] dialog = QMeiEditorView(self, check_syntax = self.case['package'].get_check_syntax(), expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotEnergyFormula -> %s" % str(result)) self.init.setEnergyFormula(self.zone, result) setGreenColor(self.pushButtonEnergy, False) def initializeVariables(self, zone): """ Initialize variables when a new volumic zone is choosen """ # Initialisation of Turbulence turb_model = self.turb.getTurbulenceModel() if turb_model not in ('k-epsilon', 'k-epsilon-PL', 'Rij-epsilon', 'Rij-SSG', 'Rij-EBRSM', 'v2f-BL-v2/k', 'k-omega-SST', 'Spalart-Allmaras'): for item in self.turb_group: item.hide() else: for item in self.turb_group: item.show() turb_init = self.init.getInitialTurbulenceChoice(self.zone) self.modelTurbulence.setItem(str_model = turb_init) if turb_init == 'formula': self.pushButtonTurbulence.setEnabled(True) turb_formula = self.init.getTurbFormula(zone, turb_model) if not turb_formula: turb_formula = self.init.getDefaultTurbFormula(turb_model) self.init.setTurbFormula(zone, turb_formula) setGreenColor(self.pushButtonTurbulence, True) else: self.pushButtonTurbulence.setEnabled(False) setGreenColor(self.pushButtonTurbulence, False) #velocity velocity_formula = self.init.getVelocityFormula(zone) if not velocity_formula: velocity_formula = self.init.getDefaultVelocityFormula() self.init.setVelocityFormula(zone, velocity_formula) setGreenColor(self.pushButtonVelocity, True) # Initialisation of Model Variables if thermal model is selectionned for item in self.thermal_group: item.hide() model = self.therm.getThermalScalarModel() if model != "off" and self.comp.getCompressibleModel() == 'off': for item in self.thermal_group: item.show() th_formula = self.init.getThermalFormula(zone) if not th_formula: th_formula = self.init.getDefaultThermalFormula() self.init.setThermalFormula(zone, th_formula) setGreenColor(self.pushButtonThermal, True) # Initialisation of the termodynamics values for the compressible model if self.comp.getCompressibleModel() != 'off': nb_box = 0 box_list = self.init.getCheckedBoxList(self.zone) if box_list == []: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(False) __Button.setEnabled(False) setGreenColor(__Button, False) elif len(box_list) == 1: box = box_list[0] for name in self.thermodynamic_list: if name != box: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(False) __Button.setEnabled(False) setGreenColor(__Button,False) if box == 'Temperature': self.checkBoxEnergy.setEnabled(False) elif box == 'Energy': self.checkBoxTemperature.setEnabled(False) __checkBox = getattr(self, "checkBox" + box) __checkBox.setChecked(True) __Button = getattr(self, "pushButton" + box) __Button.setEnabled(True) setGreenColor(__Button, True) elif len(box_list) == 2: box1 = box_list[0] box2 = box_list[1] for name in self.thermodynamic_list: if name not in box_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(False) __checkBox.setEnabled(False) __Button.setEnabled(False) for name in box_list: __checkBox = getattr(self, "checkBox" + name) __Button = getattr(self, "pushButton" + name) __checkBox.setChecked(True) __Button.setEnabled(True) setGreenColor(__Button, True) def tr(self, text): """ Translation """ return text
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_OpenTurnsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = OpenTurnsModel(case) if not self.mdl.getHostName(): self.mdl.setDefaultOptions() # Combo model config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) self.nmodes = 1 dist_hosts = None if config.has_section('distant_hosts'): if len(config.options('distant_hosts')) != 0: dist_hosts = config.options('distant_hosts') self.nmodes += len(dist_hosts) self.modelOtStudyHosts = ComboModel(self.comboBoxStudyMode, self.nmodes, 1) self.modelOtStudyHosts.addItem(self.tr("Localhost"), 'localhost') self.hosts_bmgr = {} if config.has_option('install', 'batch'): self.hosts_bmgr['localhost'] = (config.get('install', 'batch')).lower() else: self.hosts_bmgr['localhost'] = 'none' # Check for distant builds: # Hosts are stored in the form <batch_rm>_<host_name> hence the split # used hereafter to determine the "real" host name self.hosts_binpath = {} self.hosts_binpath['localhost'] = 'default' self.distant_host_builds = None if dist_hosts != None: self.distant_host_builds = {} for key in dist_hosts: host_name = key.split('_')[1] self.hosts_bmgr[host_name] = key.split('_')[0] self.hosts_binpath[host_name] = config.get( 'distant_hosts', key) self.addDistantBuilds(host_name) dh_not_found = False if self.distant_host_builds[host_name] == None: self.distant_host_builds[host_name] = ['none found'] dh_not_found = True host_tag = 'distant : ' + host_name self.modelOtStudyHosts.addItem(self.tr(host_tag), host_name, warn=dh_not_found) if dh_not_found: self.modelOtStudyHosts.disableItem(str_model=host_name) # --------------------------------------- # Connections: self.comboBoxStudyMode.activated[str].connect(self.slotOtStudyMode) self.comboBoxDistantBuilds.activated[str].connect(self.slotBuildChoice) self.lineEditDistWorkDir.textChanged[str].connect(self.slotOtDistWdir) self.spinBoxNumberNodes.valueChanged[int].connect( self.slotUpdateNodesNumber) self.spinBoxNumberTasks.valueChanged[int].connect( self.slotUpdateTasksNumber) self.spinBoxNumberThreads.valueChanged[int].connect( self.slotUpdateThreadsNumber) self.spinBoxNumberDays.valueChanged[int].connect(self.slotUpdateWCDays) self.spinBoxNumberHours.valueChanged[int].connect( self.slotUpdateWCHours) self.spinBoxNumberMinutes.valueChanged[int].connect( self.slotUpdateWCMinutes) self.spinBoxNumberSeconds.valueChanged[int].connect( self.slotUpdateWCSeconds) self.lineEditWCKEY.textChanged[str].connect(self.slotUpdateWckey) self.pushButtonLaunchOT.clicked.connect(self.slotLaunchCsOt) # --------------------------------------- # Hide/Show initial elements if self.nmodes == 1: self.groupBoxLocalLaunch.show() self.groupBoxDistantLaunch.hide() self.setAvailableBuildsList('localhost') else: self.setAvailableBuildsList(self.mdl.getHostName()) if self.mdl.getHostName() == "localhost": self.groupBoxLocalLaunch.show() self.groupBoxDistantLaunch.hide() else: self.groupBoxLocalLaunch.hide() self.groupBoxDistantLaunch.show() # --------------------------------------- # Initial values if dist_hosts != None: self.modelOtStudyHosts.setItem(str_model=self.mdl.host_name) else: self.modelOtStudyHosts.setItem(str_model='localhost') self.spinBoxLocalProcs.setValue(int(self.mdl.nprocs)) self.spinBoxLocalThreads.setValue(1) self.spinBoxNumberNodes.setValue(int(self.mdl.nnodes)) self.spinBoxNumberTasks.setValue(int(self.mdl.ntasks)) self.spinBoxNumberThreads.setValue(int(self.mdl.nthreads)) wct = self.mdl.getWallClockTime() self.spinBoxNumberDays.setValue(int(wct[0])) self.spinBoxNumberHours.setValue(int(wct[1])) self.spinBoxNumberMinutes.setValue(int(wct[2])) self.spinBoxNumberSeconds.setValue(int(wct[3])) self.lineEditWCKEY.setText(self.mdl.getWCKEY())
class InitializationView(QWidget, Ui_InitializationForm): """ """ def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_InitializationForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.init = InitializationModel(self.case) self.turb = TurbulenceModel(self.case) self.therm = ThermalScalarModel(self.case) self.th_sca = DefineUserScalarsModel(self.case) self.comp = CompressibleModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) self.notebook = NotebookModel(self.case) # create group to control hide/show options self.turb_group = [ self.labelTurbulence, self.pushButtonTurbulence, self.comboBoxTurbulence ] self.thermal_group = [self.labelThermal, self.pushButtonThermal] self.velocity_group = [self.labelVelocity, self.pushButtonVelocity] self.species_group = [ self.labelSpecies, self.comboBoxSpecies, self.pushButtonSpecies ] self.meteo_group = [ self.labelMeteo, self.comboBoxMeteo, self.pushButtonMeteo ] self.thermodynamic_list = [ 'Pressure', 'Density', 'Temperature', 'Energy' ] # 1/ Combo box models self.modelZone = ComboModel(self.comboBoxZone, 1, 1) if self.comp.getCompressibleModel() != 'off': self.groupBoxThermodynamic.show() else: self.groupBoxThermodynamic.hide() self.zone = "" zones = self.volzone.getZones() for zone in zones: if zone.getNature()['initialization'] == "on": label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelZone.setItem(str_model=self.zone) self.modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1) self.modelTurbulence.addItem(self.tr("Initialization by formula"), 'formula') self.modelTurbulence.addItem( self.tr("Initialization by reference value(s)"), 'reference_value') # 2/ Connections self.comboBoxZone.activated[str].connect(self.slotZone) self.comboBoxTurbulence.activated[str].connect(self.slotChoice) self.comboBoxSpecies.activated[str].connect(self.slotSpeciesChoice) self.comboBoxMeteo.activated[str].connect(self.slotMeteoChoice) self.checkBoxPressure.clicked.connect(self.slotPressure) self.checkBoxDensity.clicked.connect(self.slotDensity) self.checkBoxTemperature.clicked.connect(self.slotTemperature) self.checkBoxEnergy.clicked.connect(self.slotEnergy) self.pushButtonVelocity.clicked.connect(self.slotVelocityFormula) self.pushButtonThermal.clicked.connect(self.slotThermalFormula) self.pushButtonTurbulence.clicked.connect(self.slotTurbulenceFormula) self.pushButtonSpecies.clicked.connect(self.slotSpeciesFormula) self.pushButtonMeteo.clicked.connect(self.slotMeteoFormula) self.pushButtonPressure.clicked.connect(self.slotPressureFormula) self.pushButtonDensity.clicked.connect(self.slotDensityFormula) self.pushButtonTemperature.clicked.connect(self.slotTemperatureFormula) self.pushButtonEnergy.clicked.connect(self.slotEnergyFormula) self.pushButtonHydraulicHead.clicked.connect( self.slotHydraulicHeadFormula) choice = self.init.getInitialTurbulenceChoice(self.zone) self.modelTurbulence.setItem(str_model=choice) # species treatment self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.scalar = "" scalar_list = self.th_sca.getUserScalarNameList() for s in self.th_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for item in self.species_group: item.show() for scalar in scalar_list: self.modelSpecies.addItem(self.tr(scalar), scalar) self.modelSpecies.setItem(str_model=self.scalar) exp = self.init.getSpeciesFormula(self.zone, self.scalar) if exp: self.pushButtonSpecies.setStyleSheet("background-color: green") self.pushButtonSpecies.setToolTip(exp) else: self.pushButtonSpecies.setStyleSheet("background-color: red") else: for item in self.species_group: item.hide() # meteo self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1) self.scalar_meteo = "" scalar_meteo_list = DefineUserScalarsModel( self.case).getMeteoScalarsNameList() if scalar_meteo_list != None and scalar_meteo_list != []: self.scalar_meteo = scalar_meteo_list[0] for item in self.meteo_group: item.show() for scalar in scalar_meteo_list: self.modelMeteo.addItem(self.tr(scalar), scalar) self.modelMeteo.setItem(str_model=self.scalar_meteo) exp = self.init.getMeteoFormula(self.zone, self.scalar_meteo) if exp: self.pushButtonMeteo.setStyleSheet("background-color: green") self.pushButtonMeteo.setToolTip(exp) else: self.pushButtonMeteo.setStyleSheet("background-color: red") else: for item in self.meteo_group: item.hide() if GroundwaterModel(self.case).getGroundwaterModel() == "off": self.labelHydraulicHead.hide() self.pushButtonHydraulicHead.hide()
class InterfacialAreaView(QWidget, Ui_InterfacialArea): """ InterfacialAreaView layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_InterfacialArea.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = InterfacialAreaModel(self.case) # Combo box models id_to_set = -1 self.modelField = ComboModel(self.comboBoxField, 1, 1) # For consistency with the previous pages, the second phase of the # Large Interface Model is set before the dispersed fields if InterfacialForcesModel(self.case).getBubblesForLIMStatus() == 'on': id_to_set = 2 label = self.mdl.getLabel(id_to_set) name = str(id_to_set) self.modelField.addItem(self.tr(label), name) self.modelField.setItem(str_model=name) for fieldId in self.mdl.getDispersedFieldList(): label = self.mdl.getLabel(fieldId) name = str(fieldId) self.modelField.addItem(self.tr(label), name) if len(self.mdl.getDispersedFieldList()) > 0 and id_to_set == -1: id_to_set = self.mdl.getDispersedFieldList()[0] self.modelField.setItem(str_model=id_to_set) # case no field self.currentid = id_to_set self.modelModel = ComboModel(self.comboBoxModel, 2, 1) self.modelModel.addItem(self.tr("constant"), "constant") self.modelModel.addItem(self.tr("interfacial area transport"), "interfacial_area_transport") self.modelSourceTerm = ComboModel(self.comboBoxSourceTerm, 4, 1) self.modelSourceTerm.addItem( self.tr("No coalescence, no fragmentation"), "no_coalescence_no_fragmentation") self.modelSourceTerm.addItem(self.tr("Yao & Morel"), "wei_yao") self.modelSourceTerm.addItem(self.tr("Kamp & Colin"), "kamp_colin") self.modelSourceTerm.addItem(self.tr("Ruyer & Seiler"), "ruyer_seiler") self.modelSourceTerm.disableItem(2) # Validators validatorDefDiam = DoubleValidator(self.lineEditDefaultDiameter, min=0.0) validatorMinDiam = DoubleValidator(self.lineEditMinDiameter, min=0.0) validatorMaxDiam = DoubleValidator(self.lineEditMaxDiameter, min=0.0) validatorDefDiam.setExclusiveMin(True) validatorMinDiam.setExclusiveMin(True) validatorMaxDiam.setExclusiveMin(True) self.lineEditDefaultDiameter.setValidator(validatorDefDiam) self.lineEditMinDiameter.setValidator(validatorMinDiam) self.lineEditMaxDiameter.setValidator(validatorMaxDiam) # Connect signals to slots self.comboBoxField.activated[str].connect(self.slotField) self.comboBoxModel.activated[str].connect(self.slotModel) self.comboBoxSourceTerm.activated[str].connect(self.slotSourceTerm) self.lineEditDefaultDiameter.textChanged[str].connect( self.slotDefaultDiameter) self.lineEditMinDiameter.textChanged[str].connect(self.slotMinDiameter) self.lineEditMaxDiameter.textChanged[str].connect(self.slotMaxDiameter) # Initialize widget self.initializeVariables(self.currentid) self.case.undoStartGlobal()
def createEditor(self, parent, option, index): editor = QComboBox(parent) self.modelCombo = ComboModel(editor, 1, 1) editor.installEventFilter(self) return editor
class BoundaryConditionsElectricalView(QWidget, Ui_BoundaryConditionsElectricalForm): """ Boundary condifition for the velocity part """ def __init__(self, parent): """ Constructor. """ QWidget.__init__(self, parent) Ui_BoundaryConditionsElectricalForm.__init__(self) self.setupUi(self) def setup(self, case): """ Setup the widget. """ self.__case = case self.__boundary = None self.__model = ElectricalModel(self.__case) self.species_list = [] self.notebook = NotebookModel(self.__case) self.lineEditValuePotElec.textChanged[str].connect(self.slotPotElec) self.lineEditValuePotElecIm.textChanged[str].connect( self.slotPotElecIm) self.lineEditValueSpecies.textChanged[str].connect(self.slotSpecies) self.pushButtonPotVectorFormula.clicked.connect( self.slotPotVectorFormula) self.comboBoxTypePotElec.activated[str].connect(self.slotPotElecChoice) self.comboBoxTypePotElecIm.activated[str].connect( self.slotPotElecImChoice) self.comboBoxTypePotVector.activated[str].connect( self.slotPotVectorChoice) self.comboBoxSpecies.activated[str].connect(self.slotSpeciesChoice) self.comboBoxPotVector.activated[str].connect( self.slotPotVectorComponentChoice) ## Validators validatorPotElec = DoubleValidator(self.lineEditValuePotElec) validatorPotElecIm = DoubleValidator(self.lineEditValuePotElecIm) validatorSpecies = DoubleValidator(self.lineEditValueSpecies, min=0.) self.lineEditValuePotElec.setValidator(validatorPotElec) self.lineEditValuePotElecIm.setValidator(validatorPotElecIm) self.lineEditValueSpecies.setValidator(validatorSpecies) def __setBoundary(self, boundary): """ Set the current boundary """ self.__boundary = boundary self.nature = boundary.getNature() self.groupBoxPotElecIm.hide() self.groupBoxPotVector.hide() self.groupBoxMixture.hide() self.modelPotElec = ComboModel(self.comboBoxTypePotElec, 1, 1) self.modelPotElecIm = ComboModel(self.comboBoxTypePotElecIm, 1, 1) self.modelPotVector = ComboModel(self.comboBoxTypePotVector, 1, 1) self.modelPotElec.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElec.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElec.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElec.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') if self.__model.getScaling() == 'on': self.modelPotElec.addItem(self.tr("Implicit value (dpot)"), 'dirichlet_implicit') #TODO self.modelPotElec.disableItem(1) self.modelPotElec.disableItem(3) self.potElec = "elec_pot_r" self.modelPotElecLabel = ComboModel(self.comboBoxPotElec, 1, 1) self.modelPotElecLabel.addItem(self.tr(self.potElec), self.potElec) self.modelPotElecLabel.setItem(str_model=self.potElec) self.modelPotElecIm.addItem(self.tr("Prescribed value"), 'dirichlet') self.modelPotElecIm.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotElecIm.addItem(self.tr("Prescribed flux"), 'neumann') self.modelPotElecIm.addItem(self.tr("Prescribed flux (user law)"), 'neumann_formula') #TODO self.modelPotElecIm.disableItem(1) self.modelPotElecIm.disableItem(3) self.potElecIm = 'elec_pot_i' self.modelPotElecImLabel = ComboModel(self.comboBoxPotElecIm, 1, 1) self.modelPotElecImLabel.addItem(self.tr(self.potElecIm), self.potElecIm) self.modelPotElecImLabel.setItem(str_model=self.potElecIm) self.modelPotVector.addItem(self.tr("Prescribed value (user law)"), 'dirichlet_formula') self.modelPotVector.addItem(self.tr("Null flux"), 'neumann') self.modelPotVector.addItem(self.tr("Implicit flux"), 'neumann_implicit') self.modelPotVector.disableItem(0) self.potVect = 'vec_potential' self.modelPotVectLabel = ComboModel(self.comboBoxPotVector, 1, 1) self.modelPotVectLabel.addItem(self.tr('vec_potential'), 'vec_potential') self.modelPotVectLabel.setItem(str_model=self.potVect) if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.groupBoxPotElecIm.show() elif self.__model.getElectricalModel() == 'arc': self.groupBoxPotVector.show() self.species = "" if self.nature == 'inlet': if self.__model.getGasNumber() > 1: self.groupBoxMixture.show() self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.species_list = self.__model.getSpeciesLabelsList() for species in self.species_list: self.modelSpecies.addItem(self.tr(species), species) self.species = self.species_list[0] self.modelSpecies.setItem(str_model=self.species) self.initializeVariables() def initializeVariables(self): """ Initialize widget """ self.lineEditValuePotElec.hide() self.lineEditValuePotElecIm.hide() self.lineEditValuePotVector.hide() self.labelValuePotVector.hide() self.labelValuePotElec.hide() self.labelValuePotElecIm.hide() self.pushButtonPotVectorFormula.setEnabled(False) self.pushButtonPotVectorFormula.setStyleSheet("background-color: None") self.pushButtonPotElecFormula.setEnabled(False) self.pushButtonPotElecFormula.setStyleSheet("background-color: None") self.pushButtonPotElecImFormula.setEnabled(False) self.pushButtonPotElecImFormula.setStyleSheet("background-color: None") # Initialize electric potential self.potElec_type = self.__b.getElecScalarChoice(self.potElec) self.modelPotElec.setItem(str_model=self.potElec_type) if self.potElec_type == 'dirichlet' or self.potElec_type == 'neumann': self.lineEditValuePotElec.show() self.labelValuePotElec.show() v = self.__b.getElecScalarValue(self.potElec, self.potElec_type) self.lineEditValuePotElec.setText(str(v)) # Initialize imaginary electric potential if self.__model.getElectricalModel() == 'joule': if self.__model.getJouleModel() == 'three-phase' or \ self.__model.getJouleModel() == 'three-phase+Transformer': self.potElecIm_type = self.__b.getElecScalarChoice( self.potElecIm) self.modelPotElecIm.setItem(str_model=self.potElecIm_type) if self.potElecIm_type == 'dirichlet' or self.potElecIm_type == 'neumann': self.lineEditValuePotElecIm.show() self.labelValuePotElecIm.show() v = self.__b.getElecScalarValue(self.potElecIm, self.potElecIm_type) self.lineEditValuePotElecIm.setText(str(v)) # Initialize potential vector if self.__model.getElectricalModel() == 'arc': self.potVec_type = self.__b.getPotentialVectorChoice(self.potVect) self.modelPotVector.setItem(str_model=self.potVec_type) if self.potVec_type == 'dirichlet_formula': self.pushButtonPotVectorFormula.setEnabled(True) exp = self.__b.getElecScalarFormula(self.potVect, self.potVec_type) if exp: self.pushButtonPotVectorFormula.setStyleSheet( "background-color: green") self.pushButtonPotVectorFormula.setToolTip(exp) else: self.pushButtonPotVectorFormula.setStyleSheet( "background-color: red") # Initialize species if self.species: v = self.__b.getElecScalarValue(self.species, 'dirichlet') self.lineEditValueSpecies.setText(str(v)) @pyqtSlot(str) def slotPotElecChoice(self, text): """ INPUT choice for electric potential type """ potElec_type = self.modelPotElec.dicoV2M[str(text)] self.__b.setElecScalarChoice(self.potElec, potElec_type) self.initializeVariables() @pyqtSlot(str) def slotPotElecImChoice(self, text): """ INPUT choice for imaginary electric potential type """ potElecIm_type = self.modelPotElecIm.dicoV2M[str(text)] self.__b.setElecScalarChoice(self.potElecIm, potElecIm_type) self.initializeVariables() @pyqtSlot(str) def slotPotVectorChoice(self, text): """ INPUT choice for potential vector type """ potVec_choice = self.modelPotVector.dicoV2M[str(text)] self.__b.setPotentialVectorChoice(self.potVect, potVec_choice) self.initializeVariables() @pyqtSlot(str) def slotSpeciesChoice(self, text): """ INPUT species choice """ self.species = self.modelSpecies.dicoV2M[str(text)] self.initializeVariables() @pyqtSlot(str) def slotPotVectorComponentChoice(self, text): """ INPUT potential vector component choice """ self.potVect = self.modelPotVectLabel.dicoV2M[str(text)] self.initializeVariables() @pyqtSlot(str) def slotPotElec(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.potElec, self.potElec_type, value) @pyqtSlot(str) def slotPotElecIm(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.potElecIm, self.potElecIm_type, value) @pyqtSlot(str) def slotSpecies(self, var): """ """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(var, float) self.__b.setElecScalarValue(self.species, 'dirichlet', value) @pyqtSlot() def slotPotVectorFormula(self): """ """ exp = self.__b.getElecScalarFormula(self.potVect, self.potVec_type) exa = """#example: """ if not exp: exp = self.potVect + "[0] = 0;\n" + \ self.potVect + "[1] = 0;\n" + \ self.potVect + "[2] = 0;\n" req = [(self.potVect + "[0]", 'vector potential X'), (self.potVect + "[1]", 'vector potential Y'), (self.potVect + "[2]", 'vector potential Z')] sym = [('x', "X cell's gravity center"), ('y', "Y cell's gravity center"), ('z', "Z cell's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMeiEditorView(self, expression=exp, required=req, symbols=sym, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotPotVectorFormula -> %s" % str(result)) self.__b.setElecScalarFormula(self.potVect, self.potVec_type, str(result)) self.pushButtonPotVectorFormula.setToolTip(result) self.pushButtonPotVectorFormula.setStyleSheet( "background-color: green") def showWidget(self, b): """ Show the widget. """ self.__b = b if self.__model.getElectricalModel() != 'off': label = b.getLabel() nature = "joule_" + b.getNature() self.__b = Boundary(nature, label, self.__case) self.__setBoundary(b) self.show() else: self.hideWidget() def hideWidget(self): """ Hide all. """ self.hide() def tr(self, text): """ Translation. """ return text
class MobileMeshView(QWidget, Ui_MobileMeshForm): """ Class to open Page. """ viscosity_iso = """# Viscosity of the mesh allows to control the deformation # of the mesh. Viscosity must be greater than zero. # It could be isotropic (the same for all directions) or # orthotropic. # # In the following example, a hight value of viscosity # is imposed around a mobile cylinder. # The viscosity is specfied for all cells # on the initial mesh before any deformation. # xr2 = 1.5^2; xcen = 5.0; ycen = 0.; zcen = 6.0; xray2 = (x-xcen)^2 + (y-ycen)^2 + (z-zcen)^2; mesh_viscosity_1 = 1; if (xray2 < xr2) mesh_viscosity_1 = 1e10; """ viscosity_ortho = """# Viscosity of the mesh allows to control the deformation # of the mesh. Viscosity must be greater than zero. # It could be isotropic (the same for all directions) or # orthotropic. # # In the following example, a hight value of viscosity # is imposed around a mobile cylinder. # The viscosity is specfied for all cells # on the initial mesh before any deformation. # xr2 = 1.5^2; xcen = 5.0; ycen = 0.; zcen = 6.0; xray2 = (x-xcen)^2 + (y-ycen)^2 + (z-zcen)^2; mesh_viscosity_1 = 1; mesh_viscosity_2 = 1; mesh_viscosity_3 = 1; if (xray2 < xr2) { mesh_viscosity_1 = 1e10; mesh_viscosity_2 = 1e10; mesh_viscosity_3 = 1e10; } """ def __init__(self, parent, case, browser): """ Constructor """ QWidget.__init__(self, parent) Ui_MobileMeshForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = MobileMeshModel(self.case) self.browser = browser self.notebook = NotebookModel(self.case) # Combo model VISCOSITY self.modelVISCOSITY = ComboModel(self.comboBoxVISCOSITY, 2, 1) self.modelVISCOSITY.addItem(self.tr("isotropic"), 'isotrop') self.modelVISCOSITY.addItem(self.tr("orthotropic"), 'orthotrop') # Connections self.lineEditNALINF.textChanged[str].connect(self.slotNalinf) self.comboBoxVISCOSITY.activated[str].connect(self.slotViscosityType) self.pushButtonFormula.clicked.connect(self.slotFormula) # Validators validatorNALINF = IntValidator(self.lineEditNALINF, min=0) self.lineEditNALINF.setValidator(validatorNALINF) # Settings nalinf = self.mdl.getSubIterations() self.lineEditNALINF.setText(str(nalinf)) value = self.mdl.getViscosity() self.modelVISCOSITY.setItem(str_model=value) exp = self.mdl.getFormula() if exp: self.pushButtonFormula.setStyleSheet("background-color: green") self.pushButtonFormula.setToolTip(exp) else: self.pushButtonFormula.setStyleSheet("background-color: red") self.case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_NucleateBoiling.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = NucleateBoilingModel(self.case) self.modelHeatTransferModel = ComboModel( self.comboBoxHeatTransferModel, 2, 1) self.modelHeatTransferModel.addItem( self.tr("Extended Kurul-Podowski model"), "extended_kurul-podowski") self.modelHeatTransferModel.addItem( self.tr("Standard Kurul-Podowski model"), "standard_kurul-podowski") self.modelWallFunctionModel = ComboModel( self.comboBoxWallFunctionModel, 3, 1) self.modelWallFunctionModel.addItem( self.tr("standard (single phase wall function)"), "standard") self.modelWallFunctionModel.addItem(self.tr("Koncar Tiselj-NED 2008"), "koncar") self.modelWallFunctionModel.addItem(self.tr("Mimouni et al-NED 2008"), "mimouni") self.modelYPlus = ComboModel(self.comboBoxYPlus, 3, 1) self.modelYPlus.addItem(self.tr("Boundary cell center"), "center") self.modelYPlus.addItem(self.tr("Y+ = "), "Yplus_value") self.modelYPlus.addItem(self.tr("Nucleate bubble diameter"), "diameter") # Validators validatorYplus = DoubleValidator(self.lineEditYPlus, min=0.0) validatorRad = DoubleValidator(self.lineEditMaxRadius, min=0.0) validatorDiam = DoubleValidator(self.lineEditMaxDiam, min=0.0) validatorSat = DoubleValidator(self.lineEditMaxOverSaturation, min=0.0) validatorLam = DoubleValidator(self.lineEditThermalConductivity, min=0.0) validatorRho = DoubleValidator(self.lineEditDensity, min=0.0) validatorCp = DoubleValidator(self.lineEditSpecificHeat, min=0.0) validatorTh = DoubleValidator(self.lineEditThickness, min=0.0) validatorYplus.setExclusiveMin(True) validatorRad.setExclusiveMin(True) validatorDiam.setExclusiveMin(True) validatorSat.setExclusiveMin(True) validatorLam.setExclusiveMin(True) validatorRho.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorTh.setExclusiveMin(True) self.lineEditYPlus.setValidator(validatorYplus) self.lineEditMaxRadius.setValidator(validatorRad) self.lineEditMaxDiam.setValidator(validatorDiam) self.lineEditMaxOverSaturation.setValidator(validatorSat) self.lineEditThermalConductivity.setValidator(validatorLam) self.lineEditDensity.setValidator(validatorRho) self.lineEditSpecificHeat.setValidator(validatorCp) self.lineEditThickness.setValidator(validatorTh) # Connect signals to slots self.comboBoxHeatTransferModel.activated[str].connect( self.slotHeatTransferModel) self.comboBoxWallFunctionModel.activated[str].connect( self.slotWallFunctionModel) self.comboBoxYPlus.activated[str].connect(self.slotYPlus) self.checkBoxThickness.clicked.connect(self.slotThickness) self.lineEditYPlus.textChanged[str].connect(self.slotYPlusValue) self.lineEditMaxRadius.textChanged[str].connect(self.slotMaxRadius) self.lineEditMaxDiam.textChanged[str].connect(self.slotMaxDiam) self.lineEditMaxOverSaturation.textChanged[str].connect( self.slotMaxOverSaturation) self.lineEditThermalConductivity.textChanged[str].connect( self.slotThermalConductivity) self.lineEditDensity.textChanged[str].connect(self.slotDensity) self.lineEditSpecificHeat.textChanged[str].connect( self.slotSpecificHeat) self.lineEditThickness.textChanged[str].connect( self.slotThicknessValue) # load values isYPlus = self.mdl.getYPlusModel() self.modelYPlus.setItem(str_model=isYPlus) if isYPlus == "Yplus_value": self.lineEditYPlus.show() self.lineEditYPlus.setText(str(self.mdl.getYPlusValue())) else: self.lineEditYPlus.hide() self.lineEditMaxRadius.setText(str(self.mdl.getMaxRadius())) self.lineEditMaxDiam.setText(str(self.mdl.getMaxDiameter())) self.lineEditMaxOverSaturation.setText( str(self.mdl.getMaxOverSaturation())) self.lineEditThermalConductivity.setText( str(self.mdl.getThermalConductivity())) self.lineEditDensity.setText(str(self.mdl.getDensity())) self.lineEditSpecificHeat.setText(str(self.mdl.getSpecificHeat())) model = self.mdl.getHeatTransferModel() self.modelHeatTransferModel.setItem(str_model=model) if model == "standard_kurul-podowski": self.labelMaxRadius.setEnabled(0) self.lineEditMaxRadius.setEnabled(0) self.labelMaxRadiusUnit.setEnabled(0) self.labelMaxDiam.setEnabled(0) self.lineEditMaxDiam.setEnabled(0) self.labelMaxDiamUnit.setEnabled(0) else: self.labelMaxRadius.setEnabled(1) self.lineEditMaxRadius.setEnabled(1) self.labelMaxRadiusUnit.setEnabled(1) self.labelMaxDiam.setEnabled(1) self.lineEditMaxDiam.setEnabled(1) self.labelMaxDiamUnit.setEnabled(1) isThickness = self.mdl.getThicknessStatus() == "on" self.checkBoxThickness.setChecked(isThickness) if isThickness: self.lineEditThickness.show() self.labelThickness1.show() self.labelThickness2.show() self.lineEditThickness.setText(str(self.mdl.getThicknessValue())) else: self.lineEditThickness.hide() self.labelThickness1.hide() self.labelThickness2.hide() model = self.mdl.getWallFunctionModel() self.modelWallFunctionModel.setItem(str_model=model) self.case.undoStartGlobal()
class GlobalNumericalParametersView(QWidget, Ui_GlobalNumericalParameters): """ Global numerical parameters layout. """ def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_GlobalNumericalParameters.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = GlobalNumericalParametersModel(self.case) # Combo model self.modelVelocityAlgorithm = ComboModel( self.comboBoxVelocityAlgorithm, 3, 1) self.modelVelocityAlgorithm.addItem(self.tr("Standard"), "standard_difvit") self.modelVelocityAlgorithm.addItem(self.tr("Coupled"), "coupled_difvitc") self.modelVelocityAlgorithm.addItem( self.tr("Mean velocity - relative velocity"), "mean_velocity_relative_velocity") mfm = MainFieldsModel(self.case) if len(mfm.getFieldIdList()) < 2: self.modelVelocityAlgorithm.disableItem(2) else: self.modelVelocityAlgorithm.enableItem(2) # Validator validatorMaxRestart = IntValidator(self.lineEditMaxRestart, min=0) validatorSplitting = DoubleValidator(self.lineEditTimeSplitting, min=0.) validatorPRelax = DoubleValidator(self.lineEditPressureRelaxation, min=0.) validatorMinP = DoubleValidator(self.lineEditMinimumPressure) validatorMaxP = DoubleValidator(self.lineEditMaximumPressure) validatorMaxRestart.setExclusiveMin(False) validatorSplitting.setExclusiveMin(True) validatorPRelax.setExclusiveMin(True) self.lineEditMaxRestart.setValidator(validatorMaxRestart) self.lineEditTimeSplitting.setValidator(validatorSplitting) self.lineEditPressureRelaxation.setValidator(validatorPRelax) self.lineEditMinimumPressure.setValidator(validatorMinP) self.lineEditMaximumPressure.setValidator(validatorMaxP) # Connections self.checkBoxRestart.clicked.connect(self.slotRestart) self.checkBoxPotentialState.clicked.connect(self.slotPotentialState) self.checkBoxFacesReconstruction.clicked.connect( self.slotFacesReconstruction) self.checkBoxMultigrid.clicked.connect(self.slotMultigrid) self.lineEditMinimumPressure.textChanged[str].connect( self.slotMinimumPressure) self.lineEditMaximumPressure.textChanged[str].connect( self.slotMaximumPressure) self.pushButtonAdvanced.clicked.connect(self.slotAdvancedOptions) self.lineEditMaxRestart.textChanged[str].connect(self.slotMaxRestart) self.lineEditTimeSplitting.textChanged[str].connect( self.slotTimeSplitting) self.lineEditPressureRelaxation.textChanged[str].connect( self.slotPressureRelaxation) self.checkBoxUpwindAlphaEnergy.clicked.connect( self.slotUpwindAlphaEnergy) self.checkBoxStopRestart.clicked.connect(self.slotStopRestart) self.comboBoxVelocityAlgorithm.activated[str].connect( self.slotVelocityAlgorithm) self.checkBoxRegulBadCells.clicked.connect(self.slotRegulateBadCells) # Initialize widget status = self.mdl.getRestartTimeStep() if status == 'on': self.checkBoxRestart.setChecked(1) self.groupBoxRestartOption.show() value = self.mdl.getMaxNumberOfRestart() self.lineEditMaxRestart.setText(str(value)) value = self.mdl.getTimeSplit() self.lineEditTimeSplitting.setText(str(value)) value = self.mdl.getPressureRelaxation() self.lineEditPressureRelaxation.setText(str(value)) status = self.mdl.getUpwindScheme() if status == 'on': self.checkBoxUpwindAlphaEnergy.setChecked(True) else: self.checkBoxUpwindAlphaEnergy.setChecked(False) status = self.mdl.getStopNoConvergence() if status == 'on': self.checkBoxStopRestart.setChecked(True) else: self.checkBoxStopRestart.setChecked(False) else: self.checkBoxRestart.setChecked(0) self.groupBoxRestartOption.hide() is_compressible = False for fid in mfm.getFieldIdList(): if mfm.getCompressibleStatus(int(fid)) == 'on': is_compressible = True break if is_compressible: self.mdl.setPotentielState('off') self.checkBoxPotentialState.setChecked(0) self.checkBoxPotentialState.setEnabled(False) else: status = self.mdl.getPotentielState() if status == 'on': self.checkBoxPotentialState.setChecked(1) else: self.checkBoxPotentialState.setChecked(0) status = self.mdl.getFacesReconstruction() if status == 'on': self.checkBoxFacesReconstruction.setChecked(1) else: self.checkBoxFacesReconstruction.setChecked(0) status = self.mdl.getRegulateBadCElls() self.checkBoxRegulBadCells.setChecked(status == 'on') status = self.mdl.getMultigridStatus() if status == 'on': self.checkBoxMultigrid.setChecked(1) else: self.checkBoxMultigrid.setChecked(0) value = self.mdl.getMinPressure() self.lineEditMinimumPressure.setText(str(value)) value = self.mdl.getMaxPressure() self.lineEditMaximumPressure.setText(str(value)) model = self.mdl.getVelocityPredictorAlgo() self.modelVelocityAlgorithm.setItem(str_model=model) self.case.undoStartGlobal() @pyqtSlot() def slotRestart(self): """ Input if restart time step if not converged """ if self.checkBoxRestart.isChecked(): self.mdl.setRestartTimeStep('on') self.groupBoxRestartOption.show() value = self.mdl.getMaxNumberOfRestart() self.lineEditMaxRestart.setText(str(value)) value = self.mdl.getTimeSplit() self.lineEditTimeSplitting.setText(str(value)) value = self.mdl.getPressureRelaxation() self.lineEditPressureRelaxation.setText(str(value)) status = self.mdl.getUpwindScheme() if status == 'on': self.checkBoxUpwindAlphaEnergy.setChecked(True) else: self.checkBoxUpwindAlphaEnergy.setChecked(False) status = self.mdl.getStopNoConvergence() if status == 'on': self.checkBoxStopRestart.setChecked(True) else: self.checkBoxStopRestart.setChecked(False) else: self.mdl.setRestartTimeStep('off') self.groupBoxRestartOption.hide() @pyqtSlot() def slotPotentialState(self): """ Input if restart time step if not converged """ if self.checkBoxPotentialState.isChecked(): self.mdl.setPotentielState('on') else: self.mdl.setPotentielState('off') @pyqtSlot() def slotFacesReconstruction(self): """ Input if faces reconstruction """ if self.checkBoxFacesReconstruction.isChecked(): self.mdl.setFacesReconstruction('on') self.checkBoxFacesReconstruction.setChecked(1) else: self.mdl.setFacesReconstruction('off') @pyqtSlot() def slotMultigrid(self): """ Input if multigrid for pressure """ if self.checkBoxMultigrid.isChecked(): self.mdl.setMultigridStatus('on') else: self.mdl.setMultigridStatus('off') @pyqtSlot(str) def slotMinimumPressure(self, text): """ Input value of minimum pressure """ if self.lineEditMinimumPressure.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMinPressure(value) @pyqtSlot(str) def slotMaximumPressure(self, text): """ Input value of maximum pressure """ if self.lineEditMaximumPressure.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setMaxPressure(value) @pyqtSlot() def slotAdvancedOptions(self): """ Ask one popup for advanced specifications """ default = {} default['velocity_update'] = self.mdl.getVelocityUpdate() default['pressure_symetrisation'] = self.mdl.getPressureSymetrisation() default['pressure_gradient'] = self.mdl.getPressureGradient() default['max_sum_alpha'] = self.mdl.getSumAlpha() default['alpha_p_cycle'] = self.mdl.getAlphaPressureCycles() log.debug("slotAdvancedOptions -> %s" % str(default)) dialog = GlobalNumericalParametersAdvancedOptionsDialogView( self, self.case, default) if dialog.exec_(): result = dialog.get_result() log.debug("slotAdvancedOptions -> %s" % str(result)) self.mdl.setVelocityUpdate(result['velocity_update']) self.mdl.setPressureSymetrisation(result['pressure_symetrisation']) self.mdl.setPressureGradient(result['pressure_gradient']) self.mdl.setSumAlpha(result['max_sum_alpha']) self.mdl.setAlphaPressureCycles(result['alpha_p_cycle']) @pyqtSlot(str) def slotMaxRestart(self, text): """ Input value of Maximum number of restart """ if self.lineEditMaxRestart.validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.mdl.setMaxNumberOfRestart(value) @pyqtSlot(str) def slotTimeSplitting(self, text): """ Input value of time-step splitting """ if self.lineEditTimeSplitting.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setTimeSplit(value) @pyqtSlot(str) def slotPressureRelaxation(self, text): """ Input value of pressure increment relaxation """ if self.lineEditPressureRelaxation.validator( ).state == QValidator.Acceptable: value = from_qvariant(text, float) self.mdl.setPressureRelaxation(value) @pyqtSlot() def slotUpwindAlphaEnergy(self): """ Input if upwind scheme for mass and energy """ if self.checkBoxUpwindAlphaEnergy.isChecked(): self.mdl.setUpwindScheme('on') else: self.mdl.setUpwindScheme('off') @pyqtSlot() def slotStopRestart(self): """ Input if stop if no convergence """ if self.checkBoxStopRestart.isChecked(): self.mdl.setStopNoConvergence('on') else: self.mdl.setStopNoConvergence('off') @pyqtSlot(str) def slotVelocityAlgorithm(self, text): """ Input velocity algorithm model """ model = self.modelVelocityAlgorithm.dicoV2M[str(text)] self.mdl.setVelocityPredictorAlgo(model) @pyqtSlot() def slotRegulateBadCells(self): """ Activate bad cells regulations. """ if self.checkBoxRegulBadCells.isChecked(): self.mdl.setRegulateBadCells('on') else: self.mdl.setRegulateBadCells('off') def tr(self, text): """ Translation """ return text
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_DarcyLawForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = DarcyLawModel(self.case) self.list_scalars = [] self.m_sca = DefineUserScalarsModel(self.case) for s in self.m_sca.getUserScalarNameList(): self.list_scalars.append((s, self.tr("Additional scalar"))) # Create the Page layout. # Model and QTreeView for Head Losses self.modelDarcyLaw = StandardItemModelDarcyLaw() self.treeView.setModel(self.modelDarcyLaw) # Combo model self.modelDarcyLawType = ComboModel(self.comboBoxType, 2, 1) self.modelDarcyLawType.addItem(self.tr("User law"), 'user') self.modelDarcyLawType.addItem(self.tr("Van Genuchten law"), 'VanGenuchten') self.modelNameDiff = ComboModel(self.comboBoxNameDiff,1,1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('variable'), 'variable') # Set up validators self.lineEditKs.setValidator(DoubleValidator(self.lineEditKs)) self.lineEditThetas.setValidator(DoubleValidator(self.lineEditThetas)) self.lineEditThetar.setValidator(DoubleValidator(self.lineEditThetar)) self.lineEditN.setValidator(DoubleValidator(self.lineEditN)) self.lineEditL.setValidator(DoubleValidator(self.lineEditL)) self.lineEditAlpha.setValidator(DoubleValidator(self.lineEditAlpha)) self.lineEditLongitudinal.setValidator(DoubleValidator(self.lineEditLongitudinal)) self.lineEditTransverse.setValidator(DoubleValidator(self.lineEditTransverse)) self.scalar = "" scalar_list = self.m_sca.getUserScalarNameList() for s in self.m_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for scalar in scalar_list: self.modelNameDiff.addItem(scalar) # Connections self.connect(self.treeView, SIGNAL("clicked(const QModelIndex &)"), self.slotSelectDarcyLawZones) self.connect(self.comboBoxType, SIGNAL("activated(const QString&)"), self.slotDarcyLaw) self.connect(self.lineEditKs, SIGNAL("textChanged(const QString &)"), self.slotKs) self.connect(self.lineEditThetas, SIGNAL("textChanged(const QString &)"), self.slotThetas) self.connect(self.lineEditThetar, SIGNAL("textChanged(const QString &)"), self.slotThetar) self.connect(self.lineEditN, SIGNAL("textChanged(const QString &)"), self.slotN) self.connect(self.lineEditL, SIGNAL("textChanged(const QString &)"), self.slotL) self.connect(self.lineEditAlpha, SIGNAL("textChanged(const QString &)"), self.slotAlpha) self.connect(self.lineEditLongitudinal, SIGNAL("textChanged(const QString &)"), self.slotLongitudinal) self.connect(self.lineEditTransverse, SIGNAL("textChanged(const QString &)"), self.slotTransverse) self.connect(self.pushButtonUserLaw, SIGNAL("clicked()"), self.slotFormula) self.connect(self.comboBoxNameDiff, SIGNAL("activated(const QString&)"), self.slotNameDiff) self.connect(self.comboBoxDiff, SIGNAL("activated(const QString&)"), self.slotStateDiff) self.connect(self.pushButtonDiff, SIGNAL("clicked()"), self.slotFormulaDiff) # Initialize Widgets self.entriesNumber = -1 d = self.mdl.getNameAndLocalizationZone() liste=[] liste=list(d.items()) t=[] for t in liste : NamLoc=t[1] Lab=t[0 ] self.modelDarcyLaw.insertItem(Lab, NamLoc[0],NamLoc[1]) self.forgetStandardWindows() self.case.undoStartGlobal()
def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_InitializationForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.init = InitializationModel(self.case) self.turb = TurbulenceModel(self.case) self.therm = ThermalScalarModel(self.case) self.th_sca = DefineUserScalarsModel(self.case) self.comp = CompressibleModel(self.case) self.volzone = LocalizationModel('VolumicZone', self.case) # create group to control hide/show options self.turb_group = [self.labelTurbulence, self.pushButtonTurbulence, self.comboBoxTurbulence] self.thermal_group = [self.labelThermal, self.pushButtonThermal] self.species_group = [self.labelSpecies, self.comboBoxSpecies, self.pushButtonSpecies] self.meteo_group = [self.labelMeteo, self.comboBoxMeteo, self.pushButtonMeteo] self.thermodynamic_list = ['Pressure', 'Density', 'Temperature', 'Energy'] # 1/ Combo box models self.modelZone = ComboModel(self.comboBoxZone, 1, 1) if self.comp.getCompressibleModel() != 'off': self.groupBoxThermodynamic.show() else: self.groupBoxThermodynamic.hide() self.zone = "" zones = self.volzone.getZones() for zone in zones: if zone.getNature()['initialization'] == "on": label = zone.getLabel() name = str(zone.getCodeNumber()) self.modelZone.addItem(self.tr(label), name) if label == "all_cells": self.zone = name if not self.zone: self.zone = name self.modelZone.setItem(str_model = self.zone) self.modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1) self.modelTurbulence.addItem(self.tr("Initialization by formula"), 'formula') self.modelTurbulence.addItem(self.tr("Initialization by reference value(s)"), 'reference_value') # 2/ Connections self.connect(self.comboBoxZone, SIGNAL("activated(const QString&)"), self.slotZone) self.connect(self.comboBoxTurbulence, SIGNAL("activated(const QString&)"), self.slotChoice) self.connect(self.comboBoxSpecies, SIGNAL("activated(const QString&)"), self.slotSpeciesChoice) self.connect(self.comboBoxMeteo, SIGNAL("activated(const QString&)"), self.slotMeteoChoice) self.connect(self.checkBoxPressure, SIGNAL("clicked()"), self.slotPressure) self.connect(self.checkBoxDensity, SIGNAL("clicked()"), self.slotDensity) self.connect(self.checkBoxTemperature, SIGNAL("clicked()"), self.slotTemperature) self.connect(self.checkBoxEnergy, SIGNAL("clicked()"), self.slotEnergy) self.connect(self.pushButtonVelocity, SIGNAL("clicked()"), self.slotVelocityFormula) self.connect(self.pushButtonThermal, SIGNAL("clicked()"), self.slotThermalFormula) self.connect(self.pushButtonTurbulence, SIGNAL("clicked()"), self.slotTurbulenceFormula) self.connect(self.pushButtonSpecies, SIGNAL("clicked()"), self.slotSpeciesFormula) self.connect(self.pushButtonMeteo, SIGNAL("clicked()"), self.slotMeteoFormula) self.connect(self.pushButtonPressure, SIGNAL("clicked()"), self.slotPressureFormula) self.connect(self.pushButtonDensity, SIGNAL("clicked()"), self.slotDensityFormula) self.connect(self.pushButtonTemperature,SIGNAL("clicked()"), self.slotTemperatureFormula) self.connect(self.pushButtonEnergy, SIGNAL("clicked()"), self.slotEnergyFormula) self.connect(self.pushButtonPressure_2, SIGNAL("clicked()"), self.slotPressureFormula) choice = self.init.getInitialTurbulenceChoice(self.zone) self.modelTurbulence.setItem(str_model = choice) # species treatment self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1) self.scalar = "" scalar_list = self.th_sca.getUserScalarNameList() for s in self.th_sca.getScalarsVarianceList(): if s in scalar_list: scalar_list.remove(s) if scalar_list != []: self.scalar = scalar_list[0] for item in self.species_group: item.show() for scalar in scalar_list: self.modelSpecies.addItem(self.tr(scalar), scalar) self.modelSpecies.setItem(str_model = self.scalar) setGreenColor(self.pushButtonSpecies, True) else: for item in self.species_group: item.hide() # meteo self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1) self.scalar_meteo = "" scalar_meteo_list = DefineUserScalarsModel( self.case).getMeteoScalarsNameList() if scalar_meteo_list != None and scalar_meteo_list != []: self.scalar_meteo = scalar_meteo_list[0] for item in self.meteo_group: item.show() for scalar in scalar_meteo_list: self.modelMeteo.addItem(self.tr(scalar), scalar) self.modelMeteo.setItem(str_model = self.scalar_meteo) setGreenColor(self.pushButtonMeteo, True) else: for item in self.meteo_group: item.hide() if DarcyModel(self.case).getDarcyModel() == "off": self.labelpressure.hide() self.pushButtonPressure_2.hide() else: setGreenColor(self.pushButtonPressure_2, True) # Initialize widget self.initializeVariables(self.zone) self.case.undoStartGlobal()
class LagrangianBoundaryView(QWidget, Ui_LagrangianBoundaryForm): """ """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_LagrangianBoundaryForm.__init__(self) self.setupUi(self) def setup(self, case): self.case = case self.case.undoStopGlobal() self.model = LagrangianBoundariesModel(self.case) self.zone = None self.dicoM2V = {} self.dicoV2M = {} self._setConnections() self._setValidators() self.case.undoStartGlobal() def _setValidators(self): validatorIJNBP = IntValidator(self.lineEditIJNBP, min=0) validatorIJFRE = IntValidator(self.lineEditIJFRE, min=0) validatorICLST = IntValidator(self.lineEditICLST, min=0) validatorIDEBT = DoubleValidator(self.lineEditIDEBT, min=0.) validatorIPOIT = DoubleValidator(self.lineEditIPOIT, min=0.) validatorIPOIT.setExclusiveMin(True) validatorIROPT = DoubleValidator(self.lineEditIROPT, min=0.) validatorIROPT.setExclusiveMin(True) validatorIRCOLM = DoubleValidator(self.lineEditIRCOLM, min=0.) validatorIUNO = DoubleValidator(self.lineEditIUNO) validatorIUPT = DoubleValidator(self.lineEditIUPT) validatorIVPT = DoubleValidator(self.lineEditIVPT) validatorIWPT = DoubleValidator(self.lineEditIWPT) validatorITPT = DoubleValidator(self.lineEditITPT) validatorICPT = DoubleValidator(self.lineEditICPT) validatorIEPSI = DoubleValidator(self.lineEditIEPSI) validatorIDPT = DoubleValidator(self.lineEditIDPT, min=0.) validatorIVDPT = DoubleValidator(self.lineEditIVDPT) validatorINUCHL = IntValidator(self.lineEditINUCHL, min=0) validatorIHPT = DoubleValidator(self.lineEditIHPT) self.lineEditIJNBP.setValidator(validatorIJNBP) self.lineEditIJFRE.setValidator(validatorIJFRE) self.lineEditICLST.setValidator(validatorICLST) self.lineEditIDEBT.setValidator(validatorIDEBT) self.lineEditIPOIT.setValidator(validatorIPOIT) self.lineEditIROPT.setValidator(validatorIROPT) self.lineEditIRCOLM.setValidator(validatorIRCOLM) self.lineEditIUNO.setValidator(validatorIUNO) self.lineEditIUPT.setValidator(validatorIUPT) self.lineEditIVPT.setValidator(validatorIVPT) self.lineEditIWPT.setValidator(validatorIWPT) self.lineEditITPT.setValidator(validatorITPT) self.lineEditICPT.setValidator(validatorICPT) self.lineEditIEPSI.setValidator(validatorIEPSI) self.lineEditIDPT.setValidator(validatorIDPT) self.lineEditIVDPT.setValidator(validatorIVDPT) self.lineEditINUCHL.setValidator(validatorINUCHL) self.lineEditIHPT.setValidator(validatorIHPT) def _setConnections(self): self.comboBoxBoundary.activated[str].connect( self.slotSetParticleBoundary) self.lineEditNbSets.editingFinished.connect(self.slotNbSets) self.spinBoxICLAS.valueChanged[int].connect(self.slotICLAS) self.lineEditIJNBP.textChanged[str].connect(self.slotIJNBP) self.lineEditIJFRE.textChanged[str].connect(self.slotIJFRE) self.lineEditICLST.textChanged[str].connect(self.slotICLST) self.lineEditIDEBT.textChanged[str].connect(self.slotIDEBT) self.comboBoxIPOIT.activated[str].connect(self.slotIPOITChoice) self.lineEditIPOIT.textChanged[str].connect(self.slotIPOIT) self.lineEditIROPT.textChanged[str].connect(self.slotIROPT) self.lineEditIRCOLM.textChanged[str].connect(self.slotIRCOLM) self.comboBoxIJUVW.activated[str].connect(self.slotIJUVW) self.lineEditIUNO.textChanged[str].connect(self.slotIUNO) self.lineEditIUPT.textChanged[str].connect(self.slotIUPT) self.lineEditIVPT.textChanged[str].connect(self.slotIVPT) self.lineEditIWPT.textChanged[str].connect(self.slotIWPT) self.comboBoxIJRTP.activated[str].connect(self.slotIJRTP) self.lineEditITPT.textChanged[str].connect(self.slotITPT) self.lineEditICPT.textChanged[str].connect(self.slotICPT) self.lineEditIEPSI.textChanged[str].connect(self.slotIEPSI) self.lineEditIDPT.textChanged[str].connect(self.slotIDPT) self.lineEditIVDPT.textChanged[str].connect(self.slotIVDPT) self.lineEditINUCHL.textChanged[str].connect(self.slotINUCHL) self.lineEditIHPT.textChanged[str].connect(self.slotIHPT) def showWidget(self, zone): self.zone = zone self.show() self._hideSubWidgets() self._defineV2MDictionary() self._fillComboBoxes() self._loadCase() def _hideSubWidgets(self): self.groupBoxNbSets.hide() self.groupBoxSetNumber.hide() self.groupBoxMain.hide() self.groupBoxRate.hide() self.groupBoxVelocity.hide() self.groupBoxTemperature.hide() self.groupBoxDiameter.hide() self.groupBoxCoal.hide() def _defineV2MDictionary(self): if self.model.getFoulingStatus() == "on": self.dicoM2V = { "wall": { "inlet": self.tr("Particles inlet"), "bounce": self.tr("Particles rebound"), "deposit1": self.tr("Deposition and elimination"), "deposit2": self.tr("Deposition"), "fouling": self.tr("Fouling") }, "inlet": { "inlet": self.tr("Particles inlet"), "bounce": self.tr("Particles rebound"), "outlet": self.tr("Particles outlet") }, "outlet": { "outlet": self.tr("Particles outlet") }, "free_inlet_outlet": { "inlet": self.tr("Particles inlet"), "outlet": self.tr("Particles outlet") }, "imposed_p_outlet": { "outlet": self.tr("Particles outlet") }, "symmetry": { "part_symmetry": self.tr("Particles symmetry"), "bounce": self.tr("Particles rebound") } }[self.zone.getNature()] else: self.dicoM2V = { "wall": { "inlet": self.tr("Particles inlet"), "bounce": self.tr("Particles rebound"), "deposit1": self.tr("Deposition and elimination"), "deposit2": self.tr("Deposition") }, "inlet": { "inlet": self.tr("Particles inlet"), "bounce": self.tr("Particles rebound"), "outlet": self.tr("Particles outlet") }, "outlet": { "outlet": self.tr("Particles outlet") }, "free_inlet_outlet": { "inlet": self.tr("Particles inlet"), "outlet": self.tr("Particles outlet") }, "imposed_p_outlet": { "outlet": self.tr("Particles outlet") }, "symmetry": { "part_symmetry": self.tr("Particles symmetry"), "bounce": self.tr("Particles rebound") } }[self.zone.getNature()] self.dicoV2M = {} for k, v in self.dicoM2V.items(): self.dicoV2M[v] = k def _fillComboBoxes(self): self.modelParticleBoundary = ComboModel(self.comboBoxBoundary, 1, 1) for key, value in self.dicoM2V.items(): self.modelParticleBoundary.addItem(value, key) self.modelIPOIT = ComboModel(self.comboBoxIPOIT, 2, 1) self.modelIPOIT.addItem(self.tr("Mass flow rate"), "rate") self.modelIPOIT.addItem(self.tr("Statistical weight set by values"), "prescribed") self.modelIJUVW = ComboModel(self.comboBoxIJUVW, 3, 1) self.modelIJUVW.addItem(self.tr("Fluid velocity"), "fluid") self.modelIJUVW.addItem(self.tr("Normal direction velocity"), "norm") self.modelIJUVW.addItem(self.tr("Velocity given by values"), "components") self.modelIJRTP = ComboModel(self.comboBoxIJRTP, 2, 1) self.modelIJRTP.addItem(self.tr("Fluid temperature"), "fluid") self.modelIJRTP.addItem(self.tr("Temperature set by values"), "prescribed") def _loadCase(self): nature = self.zone.getNature() label = self.zone.getLabel() self.model.setCurrentBoundaryNode(nature, label) interaction = self.model.getBoundaryChoice(nature, label) if interaction not in self.dicoM2V.keys(): print("error: BC '" + label + "' (" + nature + ") type '" + interaction + "' requested\n" " but model is not active: set to rebound") interaction = 'bounce' self.model.setBoundaryChoice(nature, label, interaction) self.modelParticleBoundary.setItem(str_model=interaction) self.slotSetParticleBoundary( self.dicoM2V[interaction] ) # this is needed because setItem does not trigger comboBox activation if interaction == "inlet": nb_sets = self.model.getNumberOfSetsValue() self.updateInletDisplay(nb_sets) def hideWidget(self): self.hide() def updateInletDisplay(self, nb_sets): self.lineEditNbSets.setText(str(nb_sets)) if int(nb_sets) > 0: self.groupBoxSetNumber.show() self.spinBoxICLAS.setMinimum(1) self.spinBoxICLAS.setMaximum(nb_sets) self.spinBoxICLAS.setValue(1) self.slotICLAS(1) else: self.groupBoxSetNumber.hide() self.groupBoxMain.hide() self.groupBoxRate.hide() self.groupBoxVelocity.hide() self.groupBoxTemperature.hide() self.groupBoxDiameter.hide() self.groupBoxCoal.hide() @pyqtSlot() def slotNbSets(self): nb_sets = from_qvariant(self.lineEditNbSets.text(), to_text_string) try: nb_sets = int(nb_sets) except Exception: nb_sets = self.model.getNumberOfSetsValue() self.lineEditNbSets.setText(str(nb_sets)) return self.model.setNumberOfSetsValue(nb_sets) self.updateInletDisplay(nb_sets) return @pyqtSlot(str) def slotSetParticleBoundary(self, interaction): interaction = self.dicoV2M[interaction] self.model.setBoundaryChoice(self.zone.getNature(), self.zone.getLabel(), interaction) if interaction == "inlet": self.groupBoxNbSets.show() else: self.lineEditNbSets.setText("0") self.groupBoxNbSets.hide() @pyqtSlot(int) def slotICLAS(self, iset): """ Input ICLAS. """ self.iset = iset label = self.zone.getLabel() interaction = self.dicoV2M[str(self.comboBoxBoundary.currentText())] if interaction == "inlet": self.model.setCurrentSetNode(iset) # Main variables self.groupBoxMain.show() npart = self.model.getNumberOfParticulesInSetValue(label, self.iset) self.lineEditIJNBP.setText(str(npart)) freq = self.model.getInjectionFrequencyValue(label, self.iset) self.lineEditIJFRE.setText(str(freq)) lagStatisticsModel = LagrangianStatisticsModel(self.case) if lagStatisticsModel.getGroupOfParticlesValue() > 0: igroup = self.model.getParticleGroupNumberValue(label, self.iset) self.lineEditICLST.setText(str(igroup)) self.labelICLST.show() self.lineEditICLST.show() else: self.labelICLST.hide() self.lineEditICLST.hide() # Rate / stat. weight self.groupBoxRate.show() choice = self.model.getStatisticalWeightChoice(label, self.iset) self.modelIPOIT.setItem(str_model=choice) text = self.modelIPOIT.dicoM2V[choice] self.slotIPOITChoice(text) # Velocity self.groupBoxVelocity.show() choice = self.model.getVelocityChoice(label, self.iset) self.modelIJUVW.setItem(str_model=choice) text = self.modelIJUVW.dicoM2V[choice] self.slotIJUVW(text) # Fouling colm = self.model.getFoulingIndexValue(label, self.iset) self.lineEditIRCOLM.setText(str(colm)) # Temperature lagModel = LagrangianModel(self.case) part_model = lagModel.getParticlesModel() status = lagModel.getHeating() if part_model == "thermal" and status == "on": self.groupBoxTemperature.show() choice = self.model.getTemperatureChoice(label, self.iset) self.modelIJRTP.setItem(str_model=choice) text = self.modelIJRTP.dicoM2V[choice] self.slotIJRTP(text) cp = self.model.getSpecificHeatValue(label, self.iset) self.lineEditICPT.setText(str(cp)) eps = self.model.getEmissivityValue(label, self.iset) self.lineEditIEPSI.setText(str(eps)) # Coals if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.groupBoxCoal.show() icoal = self.model.getCoalNumberValue(label, self.iset) self.lineEditINUCHL.setText(str(icoal)) temp = self.model.getCoalTemperatureValue(label, self.iset) self.lineEditIHPT.setText(str(temp)) # Diameter self.groupBoxDiameter.show() diam = self.model.getDiameterValue(label, self.iset) vdiam = self.model.getDiameterVarianceValue(label, self.iset) self.lineEditIDPT.setText(str(diam)) self.lineEditIVDPT.setText(str(vdiam)) # Coal if CoalCombustionModel( self.case).getCoalCombustionModel("only") != 'off': self.labelIROPT.hide() self.labelUnitIROPT.hide() self.lineEditIROPT.hide()
def setup(self, case): """ Setup the widget """ self.case = case self.__boundary = None self.case.undoStopGlobal() self.mdl = CompressibleModel(self.case) self.gas = GasCombustionModel(self.case) self.notebook = NotebookModel(self.case) # Connections self.comboBoxVelocity.activated[str].connect(self.__slotChoiceVelocity) self.lineEditVelocity.textChanged[str].connect( self.__slotVelocityValue) self.comboBoxDirection.activated[str].connect( self.__slotChoiceDirection) self.lineEditDirectionX.textChanged[str].connect(self.__slotDirX) self.lineEditDirectionY.textChanged[str].connect(self.__slotDirY) self.lineEditDirectionZ.textChanged[str].connect(self.__slotDirZ) self.comboBoxTypeInlet.activated[str].connect(self.__slotInletType) self.checkBoxPressure.clicked.connect(self.__slotPressure) self.checkBoxDensity.clicked.connect(self.__slotDensity) self.checkBoxTemperature.clicked.connect(self.__slotTemperature) self.checkBoxEnergy.clicked.connect(self.__slotEnergy) self.lineEditPressure.textChanged[str].connect( self.__slotPressureValue) self.lineEditDensity.textChanged[str].connect(self.__slotDensityValue) self.lineEditTotalPressure.textChanged[str].connect( self.__slotTotalPressure) self.lineEditTotalEnthalpy.textChanged[str].connect( self.__slotTotalEnthalpy) self.lineEditTemperature.textChanged[str].connect( self.__slotTemperatureValue) self.lineEditEnergy.textChanged[str].connect(self.__slotEnergyValue) self.comboBoxTypeInletGasComb.activated[str].connect( self.__slotInletTypeGasComb) self.lineEditTemperatureGasComb.textChanged[str].connect( self.__slotTemperatureGasComb) self.lineEditFraction.textChanged[str].connect( self.__slotMeanMixtureFraction) # Combo models self.modelVelocity = ComboModel(self.comboBoxVelocity, 6, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("volumic flow rate"), 'flow2') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelVelocity.addItem(self.tr("volumic flow rate (user law)"), 'flow2_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal direction to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("imposed inlet"), 'imposed_inlet') self.modelTypeInlet.addItem(self.tr("subsonic inlet (imposed total pressure and total enthalpy)"), \ 'subsonic_inlet_PH') self.modelTypeInletGasComb = ComboModel(self.comboBoxTypeInletGasComb, 2, 1) model = self.gas.getGasCombustionModel() if model == 'lwp' or model == 'ebu': self.modelTypeInletGasComb.addItem(self.tr("Unburned gas"), 'unburned') self.modelTypeInletGasComb.addItem(self.tr("Burned gas"), 'burned') elif model == 'd3p': self.modelTypeInletGasComb.addItem(self.tr("Oxydant"), 'oxydant') self.modelTypeInletGasComb.addItem(self.tr("Fuel"), 'fuel') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorP = DoubleValidator(self.lineEditPressure, min=0.0) validatorD = DoubleValidator(self.lineEditDensity, min=0.0) validatorT = DoubleValidator(self.lineEditTemperature, min=0.0) validatorE = DoubleValidator(self.lineEditEnergy, min=0.0) validatorP2 = DoubleValidator(self.lineEditTotalPressure, min=0.0) validatorH2 = DoubleValidator(self.lineEditTotalEnthalpy, min=0.0) validatorTemp = DoubleValidator(self.lineEditTemperatureGasComb, min=0.) validatorFrac = DoubleValidator(self.lineEditFraction, min=0., max=1.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditPressure.setValidator(validatorP) self.lineEditDensity.setValidator(validatorD) self.lineEditTemperature.setValidator(validatorT) self.lineEditEnergy.setValidator(validatorE) self.lineEditTotalPressure.setValidator(validatorP2) self.lineEditTotalEnthalpy.setValidator(validatorH2) self.lineEditTemperatureGasComb.setValidator(validatorTemp) self.lineEditFraction.setValidator(validatorFrac) self.pushButtonVelocityFormula.clicked.connect( self.__slotVelocityFormula) self.pushButtonDirectionFormula.clicked.connect( self.__slotDirectionFormula) self.case.undoStartGlobal()
def __init__(self, parent, case, stbar): """ Constructor """ QWidget.__init__(self, parent) Ui_ElectricalForm.__init__(self) self.setupUi(self) self.case = case self.stbar = stbar self.case.undoStopGlobal() self.model = ElectricalModel(self.case) # Combo model self.modelJoule = ComboModel(self.comboBoxJouleModel, 4, 1) self.modelJoule.addItem(self.tr("AC/DC"), "AC/DC") self.modelJoule.addItem(self.tr("three-phase"), "three-phase") self.modelJoule.addItem(self.tr("AC/DC with Transformer coupling"), "AC/DC+Transformer") self.modelJoule.addItem(self.tr("three-phase with Transformer coupling"), "three-phase+Transformer") self.modelJoule.disableItem(str_model="AC/DC+Transformer") self.modelJoule.disableItem(str_model="three-phase+Transformer") self.modelScaling = ComboModel(self.comboBoxScalingModel, 3, 1) self.modelScaling.addItem(self.tr("general case"), "general_case") self.modelScaling.addItem(self.tr("plane define"), "plane_define") self.modelScaling.addItem(self.tr("user define"), "user") self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("X"), "X") self.modelDirection.addItem(self.tr("Y"), "Y") self.modelDirection.addItem(self.tr("Z"), "Z") # Connections self.connect(self.pushButtonPropertiesData, SIGNAL("pressed()"), self.__slotSearchPropertiesData) self.connect(self.lineEditSRROM, SIGNAL("textChanged(const QString &)"), self.slotSRROM) self.connect(self.lineEditPower, SIGNAL("textChanged(const QString &)"), self.slotPower) self.connect(self.lineEditCurrent, SIGNAL("textChanged(const QString &)"), self.slotCurrent) self.connect(self.checkBoxScaling, SIGNAL("clicked()"), self.slotScaling) self.connect(self.comboBoxJouleModel, SIGNAL("activated(const QString&)"), self.slotJouleModel) self.connect(self.comboBoxScalingModel, SIGNAL("activated(const QString&)"), self.slotScalingModel) self.connect(self.comboBoxDirection, SIGNAL("clicked()"), self.slotDirection) self.connect(self.lineEditPlaneDefinitionA, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefA) self.connect(self.lineEditPlaneDefinitionB, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefB) self.connect(self.lineEditPlaneDefinitionC, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefC) self.connect(self.lineEditPlaneDefinitionD, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefD) self.connect(self.lineEditEpsilon, SIGNAL("textChanged(const QString &)"), self.slotPlaneDefEpsilon) # Validators validatorSRROM = DoubleValidator(self.lineEditSRROM, min=0.0, max=1.0) validatorSRROM.setExclusiveMin(False) validatorPower = DoubleValidator(self.lineEditPower, min=0.0) validatorPower.setExclusiveMin(False) validatorCurrent = DoubleValidator(self.lineEditCurrent, min=0.0) validatorCurrent.setExclusiveMin(False) validatorDefinitionA = DoubleValidator(self.lineEditPlaneDefinitionA) validatorDefinitionB = DoubleValidator(self.lineEditPlaneDefinitionB) validatorDefinitionC = DoubleValidator(self.lineEditPlaneDefinitionC) validatorDefinitionD = DoubleValidator(self.lineEditPlaneDefinitionD) validatorEpsilon = DoubleValidator(self.lineEditEpsilon) self.lineEditSRROM.setValidator(validatorSRROM) self.lineEditPower.setValidator(validatorPower) self.lineEditCurrent.setValidator(validatorCurrent) self.lineEditPlaneDefinitionA.setValidator(validatorDefinitionA) self.lineEditPlaneDefinitionB.setValidator(validatorDefinitionB) self.lineEditPlaneDefinitionC.setValidator(validatorDefinitionC) self.lineEditPlaneDefinitionD.setValidator(validatorDefinitionD) self.lineEditEpsilon.setValidator(validatorEpsilon) # Initialize widget self.__initializeWidget() self.case.undoStartGlobal()
class BoundaryConditionsVelocityInletView( QWidget, Ui_BoundaryConditionsVelocityInletForm): """ Boundary condition for velocity in inlet, without particular physics. """ def __init__(self, parent): """ Constructor """ QWidget.__init__(self, parent) Ui_BoundaryConditionsVelocityInletForm.__init__(self) self.setupUi(self) self.thermodynamic_list = [ 'Pressure', 'Density', 'Temperature', 'Energy' ] def setup(self, case): """ Setup the widget """ self.case = case self.__boundary = None self.case.undoStopGlobal() self.mdl = CompressibleModel(self.case) self.gas = GasCombustionModel(self.case) self.notebook = NotebookModel(self.case) # Connections self.comboBoxVelocity.activated[str].connect(self.__slotChoiceVelocity) self.lineEditVelocity.textChanged[str].connect( self.__slotVelocityValue) self.comboBoxDirection.activated[str].connect( self.__slotChoiceDirection) self.lineEditDirectionX.textChanged[str].connect(self.__slotDirX) self.lineEditDirectionY.textChanged[str].connect(self.__slotDirY) self.lineEditDirectionZ.textChanged[str].connect(self.__slotDirZ) self.comboBoxTypeInlet.activated[str].connect(self.__slotInletType) self.checkBoxPressure.clicked.connect(self.__slotPressure) self.checkBoxDensity.clicked.connect(self.__slotDensity) self.checkBoxTemperature.clicked.connect(self.__slotTemperature) self.checkBoxEnergy.clicked.connect(self.__slotEnergy) self.lineEditPressure.textChanged[str].connect( self.__slotPressureValue) self.lineEditDensity.textChanged[str].connect(self.__slotDensityValue) self.lineEditTotalPressure.textChanged[str].connect( self.__slotTotalPressure) self.lineEditTotalEnthalpy.textChanged[str].connect( self.__slotTotalEnthalpy) self.lineEditTemperature.textChanged[str].connect( self.__slotTemperatureValue) self.lineEditEnergy.textChanged[str].connect(self.__slotEnergyValue) self.comboBoxTypeInletGasComb.activated[str].connect( self.__slotInletTypeGasComb) self.lineEditTemperatureGasComb.textChanged[str].connect( self.__slotTemperatureGasComb) self.lineEditFraction.textChanged[str].connect( self.__slotMeanMixtureFraction) # Combo models self.modelVelocity = ComboModel(self.comboBoxVelocity, 6, 1) self.modelVelocity.addItem(self.tr("norm"), 'norm') self.modelVelocity.addItem(self.tr("mass flow rate"), 'flow1') self.modelVelocity.addItem(self.tr("volumic flow rate"), 'flow2') self.modelVelocity.addItem(self.tr("norm (user law)"), 'norm_formula') self.modelVelocity.addItem(self.tr("mass flow rate (user law)"), 'flow1_formula') self.modelVelocity.addItem(self.tr("volumic flow rate (user law)"), 'flow2_formula') self.modelDirection = ComboModel(self.comboBoxDirection, 3, 1) self.modelDirection.addItem(self.tr("normal direction to the inlet"), 'normal') self.modelDirection.addItem(self.tr("specified coordinates"), 'coordinates') self.modelDirection.addItem(self.tr("user profile"), 'formula') self.modelTypeInlet = ComboModel(self.comboBoxTypeInlet, 2, 1) self.modelTypeInlet.addItem(self.tr("imposed inlet"), 'imposed_inlet') self.modelTypeInlet.addItem(self.tr("subsonic inlet (imposed total pressure and total enthalpy)"), \ 'subsonic_inlet_PH') self.modelTypeInletGasComb = ComboModel(self.comboBoxTypeInletGasComb, 2, 1) model = self.gas.getGasCombustionModel() if model == 'lwp' or model == 'ebu': self.modelTypeInletGasComb.addItem(self.tr("Unburned gas"), 'unburned') self.modelTypeInletGasComb.addItem(self.tr("Burned gas"), 'burned') elif model == 'd3p': self.modelTypeInletGasComb.addItem(self.tr("Oxydant"), 'oxydant') self.modelTypeInletGasComb.addItem(self.tr("Fuel"), 'fuel') # Validators validatorVelocity = DoubleValidator(self.lineEditVelocity) validatorX = DoubleValidator(self.lineEditDirectionX) validatorY = DoubleValidator(self.lineEditDirectionY) validatorZ = DoubleValidator(self.lineEditDirectionZ) validatorP = DoubleValidator(self.lineEditPressure, min=0.0) validatorD = DoubleValidator(self.lineEditDensity, min=0.0) validatorT = DoubleValidator(self.lineEditTemperature, min=0.0) validatorE = DoubleValidator(self.lineEditEnergy, min=0.0) validatorP2 = DoubleValidator(self.lineEditTotalPressure, min=0.0) validatorH2 = DoubleValidator(self.lineEditTotalEnthalpy, min=0.0) validatorTemp = DoubleValidator(self.lineEditTemperatureGasComb, min=0.) validatorFrac = DoubleValidator(self.lineEditFraction, min=0., max=1.) # Apply validators self.lineEditVelocity.setValidator(validatorVelocity) self.lineEditDirectionX.setValidator(validatorX) self.lineEditDirectionY.setValidator(validatorY) self.lineEditDirectionZ.setValidator(validatorZ) self.lineEditPressure.setValidator(validatorP) self.lineEditDensity.setValidator(validatorD) self.lineEditTemperature.setValidator(validatorT) self.lineEditEnergy.setValidator(validatorE) self.lineEditTotalPressure.setValidator(validatorP2) self.lineEditTotalEnthalpy.setValidator(validatorH2) self.lineEditTemperatureGasComb.setValidator(validatorTemp) self.lineEditFraction.setValidator(validatorFrac) self.pushButtonVelocityFormula.clicked.connect( self.__slotVelocityFormula) self.pushButtonDirectionFormula.clicked.connect( self.__slotDirectionFormula) self.case.undoStartGlobal() def showWidget(self, boundary): """ Show the widget """ self.__boundary = boundary # Initialize velocity choice = self.__boundary.getVelocityChoice() self.modelVelocity.setItem(str_model=choice) self.__updateLabel() if choice[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) self.lineEditVelocity.setEnabled(False) else: self.pushButtonVelocityFormula.setEnabled(False) self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) # Initialize direction choice = self.__boundary.getDirectionChoice() self.modelDirection.setItem(str_model=choice) text = self.modelDirection.dicoM2V[choice] if choice == "formula": self.pushButtonDirectionFormula.setEnabled(True) self.frameDirectionCoordinates.hide() elif choice == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif choice == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.frameDirectionCoordinates.hide() self.initialize() def initialize(self): """ Initialize widget for compressible """ self.comboBoxVelocity.show() self.lineEditVelocity.show() self.labelUnitVelocity.show() self.pushButtonVelocityFormula.show() # Initialize thermodynamic value if self.mdl.getCompressibleModel() != 'off': inlet_type = self.__boundary.getInletType() self.modelTypeInlet.setItem(str_model=inlet_type) self.__boundary.setInletType(inlet_type) if inlet_type == 'imposed_inlet': self.groupBoxThermodynamic.show() self.frameDensity.hide() for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setChecked(False) __checkBox.setEnabled(False) __lineEdit.setEnabled(False) __lineEdit.clear() box_list = self.__boundary.getCheckedBoxList() if len(box_list) == 0: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) elif len(box_list) == 1: for name in self.thermodynamic_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) box = box_list[0] if box == 'Temperature': self.checkBoxEnergy.setEnabled(False) elif box == 'Energy': self.checkBoxTemperature.setEnabled(False) __checkBox = getattr(self, "checkBox" + box) __checkBox.setChecked(True) __lineEdit = getattr(self, "lineEdit" + box) __lineEdit.setEnabled(True) v1 = self.__boundary.getListValue()[0] __lineEdit.setText(str(v1)) elif len(box_list) == 2: v1, v2 = self.__boundary.getListValue() for name in box_list: __checkBox = getattr(self, "checkBox" + name) __lineEdit = getattr(self, "lineEdit" + name) __checkBox.setEnabled(True) __checkBox.setChecked(True) __lineEdit.setEnabled(True) if v1 >= 0.: __lineEdit.setText(str(v1)) else: __lineEdit.setText(str(v2)) v1 = -1. elif inlet_type == 'subsonic_inlet_PH': self.comboBoxVelocity.hide() self.lineEditVelocity.hide() self.labelUnitVelocity.hide() self.pushButtonVelocityFormula.hide() self.groupBoxThermodynamic.hide() self.frameDensity.show() pressure = self.__boundary.getThermoValue('total_pressure') self.lineEditTotalPressure.setText(str(pressure)) enthalpy = self.__boundary.getThermoValue('enthalpy') self.lineEditTotalEnthalpy.setText(str(enthalpy)) else: self.groupBoxCompressible.hide() # Initialize temperature and mean mixture fraction model = self.gas.getGasCombustionModel() if model != 'off': self.groupBoxGasCombustion.show() inlet_type = self.__boundary.getInletGasCombustionType() self.modelTypeInletGasComb.setItem(str_model=inlet_type) if model == 'd3p': self.lineEditTemperatureGasComb.hide() self.labelTemperature_2.hide() self.labelUnitTemp.hide() self.lineEditFraction.setEnabled(False) f = self.__boundary.setMeanMixtureFraction(1) self.lineEditFraction.setText( str(1) if inlet_type == 'oxydant' else str(0)) else: self.lineEditTemperatureGasComb.show() self.labelTemperature_2.show() self.labelUnitTemp.show() t = self.__boundary.getGasCombustionTemperature() self.lineEditTemperatureGasComb.setText(str(t)) self.lineEditFraction.setEnabled(True) f = self.__boundary.getMeanMixtureFraction() self.lineEditFraction.setText(str(f)) else: self.groupBoxGasCombustion.hide() self.show() def hideWidget(self): """ Hide all """ self.hide() def getVelocityExpression(self, boundary): """ Get the mathematical expression for velocity """ exp = boundary.getVelocity() c = boundary.getVelocityChoice() if c == 'norm_formula': n = 'u_norm' elif c == 'flow1_formula': n = 'q_m' elif c == 'flow2_formula': n = 'q_v' return exp, n @pyqtSlot(str) def __slotChoiceVelocity(self, text): """ Private slot. Input the velocity boundary type choice (norm, ). @type text: C{QString} @param text: velocity boundary type choice. """ c = self.modelVelocity.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setVelocityChoice(c) if c[-7:] == "formula": self.pushButtonVelocityFormula.setEnabled(True) exp = self.__boundary.getVelocity() if exp: self.pushButtonVelocityFormula.setStyleSheet( "background-color: green") self.pushButtonVelocityFormula.setToolTip(exp) else: self.pushButtonVelocityFormula.setStyleSheet( "background-color: red") self.lineEditVelocity.setEnabled(False) self.lineEditVelocity.setText("") else: self.pushButtonVelocityFormula.setEnabled(False) self.pushButtonVelocityFormula.setStyleSheet( "background-color: None") self.lineEditVelocity.setEnabled(True) v = self.__boundary.getVelocity() self.lineEditVelocity.setText(str(v)) self.__updateLabel() def __updateLabel(self): """ Update the unit for the velocity specification. """ c = self.__boundary.getVelocityChoice() if c in ('norm', 'norm_formula'): self.labelUnitVelocity.setText(str('m/s')) elif c in ('flow1', 'flow1_formula'): self.labelUnitVelocity.setText(str('kg/s')) elif c in ('flow2', 'flow2_formula'): self.labelUnitVelocity.setText(str('m<sup>3</sup>/s')) @pyqtSlot(str) def __slotVelocityValue(self, text): """ Private slot. New value associated to the velocity boundary type. @type text: C{QString} @param text: value """ if self.lineEditVelocity.validator().state == QValidator.Acceptable: v = from_qvariant(text, float) self.__boundary.setVelocity(v) @pyqtSlot() def __slotVelocityFormula(self): """ """ exp = self.__boundary.getVelocity() c = self.__boundary.getVelocityChoice() if c == 'norm_formula': exa = "u_norm = 1.0;" req = [('u_norm', 'Norm of the velocity')] elif c == 'flow1_formula': exa = "q_m = 1.0;" req = [('q_m', 'mass flow rate')] elif c == 'flow2_formula': exa = "q_v = 1.0;" req = [('q_v', 'volumic flow rate')] sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(parent=self, function_type="bnd", zone_name=self.__boundary._label, variable_name="velocity", expression=exp, required=req, symbols=sym, condition=c, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaVelocity -> %s" % str(result)) self.__boundary.setVelocity(str(result)) self.pushButtonVelocityFormula.setStyleSheet( "background-color: green") self.pushButtonVelocityFormula.setToolTip(result) @pyqtSlot(str) def __slotChoiceDirection(self, text): """ Input the direction type choice. """ c = self.modelDirection.dicoV2M[str(text)] log.debug("slotChoiceVelocity: %s " % c) self.__boundary.setDirectionChoice(c) if c == "formula": self.pushButtonDirectionFormula.setEnabled(True) exp = self.__boundary.getDirection('direction_formula') if exp: self.pushButtonDirectionFormula.setStyleSheet( "background-color: green") self.pushButtonDirectionFormula.setToolTip(exp) else: self.pushButtonDirectionFormula.setStyleSheet( "background-color: red") self.frameDirectionCoordinates.hide() elif c == "coordinates": self.pushButtonDirectionFormula.setEnabled(False) self.pushButtonDirectionFormula.setStyleSheet( "background-color: None") self.frameDirectionCoordinates.show() v = self.__boundary.getDirection('direction_x') self.lineEditDirectionX.setText(str(v)) v = self.__boundary.getDirection('direction_y') self.lineEditDirectionY.setText(str(v)) v = self.__boundary.getDirection('direction_z') self.lineEditDirectionZ.setText(str(v)) elif c == "normal": self.pushButtonDirectionFormula.setEnabled(False) self.pushButtonDirectionFormula.setStyleSheet( "background-color: None") self.frameDirectionCoordinates.hide() @pyqtSlot(str) def __slotDirX(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_x', value) @pyqtSlot(str) def __slotDirY(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_y', value) @pyqtSlot(str) def __slotDirZ(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_z', value) @pyqtSlot() def __slotDirectionFormula(self): """ """ exp = self.__boundary.getDirection('direction_formula') req = [('dir_x', 'Direction of the flow along X'), ('dir_y', 'Direction of the flow along Y'), ('dir_z', 'Direction of the flow along Z')] exa = "dir_x = 3.0;\ndir_y = 1.0;\ndir_z = 0.0;\n" sym = [('x', "X face's gravity center"), ('y', "Y face's gravity center"), ('z', "Z face's gravity center"), ('dt', 'time step'), ('t', 'current time'), ('iter', 'number of iteration')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(parent=self, function_type="bnd", zone_name=self.__boundary._label, variable_name="direction", expression=exp, required=req, symbols=sym, condition="formula", examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaDirection -> %s" % str(result)) self.__boundary.setDirection('direction_formula', str(result)) self.pushButtonDirectionFormula.setToolTip(result) self.pushButtonDirectionFormula.setStyleSheet( "background-color: green") @pyqtSlot(str) def __slotInletType(self, text): """ INPUT inlet type : 'oxydant'/'fuel' or 'burned'/'unburned' """ value = self.modelTypeInlet.dicoV2M[str(text)] log.debug("__slotInletType value = %s " % value) self.__boundary.setInletType(value) self.initialize() @pyqtSlot() def __slotPressure(self): """ Pressure selected or not for the initialisation. """ if self.checkBoxPressure.isChecked(): self.__boundary.setThermoStatus('pressure', "on") else: self.__boundary.setThermoStatus('pressure', "off") self.initialize() @pyqtSlot() def __slotDensity(self): """ Density selected or not for the initialisation. """ if self.checkBoxDensity.isChecked(): self.__boundary.setThermoStatus('density', "on") else: self.__boundary.setThermoStatus('density', "off") self.initialize() @pyqtSlot() def __slotTemperature(self): """ Temperature selected or not for the initialisation. """ if self.checkBoxTemperature.isChecked(): self.__boundary.setThermoStatus('temperature', "on") else: self.__boundary.setThermoStatus('temperature', "off") self.initialize() @pyqtSlot() def __slotEnergy(self): """ Energy selected or not for the initialisation. """ if self.checkBoxEnergy.isChecked(): self.__boundary.setThermoStatus('energy', "on") else: self.__boundary.setThermoStatus('energy', "off") self.initialize() @pyqtSlot(str) def __slotPressureValue(self, text): """ INPUT inlet Pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('pressure', t) @pyqtSlot(str) def __slotDensityValue(self, text): """ INPUT inlet Density """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('density', t) @pyqtSlot(str) def __slotTemperatureValue(self, text): """ INPUT inlet Temperature """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('temperature', t) @pyqtSlot(str) def __slotEnergyValue(self, text): """ INPUT inlet Energy """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('energy', t) @pyqtSlot(str) def __slotTotalPressure(self, text): """ INPUT inlet total pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('total_pressure', t) @pyqtSlot(str) def __slotTotalEnthalpy(self, text): """ INPUT inlet total enthalpy """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setThermoValue('enthalpy', t) @pyqtSlot(str) def __slotTemperatureGasComb(self, text): """ INPUT inlet temperature """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setGasCombustionTemperature(t) @pyqtSlot(str) def __slotMeanMixtureFraction(self, text): """ INPUT inlet mean mixutre fraction """ if self.sender().validator().state == QValidator.Acceptable: f = from_qvariant(text, float) self.__boundary.setMeanMixtureFraction(f) @pyqtSlot(str) def __slotInletTypeGasComb(self, text): """ INPUT inlet type : 'oxydant'/'fuel' or 'burned'/'unburned' """ value = self.modelTypeInletGasComb.dicoV2M[str(text)] log.debug("__slotInletTypeGasComb value = %s " % value) self.__boundary.setInletGasCombustionType(value) self.initialize() def tr(self, text): """ Translation """ return text