def slotSpeciesGroundWaterFormula(self): """ """ exa = """#example: """ exp, req, sym, knf = self.mdl.getGroundWaterSpeciesFormulaComponents( self.zone_id, self.scalar) zone_name = self.zone.getLabel() dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name=self.scalar, expression=exp, required=req, symbols=sym, known_fields=knf, examples=exa, source_type='scalar_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotSpeciesGroundWaterFormula -> %s" % str(result)) self.mdl.setGroundWaterSpeciesFormula(self.zone_id, self.scalar, str(result)) self.pushButtonSpecies2.setToolTip(result) self.pushButtonSpecies2.setStyleSheet("background-color: green")
def slotRichardsFormula(self): """ """ exa = """#example: """ exp, req, sym = self.mdl.getRichardsFormulaComponents(self.zone_id) zone_name = self.zone.getLabel() dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name="richards", expression=exp, required=req, symbols=sym, examples=exa, source_type='momentum_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotRichardsFormula -> %s" % str(result)) self.mdl.setRichardsFormula(self.zone_id, str(result)) self.pushButtonRichards.setToolTip(result) self.pushButtonRichards.setStyleSheet("background-color: green")
def slotFormula(self): """ Run formula editor. """ exp = self.mdl.getFormula() exp, req, sca, symb = self.mdl.getFormulaViscComponents() if self.mdl.getViscosity() == 'isotrop': exa = MobileMeshView.viscosity_iso else: exa = MobileMeshView.viscosity_ortho dialog = QMegEditorView(parent = self, function_type = 'vol', zone_name = "all_cells", variable_name = "mesh_viscosity", expression = exp, required = req, symbols = symb, known_fields = [], examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMobileMeshView -> %s" % str(result)) self.mdl.setFormula(str(result)) self.pushButtonFormula.setStyleSheet("background-color: green") self.pushButtonFormula.setToolTip(result)
def slotMomentumFormula(self): """ Set momentumFormula of the source term """ exa = """#example:\n tau = 10.; # relaxation time (s)\n vel_x_imp = 1.5; #target velocity (m/s)\n Su = rho * (vel_x_imp - u) / tau;\n dSudu = - rho / tau; # Jacobian of the source term""" exp, req, sym = self.mdl.getMomentumFormulaComponents(self.zone_id) knf = [('rho', 'density')] zone_name = self.zone.getLabel() dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name="momentum", expression=exp, required=req, symbols=sym, known_fields=knf, examples=exa, source_type='momentum_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaVelocity -> %s" % str(result)) self.mdl.setMomentumFormula(self.zone_id, str(result)) self.pushButtonMomentum.setToolTip(result) self.pushButtonMomentum.setStyleSheet("background-color: green")
def slotFormula(self): """ User formula for Groundwater functions """ label, name, local = self.modelGroundwaterLaw.getItem( self.entriesNumber) exp, req, sym = self.mdl.getGroundwaterLawFormulaComponents(name) exa = """#example: \n""" + self.mdl.getDefaultGroundwaterLawFormula() dialog = QMegEditorView( parent=self, function_type='vol', zone_name=label, variable_name='capacity+saturation+permeability', expression=exp, required=req, symbols=sym, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormula -> %s" % str(result)) self.mdl.setGroundwaterLawFormula(name, str(result)) self.pushButtonUserLaw.setStyleSheet("background-color: green") self.pushButtonUserLaw.setToolTip(result)
def slotSpeciesFormula(self): """ """ exa = """#example: """ exp, req, sym = self.mdl.getSpeciesFormulaComponents( self.zone, self.scalar) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name=self.scalar, expression=exp, required=req, symbols=sym, examples=exa, source_type='scalar_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaSpecies -> %s" % str(result)) self.mdl.setSpeciesFormula(self.zone, self.scalar, str(result)) self.pushButtonSpecies.setToolTip(result) self.pushButtonSpecies.setStyleSheet("background-color: green")
def slotMomentumFormula(self): """ Set momentumFormula of the source term """ exa = """#example:\n tau = 10.; # relaxation time (s)\n vel_x_imp = 1.5; #target velocity (m/s)\n Su = rho * (vel_x_imp - velocity[0]) / tau;\n dSudu = - rho / tau; # Jacobian of the source term""" exp, req, sym = self.mdl.getMomentumFormulaComponents(self.zone) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name="momentum", expression=exp, required=req, symbols=sym, examples=exa, source_type='momentum_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaVelocity -> %s" % str(result)) self.mdl.setMomentumFormula(self.zone, str(result)) self.pushButtonMomentum.setToolTip(result) self.pushButtonMomentum.setStyleSheet("background-color: green")
def slotThermalFormula(self): """ Input the initial formula of thermal scalar """ exa = """#example: """ exp, req, sym, knf = self.mdl.getThermalFormulaComponents( self.zone_id, self.th_sca_name) zone_name = self.zone.getLabel() dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name=self.th_sca_name, expression=exp, required=req, symbols=sym, known_fields=knf, examples=exa, source_type='thermal_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaThermal -> %s" % str(result)) self.mdl.setThermalFormula(self.zone_id, self.th_sca_name, str(result)) self.pushButtonThermal.setToolTip(result) self.pushButtonThermal.setStyleSheet("background-color: green")
def slotFormulaDiff(self): """ User formula for the diffusion coefficient """ exp, req, sca, sym = self.mdl.getFormulaDiffComponents(self.scalar) exa = '' dname = self.mdl.m_sca.getScalarDiffusivityName(self.scalar) dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name=dname, expression=exp, required=req, symbols=sym, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaDiff -> %s" % str(result)) self.mdl.m_sca.setDiffFormula(self.scalar, str(result)) self.pushButtonDiff.setToolTip(result) self.pushButtonDiff.setStyleSheet("background-color: green")
def slotHydraulicHeadFormula(self): """ Input the initial Hydraulic Head formula """ exa = """#example: """ exp, req, sym = self.init.getHydraulicHeadFormulaComponents( self.zone_id) dialog = QMegEditorView(parent=self, function_type="ini", zone_name=self.zone_name, variable_name="hydraulic_head", expression=exp, required=req, symbols=sym, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotHydraulicHeadFormula -> %s" % str(result)) self.init.setHydraulicHeadFormula(self.zone_id, str(result)) self.pushButtonHydraulicHead.setStyleSheet( "background-color: green") self.pushButtonHydraulicHead.setToolTip(result)
def slotFormula(self, name): """ User formula for a given saturation property. """ exp, req, sca, symbols = self.mdl.getFormulaComponents( 'none', name, zone=self.zone_id) if not exp: exp = self.mdl.getDefaultFormula('none', name) exa = self.mdl.getExampleFormula('none', name) dialog = QMegEditorView(parent=self, function_type='vol', zone_name=self.zone_name, variable_name=name, expression=exp, required=req, symbols=symbols, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() _k = self.sat_ppts[name] _button = getattr(self, "pushButton" + _k) log.debug("slotFormula%s -> %s" % (_k, str(result))) self.mdl.setFormula('none', name, result, zone=self.zone_id) _button.setStyleSheet(_ok_str) _button.setToolTip(result)
def slotSpeciesFormula(self): """ Input the initial formula of species """ exp, req, sym = self.init.getSpeciesFormulaComponents( self.zone, self.scalar) name = DefineUserScalarsModel(self.case).getScalarName(self.scalar) exa = """#example: \n""" + str(name) + """ = 0;\n""" zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent=self, function_type="ini", zone_name=zone_name, variable_name=name, 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, str(result)) self.pushButtonSpecies.setStyleSheet("background-color: green") self.pushButtonSpecies.setToolTip(result)
def slotExplicitFormula(self): """ Explicit formula for variable porosity """ objId = self.current_obj exp, req, sym = self.ibm.getIBMFormulaComponents(objId - 1) exa = """if (x < 0.5) indicator = 0; else indicator = 1;""" name = self.ibm.getObjectName(objId) dialog = QMegEditorView(parent=self, function_type='ibm', zone_name=name, variable_name='porosity', expression=exp, required=req, symbols=sym, known_fields=[], examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotExplicitFormula -> %s" % str(result)) self.ibm.setObjectFormula(objId - 1, result) self.pushButtonExplicit.setStyleSheet("background-color: green") self.pushButtonExplicit.setToolTip(exp)
def slotFormulaAl(self): """ User formula for thermal conductivity """ exp, req, sca, symbols_al = self.mdl.getFormulaAlComponents() self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": TempInContext = "(" + s + " + 273.15)" exa = FluidCharacteristicsView.thermal_conductivity.replace( "temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.thermal_conductivity_h else: exa = FluidCharacteristicsView.thermal_conductivity dialog = QMegEditorView(parent=self, function_type='vol', zone_name='all_cells', variable_name='thermal_conductivity', expression=exp, required=req, symbols=symbols_al, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaAl -> %s" % str(result)) self.mdl.setFormula('thermal_conductivity', str(result)) self.pushButtonAl.setToolTip(result) self.pushButtonAl.setStyleSheet("background-color: green")
def __slotDirectionFormula(self): """ """ exp = self.__boundary.getDirection(self.__currentField, '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 = QMegEditorView(parent = self, function_type = "bnd", zone_name = self.__boundary._label, variable_name = "direction_"+str(self.__currentField), 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(self.__currentField, 'direction_formula', result) self.pushButtonDirectionFormula.setToolTip(result) self.pushButtonDirectionFormula.setStyleSheet("background-color: green")
def slotMeteoFormula(self): """ """ name = self.scalar_meteo exa = """#example: \n""" + str(name) + """ = 0;\n""" exp, req, sym = self.init.getMeteoFormulaComponents( self.zone, self.scalar_meteo) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent=self, function_type="ini", zone_name=zone_name, variable_name=name, 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, str(result)) self.pushButtonMeteo.setStyleSheet("background-color: green") self.pushButtonMeteo.setToolTip(result)
def slotEnergyFormula(self): """ Input the initial Energy formula """ exa = """#example: """ exp, req, sym = self.init.getEnergyFormulaComponenets(self.zone) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent=self, function_type="ini", zone_name=zone_name, variable_name="energy", 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, str(result)) self.pushButtonEnergy.setStyleSheet("background-color: green") self.pushButtonEnergy.setToolTip(result)
def slotFormulaAl(self): """ User formula for thermal conductivity """ exp, req, sca, symbols_al = self.mdl.getFormulaAlComponents() self.m_th = ThermalScalarModel(self.case) s = self.m_th.getThermalScalarName() mdl = self.m_th.getThermalScalarModel() if mdl == "temperature_celsius": TempInContext = "(" + s + " + 273.15)" exa = FluidCharacteristicsView.thermal_conductivity.replace( "temperature", TempInContext) elif mdl == "enthalpy": exa = FluidCharacteristicsView.thermal_conductivity_h else: exa = FluidCharacteristicsView.thermal_conductivity mci = mei_to_c_interpreter(self.case, False) mci.init_cell_block(exp, req, symbols_al, sca, 'thermal_conductivity') dialog = QMegEditorView(self, mei_to_c=mci, expression=exp, required=req, symbols=symbols_al, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaAl -> %s" % str(result)) self.mdl.setFormula('thermal_conductivity', str(result)) self.pushButtonAl.setToolTip(result) self.pushButtonAl.setStyleSheet("background-color: green")
def slotFormula(self): """ """ exp = self.mdl.getFormula(self.label_select) exa = """#example: a line segment between (x0, y0, z0) and (x1, y1, z1) #(s, the parameter is always between 0 and 1) x0 = 3.2; x1 = 2; y0 = 2; y1 = 2; z0 = 5; z1 = -0.5; x = x1*s + x0*(1.-s); y = y1*s + y0*(1.-s); z = z1*s + z0*(1.-s);""" req = [('x', "x formula"), ('y', "y formula"), ('z', "z formula")] sym = [('s', 'parameter')] for (nme, val) in self.notebook.getNotebookList(): sym.append((nme, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(self, function_type='pfl', zone_name=self.label_select, variable_name='coords', expression=exp, required=req, symbols=sym, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotLineFormula -> %s" % str(result)) self.mdl.setFormula(self.label_select, str(result)) self.pushButtonFormula.setToolTip(result) self.pushButtonFormula.setStyleSheet("background-color: green")
def slotVelocity(self): """ Formula for velocity """ exp, req, sym = self.mdl.getFormulaComponents(self.zone, self.currentid, 'velocity') if not exp: exp = "u = 0.;\nv = 0.;\nw = 0.;" exa = "u = 3.0;\nv = 1.0;\nw = 0.0;\n" name = 'velocity_%s' % (str(self.currentid)) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent = self, function_type = 'ini', zone_name = zone_name, variable_name = name, expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormula(self.zone, self.currentid, 'velocity', result) self.pushButtonVelocity.setStyleSheet("background-color: green") self.pushButtonVelocity.setToolTip(result)
def slotFormulaPorosity(self): """ User formula for density """ label, name, local = self.modelPorosity.getItem(self.entriesNumber) choice = self.mdl.getPorosityModel(name) fname = 'porosity' if choice == 'anisotropic': fname += '+tensorial_porosity' exp, req, sca, sym = self.mdl.getPorosityFormulaComponents(name) if exp == None: exp = self.getDefaultPorosityFormula(choice) exa = """#example: \n""" + self.mdl.getDefaultPorosityFormula(choice) dialog = QMegEditorView(parent=self, function_type='vol', zone_name=label, variable_name=fname, expression=exp, required=req, symbols=sym, known_fields=sca, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaPorosity -> %s" % str(result)) self.mdl.setPorosityFormula(name, str(result)) self.pushButtonPorosity.setToolTip(result) self.pushButtonPorosity.setStyleSheet("background-color: green")
def slotHydraulicHeadFormula(self): """ """ exp = self.__boundary.getHydraulicHeadFormula() exa = """#example: """ req = [("H", "hydraulic head")] 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='hydraulic_head', expression=exp, required=req, symbols=sym, condition='dirichlet_formula', examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotHydraulicHeadFormula -> %s" % str(result)) self.__boundary.setHydraulicHeadFormula(str(result)) self.pushButtonHydraulicHead.setStyleSheet( "background-color: green") self.pushButtonHydraulicHead.setToolTip(result)
def slotScalar(self): """ Formula for species """ exp, req, sym = self.mdl.getScalarFormulaComponents(self.zone, self.currentid, self.currentScalar) if not exp: exp = self.currentScalarLabel + """ = 0;\n""" exa = """#example: """ name = self.currentScalarLabel zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent = self, function_type = 'ini', zone_name = zone_name, variable_name = name, expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormulaScalar(self.zone, self.currentid, self.currentScalar, result) self.pushButtonScalar.setStyleSheet("background-color: green") self.pushButtonScalar.setToolTip(result)
def slotThermalFormula(self): """ Input the initial formula of thermal scalar """ exa = """#example: """ exp, req, sym = self.mdl.getThermalFormulaComponents( self.zone, self.currentId, self.th_sca_name) name = 'enthalpy_%s' % (str(self.currentId)) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent=self, function_type='src', zone_name=zone_name, variable_name=name, expression=exp, required=req, symbols=sym, examples=exa, source_type='thermal_source_term') if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaThermal -> %s" % str(result)) self.mdl.setThermalFormula(self.zone, self.currentId, self.th_sca_name, str(result)) self.pushButtonThermal.setToolTip(result) self.pushButtonThermal.setStyleSheet("background-color: green")
def __slotVelocityFormula(self): """ """ exp = self.__boundary.getVelocity(self.__currentField) c = self.__boundary.getVelocityChoice(self.__currentField) if c == 'norm_formula': req = [('u_norm', 'Norm of the velocity')] exa = "u_norm = 1.0;" elif c == 'flow1_formula': req = [('q_m', 'Mass flow rate')] exa = "q_m = 1.0;" if c == 'norm_formula': 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')] elif c == 'flow1_formula': 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 (name, val) in self.notebook.getNotebookList(): sym.append((name, 'value (notebook) = ' + str(val))) dialog = QMegEditorView(parent = self, function_type = "bnd", zone_name = self.__boundary._label, variable_name = "velocity_"+str(self.__currentField), 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(self.__currentField, result) self.pushButtonVelocityFormula.setToolTip(result) self.pushButtonVelocityFormula.setStyleSheet("background-color: green")
def __slotFormula(self): """ Run formula editor. """ exp = self.__boundary.getALEFormula() c = self.__boundary.getALEChoice(); if c == "fixed_velocity": if not exp: exp = 'mesh_velocity[0] = 0.;\nmesh_velocity[1] = 0.;\nmesh_velocity[2] = 0.;' req = [('mesh_velocity[0]', 'Fixed velocity of the mesh'), ('mesh_velocity[1]', 'Fixed velocity of the mesh'), ('mesh_velocity[2]', 'Fixed velocity of the mesh')] exa = 'mesh_velocity[0] = 0.;\nmesh_velocity[1] = 0.;\nmesh_velocity[2] = 1.;' elif c == "fixed_displacement": if not exp: exp = 'mesh_displacement[0] = 0.;\nmesh_displacement[1] = 0.;\nmesh_displacement[2] = 0.;' req = [('mesh_displacement[0]', 'Fixed displacement of the mesh'), ('mesh_displacement[1]', 'Fixed displacement of the mesh'), ('mesh_displacement[2]', 'Fixed displacement of the mesh')] exa = 'mesh_displacement[0] = 0.;\nmesh_displacement[1] = 0.;\nmesh_displacement[2] = 1.;' 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 = 'mesh_velocity', expression = exp, required = req, symbols = sym, condition = c, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaMobileMeshBoundary -> %s" % str(result)) self.__boundary.setFormula(str(result)) self.pushButtonMobilBoundary.setStyleSheet("background-color: green") self.pushButtonMobilBoundary.setToolTip(result)
def slotEnergy(self): """ Formula for energy """ exp, req, sym = self.mdl.getFormulaComponents(self.zone, self.currentid, 'enthalpy') th_sca_label = self.mdl.getEnergyModel(self.zone, self.currentid) if not exp: if str(th_sca_label) == 'enthalpy': exp = th_sca_label + """ = 50000.0;\n""" elif str(th_sca_label) == 'temperature': exp = th_sca_label + """ = 293.15;\n""" elif ('enthalpy' in exp and str(th_sca_label) == 'temperature'): exp = th_sca_label + """ = 293.15;\n""" elif ('temperature' in exp and str(th_sca_label) == 'enthalpy'): exp = th_sca_label + """ = 50000.0;\n""" exa = """#example: """ name = 'enthalpy_%s' % (str(self.currentid)) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break dialog = QMegEditorView(parent = self, function_type = 'ini', zone_name = zone_name, variable_name = name, expression = exp, required = req, symbols = sym, examples = exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotFormulaRho -> %s" % str(result)) self.mdl.setFormula(self.zone, self.currentid, 'enthalpy', result) self.pushButtonEnergy.setStyleSheet("background-color: green") self.pushButtonEnergy.setToolTip(result)
def slotThermalFormula(self): """ """ name = self.thermal variable_name = name thermal_type, convert = self.__get_thermal_type__() if convert: name = convert exp = self.__boundary.getScalarFormula(self.thermal, thermal_type) exa = """#example: """ if thermal_type == 'dirichlet_formula': req = [(name, str(name))] elif thermal_type == 'neumann_formula': req = [("flux", "flux")] elif thermal_type == 'exchange_coefficient_formula': req = [(name, str(name)), ("hc", "heat coefficient")] 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))) c = self.__boundary.getScalarChoice(variable_name) dialog = QMegEditorView(parent=self, function_type='bnd', zone_name=self.__boundary._label, variable_name=name, expression=exp, required=req, symbols=sym, condition=c, examples=exa) if dialog.exec_(): result = dialog.get_result() log.debug("slotThermalFormula -> %s" % str(result)) self.__boundary.setScalarFormula(self.thermal, thermal_type, str(result)) self.pushButtonThermal.setStyleSheet("background-color: green") self.pushButtonThermal.setToolTip(exp)
def slotTurbulenceFormula(self): """ INPUT user formula """ turb_model = self.turb.getTurbulenceModel() exa = """#example \n""" + self.init.getDefaultTurbFormula(turb_model) exp, req, sym = self.init.getTurbFormulaComponents( self.zone, turb_model) zone_name = None for zone in self.volzone.getZones(): if str(zone.getCodeNumber()) == self.zone: zone_name = zone.getLabel() break if turb_model in ('k-epsilon', 'k-epsilon-PL'): turb_vname = 'turbulence_ke' elif turb_model in ('Rij-epsilon', 'Rij-SSG'): turb_vname = 'turbulence_rije' elif turb_model == 'Rij-EBRSM': turb_vname = 'turbulence_rij_ebrsm' elif turb_model == 'v2f-BL-v2/k': turb_vname = 'turbulence_v2f' elif turb_model == 'k-omega-SST': turb_vname = 'turbulence_kw' elif turb_model == 'Spalart-Allmaras': turb_vname = 'turbulence_spalart' dialog = QMegEditorView(parent=self, function_type="ini", zone_name=zone_name, variable_name=turb_vname, 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, str(result)) self.pushButtonTurbulence.setStyleSheet("background-color: green") self.pushButtonTurbulence.setToolTip(result)
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))) c = self.__b.getElecScalarChoice(self.potVect) dialog = QMegEditorView(parent=self, function_type='bnd', zone_name=self.__boundary._label, variable_name=self.potVect, expression=exp, required=req, symbols=sym, condition=c, 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")