Exemple #1
0
    def switch_case_to_saturne(self):

        if self.case.xmlRootNode().tagName == "Code_Saturne_GUI":
            return

        from code_saturne.cs_package import package as cs_package
        self.case['package'] = cs_package()

        from code_saturne.model.XMLinitialize import XMLinit

        self.case.root().xmlRemoveChild("additional_scalars")
        self.case.root().xmlRemoveChild("closure_modeling")
        self.case.root().xmlRemoveChild("thermophysical_models")
        self.case.root().xmlRemoveChild("numerical_parameters")

        self.case.xmlRootNode().tagName = "Code_Saturne_GUI"
        self.case.root()["solver_version"] = ""

        XMLinit(self.case).initialize()
Exemple #2
0
    def slotRadioButton(self):

        checkCur = None
        model_expr = None

        for ind in [
                'SinglePhase', 'Hgn', 'Atmospheric', 'JouleEffect',
                'Groundwater', 'ReactiveFlows', 'NeptuneCFD'
        ]:

            radioButton = eval('self.radioButton' + ind)
            combo = eval('self.comboBox' + ind)
            model = eval('self.model' + ind)

            if radioButton.isChecked():
                combo.show()
                model_expr = 'self.slot' + ind + '(model)'
                checkCur = ind
            else:
                combo.hide()
                model.setItem(0)

        # 2 signals may be sent on button toggles, so update
        # what is necessary.
        if self.checkPrev == checkCur:
            return

        # Restore visibility of features which may be masked with
        # some models.

        self.labelLagrangian.show()
        self.comboBoxLagrangian.show()
        self.labelTurboMachinery.show()
        self.comboBoxTurboMachinery.show()
        self.checkBoxALE.show()
        self.checkBoxFans.show()

        # Update

        if checkCur == 'NeptuneCFD':

            self.switch_case_to_neptune()

            self.init_neptune()

            try:
                from neptune_cfd.nc_package import package as nc_package
                self.case['package'] = nc_package()
            except Exception:
                from code_saturne.cs_package import package as cs_package
                self.case['package'] = cs_package()

            if hasattr(self.parent, 'updateTitleBar'):
                self.parent.updateTitleBar()

        elif self.checkPrev == 'NeptuneCFD':

            self.switch_case_to_saturne()

            self.init_saturne()

            if hasattr(self.parent, 'updateTitleBar'):
                self.parent.updateTitleBar()

            eval('self.radioButton' + checkCur + '.setChecked(True)')

        else:  # Both selected and previous models are Code_Saturne models.

            # setting of the previous model saturne to 'off'
            if self.checkPrev == 'SinglePhase':
                self.comp.setCompressibleModel('off')
            if self.checkPrev == 'Atmospheric':
                self.atmo.setAtmosphericFlowsModel('off')
            if self.checkPrev == 'Hgn':
                self.hgn.setHgnModel('off')
            if self.checkPrev == 'JouleEffect':
                self.elect.setElectricalModel('off')
            if self.checkPrev == 'Groundwater':
                self.darc.setGroundwaterModel('off')
                self.labelLagrangian.show()
                self.comboBoxLagrangian.show()
                self.labelTurboMachinery.show()
                self.comboBoxTurboMachinery.show()
                self.checkBoxALE.show()
                self.checkBoxFans.show()
            if self.checkPrev == 'ReactiveFlows':
                self.gas.setGasCombustionModel('off')
                self.pcoal.setCoalCombustionModel('off')

                self.comboBoxGasCombustion.hide()
                self.comboBoxCoalCombustion.hide()

                self.modelLagrangian.enableItem(str_model='two_way')

            if checkCur == 'ReactiveFlows':
                if self.pcoal.getCoalCombustionModel() != 'off':
                    combo = self.comboBoxCoalCombustion
                    model = self.modelCoalCombustion
                else:
                    combo = self.comboBoxGasCombustion
                    model = self.modelGasCombustion
                combo.show()
                model_expr = 'self.slotReactiveFlows(model)'

            eval(model_expr)

        self.browser.configureTree(self.case)
        self.checkPrev = checkCur
