def print_modules(pkg): """ Print Code_Saturne environment modules info. """ import cs_config c = cs_config.config() if c.env_modulecmd: print("Module command: " + str(c.env_modulecmd)) print("Environment modules: " + str(c.env_modules))
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_PerformanceTuningForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = PerformanceTuningModel(self.case) # Combo models and items self.modelPartType = ComboModel(self.comboBox_PartType, 4, 1) self.modelPartOut = ComboModel(self.comboBox_PartOutput, 3, 1) self.modelPartType.addItem(self.tr("Default"), 'default') self.modelPartType.addItem(self.tr("PT-SCOTCH / SCOTCH"), 'scotch') self.modelPartType.addItem(self.tr("ParMETIS / METIS"), 'metis') self.modelPartType.addItem(self.tr("Morton curve (bounding box)"), 'morton sfc') self.modelPartType.addItem(self.tr("Morton curve (bounding cube)"), 'morton sfc cube') self.modelPartType.addItem(self.tr("Hilbert curve (bounding box)"), 'hilbert sfc') self.modelPartType.addItem(self.tr("Hilbert curve (bounding cube)"), 'hilbert sfc cube') self.modelPartType.addItem(self.tr("Block (unoptimized)"), 'block') import cs_config cfg = cs_config.config() if cfg.libs['scotch'].have == "no": self.comboBox_PartType.setItemData(1, QColor(Qt.red), Qt.TextColorRole) if cfg.libs['metis'].have == "no": self.comboBox_PartType.setItemData(2, QColor(Qt.red), Qt.TextColorRole) self.modelPartOut.addItem(self.tr("No"), 'no') self.modelPartOut.addItem(self.tr("For graph-based partitioning"), 'default') self.modelPartOut.addItem(self.tr("Yes"), 'yes') self.modelBlockIORead = ComboModel(self.comboBox_IORead, 6, 1) self.modelBlockIOWrite = ComboModel(self.comboBox_IOWrite, 4, 1) self.modelBlockIORead.addItem(self.tr("Default"), 'default') self.modelBlockIORead.addItem(self.tr("Standard I/O, serial"), 'stdio serial') self.modelBlockIORead.addItem(self.tr("Standard I/O, parallel"), 'stdio parallel') self.modelBlockIORead.addItem(self.tr("MPI I/O, independent"), 'mpi independent') self.modelBlockIORead.addItem(self.tr("MPI I/O, non-collective"), 'mpi noncollective') self.modelBlockIORead.addItem(self.tr("MPI I/O, collective"), 'mpi collective') self.modelBlockIOWrite.addItem(self.tr("Default"), 'default') self.modelBlockIOWrite.addItem(self.tr("Standard I/O, serial"), 'stdio serial') self.modelBlockIOWrite.addItem(self.tr("MPI I/O, non-collective"), 'mpi noncollective') self.modelBlockIOWrite.addItem(self.tr("MPI I/O, collective"), 'mpi collective') # Validators partListVd = RegExpValidator(self.lineEdit_PartList, QRegExp("[0-9- ]*")) self.lineEdit_PartList.setValidator(partListVd) # Connections self.radioButtonYes.clicked.connect(self.slotPartition) self.radioButtonNo.clicked.connect(self.slotPartition) self.toolButton_PartInputDir.pressed.connect( self.slotSearchPartInputDirectory) self.comboBox_PartOutput.activated[str].connect(self.slotPartOut) self.comboBox_PartType.activated[str].connect(self.slotPartType) self.lineEdit_PartList.textChanged[str].connect(self.slotPartitionList) self.spinBoxRankStep.valueChanged[int].connect(self.slotRankStep) self.checkBox_IgnorePerio.clicked[bool].connect(self.slotIgnorePerio) self.comboBox_IORead.activated[str].connect(self.slotBlockIOReadMethod) self.comboBox_IOWrite.activated[str].connect( self.slotBlockIOWriteMethod) self.spinBoxIORankStep.valueChanged[int].connect( self.slotBlockIORankStep) self.spinBoxIOMinBlockSize.valueChanged[int].connect( self.slotBlockIOMinSize) self.tabWidget.currentChanged[int].connect(self.slotchanged) # Widget initialization self.partinput_path = self.mdl.getPartitionInputPath() if self.partinput_path: if not os.path.isdir( os.path.join(self.case['case_path'], self.partinput_path)): title = self.tr("WARNING") msg = self.tr("Invalid path in %s!" % self.partinput_path) QMessageBox.warning(self, title, msg) self.radioButtonYes.setChecked(True) self.radioButtonNo.setChecked(False)
def initializeWidget(self): """ """ mdls = self.mdl.getThermoPhysicalModel() mdl_atmo, mdl_joule, mdl_thermal, mdl_gas, mdl_coal, mdl_comp = mdls self.groupBoxMassMolar.hide() if mdl_atmo != "off": self.labelInfoT0.hide() elif mdl_comp != "off" or mdl_coal != "off": m = self.mdl.getMassemol() self.lineEditMassMolar.setText(str(m)) self.groupBoxMassMolar.show() if mdl_thermal != "off": t = self.mdl.getTemperature() self.lineEditT0.setText(str(t)) if mdl_thermal == "temperature_celsius": self.labelUnitT0.setText("\xB0 C") if self.mdl.getMaterials() != "user_material": self.labelInfoT0.hide() else: self.groupBoxTemperature.hide() if mdl_gas == 'd3p': self.groupBoxTempd3p.show() t_oxy = self.mdl.getTempOxydant() t_fuel = self.mdl.getTempFuel() self.lineEditOxydant.setText(str(t_oxy)) self.lineEditFuel.setText(str(t_fuel)) else: self.groupBoxTempd3p.hide() darc = GroundwaterModel(self.case).getGroundwaterModel() if darc != 'off': self.groupBoxPressure.hide() else: p = self.mdl.getPressure() self.lineEditP0.setText(str(p)) if (self.freesteam == 1 or EOS == 1 or coolprop_fluids): self.tables = True else: self.tables = False if self.tables == False or mdl_joule != 'off' or mdl_comp != 'off': self.groupBoxTableChoice.hide() else: self.groupBoxTableChoice.show() self.lineEditReference.setEnabled(False) # suppress perfect gas self.modelMaterial.addItem(self.tr('user material'), 'user_material') tmp = ["Argon", "Nitrogen", "Hydrogen", "Oxygen", "Helium", "Air"] if EOS == 1: fls = self.ava.whichFluids() for fli in fls: if fli not in tmp: tmp.append(fli) self.modelMaterial.addItem(self.tr(fli), fli) if self.freesteam == 1 and EOS == 0: self.modelMaterial.addItem(self.tr('Water'), 'Water') if coolprop_fluids and EOS == 0: have_coolprop = False if cs_config.config().libs['coolprop'].have != "no": have_coolprop = True for fli in coolprop_fluids: if self.freesteam == 1 and fli == 'Water': continue self.modelMaterial.addItem(self.tr(fli), fli, coolprop_warn) material = self.mdl.getMaterials() self.modelMaterial.setItem(str_model=material) self.updateMethod() #compressible self.groupBoxViscv0.hide() # combustion self.groupBoxDiftl0.hide() if self.scalar == "": self.groupBoxDiff.hide() else: self.groupBoxDiff.show() self.lineEditDiff.setText( str( self.mdl.m_sca.getScalarDiffusivityInitialValue( self.scalar))) diff_choice = self.mdl.m_sca.getScalarDiffusivityChoice( self.scalar) self.modelDiff.setItem(str_model=diff_choice) self.modelNameDiff.setItem(str_model=str(self.scalar)) if diff_choice != 'user_law': self.pushButtonDiff.hide() self.pushButtonDiff.setEnabled(False) self.pushButtonDiff.setStyleSheet("background-color: None") else: self.pushButtonDiff.show() self.pushButtonDiff.setEnabled(True) name = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) exp = self.mdl.m_sca.getDiffFormula(self.scalar) if exp: self.pushButtonDiff.setStyleSheet( "background-color: green") self.pushButtonDiff.setToolTip(exp) else: self.pushButtonDiff.setStyleSheet("background-color: red") # Standard Widget initialization for tag, symbol in self.mdl.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __labelu = getattr(self, "labelUnit" + symbol) if tag != 'dynamic_diffusion': __labelv = getattr(self, "labelVar" + symbol) c = self.mdl.getPropertyMode(tag) if c not in __model.getItems(): c = 'constant' self.mdl.setPropertyMode(tag, c) __model.setItem(str_model=c) if c == 'user_law': __button.show() __button.setEnabled(True) __label.setText(self.tr("Reference value")) else: __button.hide() __button.setEnabled(False) __label.setText(self.tr("Reference value")) if c == 'thermal_law': __line.hide() __label.hide() __labelu.hide() __labelv.hide() else: __line.show() __label.show() __labelu.show() __labelv.show() if self.mdl.getMaterials() == "user_material": __model.disableItem(str_model='thermal_law') else: __model.enableItem(str_model='thermal_law') else: __label.setText(self.tr("Reference value")) self.mdl.getInitialValue(tag) __line.setText(str(self.mdl.getInitialValue(tag))) # If no thermal scalar, hide specific heat and thermal conductivity. if mdl_thermal == 'off': self.groupBoxCp.hide() self.groupBoxAl.hide() if mdl_gas != 'off' or mdl_coal != 'off': self.groupBoxDiftl0.show() for tag, symbol in self.mdl.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __combo = getattr(self, "comboBox" + symbol) # Gas or coal combustion if mdl_gas != 'off' or mdl_coal != 'off': if tag == 'density': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'predefined_law') __label.setText( self.tr("Calculation by\n perfect gas law")) __line.setText(str("")) __line.setEnabled(False) elif tag == 'dynamic_diffusion': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() else: __model.setItem(str_model='constant') self.mdl.setPropertyMode(tag, 'constant') # Joule if mdl_joule == 'arc': __model.disableItem(str_model='constant') __model.disableItem(str_model='predefined_law') __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'predefined_law') if mdl_joule == 'joule': __model.setItem(str_model='user_law') __model.disableItem(str_model='constant') self.mdl.setPropertyMode(tag, 'user_law') # Atmospheric Flows if mdl_atmo != 'off': if tag == 'density': __model.disableItem(str_model='constant') __model.disableItem(str_model='predefined_law') __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() # Compressible Flows if mdl_comp != 'off': self.groupBoxViscv0.show() if tag == 'density': __model.setItem(str_model='predefined_law') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() __combo.hide() __button.hide() self.mdl.setPropertyMode(tag, 'predefined_law') __line.setEnabled(True) if tag == 'specific_heat': __model.setItem(str_model='constant') __combo.setEnabled(False) __button.setEnabled(False) __button.hide() self.mdl.setPropertyMode(tag, 'constant') self.groupBoxCp.setTitle('Isobaric specific heat') if tag == 'volume_viscosity': __combo.setEnabled(True) c = self.mdl.getPropertyMode(tag) if c == 'predefined_law': __button.setEnabled(True) else: __button.setEnabled(False) else: if tag == 'specific_heat': self.groupBoxCp.setTitle('Specific heat')
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_FluidCharacteristicsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = FluidCharacteristicsModel(self.case) self.notebook = NotebookModel(self.case) if EOS == 1: self.ava = eosAva.EosAvailable() import cs_config cfg = cs_config.config() self.freesteam = 0 if cfg.libs['freesteam'].have != "no": self.freesteam = 1 self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() tsm = self.mdl.tsm # Particular Widget initialization taking into account of "Calculation Features" mdl_atmo, mdl_joule, mdl_thermal, mdl_gas, mdl_coal, mdl_comp = self.mdl.getThermoPhysicalModel( ) # Combo models self.modelRho = ComboModel(self.comboBoxRho, 3, 1) self.modelMu = ComboModel(self.comboBoxMu, 3, 1) self.modelCp = ComboModel(self.comboBoxCp, 3, 1) self.modelAl = ComboModel(self.comboBoxAl, 3, 1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelNameDiff = ComboModel(self.comboBoxNameDiff, 1, 1) self.modelViscv0 = ComboModel(self.comboBoxViscv0, 3, 1) self.modelDiftl0 = ComboModel(self.comboBoxDiftl0, 3, 1) self.modelMaterial = ComboModel(self.comboBoxMaterial, 1, 1) self.modelMethod = ComboModel(self.comboBoxMethod, 1, 1) self.modelPhas = ComboModel(self.comboBoxPhas, 2, 1) self.modelRho.addItem(self.tr('constant'), 'constant') self.modelRho.addItem(self.tr('user law'), 'user_law') self.modelRho.addItem(self.tr('material law'), 'thermal_law') if mdl_atmo != 'off': self.modelRho.addItem(self.tr('defined in atphyv'), 'predefined_law') elif mdl_joule == 'arc': self.modelRho.addItem(self.tr('defined in elphyv'), 'predefined_law') elif mdl_comp != 'off': self.modelRho.addItem(self.tr('predefined law'), 'predefined_law') elif mdl_gas != 'off' or mdl_coal != 'off': self.modelRho.addItem(self.tr('predefined law'), 'predefined_law') self.modelMu.addItem(self.tr('constant'), 'constant') self.modelMu.addItem(self.tr('user law'), 'user_law') self.modelMu.addItem(self.tr('material law'), 'thermal_law') if mdl_joule == 'arc': self.modelMu.addItem(self.tr('defined in elphyv'), 'predefined_law') self.modelCp.addItem(self.tr('constant'), 'constant') self.modelCp.addItem(self.tr('user law'), 'user_law') self.modelCp.addItem(self.tr('material law'), 'thermal_law') if mdl_joule == 'arc': self.modelCp.addItem(self.tr('defined in elphyv'), 'predefined_law') self.modelAl.addItem(self.tr('constant'), 'constant') self.modelAl.addItem(self.tr('user law'), 'user_law') self.modelAl.addItem(self.tr('material law'), 'thermal_law') if mdl_joule == 'arc': self.modelAl.addItem(self.tr('defined in elphyv'), 'predefined_law') self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('user law'), 'user_law') self.modelViscv0.addItem(self.tr('constant'), 'constant') self.modelViscv0.addItem(self.tr('user law'), 'user_law') self.modelViscv0.addItem(self.tr('material law'), 'thermal_law') self.modelDiftl0.addItem(self.tr('constant'), 'constant') self.modelDiftl0.addItem(self.tr('user law'), 'user_law') self.modelDiftl0.addItem(self.tr('material law'), 'thermal_law') if mdl_gas != 'off' or mdl_coal != 'off': self.modelDiftl0.addItem(self.tr('predefined law'), 'predefined_law') self.modelPhas.addItem(self.tr('liquid'), 'liquid') self.modelPhas.addItem(self.tr('gas'), 'gas') self.scalar = "" scalar_list = self.mdl.m_sca.getUserScalarNameList() for s in self.mdl.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) # Validators validatorP0 = DoubleValidator(self.lineEditP0, min=0.0) self.lineEditP0.setValidator(validatorP0) validatorT0 = DoubleValidator(self.lineEditT0, min=0.0) validatorT0.setExclusiveMin(True) self.lineEditT0.setValidator(validatorT0) validatorOxydant = DoubleValidator(self.lineEditOxydant, min=0.0) validatorOxydant.setExclusiveMin(True) self.lineEditOxydant.setValidator(validatorOxydant) validatorFuel = DoubleValidator(self.lineEditFuel, min=0.0) validatorFuel.setExclusiveMin(True) self.lineEditFuel.setValidator(validatorFuel) validatorMM = DoubleValidator(self.lineEditMassMolar, min=0.0) validatorMM.setExclusiveMin(True) self.lineEditMassMolar.setValidator(validatorMM) validatorRho = DoubleValidator(self.lineEditRho, min=0.0) validatorMu = DoubleValidator(self.lineEditMu, min=0.0) validatorCp = DoubleValidator(self.lineEditCp, min=0.0) validatorAl = DoubleValidator(self.lineEditAl, min=0.0) validatorDiff = DoubleValidator(self.lineEditDiff, min=0.0) validatorViscv0 = DoubleValidator(self.lineEditViscv0, min=0.0) validatorDiftl0 = DoubleValidator(self.lineEditDiftl0, min=0.0) validatorRho.setExclusiveMin(True) validatorMu.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorAl.setExclusiveMin(True) validatorDiff.setExclusiveMin(True) validatorDiftl0.setExclusiveMin(True) self.lineEditRho.setValidator(validatorRho) self.lineEditMu.setValidator(validatorMu) self.lineEditCp.setValidator(validatorCp) self.lineEditAl.setValidator(validatorAl) self.lineEditDiff.setValidator(validatorDiff) self.lineEditViscv0.setValidator(validatorViscv0) self.lineEditDiftl0.setValidator(validatorDiftl0) # Connections self.lineEditP0.textChanged[str].connect(self.slotPressure) self.lineEditT0.textChanged[str].connect(self.slotTemperature) self.lineEditOxydant.textChanged[str].connect(self.slotTempOxydant) self.lineEditFuel.textChanged[str].connect(self.slotTempFuel) self.lineEditMassMolar.textChanged[str].connect(self.slotMassemol) self.comboBoxRho.currentIndexChanged[str].connect(self.slotStateRho) self.comboBoxMu.currentIndexChanged[str].connect(self.slotStateMu) self.comboBoxCp.currentIndexChanged[str].connect(self.slotStateCp) self.comboBoxAl.currentIndexChanged[str].connect(self.slotStateAl) self.comboBoxDiff.currentIndexChanged[str].connect(self.slotStateDiff) self.comboBoxNameDiff.activated[str].connect(self.slotNameDiff) self.comboBoxViscv0.currentIndexChanged[str].connect( self.slotStateViscv0) self.comboBoxMaterial.activated[str].connect(self.slotMaterial) self.comboBoxMethod.activated[str].connect(self.slotMethod) self.comboBoxPhas.activated[str].connect(self.slotPhas) self.lineEditRho.textChanged[str].connect(self.slotRho) self.lineEditMu.textChanged[str].connect(self.slotMu) self.lineEditCp.textChanged[str].connect(self.slotCp) self.lineEditAl.textChanged[str].connect(self.slotAl) self.lineEditDiff.textChanged[str].connect(self.slotDiff) self.lineEditDiftl0.textChanged[str].connect(self.slotDiftl0) self.lineEditViscv0.textChanged[str].connect(self.slotViscv0) self.pushButtonRho.clicked.connect(self.slotFormulaRho) self.pushButtonMu.clicked.connect(self.slotFormulaMu) self.pushButtonCp.clicked.connect(self.slotFormulaCp) self.pushButtonAl.clicked.connect(self.slotFormulaAl) self.pushButtonDiff.clicked.connect(self.slotFormulaDiff) self.pushButtonViscv0.clicked.connect(self.slotFormulaViscv0) self.initializeWidget() self.case.undoStartGlobal()
import eosAva except: EOS = 0 else: import eosAva #------------------------------------------------------------------------------- # Coolprop #------------------------------------------------------------------------------- import cs_config coolprop_fluids = [] coolprop_warn = False if cs_config.config().libs['coolprop'].have != "no" and not coolprop_fluids: try: import sys sys.path.insert( 0, cs_config.config().libs['coolprop'].flags['pythonpath']) import CoolProp sys.pop(0) seld.coolprop_fluids = [] for f in CoolProp.__fluids__: coolprop_fluids.append(f) coolprop_fluids.sort() except Exception: # CoolProp might be available but not its Python bindings
def main(argv, pkg): """ Start Qt and a session of the application. """ from cs_exec_environment import set_modules, source_rcfile set_modules(pkg) source_rcfile(pkg) # Test the package name to know which modules have to be imported if pkg.name == 'code_saturne': images_path = os.path.join(pkg.get_dir('pkgdatadir'), 'images') sys.path.insert(1, os.path.join(pkg.get_dir('pkgpythondir'), 'Base')) else: images_path = os.path.join(pkg.get_dir('pkgpythondir'), 'core', 'icons') sys.path.insert(1, os.path.join(pkg.get_dir('pkgpythondir'), 'core')) sys.path.insert(1, pkg.get_dir('cspythondir')) # Test if EOS modules could be imported cfg = cs_config.config() if cfg.libs['eos'].have == "yes": eosprefix = cfg.libs['eos'].prefix try: from distutils import sysconfig eospath = os.path.join(sysconfig.get_python_lib(0, 0, prefix=eosprefix), 'eos') except Exception: eospath = '' if sys.platform.startswith('win'): eospath = os.path.join(eosprefix, 'lib', 'python' + sys.version[:3], 'site-packages', 'eos') if eospath: if os.path.isdir(eospath) and not eospath in sys.path: sys.path.insert(0, eospath) case, spl = process_cmd_line(argv) app = QApplication(argv) app.setOrganizationName(pkg.code_name) # Defines the name of subdirectory under .config app.setOrganizationDomain(pkg.url) app.setApplicationName("gui") # Defines the name of the configuration file #app.setWindowIcon(QIcon(":/icon.png")) app.lastWindowClosed.connect(app.quit) # Locale detection locale = QLocale.system().name() translator = QTranslator(app) if translator.load("qt_" + locale, QLibraryInfo.location(QLibraryInfo.TranslationsPath)): app.installTranslator(translator) if spl: app.setOverrideCursor(QCursor(Qt.WaitCursor)) pixmap = QPixmap('%s/splashscreen.png' % images_path) splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) # this is usefull if the splashscreen is not a regular ractangle... splash.show() if pkg.name == 'neptune_cfd': splash.showMessage("%(name)s %(vers)s starting..." \ % {'name': pkg.name, 'vers':pkg.version}, Qt.AlignHCenter | Qt.AlignVCenter, Qt.black) app.processEvents() QTimer.singleShot(1500, splash.hide) from code_saturne.Base.MainView import MainView mv = MainView(cmd_package = pkg, cmd_case = case) try: mv.show() if spl: app.processEvents() app.restoreOverrideCursor() except: print("\n Unable to display a Qt window.") print(" Please check your display environment.\n") sys.exit(0) sys.exit(app.exec_())
def main(argv, pkg): """ Start Qt and a session of the application. """ from cs_exec_environment import set_modules, source_rcfile set_modules(pkg) source_rcfile(pkg) # Test the package name to know which modules have to be imported if pkg.name == 'code_saturne': images_path = os.path.join(pkg.get_dir('pkgdatadir'), 'images') sys.path.insert(1, os.path.join(pkg.get_dir('pkgpythondir'), 'Base')) else: images_path = os.path.join(pkg.get_dir('pkgpythondir'), 'core', 'icons') sys.path.insert(1, os.path.join(pkg.get_dir('pkgpythondir'), 'core')) sys.path.insert(1, pkg.get_dir('cspythondir')) # Test if EOS modules could be imported cfg = cs_config.config() if cfg.libs['eos'].have == "yes": eosprefix = cfg.libs['eos'].prefix try: from distutils import sysconfig eospath = os.path.join(sysconfig.get_python_lib(0, 0, prefix=eosprefix), 'eos') except Exception: eospath = '' if sys.platform.startswith('win'): eospath = os.path.join(eosprefix, 'lib', 'python' + sys.version[:3], 'site-packages', 'eos') if eospath: if os.path.isdir(eospath) and not eospath in sys.path: sys.path.insert(0, eospath) case, spl = process_cmd_line(argv) app = QApplication(argv) app.setOrganizationName(pkg.code_name) # Defines the name of subdirectory under .config app.setOrganizationDomain(pkg.url) app.setApplicationName("gui") # Defines the name of the configuration file #app.setWindowIcon(QIcon(":/icon.png")) app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) # Locale detection locale = QLocale.system().name() translator = QTranslator(app) if translator.load("qt_" + locale, QLibraryInfo.location(QLibraryInfo.TranslationsPath)): app.installTranslator(translator) if spl: app.setOverrideCursor(QCursor(Qt.WaitCursor)) pixmap = QPixmap('%s/splashscreen.png' % images_path) splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) # this is usefull if the splashscreen is not a regular ractangle... splash.show() if pkg.name == 'neptune_cfd': splash.showMessage("%(name)s %(vers)s starting..." \ % {'name': pkg.name, 'vers':pkg.version}, Qt.AlignHCenter | Qt.AlignVCenter, Qt.black) app.processEvents() QTimer.singleShot(1500, splash.hide) from code_saturne.Base.MainView import MainView mv = MainView(cmd_package = pkg, cmd_case = case) try: mv.show() if spl: app.processEvents() app.restoreOverrideCursor() except: print("\n Unable to display a Qt window.") print(" Please check your display environment.\n") sys.exit(0) sys.exit(app.exec_())
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_ImmersedBoundariesNeptune.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.ibm = ImmersedBoundariesModel(self.case) self.current_obj = None # Models self.modelFSI = StandardItemModelFSI(self.ibm) self.tableViewFSI.setModel(self.modelFSI) if QT_API == "PYQT4": self.tableViewFSI.verticalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewFSI.horizontalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewFSI.horizontalHeader().setResizeMode( 4, QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewFSI.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewFSI.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewFSI.horizontalHeader().setSectionResizeMode( 4, QHeaderView.Stretch) self.modelFSI.dataChanged.connect(self.dataChanged) delegateObjectLabel = FSIObjectNameDelegate(self.tableViewFSI) self.tableViewFSI.setItemDelegateForColumn(0, delegateObjectLabel) delegateObjectMotion = FSIMovingDelegate(self.tableViewFSI) self.tableViewFSI.setItemDelegateForColumn(1, delegateObjectMotion) delegateObjectType = FSITypeDelegate(self.tableViewFSI, self.ibm) self.tableViewFSI.setItemDelegateForColumn(2, delegateObjectType) self.checkBoxActivate.stateChanged.connect(self.slotCheckActivate) self.tableViewFSI.clicked.connect(self.slotChangedSelection) for ind in ['Explicit', 'MEDCoupling']: eval('self.radioButton' + ind + '.toggled.connect(self.slotRadioButton)') # Connections self.pushButtonAddFSI.clicked.connect(self.slotAddFSI) self.pushButtonDeleteFSI.clicked.connect(self.slotDeleteFSI) # Check for MEDCoupling presence import cs_config cfg = cs_config.config() self.has_medcoupling = cfg.libs['medcoupling'].have == 'yes' # deactivated for the moment self.has_medcoupling = False self.radioButtonMEDCoupling.setEnabled(self.has_medcoupling) if self.ibm.getMethod( ) == 'medcoupling' and self.has_medcoupling == False: self.setMethod('explicit') # Show/hide widgets on start if self.ibm.getOnOff() == 'off': self.groupBoxMethod.hide() self.groupBoxObjects.hide() self.groupBoxObjProperties.hide() self.groupBoxExplicit.hide() self.groupBoxMEDCoupling.hide() else: self.groupBoxMethod.show() self.groupBoxObjects.show() if self.ibm.getMethod() == 'explicit': self.groupBoxExplicit.show() else: self.groupBoxMEDCoupling.show() self.updatePageView() 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()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_ImmersedBoundariesNeptune.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.ibm = ImmersedBoundariesModel(self.case) self.current_obj = None # Models self.modelFSI = StandardItemModelFSI(self.ibm) self.tableViewFSI.setModel(self.modelFSI) for obj in range(1, self.ibm.getNumberOfFSIObjects() + 1): self.modelFSI.addItem(self.ibm.getObjectName(obj), self.ibm.getObjectInteraction(obj)) if QT_API == "PYQT4": self.tableViewFSI.verticalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewFSI.horizontalHeader().setResizeMode( QHeaderView.ResizeToContents) # self.tableViewFSI.horizontalHeader().setResizeMode(2, QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewFSI.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewFSI.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) # self.tableViewFSI.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch) self.modelFSI.dataChanged.connect(self.dataChanged) delegateObjectLabel = FSIObjectNameDelegate(self.tableViewFSI) self.tableViewFSI.setItemDelegateForColumn(0, delegateObjectLabel) delegateObjectType = FSITypeDelegate(self.tableViewFSI, self.ibm) self.tableViewFSI.setItemDelegateForColumn(1, delegateObjectType) self.checkBoxActivate.stateChanged.connect(self.slotCheckActivate) self.tableViewFSI.clicked[QModelIndex].connect( self.slotChangedSelection) for ind in ['Explicit', 'MEDCoupling']: eval('self.radioButton' + ind + '.toggled.connect(self.slotRadioButton)') # Connections self.pushButtonAddFSI.clicked.connect(self.slotAddFSI) self.pushButtonDeleteFSI.clicked.connect(self.slotDeleteFSI) self.pushButtonExplicit.clicked.connect(self.slotExplicitFormula) validatorDensity = DoubleValidator(self.lineEditObjDensity, min=0.0) self.lineEditObjDensity.setValidator(validatorDensity) self.lineEditObjDensity.textChanged[str].connect(self.slotObjDensity) validatorStiffness = DoubleValidator(self.lineEditObjStiffness, min=0.0) self.lineEditObjStiffness.setValidator(validatorStiffness) self.lineEditObjStiffness.textChanged[str].connect( self.slotObjStiffness) validatorDamping = DoubleValidator(self.lineEditObjDamping, min=0.0) self.lineEditObjDamping.setValidator(validatorDamping) self.lineEditObjDamping.textChanged[str].connect(self.slotObjDamping) self.lineEditXInit.textChanged[str].connect(self.slotObjXinit) self.lineEditYInit.textChanged[str].connect(self.slotObjYinit) self.lineEditZInit.textChanged[str].connect(self.slotObjZinit) self.lineEditXEq.textChanged[str].connect(self.slotObjXeq) self.lineEditYEq.textChanged[str].connect(self.slotObjYeq) self.lineEditZEq.textChanged[str].connect(self.slotObjZeq) self.lineEditVelXInit.textChanged[str].connect(self.slotObjVelXinit) self.lineEditVelYInit.textChanged[str].connect(self.slotObjVelYinit) self.lineEditVelZInit.textChanged[str].connect(self.slotObjVelZinit) self.lineEditAccXInit.textChanged[str].connect(self.slotObjAccXinit) self.lineEditAccYInit.textChanged[str].connect(self.slotObjAccYinit) self.lineEditAccZInit.textChanged[str].connect(self.slotObjAccZinit) # Check for MEDCoupling presence import cs_config cfg = cs_config.config() self.has_medcoupling = cfg.libs['medcoupling'].have == 'yes' # deactivated for the moment self.has_medcoupling = False self.radioButtonMEDCoupling.setEnabled(self.has_medcoupling) if self.ibm.getMethod( ) == 'medcoupling' and self.has_medcoupling == False: self.setMethod('explicit') # Show/hide widgets on start if self.ibm.getOnOff() == 'off': self.groupBoxMethod.hide() self.groupBoxObjects.hide() self.groupBoxObjProperties.hide() self.groupBoxExplicit.hide() self.groupBoxMEDCoupling.hide() else: self.groupBoxMethod.show() self.groupBoxObjects.show() if self.ibm.getMethod() == 'explicit': self.groupBoxExplicit.show() else: self.groupBoxMEDCoupling.show() self.updatePageView() self.case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_FluidCharacteristicsForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.mdl = FluidCharacteristicsModel(self.case) if EOS == 1: self.ava = eosAva.EosAvailable() import cs_config cfg = cs_config.config() self.freesteam = 0 if cfg.libs['freesteam'].have != "no": self.freesteam = 1 if CompressibleModel(self.case).getCompressibleModel() != 'off': self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu'), ('specific_heat', 'Cp'), ('thermal_conductivity', 'Al'), ('volume_viscosity', 'Viscv0'), ('dynamic_diffusion', 'Diftl0')] elif CoalCombustionModel(self.case).getCoalCombustionModel() != 'off' or \ GasCombustionModel(self.case).getGasCombustionModel() != 'off': self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu'), ('specific_heat', 'Cp'), ('dynamic_diffusion', 'Diftl0')] else: self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu'), ('specific_heat', 'Cp'), ('thermal_conductivity', 'Al')] self.list_scalars = [] self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": self.list_scalars.append((s, self.tr("Thermal scalar: temperature (C)"))) elif mdl == "temperature_kelvin": self.list_scalars.append((s, self.tr("Thermal scalar: temperature (K)"))) elif mdl != "off": self.list_scalars.append((s, self.tr("Thermal scalar"))) self.m_sca = DefineUserScalarsModel(self.case) for s in self.m_sca.getUserScalarNameList(): self.list_scalars.append((s, self.tr("Additional scalar"))) # Particular Widget initialization taking into account of "Calculation Features" mdl_atmo, mdl_joule, mdl_thermal, mdl_gas, mdl_coal, mdl_comp = self.mdl.getThermoPhysicalModel() # Combo models self.modelRho = ComboModel(self.comboBoxRho, 3, 1) self.modelMu = ComboModel(self.comboBoxMu, 3, 1) self.modelCp = ComboModel(self.comboBoxCp, 3, 1) self.modelAl = ComboModel(self.comboBoxAl, 3, 1) self.modelDiff = ComboModel(self.comboBoxDiff, 2, 1) self.modelNameDiff = ComboModel(self.comboBoxNameDiff,1,1) self.modelViscv0 = ComboModel(self.comboBoxViscv0, 3, 1) self.modelDiftl0 = ComboModel(self.comboBoxDiftl0, 3, 1) self.modelMaterial = ComboModel(self.comboBoxMaterial, 1, 1) self.modelMethod = ComboModel(self.comboBoxMethod, 1, 1) self.modelPhas = ComboModel(self.comboBoxPhas, 2, 1) self.modelRho.addItem(self.tr('constant'), 'constant') self.modelRho.addItem(self.tr('variable'), 'variable') self.modelRho.addItem(self.tr('thermal law'), 'thermal_law') if mdl_atmo != 'off': self.modelRho.addItem(self.tr('defined in atphyv'), 'variable') elif mdl_joule == 'arc': self.modelRho.addItem(self.tr('defined in elphyv'), 'variable') self.modelMu.addItem(self.tr('constant'), 'constant') self.modelMu.addItem(self.tr('variable'), 'variable') self.modelMu.addItem(self.tr('thermal law'), 'thermal_law') if mdl_joule == 'arc': self.modelMu.addItem(self.tr('defined in elphyv'), 'variable') self.modelCp.addItem(self.tr('constant'), 'constant') self.modelCp.addItem(self.tr('variable'), 'variable') self.modelCp.addItem(self.tr('thermal law'), 'thermal_law') if mdl_joule == 'arc': self.modelCp.addItem(self.tr('defined in elphyv'), 'variable') self.modelAl.addItem(self.tr('constant'), 'constant') self.modelAl.addItem(self.tr('variable'), 'variable') self.modelAl.addItem(self.tr('thermal law'), 'thermal_law') if mdl_joule == 'arc': self.modelAl.addItem(self.tr('defined in elphyv'), 'variable') self.modelDiff.addItem(self.tr('constant'), 'constant') self.modelDiff.addItem(self.tr('variable'), 'variable') self.modelViscv0.addItem(self.tr('constant'), 'constant') self.modelViscv0.addItem(self.tr('variable'), 'variable') self.modelViscv0.addItem(self.tr('thermal law'), 'thermal_law') self.modelDiftl0.addItem(self.tr('constant'), 'constant') self.modelDiftl0.addItem(self.tr('variable'), 'variable') self.modelDiftl0.addItem(self.tr('thermal law'), 'thermal_law') self.modelPhas.addItem(self.tr('liquid'), 'liquid') self.modelPhas.addItem(self.tr('gas'), 'gas') if (self.freesteam == 0 and EOS == 0) or \ self.m_th.getThermalScalarModel() == "off" or \ mdl_joule != 'off' or mdl_comp != 'off': self.groupBoxTableChoice.hide() else: self.groupBoxTableChoice.show() self.lineEditReference.setEnabled(False) # suppress perfect gas self.modelMaterial.addItem(self.tr('user material'), 'user_material') tmp = ["Argon", "Nitrogen", "Hydrogen", "Oxygen", "Helium", "Air"] if EOS == 1: fls = self.ava.whichFluids() for fli in fls: if fli not in tmp: tmp.append(fli) self.modelMaterial.addItem(self.tr(fli), fli) if self.freesteam == 1 and EOS == 0: self.modelMaterial.addItem(self.tr('Water'), 'Water') material = self.mdl.getMaterials() self.modelMaterial.setItem(str_model=material) self.updateMethod() 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.comboBoxRho, SIGNAL("activated(const QString&)"), self.slotStateRho) self.connect(self.comboBoxMu, SIGNAL("activated(const QString&)"), self.slotStateMu) self.connect(self.comboBoxCp, SIGNAL("activated(const QString&)"), self.slotStateCp) self.connect(self.comboBoxAl, SIGNAL("activated(const QString&)"), self.slotStateAl) self.connect(self.comboBoxDiff, SIGNAL("activated(const QString&)"), self.slotStateDiff) self.connect(self.comboBoxNameDiff, SIGNAL("activated(const QString&)"), self.slotNameDiff) self.connect(self.comboBoxViscv0, SIGNAL("activated(const QString&)"), self.slotStateViscv0) self.connect(self.comboBoxMaterial, SIGNAL("activated(const QString&)"), self.slotMaterial) self.connect(self.comboBoxMethod, SIGNAL("activated(const QString&)"), self.slotMethod) self.connect(self.comboBoxPhas, SIGNAL("activated(const QString&)"), self.slotPhas) self.connect(self.lineEditRho, SIGNAL("textChanged(const QString &)"), self.slotRho) self.connect(self.lineEditMu, SIGNAL("textChanged(const QString &)"), self.slotMu) self.connect(self.lineEditCp, SIGNAL("textChanged(const QString &)"), self.slotCp) self.connect(self.lineEditAl, SIGNAL("textChanged(const QString &)"), self.slotAl) self.connect(self.lineEditDiff, SIGNAL("textChanged(const QString &)"), self.slotDiff) self.connect(self.lineEditDiftl0, SIGNAL("textChanged(const QString &)"), self.slotDiftl0) self.connect(self.lineEditViscv0, SIGNAL("textChanged(const QString &)"), self.slotViscv0) self.connect(self.pushButtonRho, SIGNAL("clicked()"), self.slotFormulaRho) self.connect(self.pushButtonMu, SIGNAL("clicked()"), self.slotFormulaMu) self.connect(self.pushButtonCp, SIGNAL("clicked()"), self.slotFormulaCp) self.connect(self.pushButtonAl, SIGNAL("clicked()"), self.slotFormulaAl) self.connect(self.pushButtonDiff, SIGNAL("clicked()"), self.slotFormulaDiff) self.connect(self.pushButtonViscv0, SIGNAL("clicked()"), self.slotFormulaViscv0) # Validators validatorRho = DoubleValidator(self.lineEditRho, min = 0.0) validatorMu = DoubleValidator(self.lineEditMu, min = 0.0) validatorCp = DoubleValidator(self.lineEditCp, min = 0.0) validatorAl = DoubleValidator(self.lineEditAl, min = 0.0) validatorDiff = DoubleValidator(self.lineEditDiff, min = 0.0) validatorViscv0 = DoubleValidator(self.lineEditViscv0, min = 0.0) validatorDiftl0 = DoubleValidator(self.lineEditDiftl0, min = 0.0) validatorRho.setExclusiveMin(True) validatorMu.setExclusiveMin(True) validatorCp.setExclusiveMin(True) validatorAl.setExclusiveMin(True) validatorDiff.setExclusiveMin(True) validatorDiftl0.setExclusiveMin(True) self.lineEditRho.setValidator(validatorRho) self.lineEditMu.setValidator(validatorMu) self.lineEditCp.setValidator(validatorCp) self.lineEditAl.setValidator(validatorAl) self.lineEditDiff.setValidator(validatorDiff) self.lineEditViscv0.setValidator(validatorViscv0) self.lineEditDiftl0.setValidator(validatorDiftl0) if scalar_list == []: self.groupBoxDiff.hide() else : self.groupBoxDiff.show() self.lineEditDiff.setText(str(self.m_sca.getScalarDiffusivityInitialValue(self.scalar))) diff_choice = self.m_sca.getScalarDiffusivityChoice(self.scalar) 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) #compressible self.groupBoxViscv0.hide() # combustion self.groupBoxDiftl0.hide() # Standard Widget initialization for tag, symbol in self.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __labelu = getattr(self, "labelUnit" + symbol) if tag != 'dynamic_diffusion': __labelv = getattr(self, "labelVar" + symbol) c = self.mdl.getPropertyMode(tag) __model.setItem(str_model=c) if c == 'variable': __button.setEnabled(True) __label.setText(self.tr("Reference value")) else: __button.setEnabled(False) __label.setText(self.tr("Reference value")) if c == 'thermal_law': __line.hide() __label.hide() __labelu.hide() __labelv.hide() else: __line.show() __label.show() __labelu.show() __labelv.show() if self.mdl.getMaterials() == "user_material": __model.disableItem(str_model='thermal_law') else: __model.enableItem(str_model='thermal_law') else: __label.setText(self.tr("Reference value")) self.mdl.getInitialValue(tag) __line.setText(str(self.mdl.getInitialValue(tag))) # no 'thermal_conductivity' if not Joule and not Thermal scalar and not if mdl_joule == 'off' and mdl_thermal == 'off' and mdl_atmo == 'off' and\ CompressibleModel(self.case).getCompressibleModel() == 'off': self.groupBoxAl.hide() if mdl_gas != 'off' or mdl_coal != 'off': self.groupBoxDiftl0.show() for tag, symbol in self.lst: __model = getattr(self, "model" + symbol) __line = getattr(self, "lineEdit" + symbol) __button = getattr(self, "pushButton" + symbol) __label = getattr(self, "label" + symbol) __combo = getattr(self, "comboBox" + symbol) # Gas or coal combustion if mdl_gas != 'off' or mdl_coal != 'off': if tag == 'density': __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) self.mdl.setPropertyMode(tag, 'variable') __label.setText(self.tr("Calculation by\n perfect gas law")) __line.setText(str("")) __line.setEnabled(False) elif tag == 'dynamic_diffusion': __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) else: __model.setItem(str_model='constant') self.mdl.setPropertyMode(tag, 'constant') # Joule if mdl_joule == 'arc': __model.disableItem(str_model='constant') __model.disableItem(str_model='variable') __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) self.mdl.setPropertyMode(tag, 'variable') if mdl_joule == 'joule': __model.setItem(str_model='variable') __model.disableItem(str_model='constant') self.mdl.setPropertyMode(tag, 'variable') # Atmospheric Flows if mdl_atmo != 'off': if tag == 'density': __model.disableItem(str_model='constant') __model.disableItem(str_model='variable') __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) # Compressible Flows if mdl_comp != 'off': if tag == 'density': __model.setItem(str_model='variable') __combo.setEnabled(False) __button.setEnabled(False) __combo.hide() __button.hide() self.mdl.setPropertyMode(tag, 'variable') __line.setEnabled(True) self.groupBoxViscv0.hide() if tag == 'specific_heat': __model.setItem(str_model='constant') __combo.setEnabled(False) __button.setEnabled(False) self.mdl.setPropertyMode(tag, 'constant') self.groupBoxCp.setTitle('Isobaric specific heat') if tag == 'volume_viscosity': __combo.setEnabled(True) c = self.mdl.getPropertyMode(tag) if c == 'variable': __button.setEnabled(True) else: __button.setEnabled(False) self.groupBoxViscv0.show() else: if tag == 'specific_heat': self.groupBoxCp.setTitle('Specific heat') self.case.undoStartGlobal()
def __init__(self, case): """FluidCharacteristicsModel Constuctor.""" self.case = case self.node_models = self.case.xmlGetNode('thermophysical_models') self.node_prop = self.case.xmlGetNode('physical_properties') self.node_fluid = self.node_prop.xmlInitNode('fluid_properties') self.node_comp = self.node_models.xmlInitNode('compressible_model', 'model') self.node_gas = self.node_models.xmlInitNode('gas_combustion', 'model') self.node_coal = self.node_models.xmlInitNode('solid_fuels', 'model') # Info on available libraries self.mask_builtin = 1 << 0 self.mask_CoolProp = 1 << 1 self.mask_EOS = 1 << 2 self.mask_freesteam = 1 << 3 self.tables = 0 import cs_config cfg = cs_config.config() self.lib_properties = {} self.lib_properties['user_material'] = self.mask_builtin if EOS == 1: self.tables += self.mask_EOS self.ava = eosAva.EosAvailable() # suppress perfect gas fls = self.ava.whichFluids() for fli in fls: if fli in eos_excl: continue if fli not in self.lib_properties.keys(): self.lib_properties[fli] = self.mask_EOS else: self.lib_properties[fli] += self.mask_EOS if cfg.libs['freesteam'].have != "no": self.tables += self.mask_freesteam fli = 'Water' if fli not in self.lib_properties.keys(): self.lib_properties[fli] = self.mask_freesteam else: self.lib_properties[fli] += self.mask_freesteam if coolprop_fluids: if cfg.libs['coolprop'].have != "no": self.tables += self.mask_CoolProp for fli in coolprop_fluids: if fli not in self.lib_properties.keys(): self.lib_properties[fli] = self.mask_CoolProp else: self.lib_properties[fli] += self.mask_CoolProp # Base model needs density and molecular viscosity self.lst = [('density', 'Rho'), ('molecular_viscosity', 'Mu')] self.node_density = self.setNewFluidProperty(self.node_fluid, \ 'density') self.node_viscosity = self.setNewFluidProperty(self.node_fluid, \ 'molecular_viscosity') self.node_lst = [self.node_density, self.node_viscosity] self.node_heat = None self.node_cond = None self.node_vol_visc = None self.node_dyn = None # Get thermal scalar and model thm = ThermalScalarModel(self.case) tsn = thm.getThermalScalarName() self.tsm = thm.getThermalScalarModel() # If thermal model enabled, add thermal conductivity and specific heat if self.tsm != "off": self.lst.extend([('specific_heat', 'Cp'), \ ('thermal_conductivity', 'Al')]) self.node_heat = self.setNewFluidProperty(self.node_fluid, \ 'specific_heat') self.node_cond = self.setNewFluidProperty(self.node_fluid, \ 'thermal_conductivity') self.node_lst.extend([self.node_heat, self.node_cond]) # Define volume viscosity for compressible model if self.node_comp['model'] not in [None, "off"]: self.lst.append(('volume_viscosity', 'Viscv0')) self.node_vol_visc = self.setNewFluidProperty(self.node_fluid, \ 'volume_viscosity') self.node_lst.append(self.node_vol_visc) # Define dynamic diffusion for reactive flow elif self.node_coal['model'] not in [None, "off"] \ or self.node_gas['model'] not in [None, "off"]: self.lst.append(('dynamic_diffusion', 'Diftl0')) self.node_dyn = self.setNewFluidProperty(self.node_fluid, \ 'dynamic_diffusion') self.node_lst.append(self.node_dyn) # Build scalars list self.list_scalars = [] if self.tsm == "temperature_celsius": self.list_scalars.append( (tsn, self.tr("Thermal scalar: temperature (\xB0 C)"))) elif self.tsm == "temperature_kelvin": self.list_scalars.append( (tsn, self.tr("Thermal scalar: temperature (K)"))) elif self.tsm != "off": self.list_scalars.append((tsn, self.tr("Thermal scalar"))) self.m_sca = DefineUserScalarsModel(self.case) for s in self.m_sca.getUserScalarNameList(): self.list_scalars.append((s, self.tr("Additional scalar"))) # Notebook self.notebook = NotebookModel(self.case)