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, 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.comboBoxGasCombustionOption.activated[str].connect(self.slotGasCombustionOption)
        self.pushButtonThermochemistryData.pressed.connect(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))
            self.pushButtonThermochemistryData.setStyleSheet("background-color: green")
        else:
            self.pushButtonThermochemistryData.setStyleSheet("background-color: red")

        self.case.undoStartGlobal()
Example #3
0
    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)
        self.thermodata = ThermochemistryData(self.case)

        # Model for table View
        self.modelSpecies = StandardItemModelSpecies(self, self.thermodata)
        self.tableViewSpecies.setModel(self.modelSpecies)

        # Delegates
        delegateLabel = NameDelegate(self.tableViewSpecies)
        delegateChemicalFormula = ChemicalFormulaDelegate(
            self.tableViewSpecies)
        delegateCompFuel = ValueDelegate(self.tableViewSpecies)
        delegateCompOxi = ValueDelegate(self.tableViewSpecies)
        delegateCompProd = ValueDelegate(self.tableViewSpecies)
        delegateCoeffAbsorp = ValueDelegate(self.tableViewSpecies)

        self.tableViewSpecies.setItemDelegateForColumn(0, delegateLabel)
        self.tableViewSpecies.setItemDelegateForColumn(
            1, delegateChemicalFormula)
        self.tableViewSpecies.setItemDelegateForColumn(2, delegateCompFuel)
        self.tableViewSpecies.setItemDelegateForColumn(3, delegateCompOxi)
        self.tableViewSpecies.setItemDelegateForColumn(4, delegateCompProd)
        self.tableViewSpecies.setItemDelegateForColumn(5, delegateCoeffAbsorp)

        # tableView
        if QT_API == "PYQT4":
            self.tableViewSpecies.horizontalHeader().setResizeMode(
                QHeaderView.Stretch)
            self.tableViewSpecies.horizontalHeader().setResizeMode(
                0, QHeaderView.ResizeToContents)
            self.tableViewSpecies.horizontalHeader().setResizeMode(
                1, QHeaderView.ResizeToContents)
        elif QT_API == "PYQT5":
            self.tableViewSpecies.horizontalHeader().setSectionResizeMode(
                QHeaderView.Stretch)
            self.tableViewSpecies.horizontalHeader().setSectionResizeMode(
                0, QHeaderView.ResizeToContents)
            self.tableViewSpecies.horizontalHeader().setSectionResizeMode(
                1, QHeaderView.ResizeToContents)

        # Set models and number of elements for combo boxes
        self.modelGasCombustionOption = ComboModel(
            self.comboBoxGasCombustionOption, 1, 1)

        # Combo models to choose the mode to create the Janaf File

        self.userModeForChemicalReaction = ComboModel(self.comboBoxUserChoice,
                                                      2, 1)

        self.userModeForChemicalReaction.addItem("Automatic definition",
                                                 'auto')
        self.userModeForChemicalReaction.addItem("Defined by user", 'user')

        # Connections
        self.comboBoxUserChoice.activated[str].connect(self.slotUserChoice)
        self.comboBoxGasCombustionOption.activated[str].connect(
            self.slotGasCombustionOption)
        self.pushButtonThermochemistryData.pressed.connect(
            self.__slotSearchThermochemistryData)
        self.radioButtonCreateJanafFile.clicked.connect(
            self.slotCreateJanafFile)
        self.lineEditNbPointsTabu.textChanged[str].connect(
            self.slotNbPointsTabu)
        self.lineEditMaximumTemp.textChanged[str].connect(self.slotMaximumTemp)
        self.lineEditMinimumTemp.textChanged[str].connect(self.slotMinimumTemp)
        self.pushButtonAddSpecies.clicked.connect(self.slotAddSpecies)
        self.pushButtonDeleteSpecies.clicked.connect(self.slotDeleteSpecies)
        self.pushButtonGenerateJanafFile.clicked.connect(
            self.slotGenerateJanafFile)
        self.lineEditFuel.textChanged[str].connect(self.slotFuel)
        self.lineEditO2.textChanged[str].connect(self.slotVolPropO2)
        self.lineEditN2.textChanged[str].connect(self.slotVolPropN2)
        self.lineEditCOyield.textChanged[str].connect(self.slotCOyield)
        self.lineEditCSyield.textChanged[str].connect(self.slotCSyield)
        self.modelSpecies.dataChanged.connect(self.dataChanged)

        # Validators
        validatorNbPointsTabu = IntValidator(self.lineEditNbPointsTabu, min=1)
        validatorMaximumTemp = DoubleValidator(self.lineEditMaximumTemp,
                                               min=273.0)
        validatorMinimumTemp = DoubleValidator(self.lineEditMinimumTemp,
                                               min=273.0)
        rx = "[chonlCHONL()][CHONLchonl()0-9]{0," + str(LABEL_LENGTH_MAX -
                                                        1) + "}"
        validatorFuel = RegExpValidator(self.lineEditFuel, QRegExp(rx))
        validatorO2 = DoubleValidator(self.lineEditO2, min=1e-12, max=1.0)
        validatorN2 = DoubleValidator(self.lineEditN2, min=0.0, max=1.0)
        validatorCOyield = DoubleValidator(self.lineEditCOyield, min=0.0)
        validatorCSyield = DoubleValidator(self.lineEditCSyield, min=0.0)

        self.lineEditNbPointsTabu.setValidator(validatorNbPointsTabu)
        self.lineEditMaximumTemp.setValidator(validatorMaximumTemp)
        self.lineEditMinimumTemp.setValidator(validatorMinimumTemp)
        self.lineEditFuel.setValidator(validatorFuel)
        self.lineEditO2.setValidator(validatorO2)
        self.lineEditN2.setValidator(validatorN2)
        self.lineEditCOyield.setValidator(validatorCOyield)
        self.lineEditCSyield.setValidator(validatorCSyield)

        NbPointsTabu = self.thermodata.getNbPointsTabu()
        MaximumTemp = self.thermodata.getMaximumTemp()
        MinimumTemp = self.thermodata.getMinimumTemp()
        Option_UserMode = self.thermodata.getUserModeForChemicalReaction()
        ChemicalFormulaFuel = self.thermodata.getChemicalFormulaFuel()
        VolPropO2 = self.thermodata.getVolPropO2()
        VolPropN2 = self.thermodata.getVolPropN2()
        COyield = self.thermodata.getCOyield()
        CSyield = self.thermodata.getCSyield()

        self.lineEditNbPointsTabu.setText(str(NbPointsTabu))
        self.lineEditMaximumTemp.setText(str(MaximumTemp))
        self.lineEditMinimumTemp.setText(str(MinimumTemp))
        self.lineEditFuel.setText(str(ChemicalFormulaFuel))
        self.lineEditO2.setText(str(VolPropO2))
        self.lineEditN2.setText(str(VolPropN2))
        self.lineEditCOyield.setText(str(COyield))
        self.lineEditCSyield.setText(str(CSyield))

        # Initialize Widgets

        self.tableViewSpecies.reset()
        self.modelSpecies = StandardItemModelSpecies(self, self.thermodata)
        self.tableViewSpecies.setModel(self.modelSpecies)

        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 and name != "":
            self.labelThermochemistryFile.setText(str(name))
            self.pushButtonThermochemistryData.setStyleSheet(
                "background-color: green")
        else:
            self.pushButtonThermochemistryData.setStyleSheet(
                "background-color: red")

        self.radioButtonCreateJanafFile.hide()

        if self.thermodata.getCreateThermoDataFile() == 'on':
            self.radioButtonCreateJanafFile.setChecked(True)
            self.userModeForChemicalReaction.setItem(str_model=Option_UserMode)
            for label in self.thermodata.getSpeciesNamesList():
                self.modelSpecies.newItem(label)
        else:
            self.radioButtonCreateJanafFile.setChecked(False)

        # for the moment the option to create Janaf file in the GUI is only available with d3p
        if model == 'd3p':
            self.radioButtonCreateJanafFile.show()
            self.groupBoxTabulation.show()
            self.groupBoxChemicalReaction.show()
            self.groupBoxDefinedByUser.show()
            self.groupBoxGenerateDataFile.show()
            self.groupBoxAutomatic.show()

        self.slotCreateJanafFile()

        self.case.undoStartGlobal()