# -*- coding: iso-8859-1 -*- # #------------------------------------------------------------------------------- # Code_Saturne version 1.3 # ------------------------ # # # This file is part of the Code_Saturne User Interface, element of the # Code_Saturne CFD tool. # # Copyright (C) 1998-2007 EDF S.A., France # # contact: saturne-support@edf.fr # # The Code_Saturne User Interface is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # The Code_Saturne User Interface is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with the Code_Saturne Kernel; if not, write to the # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # #------------------------------------------------------------------------------- """ This module defines the Page in which the user defines the physical options of the treated case. This module contains the following classes and function: - AnalysisFeaturesModel - AnalysisFeaturesView - PageText - AnalysisFeaturesTestCase """ #------------------------------------------------------------------------------- # Library modules import #------------------------------------------------------------------------------- import unittest, Tix from Tkconstants import * #------------------------------------------------------------------------------- # Application modules import #------------------------------------------------------------------------------- from Base.Common import * import Base.Toolbox as Tool import Base.Dialog as Dialog import Base.TkPage as TkPage from Base.XMLmodel import configureTree from Turbulence import TurbulenceModel from ThermalScalar import ThermalScalarModel from Lagrangian import LagrangianModel from GasCombustion import GasCombustionModel from CoalCombustion import CoalCombustionModel from ElectricalModels import ElectricalModel #------------------------------------------------------------------------------- # Analysis Features View class #------------------------------------------------------------------------------- class AnalysisFeaturesView(TkPage.Page): """ Class to open Analysis Features Page. """ def _dependsPages(self, name): """ Construction of the list of dependencies Pages. """ self.case[name]['depends'] = ['models/turbul', 'models/therma', 'models/flame', 'models/species', 'models/pucoal', 'models/joule', 'models/radiat', 'models/initia', 'proper/refdat', 'bounda/dynami'] def _tkControlVariables(self): """ Tkinter variables declaration. """ self.multiphase = Tix.StringVar() self.flame = Tix.StringVar() self.coal = Tix.StringVar() self.fouling = Tix.StringVar() self.joule = Tix.StringVar() def _pageControl(self): """ Xml node declaration and supplementary default value settings. """ self.lagr = LagrangianModel(self.case) self.turb = TurbulenceModel(self.case) self.therm = ThermalScalarModel(self.case) self.gas = GasCombustionModel(self.case) self.pcoal = CoalCombustionModel(self.case) self.elect = ElectricalModel(self.case) def getFlowTreatment(self, event=None): """ Update the multi-phase flow treatment. """ self.stbar.busy() if self.multiphase.get() == 'lagrangian': self.myTree.tree.hlist.show_entry('lagran') self.lagr.setLagrangianModel('one_way') self.b[2].enable('coal_lagr') else: self.myTree.setBlankFile('lagran/models') self.myTree.setBlankFile('lagran/statis') self.myTree.closeSingleFolder('lagran') self.myTree.tree.hlist.hide_entry('lagran') self.lagr.setLagrangianModel('off') self.b[2].disable('coal_lagr') self.stbar.idle() def activateButton(self): """ Change to NORMAL the state of the reactive flow OptionMenu buttons. """ for i in range(1,4): self.b[i].configure(state=NORMAL) def disableButton(self): """ Change to DISABLED the state of the reactive flow OptionMenu buttons. """ for i in range(1,4): self.b[i].configure(state=DISABLED) def resetTree(self, event=None): """ Set the default configuration of the Hlist of the Tree. """ if self.myTree.tree.getmode('models') == 'close': self.myTree.tree.hlist.show_entry('models/therma') self.myTree.tree.hlist.hide_entry('models/flame') self.myTree.tree.hlist.hide_entry('models/species') self.myTree.tree.hlist.hide_entry('models/pucoal') self.myTree.tree.hlist.hide_entry('models/joule') self.myTree.tree.hlist.hide_entry('models/radiat') def getGasCombustionModel(self, event=None): """ Binding method for gas combustion models. """ self.stbar.busy() self.resetTree() self.activateButton() self.gas.setGasCombustionModel(self.flame.get()) model = self.gas.getGasCombustionModel() if model != 'off': #TODO : faire une popup qu previent que le scalaire thermique est perdu self.therm.turnOffThermalScalar() self.disableButton() self.b[1].configure(state=NORMAL) if self.myTree.tree.getmode('models') == 'close': self.myTree.tree.hlist.hide_entry('models/therma') self.myTree.tree.hlist.show_entry('models/radiat') self.myTree.tree.hlist.show_entry('models/flame') self.myTree.setBlankFile('models/therma') self.stbar.idle() def getPulverizedCoal(self, event=None): """ Binding method for pulverized coal combustion models """ self.stbar.busy() self.resetTree() self.activateButton() self.pcoal.setCoalCombustionModel(self.coal.get()) model = self.pcoal.getCoalCombustionModel() if model == 'coal_lagr': self.b[0].disable('single_phase') else: self.b[0].enable('single_phase') if model != 'off': # TODO : faire une popup qui previent que le scalaire thermique est perdu self.pcoal.createModel() self.therm.turnOffThermalScalar() self.disableButton() self.b[2].configure(state=NORMAL) if self.myTree.tree.getmode('models') == 'close': self.myTree.tree.hlist.hide_entry('models/therma') self.myTree.tree.hlist.show_entry('models/radiat') self.myTree.tree.hlist.show_entry('models/species') self.myTree.tree.hlist.show_entry('models/pucoal') self.myTree.setBlankFile('models/therma') self.stbar.idle() def getJouleEffect(self, event=None): """ Binding method for electrical models """ self.stbar.busy() self.resetTree() self.activateButton() self.elect.setElectricalModel(self.joule.get()) model = self.elect.getElectricalModel() if model != 'off': #TODO : faire une popup qu previent que le scalaire thermique est perdu self.therm.turnOffThermalScalar() self.disableButton() self.b[3].configure(state=NORMAL) if self.myTree.tree.getmode('models') == 'close': self.myTree.tree.hlist.hide_entry('models/therma') self.myTree.tree.hlist.show_entry('models/radiat') self.myTree.tree.hlist.show_entry('models/joule') self.myTree.setBlankFile('models/therma') self.stbar.idle() def _createWidgets(self): """ Create the Page layout. """ t = PageText() lf = [0]*4 self.b = [0]*4 for i,t1, t2 in [(0, t.MULTIPHASE_TITLE, t.MSG_MULTIPHASE ), (1, t.GAS_COMBUSTION, t.MSG_COMBUSTION ), (2, t.COAL_COMBUSTION, t.MSG_COMBUSTION ), (3, t.ELECTRICAL_MODELS, t.MSG_ELECTRICAL )]: lf[i] = Tix.LabelFrame(self.myPage, bd=2, label=t1, relief=FLAT) lf[i].label.config(font=fT) lf[i].pack(side=TOP, fill=X, padx=10, pady=10) self.b[i] = Tix.OptionMenu(lf[i].frame, options='menubutton.width 45') self.b[i].menubutton.config(bd=2, relief=RAISED) self.balloon.bind_widget(self.b[i], statusmsg=t2, balloonmsg=t.KEYWORD+"IPPMOD") self.b[i].grid(row=0, column=0, pady=15, padx=10) self.b[0].add_command('single_phase', label=t.SINGLEPHASE) self.b[0].add_command('lagrangian', label=t.LAGRANGIAN) self.b[0].config(variable=self.multiphase, command=self.getFlowTreatment) self.balloon.bind_widget(self.b[0], statusmsg=t.MSG_MULTIPHASE, balloonmsg=t.KEYWORD+"IILAGR") self.b[1].add_command('off', label=t.NO_COMBUSTION) self.b[1].add_separator('') self.b[1].add_command('ebu', label=t.EBU_TITLE) self.b[1].add_command('d3p', label=t.DIFF_TITLE) self.b[1].config(variable=self.flame, command=self.getGasCombustionModel) self.b[2].add_command('off', label=t.NO_COMBUSTION) self.b[2].add_separator('') self.b[2].add_command('coal_homo', label=t.COAL_HOMOGENEOUS) self.b[2].add_command('coal_lagr', label=t.COAL_LAGRANGIAN) self.b[2].config(variable=self.coal, command=self.getPulverizedCoal) self.b[3].add_command('off', label=t.NO_ELECTRICAL) self.b[3].add_separator('') self.b[3].add_command('joule', label=t.JOULE_TITLE) self.b[3].add_command('arc', label=t.ARCELEC_TITLE) self.b[3].config(variable=self.joule, command=self.getJouleEffect) def _initializeWidgets(self): """ Extract resquested informations from XML document. This informations are used to initialize the widgets. For this page default values of all widgets are necessary included in the XML file. """ # Multi-phase Flow # #** -->For first version of IHM : self.b[0].config(value='single_phase') self.b[0].disable('lagrangian') self.b[1].config(value='off') self.b[1].disable('ebu') self.b[1].disable('d3p') self.b[3].config(value='off') self.b[3].disable('joule') self.b[3].disable('arc') #** <-- for first version of IHM. # Multi-phase flow # if self.lagr.getLagrangianModel() == 'off': self.b[0].config(value='single_phase') self.b[2].disable('coal_lagr') else: self.b[0].config(value='lagrangian') self.b[2].enable('coal_lagr') if self.pcoal.getCoalCombustionModel() == 'coal_lagr': self.b[0].config(value='lagrangian') self.b[0].disable('single_phase') # Compatibility between turbulence model and multi-phases flow model # if self.turb.getTurbulenceModel() not in \ ('off', 'k-epsilon', 'k-epsilon-PL', 'Rij-epsilon', 'Rij-SSG', 'v2f-phi', 'k-omega-SST'): self.b[0].config(value='single_phase', state=DISABLED) # Compatibility between turbulence model and reactive flow models # if self.turb.getTurbulenceModel() not in ('k-epsilon', 'k-epsilon-PL', 'Rij-epsilon', 'Rij-SSG', 'v2f-phi', 'k-omega-SST'): for var in (self.flame, self.coal, self.joule): var.set('off') self.b[1].disable('ebu') self.b[1].disable('d3p') self.b[3].disable('joule') self.b[3].disable('arc') self.b[2].disable('coal_homo') self.b[2].disable('coal_lagr') for i, var in [(1, self.flame), (2, self.coal ), (3, self.joule)]: self.b[i].config(state=DISABLED) # Update the Tkinter variables # for mdl, var in [(self.gas.getGasCombustionModel(), self.flame), (self.pcoal.getCoalCombustionModel(), self.coal ), (self.elect.getElectricalModel(), self.joule)]: var.set(mdl) # If one model is turned on, the others are turned off # if (self.flame.get(), self.coal.get(), self.joule.get()) != \ ('off', 'off', 'off'): for i, var in [(1, self.flame), (2, self.coal ), (3, self.joule)]: if var.get() == 'off': self.b[i].config(state=DISABLED) # Update the Tree files and folders # configureTree(self.myTree.tree, self.case) #------------------------------------------------------------------------------- # Text and messages for this page #------------------------------------------------------------------------------- class PageText: """ Storage of all texts and messages for this page. """ def __init__(self): # 1) Texts # if Tool.GuiParam.lang == 'fr': self.ARCELEC_TITLE = "Arc électrique (effet Joule et forces de Laplace)" self.COAL_COMBUSTION = "Combustion du Charbon Pulvérisé" self.COAL_HOMOGENEOUS = "Approche homogène" self.COAL_LAGRANGIAN = "Couplage Eulérien/Lagrangien" self.DIFF_TITLE = "Flamme de diffusion en chimie complète rapide à 3 points" self.EBU_TITLE = "Flamme de prémélange en Eddy Break-Up" self.ELECTRICAL_MODELS = "Modèles électriques" self.GAS_COMBUSTION = "Modèles de combustion gaz" self.JOULE_TITLE = "Module effet Joule" self.KEYWORD = "Mot clé Code_Saturne : " self.LAGRANGIAN = "Écoulement multiphasique Eulérien/Lagangien" self.MULTIPHASE_TITLE = "Traitement multiphasique" self.NO_COMBUSTION = "Non" self.NO_ELECTRICAL = "Non" self.SINGLEPHASE = "Écoulement monophasique" else: self.ARCELEC_TITLE = "Joule Effect and Lorentz Forces" self.COAL_COMBUSTION = "Pulverized Coal Combustion" self.COAL_HOMOGENEOUS = "Homogeneous approach" self.COAL_LAGRANGIAN = "Gaseous phase coupling with Lagrangian coal transport" self.DIFF_TITLE = "Equilibrium chemistry diffusion flame (Presumed PDF)" self.EBU_TITLE = "Premixed flame (Eddy Break-Up)" self.ELECTRICAL_MODELS = "Electrical Models" self.GAS_COMBUSTION = "Gas Combustion Modelling" self.JOULE_TITLE = "Joule Effect" self.KEYWORD = "Code_Saturne key word: " self.LAGRANGIAN = "Eulerian/Lagangian Multi-phase Treatment" self.MULTIPHASE_TITLE = "Multi-phase Treatment" self.NO_COMBUSTION = "Off" self.NO_ELECTRICAL = "Off" self.SINGLEPHASE = "Single Phase Flow" # 2) Messages # if Tool.GuiParam.lang == 'fr': self.MSG_COMBUSTION = "Sélectionner le modèle de combustion" self.MSG_ELECTRICAL = "Sélectionner le modèle électrique" self.MSG_MULTIPHASE = "Sélectionner le type d'écoulement à traiter" else: self.MSG_COMBUSTION = "Select the combustion modelling" self.MSG_ELECTRICAL = "Select the electrical model" self.MSG_MULTIPHASE = "Select the flow treatment" #------------------------------------------------------------------------------- # End #-------------------------------------------------------------------------------