class AnalysisFeaturesView(QWidget, Ui_AnalysisFeaturesForm):
    """
    Class to open Calculation Features Page.
    """

    def __init__(self, parent, case, tree):
        """
        Constructor.
        """

        self.parent = parent

        import os
        self.icondir = os.path.dirname(os.path.abspath(__file__)) + '/../Base/'

        QWidget.__init__(self, parent)

        Ui_AnalysisFeaturesForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.browser = tree

        self.case.undoStopGlobal()

        self.checkPrev = None

        # Set models and number of elements for combo boxes

        self.modelSinglePhase    = QtPage.ComboModel(self.comboBoxSinglePhase,3,1)
        self.modelHgn            = QtPage.ComboModel(self.comboBoxHgn,2,1)
        self.modelAtmospheric    = QtPage.ComboModel(self.comboBoxAtmospheric,3,1)
        self.modelReactiveFlows  = QtPage.ComboModel(self.comboBoxReactiveFlows,2,1)
        self.modelGasCombustion  = QtPage.ComboModel(self.comboBoxGasCombustion,3,1)
        self.modelCoalCombustion = QtPage.ComboModel(self.comboBoxCoalCombustion,2,1)
        self.modelJouleEffect    = QtPage.ComboModel(self.comboBoxJouleEffect,2,1)
        self.modelGroundwater    = QtPage.ComboModel(self.comboBoxGroundwater,1,1)

        self.modelNeptuneCFD     = QtPage.ComboModel(self.comboBoxNeptuneCFD,2,1)

        self.modelSinglePhase.addItem(self.tr("Incompressible"), 'off')
        self.modelSinglePhase.addItem(self.tr("Compressible, perfect gas with constant gamma"),
                                      'constant_gamma')
        self.modelSinglePhase.addItem(self.tr("Compressible, perfect gas with variable gamma"),
                                      'variable_gamma')
        self.modelSinglePhase.disableItem(str_model='variable_gamma')

        self.modelAtmospheric.addItem(self.tr("constant density"), "constant")
        self.modelAtmospheric.addItem(self.tr("dry atmosphere"  ), "dry")
        self.modelAtmospheric.addItem(self.tr("humid atmosphere"), "humid")

        self.modelReactiveFlows.addItem(self.tr("Gas combustion"),
                                        "gas_combustion")
        self.modelReactiveFlows.addItem(self.tr("Pulverized Coal"),
                                        "pulverized_coal")

        self.modelGasCombustion.addItem(self.tr("perfect premixed flame (Eddy Break-Up)"),
                                        "ebu")
        self.modelGasCombustion.addItem(self.tr("infinitely fast chemistry diffusion flame"),
                                        "d3p")
        self.modelGasCombustion.addItem(self.tr("partial premixed flame (Libby_Williams)"),
                                        "lwp")

        self.modelCoalCombustion.addItem(self.tr("homogeneous approach"),
                                         "homogeneous_fuel")
        self.modelCoalCombustion.addItem(self.tr("homogeneous approach with moisture"),
                                         "homogeneous_fuel_moisture")

        self.modelJouleEffect.addItem(self.tr("Joule Effect"), "joule")
        self.modelJouleEffect.addItem(self.tr("Joule Effect and Laplace Forces"), "arc")

        self.modelGroundwater.addItem(self.tr("Groundwater flows"), 'groundwater')

        self.modelHgn.addItem(self.tr("No mass transfer"),
                              'no_mass_transfer')
        self.modelHgn.addItem(self.tr("Vaporization / Condensation Merkle model"),
                              'merkle_model')

        self.modelNeptuneCFD.addItem(self.tr("User-defined"), "None")
        self.modelNeptuneCFD.addItem(self.tr("Stratified flow"), "free_surface")
        self.modelNeptuneCFD.addItem(self.tr("Bubbly flow"), "boiling_flow")
        self.modelNeptuneCFD.addItem(self.tr("Droplet-laden flow"), "droplet_flow")
        self.modelNeptuneCFD.addItem(self.tr("Particle-laden flow"), "particles_flow")
        self.modelNeptuneCFD.addItem(self.tr("Multiregime liquid/gas flow"), "multiregime")

        # Lagrangian combobox

        self.modelLagrangian = QtPage.ComboModel(self.comboBoxLagrangian, 4, 1)
        self.modelLagrangian.addItem(self.tr("off"), "off")
        self.modelLagrangian.addItem(self.tr("One-way coupling"), "one_way")
        self.modelLagrangian.addItem(self.tr("Two-way coupling"), "two_way")
        self.modelLagrangian.addItem(self.tr("Frozen carrier flow"), "frozen")

        # Turbomachinery combobox

        self.modelTurboMachinery = QtPage.ComboModel(self.comboBoxTurboMachinery, 5, 1)
        self.modelTurboMachinery.addItem(self.tr("None"), "off")
        self.modelTurboMachinery.addItem(self.tr("Full transient simulation"), "transient")
        self.modelTurboMachinery.addItem(self.tr("Transient with explicit coupling"), "transient_coupled")
        self.modelTurboMachinery.addItem(self.tr("Frozen rotor model"), "frozen")
        self.modelTurboMachinery.addItem(self.tr("Frozen rotor with explicit coupling"), "frozen_coupled")

        self.__uncheckRadioButtons()

        # Connect signals to slots

        self.comboBoxAtmospheric.activated[str].connect(self.slotAtmospheric)
        self.comboBoxReactiveFlows.activated[str].connect(self.slotReactiveFlows)
        self.comboBoxGasCombustion.activated[str].connect(self.slotGasCombustion)
        self.checkBoxPther.clicked.connect(self.slotPther)
        self.comboBoxCoalCombustion.activated[str].connect(self.slotCoalCombustion)
        self.comboBoxJouleEffect.activated[str].connect(self.slotJouleEffect)
        self.comboBoxSinglePhase.activated[str].connect(self.slotSinglePhase)
        self.comboBoxGroundwater.activated[str].connect(self.slotGroundwater)
        self.comboBoxHgn.activated[str].connect(self.slotHgn)
        self.comboBoxNeptuneCFD.currentTextChanged[str].connect(self.slotNeptuneCFD)
        self.checkBoxNeptuneHeatMass.stateChanged.connect(self.slotNeptuneHeatMass)
        self.checkBoxALE.stateChanged.connect(self.slotALE)
        self.checkBoxFans.stateChanged.connect(self.slotFans)

        self.comboBoxLagrangian.activated[str].connect(self.slotLagrangian)
        self.comboBoxTurboMachinery.activated[str].connect(self.slotTurboModel)

        for ind in ['SinglePhase', 'Atmospheric',
                    'JouleEffect', 'Groundwater', 'ReactiveFlows',
                    'Hgn', 'NeptuneCFD']:
            eval('self.radioButton'+ind+'.toggled.connect(self.slotRadioButton)')

        # Initializations based on code

        if self.case.xmlRootNode().tagName == "Code_Saturne_GUI":
            self.init_saturne()

            # Enable NEPTUNE_CFD based on presence and/or environment
            # variable (environment variable has precedence
            # for ease of testing)
            enable_neptune_cfd = False
            from code_saturne.cs_package import package as cs_package
            pkg = cs_package()
            neptune_cfd_bin = os.path.join(pkg.get_dir('bindir'),
                                           'neptune_cfd' + pkg.config.shext)
            if os.path.isfile(neptune_cfd_bin):
                enable_neptune_cfd = True
            ev_enable = os.getenv('CS_GUI_ENABLE_NEPTUNE_CFD')
            if ev_enable:
                try:
                    if int(ev_enable) != 0:
                        enable_neptune_cfd = True
                    else:
                        enable_neptune_cfd = False
                except Exception:
                    pass
            self.radioButtonNeptuneCFD.setEnabled(enable_neptune_cfd)

        elif self.case.xmlRootNode().tagName == "NEPTUNE_CFD_GUI":
            self.init_neptune()

        self.tbm = TurboMachineryModel(self.case)
        self.ale = MobileMeshModel(self.case)
        self.fans = FansStatus(self.case)

        self.init_common()

        # Update the Tree files and folders

        self.browser.configureTree(self.case)

        self.case.undoStartGlobal()