# -*- 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 contains t=he following classes and function: - BoundaryConditionsModel - MultiSelect - BoundaryConditionsView - PageText """ #------------------------------------------------------------------------------- # Library modules import #------------------------------------------------------------------------------- import sys import 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.XMLvariables import Variables #------------------------------------------------------------------------------- # Multi-selection string #------------------------------------------------------------------------------- _MULTISEL = "************" #------------------------------------------------------------------------------- # Boundary Conditions model class #------------------------------------------------------------------------------- class BoundaryConditionsModel: """ Class to open Variable Boundary Conditions Page. """ def __init__(self, case): """ Constructor """ self.case = case # Xml node declaration self.node_bc = self.case.xmlInitNode('boundary_conditions') self.node_def = self.node_bc.xmlInitNode('boundary_definition') self.node_models = self.case.xmlGetNode('thermophysical_models') self.node_veloce = self.node_models.xmlGetNode('velocity_pressure') self.node_turb = self.node_models.xmlGetNode('turbulence', 'model') t = PageText() # Definition of boundaries types (same as BoundaryDef.py) # self.typeList = {'wall': t.WALL , 'inlet': t.INLET } # Definition of color (same as BoundaryDef.py) # self.typeColor = {'wall': "blue" , 'inlet': "red" } # coal combustion # import Pages.CoalCombustion as CoalCombustion coalModel = CoalCombustion.CoalCombustionModel(self.case) self.isCoalCombustion = False if coalModel.getCoalCombustionModel() != "off": self.isCoalCombustion = True self.initCoalBoundConditions() def initCoalBoundConditions(self): # velocity pressure choice for coal inlet : "flow1" for (label, type) in self.getBoundConditions(): if type == 'inlet': nodeInlet = self.node_bc.xmlGetChildNode(type, label=label) nodeVp = nodeInlet.xmlGetNode("velocity_pressure", "choice") if ((nodeVp['choice'] != "flow1") and (nodeVp['choice'] != "coal_flow")): nodeVp['choice'] = "flow1" self.getVelocityFlow(type, label) self.getTemperature(type, label) def getBoundConditions(self): """ Building list of boundaries definition """ boundList =[] for type in self.typeList.keys(): nodeList = self.node_def.xmlGetNodeList(type) for node in nodeList: label = node['label'] if not self.node_bc.xmlGetChildNode(type, label=label): self.setBoundConditions(type, label) if(label,type) not in boundList: boundList.append((label,type)) return boundList def setBoundConditions(self, type, label): """ Building boundaries nature balises """ node = self.node_bc.xmlInitNode(type, label=label) node.xmlInitNode('velocity_pressure', 'choice') if type == 'inlet':node.xmlInitNode('turbulence', 'choice') node.xmlInitNode('scalar', 'choice', 'label', 'type') def getRef(self, type, label): """ Building list of references for identical groups (type, label) """ node = self.node_def.xmlGetNodeList(type, label=label) ref = "" for n in node: valref = n.xmlGetIntList('reference') l = len(valref) if l == 1: ref = str(valref[0]) else: val = "" for i in range(0,l): val = val + " " +str(valref[i]) ref = ref + val return ref def getInfoTurbulence(self): """ Building list of references for identical groups (type, label) """ from Turbulence import TurbulenceModel turblist = TurbulenceModel(self.case).getTurbulenceVariable() del TurbulenceModel return turblist def getChoiceDefil(self, type, label): """ Check XML file info on choice of velocities's boundary conditions for wall. """ if type != 'wall': msg = "There is an error in the use of getChoiceDefil.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlInitNode('velocity_pressure', 'choice') if n['choice'] == "": n['choice'] = "off" choice = n['choice'] return choice def getVelocityChoice(self, type, label): """ Check XML file info and restitue for velocities's boundary conditions. """ if type not in ('inlet', 'wall'): msg = "There is an error in the use of getVelocityChoice.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('velocity_pressure', 'choice') choice = n['choice'] return choice def getWallVelocity(self, label): """ Check XML file info and restitue for velocities's boundary conditions. """ node = self.node_bc.xmlGetChildNode('wall', label=label) n = node.xmlGetNode('velocity_pressure', 'choice') if n['choice'] == 'on': u = n.xmlGetNode('dirichlet', name='velocity_U').xmlGetTextNode() v = n.xmlGetNode('dirichlet', name='velocity_V').xmlGetTextNode() w = n.xmlGetNode('dirichlet', name='velocity_W').xmlGetTextNode() else: raise ValueError, "getWallVelocity choice error" return u, v, w def getInletVelocity(self, label): """ Check XML file info and restitue for velocities's boundary conditions. """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure', 'choice') if self.getVelocityChoice('inlet', label) == 'dirichlet': u = n.xmlGetNode('dirichlet', name='velocity_U').xmlGetTextNode() v = n.xmlGetNode('dirichlet', name='velocity_V').xmlGetTextNode() w = n.xmlGetNode('dirichlet', name='velocity_W').xmlGetTextNode() else: raise ValueError, "getInletVelocity choice error" return u, v, w def getVelocityFlow(self, type, label): """ Put choice dirichlet for velocity in xmlfile """ if type not in ('inlet', 'wall'): msg = "There is an error in the use of setChoiceVelocity.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('velocity_pressure', 'choice') if self.getVelocityChoice(type, label) == 'flow1' or self.getVelocityChoice(type, label) == 'coal_flow': flow = n.xmlGetChildDouble('flow1') if flow == None: flow = 0.0 self.setVelocityFlow(label, flow) return flow def getTemperature(self, type, label): """ Put choice dirichlet for velocity in xmlfile """ if type not in ('inlet', 'wall'): msg = "There is an error in the use of getTemperature.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('velocity_pressure', 'choice') temperature = n.xmlGetChildDouble('temperature') if temperature == None: temperature = 0.0 self.setTemperature(label, temperature) return temperature def deleteCoalFlow(self, coal, nbCoals): """ delete coal_flow with name = coaln """ nodeList = self.node_bc.xmlGetChildNodeList('inlet') for node in nodeList: n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) n2 = n.xmlGetNode('coal_flow', name="coal"+ num) # delete coal if n2: n2.xmlRemoveNode() # rename other coals for icoal in range(coal+1,nbCoals): self.renameCoalFlow( icoal) def renameCoalFlow(self, coal): """ coaln become coaln-1 """ nodeList = self.node_bc.xmlGetChildNodeList('inlet') for node in nodeList : n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) newNum = '%2.2i' % coal n2 = n.xmlGetNode('coal_flow', name="coal"+ num) if n2: n2['name'] = "coal"+newNum def deleteClassRatio(self, coal, classe, nbClasses): """ delete ratio with name = classe """ nodeList = self.node_bc.xmlGetChildNodeList('inlet') for node in nodeList : n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) n2 = n.xmlGetNode('coal_flow', name="coal"+num) num1 = '%2.2i' % (classe+1) if n2: nratio = n2.xmlGetChildNode('ratio', name="class"+num1) # delete current class if nratio : nratio.xmlRemoveNode() # rename other classes for iclass in range(classe+1,nbClasses): self.renameClassRatio(coal, iclass) def renameClassRatio(self, coal, classe): """ classn become classn-1 """ nodeList = self.node_bc.xmlGetChildNodeList('inlet') for node in nodeList : n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) newNum = '%2.2i' % coal n2 = n.xmlGetNode('coal_flow', name="coal"+num) if n2: num = '%2.2i' % (classe+1) nratio = n2.xmlGetChildNode('ratio', name="class"+num) if nratio: nratio['name'] = "class"+newNum def updateRatio(self, coal): nodeList = self.node_bc.xmlGetChildNodeList('inlet') for node in nodeList : n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) ncoal = n.xmlGetNode('coal_flow', name="coal"+num) if ncoal: classList = ncoal.xmlGetNodeList('ratio') nbClass = len(classList) lastValue = 0 for numClass in range(0, nbClass -1): lastValue += self.getClassCoalRatio(node['label'], coal, numClass) lastValue = 100 - lastValue self.setClassCoalRatio( node['label'], lastValue, coal, nbClass) def getCoalTemperature(self, label, coal): """ Put choice dirichlet for velocity in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) n2 = n.xmlInitNode('coal_flow', name="coal"+ num) temperature = n2.xmlGetDouble('temperature') if temperature == None: temperature = 0.0 self.setCoalTemperature(label, temperature, coal) return temperature def getCoalFlow(self, label, coal): """ Put choice dirichlet for velocity in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) n2 = n.xmlInitNode('coal_flow', name="coal"+num) flow = n2.xmlGetDouble('flow1') if flow == None: flow = 0.0 self.setCoalFlow(label, flow, coal) return flow def getClassCoalRatio(self, label, coal, classe): """ Put choice dirichlet for velocity in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure', 'choice') num = '%2.2i' % (coal+1) n2 = n.xmlInitNode('coal_flow', name="coal"+num) num = '%2.2i' % (classe+1) nratio = n2.xmlGetChildNode('ratio', name="class"+num) if nratio == None: nratio = n2.xmlInitNode('ratio', name="class"+num) ratio = 0.0 self.setClassCoalRatio(label, ratio, coal, classe) else: ratio = nratio.xmlGetTextNode() return ratio def getTurbulenceChoice(self, type, label): """ Check XML file info and restitue for velocities's boundary conditions. """ if type != 'inlet': msg = "There is an error in the use of setChoiceVelocity.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('turbulence', 'choice') choice = n['choice'] return choice def getHydraulicDiameter(self, type, label): """ Put choice dirichlet for velocity in xmlfile """ if type != 'inlet': msg = "There is an error in the use of setChoiceVelocity.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('turbulence', 'choice') if self.getTurbulenceChoice(type, label) == 'hydraulic_diameter' or self.getTurbulenceChoice(type, label) == 'turbulent_intensity': d = n.xmlGetDouble('hydraulic_diameter') return d def getTurbulentIntensity(self, type, label): """ Put choice dirichlet for velocity in xmlfile """ if type != 'inlet': msg = "There is an error in the use of setChoiceVelocity.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('turbulence', 'choice') if self.getTurbulenceChoice(type, label) == 'turbulent_intensity': i = n.xmlGetDouble('turbulent_intensity') if not i: i = 2.0 self.setTurbulentIntensity(label, i) return i def setChoiceDefil(self, label, choice): """ Put value of velocity's component n in xmlfile """ node = self.node_bc.xmlGetChildNode('wall', label=label) n = node.xmlInitNode('velocity_pressure', 'choice') if n['choice'] == "": n['choice'] = "off" if n['choice'] == "off" and choice == "on": n['choice'] = "on" if not n.xmlGetNodeList('dirichlet'): n.xmlInitNode('dirichlet', name='velocity_U').xmlSetTextNode(0.0) n.xmlInitNode('dirichlet', name='velocity_V').xmlSetTextNode(0.0) n.xmlInitNode('dirichlet', name='velocity_W').xmlSetTextNode(0.0) elif choice == "off": n['choice'] = "off" def setVelocityFlow(self, label, var): """ Put value of flow in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure') if n: n.xmlSetData('flow1',var) def setTemperature(self, label, var): """ Put value of flow in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure') if n: n.xmlSetData('temperature',var) def setCoalFlow(self, label, var, coal): """ Put value of flow in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure') num = '%2.2i' % (coal+1) n2 = n.xmlGetNode('coal_flow', name="coal"+num) if n2: n2.xmlSetData('flow1',var) def setCoalTemperature(self, label, var, coal): """ Put value of flow in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure') num = '%2.2i' % (coal+1) n2 = n.xmlGetNode('coal_flow', name="coal"+ num) if n2: n2.xmlSetData('temperature',var) def setClassCoalRatio(self, label, var, coal, classe): """ Put value of flow in xmlfile """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('velocity_pressure') num = '%2.2i' % (coal+1) n2 = n.xmlGetNode('coal_flow', name="coal"+ num) num = '%2.2i' % (classe+1) nratio = n2.xmlInitNode('ratio', name="class"+ num) if nratio: nratio.xmlSetTextNode(str(var)) def setInletWallVelocity(self, type, label, component, valvit): """ Put value of velocity's component n in xmlfile """ node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('velocity_pressure', 'choice') if n['choice'] == "dirichlet" or n['choice'] == "on": n.xmlGetNode('dirichlet', name=component).xmlSetTextNode(valvit) def setChoiceVelocity(self, type, label, choice): """ Put value of velocity's component n in xmlfile """ if type not in ('inlet', 'wall'): msg = "There is an error in the use of setChoiceVelocity.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('velocity_pressure', 'choice') n['choice'] = choice def setHydraulicDiameter(self, label, var): """ Put value of hydraulic diameter for calculation of turbulence in xml file """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('turbulence', 'choice') #n = node.xmlGetNode('turbulence', choice='hydraulic_diameter') if n['choice'] == 'hydraulic_diameter' or n['choice'] == 'turbulent_intensity': n.xmlSetData('hydraulic_diameter',var) def setTurbulentIntensity(self, label, var): """ Put value of hydraulic diameter for calculation of turbulence in xml file """ node = self.node_bc.xmlGetChildNode('inlet', label=label) n = node.xmlGetNode('turbulence', choice='turbulent_intensity') if n: n.xmlSetData('turbulent_intensity',var) def setChoiceTurbu(self, type, label, choice): """ Put value of velocity's component n in xmlfile """ if type !='inlet': msg = "There is an error in the use of setChoiceVelocity.\n" raise ValueError, msg node = self.node_bc.xmlGetChildNode(type, label=label) n = node.xmlGetNode('turbulence', 'choice') n['choice'] = choice #------------------------------------------------------------------------------- # Hlist multi-selection class #------------------------------------------------------------------------------- class MultiSelect: """ This class is design in order to manage the storage of the selected items in the Hlist. """ def __init__(self, Hlist, typeList, typeColor): """ Constructor """ self.Hlist = Hlist self.typeList = typeList self.typeColor = typeColor def _initList(self): """ For each mouse selection we do reinitialize all lists. """ self.labelL = [] self.typeL = [] # self.refL = [] # self.groupL = [] def boundaryInfo(self, entry): """ Return info from the argument entry. """ # Here we must call the tk function directly without passing in # Tix.py, because of a bug in tix8.1 in the Hlist.item_cget function # h = self.Hlist label = h.tk.call(h, 'item', 'cget', entry, 0, '-text') type = h.tk.call(h, 'item', 'cget', entry, 1, '-text') # ref = h.tk.call(h, 'item', 'cget', entry, 2, '-text') # group = h.tk.call(h, 'item', 'cget', entry, 3, '-text') # if ref == "--": ref ="" # if group == "--": group ="" for key in self.typeList.keys(): if self.typeList[key] == type: type = key # return label, type, ref, group return label, type def setItems(self, entriesL): """ Store values when a new selection is done. """ self._initList() for entry in entriesL: label, type = self.boundaryInfo(entry) self.labelL.append(label) self.typeL.append(type) def backgroundColor(self): """ Find the right color for the selection background. """ type = self.typeL[0] for i in self.typeL: if type == i: iok = 1 else: iok = 0 if iok: self.Hlist.config(selectbackground=self.typeColor[type]) else: self.Hlist.config(selectbackground=wm['selectbackground']) def widgetText(self): """ Find the right texts for the widget layout. """ label, type = self.labelL[0], self.typeL[0] for i in self.labelL: if label != i: label = _MULTISEL for i in self.typeL: if type != i: type = _MULTISEL return label, type #------------------------------------------------------------------------------- # Main class #------------------------------------------------------------------------------- class BoundaryConditionsView(TkPage.Page): """ Class to open Variable Boundary Conditions Page. """ def _tkControlVariables(self): """ Tkinter variables declaration. """ self.choiceveloce = Tix.StringVar() self.choiceCoalFlow = Tix.StringVar() self.choiceturbu = Tix.StringVar() self.rc_on_off = Tix.StringVar() self.U = Tix.DoubleVar() self.V = Tix.DoubleVar() self.W = Tix.DoubleVar() self.flow = Tix.DoubleVar() self.diam = Tix.DoubleVar() self.intens = Tix.DoubleVar() self.k = Tix.DoubleVar() self.eps = Tix.DoubleVar() self.R11 = Tix.DoubleVar() self.R22 = Tix.DoubleVar() self.R33 = Tix.DoubleVar() self.R12 = Tix.DoubleVar() self.R13 = Tix.DoubleVar() self.R23 = Tix.DoubleVar() self.phi = Tix.DoubleVar() self.fb = Tix.DoubleVar() self.omega = Tix.DoubleVar() self.wall_heating = Tix.StringVar() self.valref = Tix.StringVar() # # Coal self.temperature = Tix.DoubleVar() self.coalFlow = [] self.airFlow = Tix.DoubleVar() self.coal1Flow = Tix.DoubleVar() self.coalFlow.append(self.coal1Flow) self.coal2Flow = Tix.DoubleVar() self.coalFlow.append(self.coal2Flow) self.coal3Flow = Tix.DoubleVar() self.coalFlow.append(self.coal3Flow) self.coalTemperature = [] self.airTemperature = Tix.DoubleVar() self.coal1Temperature = Tix.DoubleVar() self.coalTemperature.append(self.coal1Temperature) self.coal2Temperature = Tix.DoubleVar() self.coalTemperature.append(self.coal2Temperature) self.coal3Temperature = Tix.DoubleVar() self.coalTemperature.append(self.coal3Temperature) self.class1Coal1Ratio = Tix.DoubleVar() self.class2Coal1Ratio = Tix.DoubleVar() self.class3Coal1Ratio = Tix.DoubleVar() self.class4Coal1Ratio = Tix.DoubleVar() self.class5Coal1Ratio = Tix.DoubleVar() self.class6Coal1Ratio = Tix.DoubleVar() self.class7Coal1Ratio = Tix.DoubleVar() self.class8Coal1Ratio = Tix.DoubleVar() self.class9Coal1Ratio = Tix.DoubleVar() self.class10Coal1Ratio = Tix.DoubleVar() self.class1Coal2Ratio = Tix.DoubleVar() self.class2Coal2Ratio = Tix.DoubleVar() self.class3Coal2Ratio = Tix.DoubleVar() self.class4Coal2Ratio = Tix.DoubleVar() self.class5Coal2Ratio = Tix.DoubleVar() self.class6Coal2Ratio = Tix.DoubleVar() self.class7Coal2Ratio = Tix.DoubleVar() self.class8Coal2Ratio = Tix.DoubleVar() self.class9Coal2Ratio = Tix.DoubleVar() self.class10Coal2Ratio = Tix.DoubleVar() self.class1Coal3Ratio = Tix.DoubleVar() self.class2Coal3Ratio = Tix.DoubleVar() self.class3Coal3Ratio = Tix.DoubleVar() self.class4Coal3Ratio = Tix.DoubleVar() self.class5Coal3Ratio = Tix.DoubleVar() self.class6Coal3Ratio = Tix.DoubleVar() self.class7Coal3Ratio = Tix.DoubleVar() self.class8Coal3Ratio = Tix.DoubleVar() self.class9Coal3Ratio = Tix.DoubleVar() self.class10Coal3Ratio = Tix.DoubleVar() self.ratio = 3*[0] self.ratio[0] = [self.class1Coal1Ratio, self.class2Coal1Ratio, self.class3Coal1Ratio, self.class4Coal1Ratio, self.class5Coal1Ratio, self.class6Coal1Ratio, self.class7Coal1Ratio, self.class8Coal1Ratio, self.class9Coal1Ratio, self.class10Coal1Ratio] self.ratio[1] = [self.class1Coal2Ratio, self.class2Coal2Ratio, self.class3Coal2Ratio, self.class4Coal2Ratio, self.class5Coal2Ratio, self.class6Coal2Ratio, self.class7Coal2Ratio, self.class8Coal2Ratio, self.class9Coal2Ratio, self.class10Coal2Ratio] self.ratio[2] = [self.class1Coal3Ratio, self.class2Coal3Ratio, self.class3Coal3Ratio, self.class4Coal3Ratio, self.class5Coal3Ratio, self.class6Coal3Ratio, self.class7Coal3Ratio, self.class8Coal3Ratio, self.class9Coal3Ratio, self.class10Coal3Ratio] def _pageControl(self): """ Xml node declaration and supplementary default value settings. """ self.model = BoundaryConditionsModel(self.case) # Initialize variables concerning the display of the Hlist # self.mousePointedEntry = None self.selectedEntry = None self.currentEntry = None self.entriesNumber = 0 import Pages.CoalCombustion as CoalCombustion coalModel = CoalCombustion.CoalCombustionModel(self.case) if coalModel.getCoalCombustionModel() != "off" : import Pages.CoalThermoChemistry as CoalThermoChemistry coalModel = CoalThermoChemistry.CoalThermoChemistryModel("dp_FCP", self.case) self.coalNumber = coalModel.getCoals().getNumber() self.coalClassesNumber = [] for coal in range(0, self.coalNumber): self.coalClassesNumber.append(coalModel.getCoals().getCoal(coal+1).getClassesNumber()) else : self.coalNumber = 0 self.coalClassesNumber = [0] def getRadiativeWallHeating(self, event=None): """ Check and upload in the case the wall radiative boundary condition. """ self.stbar.busy() self.stbar.idle() def selectHList(self, entry=None): """ Browsecmd: Every single Clik on the Button1 of the mouse send TWO signal to the GUI the first one when man push the button, and the second one when the button gets back. Command: Every double-Click and Return send only ONE signal to the GUI. """ self.selectedEntry = self.mousePointedEntry self.mousePointedEntry = entry if (self.selectedEntry == self.mousePointedEntry and self.currentEntry != self.mousePointedEntry): if entry == None: msg = "There is an error in the use of the HList.\n"\ "The selectionned entry is:" + entry + "\n" raise ValueError, msg t = PageText() self.currentEntry = entry # Here we must call the tk function directly without passing in # Tix.py, because of a bug in tix8.1 in the Hlist.item_cget function # h = self.h.hlist label = h.tk.call(h, 'item', 'cget', entry, 0, '-text') type = h.tk.call(h, 'item', 'cget', entry, 1, '-text') for key in self.model.typeList.keys(): if self.model.typeList[key] == type: type = key self.h.hlist.config(selectbackground=self.model.typeColor[key]) if type == 'wall': self.wt.pack_forget() self.wv.pack_forget() self.coalwv.pack_forget() self.whd.pack_forget() self.whi.pack_forget() #self.s2.pack_forget() #self.s3.pack_forget() self.vf2.pack_forget() self.s1.pack(side=TOP, fill=X, padx=2, pady=5) self.vf.pack(side=TOP, fill=X, pady=5) self.wcomp.pack_forget() self.wnorm.pack_forget() self.wdefil.pack(side=TOP, pady=5) self.bdefil[1].select() valref = self.model.getRef(type,label) self.valref.set(valref) choice = self.model.getChoiceDefil(type, label) if choice == "on": self.bdefil[0].select() u, v, w = self.model.getWallVelocity(label) self.wcomp.pack(side=BOTTOM, pady=5) else: u = 0.0 v = 0.0 w = 0.0 self.wcomp.pack_forget() self.U.set(u) self.V.set(v) self.W.set(w) elif type == 'inlet': self.wdefil.pack_forget() self.s1.pack(side=TOP, fill=X, padx=2, pady=5) self.vf.pack(side=TOP, fill=X, pady=5) self.vf2.pack_forget() #self.s2.pack_forget() #self.s3.pack_forget() self.wt.pack_forget() self.whd.pack_forget() self.whi.pack_forget() if (self.coalNumber == 0) : valref = self.model.getRef(type,label) self.valref.set(valref) choice = self.model.getVelocityChoice(type, label) self.wv.pack(side=TOP, fill=X) self.bv.enable('flow1') self.bv.config(value =choice) if choice == "dirichlet": u, v, w = self.model.getInletVelocity(label) self.U.set(u) self.V.set(v) self.W.set(w) self.wnorm.pack_forget() self.wcomp.pack(side=BOTTOM, pady=5) if choice == "flow1": f = self.model.getVelocityFlow(type, label) self.flow.set(f) self.wcomp.pack_forget() self.wnorm.pack(side=BOTTOM, pady=5) else: f = self.model.getVelocityFlow(type, label) self.coalwv.pack(side=TOP, fill=X) #self.s3.pack(side=TOP, fill=X, padx=2, pady=5) self.vf2.pack(side=TOP, fill=X) self.coalwv1.pack(side=TOP, fill=X) choice = self.model.getVelocityChoice(type, label) if choice == "coal_flow": self.choiceCoalFlow.set("coalflow") elif choice == "flow1": self.choiceCoalFlow.set("airflow") else: msg = "Error :invalid velocity_pressure choice for coal combustion" raise ValueError, msg self.getChoiceCoalFlow() if self.model.getInfoTurbulence(): #self.s2.pack(side=TOP, fill=X, padx=2, pady=5) self.wt.pack(side=BOTTOM, padx=10, pady=5, fill=X) turb_choice = self.model.getTurbulenceChoice(type, label) if turb_choice == "hydraulic_diameter": d = self.model.getHydraulicDiameter(type, label) self.diam.set(d) self.whi.pack_forget() self.whd.pack(side=BOTTOM, padx=15, pady=5) if turb_choice == "turbulent_intensity": i = self.model.getTurbulentIntensity(type, label) d = self.model.getHydraulicDiameter(type, label) self.intens.set(i) self.diam.set(d) self.whd.pack_forget() self.whi.pack(side=BOTTOM, padx=15, pady=5) def _make_style(self): """ Define beautyfull style in order to display columns in the List. """ self.style={} self.style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=self.lf, anchor=CENTER, padx=5, pady=2, font=fB) for type in self.model.typeList.keys(): self.style[type+'b'] = Tix.DisplayStyle(Tix.TEXT, refwindow=self.lf, padx=5, fg=self.model.typeColor[type], selectforeground='#fefefe', font=fB) self.style[type] = Tix.DisplayStyle(Tix.TEXT, refwindow=self.lf, padx=5, anchor=CENTER, fg=self.model.typeColor[type], selectforeground='#fefefe', font=fN) def getChoiceDefil(self, event=None): """ INPUT choice of method of calculation of the velocity """ self.stbar.busy() answer = self.rc_on_off.get() if self.selectedEntry != None: label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setChoiceDefil(label, answer) self.wcomp.pack_forget() self.wnorm.pack_forget() self.wv.pack_forget() if answer == 'on': self.wdefil.pack(side=TOP, pady=5) self.wcomp.pack(side=BOTTOM, padx=15, pady=5) u, v, w = self.model.getWallVelocity(label) self.U.set(u) self.V.set(v) self.W.set(w) self.stbar.idle() def getChoiceVelocity(self, event=None): """ INPUT choice of method of calculation of the velocity """ self.stbar.busy() choice = self.choiceveloce.get() if self.selectedEntry != None: label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setChoiceVelocity(type, label, choice) self.wcomp.pack_forget() self.wnorm.pack_forget() self.wdefil.pack_forget() if choice == 'dirichlet': self.wcomp.pack(side=BOTTOM, padx=15, pady=5) u, v, w = self.model.getInletVelocity(label) self.U.set(u) self.V.set(v) self.W.set(w) elif choice == 'flow1': self.wnorm.pack(side=BOTTOM, padx=15, pady=5) f = self.model.getVelocityFlow(type, label) self.flow.set(f) self.stbar.idle() def getVelocity(self, i, attr, var, event=None): """ INPUT components's values of the velocity """ self.stbar.busy() if self.selectedEntry != None: if self.check2.hasType(self.ev[i], var): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setInletWallVelocity(type, label, attr, var.get()) else: t = PageText() self.stbar.set(t.MSG_TYPE) self.check2.error(self.ev[i]) self.stbar.idle() def getFlow(self, event=None): """ INPUT Flow for the velocity """ self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.en, self.flow): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setVelocityFlow(label, self.flow.get()) self.stbar.idle() def getCoalAirFlow(self, event=None): """ INPUT Flow for the velocity """ self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.coale1, self.flow): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setVelocityFlow(label, self.flow.get()) self.stbar.idle() def getTemperature(self, event=None): """ INPUT air temperature """ self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.coale2, self.temperature): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setTemperature(label, self.temperature.get()) self.stbar.idle() def getDiam(self, event=None): """ INPUT hydraulic diameter """ self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.hd, self.diam): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setHydraulicDiameter(label, self.diam.get()) self.stbar.idle() def getIntensity(self, event=None): """ INPUT turbulent intensity """ self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.it, self.intens): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setTurbulentIntensity(label, self.intens.get()) self.stbar.idle() def getChoiceTurbu(self, event=None): """ INPUT choice of method of calculation of the turbulence """ self.stbar.busy() turb_choice = self.choiceturbu.get() if self.selectedEntry != None: label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setChoiceTurbu(type, label, turb_choice) self.whd.pack_forget() self.whi.pack_forget() if turb_choice == 'hydraulic_diameter': self.whd.pack(side=BOTTOM, padx=15, pady=5) d = self.model.getHydraulicDiameter(type, label) self.diam.set(d) elif turb_choice == 'turbulent_intensity': self.whi.pack(side=BOTTOM, padx=15, pady=5) i = self.model.getTurbulentIntensity(type, label) self.intens.set(i) d = self.model.getHydraulicDiameter(type, label) self.diam.set(d) self.stbar.idle() def getCoale3(self, coal, event=None): self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.coale3[coal], self.coalFlow[coal]): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setCoalFlow(label, self.coalFlow[coal].get(), coal) self.stbar.idle() def getCoale4(self, coal, event=None): self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.coale4[coal], self.coalTemperature[coal]): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setCoalTemperature(label, self.coalTemperature[coal].get(), coal) self.stbar.idle() def getCoale5(self, coal, classe, event=None): self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.coale5[coal][classe], self.ratio[coal][classe]): label, type = self.select.boundaryInfo(self.selectedEntry) lastValue = 0 for iclasse in range(0, self.coalClassesNumber[coal]-1): lastValue += self.ratio[coal][iclasse].get() if lastValue < 100.+ 1e-6 : self.stbar.clear() self.model.setClassCoalRatio(label, self.ratio[coal][classe].get(), coal, classe) lastValue = 100 - lastValue self.ratio[coal][self.coalClassesNumber[coal]-1].set(lastValue) self.getRatioLastClass(coal) else : self.ratio[coal][classe].set(self.model.getClassCoalRatio(label, coal, classe)) self.stbar.idle() def getRatioLastClass(self, coal, event=None): self.stbar.busy() if self.selectedEntry != None: if self.check2.isPositive(self.coale5[coal][self.coalClassesNumber[coal]-1], self.ratio[coal][self.coalClassesNumber[coal]-1]): self.stbar.clear() label, type = self.select.boundaryInfo(self.selectedEntry) self.model.setClassCoalRatio(label, self.ratio[coal][self.coalClassesNumber[coal]-1].get(), coal, self.coalClassesNumber[coal]-1) self.stbar.idle() def getChoiceCoalFlow(self, event=None): value = self.choiceCoalFlow.get() label, type = self.select.boundaryInfo(self.selectedEntry) self.flow.set(self.model.getVelocityFlow('inlet', label)) self.temperature.set(self.model.getTemperature('inlet', label)) if value == 'airflow': self.model.setChoiceVelocity('inlet',label,"flow1") for coal in range(0, self.coalNumber): # Flow self.coallabel1[coal].config(state=DISABLED) self.coale3[coal].config(state=DISABLED) self.coale3[coal].unbind("<>") self.coale3[coal].config(fg='grey') self.coallabel2[coal].config(state=DISABLED) # Temperature self.coallabel3[coal].config(state=DISABLED) self.coale4[coal].config(state=DISABLED) self.coale4[coal].unbind("<>") self.coallabel4[coal].config(state=DISABLED) self.coale4[coal].config(fg='grey') # classes ratio for coal in range(0, self.coalNumber) : for coalClass in range(0, self.coalClassesNumber[coal]): self.coale5[coal][coalClass].config(state=DISABLED) self.coale5[coal][coalClass].unbind("<>") self.coale5[coal][coalClass].config(fg='grey') self.coallabel5[coal][coalClass].config(state=DISABLED) for classe in range(0,max(self.coalClassesNumber)): self.labelclass[classe].config(state=DISABLED) for coal in range(0, self.coalNumber): self.labelcoal[coal].config(state=DISABLED) else : self.model.setChoiceVelocity('inlet',label,"coal_flow") for coal in range(0, self.coalNumber): # Flow self.coallabel1[coal].config(state=NORMAL) self.coale3[coal].config(state=NORMAL) self.coalFlow[coal].set(self.model.getCoalFlow(label,coal)) self.coallabel2[coal].config(state=NORMAL) self.coale3[coal].event_add("<>", "", "", "") self.coale3[coal].bind("<>",TkPage.Callback(self.getCoale3, coal)) self.coale3[coal].config(fg='black') # Temperature self.coallabel3[coal].config(state=NORMAL) self.coale4[coal].config(state=NORMAL) self.coalTemperature[coal].set(self.model.getCoalTemperature(label,coal)) self.coallabel4[coal].config(state=NORMAL) self.coale4[coal].event_add("<>", "", "", "") self.coale4[coal].bind("<>",TkPage.Callback(self.getCoale4, coal)) self.coale4[coal].config(fg='black') for coal in range(0, self.coalNumber) : lastValue = 0. for coalClass in range(0, self.coalClassesNumber[coal]-1): self.coale5[coal][coalClass].config(state=NORMAL) lastValue += float(self.model.getClassCoalRatio(label, coal, coalClass)) self.ratio[coal][coalClass].set(self.model.getClassCoalRatio(label, coal, coalClass)) self.coallabel5[coal][coalClass].config(state=NORMAL) self.coale5[coal][coalClass].event_add("<>", "", "", "") if (coalClass == self.coalClassesNumber[coal]-1) : self.coale5[coal][coalClass].bind("<>",TkPage.Callback(self.getRatioLastClass, coal)) else: self.coale5[coal][coalClass].bind("<>",TkPage.Callback(self.getCoale5, coal, coalClass)) self.coale5[coal][coalClass].config(fg='black') # last class is computed coalClass = self.coalClassesNumber[coal]-1 lastValue = 100 - lastValue self.ratio[coal][coalClass].set(lastValue) self.coale5[coal][coalClass].config(state=DISABLED) self.coale5[coal][coalClass].config(fg='grey') self.coallabel5[coal][coalClass].config(state=NORMAL) self.getRatioLastClass(coal) for classe in range(0,max(self.coalClassesNumber)): self.labelclass[classe].config(state=NORMAL) for coal in range(0, self.coalNumber): self.labelcoal[coal].config(state=NORMAL) def _createWidgets(self): """ Create the Page layout. """ t = PageText() top = Tix.LabelFrame(self.myPage, bd=2, label=t.BOUNDARY_CONDITIONS, relief=FLAT) top.label.config(font=fT) top.pack(side=TOP, fill=X, padx=10, pady=10) ###### HList : put boundaries conditions ######## ############ wlv = Tix.Frame(top.frame, relief=FLAT) wlv.pack(side=TOP) leftw = Tix.Frame(wlv, bd=2, relief=FLAT) #leftw.pack(side=LEFT, pady=10) leftw.pack(side=LEFT) self.lf = Tix.Frame(leftw, bd=2, relief=FLAT) self.lf.pack(side=LEFT) # Put a simple hierachy into the HList (two levels). Use colors and # separator widgets (frames) to make the list look fancy # self.h = Tix.ScrolledHList(self.lf, options='hlist.columns 3 hlist.header 1' ) self.h.config(scrollbar="auto +y +x") self.h.hlist.config(browsecmd=self.selectHList, command=self.selectHList, bg=wm['hlistbackground']) self.h.hsb.config(width=10, bd=1) self.h.vsb.config(width=10, bd=1) self.h.pack(padx=0, pady=5, side=LEFT) # First some styles for the headers # self._make_style() # Create the headers # self.h.hlist.header_create(0, itemtype=Tix.TEXT, text=t.LABEL, style=self.style['header']) self.h.hlist.header_create(1, itemtype=Tix.TEXT, text=t.TYPE, style=self.style['header']) # Notice that we use 3 columns in the hlist widget. This way when the user # expands the windows wide, the right side of the header doesn't look # chopped off. The following line ensures that the 3 column header is # not shown unless the hlist window is wider than its contents. # self.h.hlist.column_width(2,0) # Let configure the appearance of the HList subwidget # self.h.hlist.config(separator='.', width=25, height=11, drawbranch=0, indent=10) # Let configure the width of the columns # self.h.hlist.column_width(0, chars=16) self.h.hlist.column_width(1, chars=9) # we put in inactive window referency(ies) relative at the label # wref = Tix.Frame(leftw, relief=FLAT) wref.pack(side=BOTTOM, pady=5) Tix.Label(wref, text=t.REF).grid(row=0,column=0,padx=3) self.ref = Tix.Entry(wref, width=25, relief=GROOVE, bd=2, bg='lightblue', textvariable=self.valref) self.ref.grid(row=1, column=0, sticky=E) scroll = Tix.Scrollbar(wref, orient=HORIZONTAL, width=10, bd=2, command=TkPage.Callback(self._scrollHandler, self.ref)) scroll.grid(row=2, column=0, sticky=E+W) self.ref['xscrollcommand'] = scroll.set self.ref.config(state=DISABLED) # self._InfoXmlText() self.select = MultiSelect(self.h.hlist, self.model.typeList, self.model.typeColor) ###### Separator self.s1 = Tix.Frame(top.frame, height=2, bd=2, relief=SUNKEN) self.s1.pack(side=BOTTOM, fill=X, padx=2, pady=5) ###### Put boundaries conditions for VELOCITY ######## ############ vitl =[0]*3 self.ev =[0]*3 self.vf = Tix.Frame(top.frame, relief=FLAT) self.vf.pack(side=TOP, fill=X, padx=10, pady=5) #### For WALL **** #choice for wall velocity self.wdefil = Tix.Frame(self.vf, relief=FLAT) self.wdefil.pack(side=TOP, pady=5) ldefil = Tix.Label(self.wdefil, text=t.DEFIL) ldefil.grid(row=0, column=0, sticky=W) #self.balloon.bind_widget(ldefil, balloonmsg=t.KEYWORD+"a completer") self.bdefil = [0]*2 for (i, tx1, tx2) in [(0, t.ON, 'on') , (1, t.OFF, 'off') ]: self.bdefil[i] = Tix.Radiobutton(self.wdefil, text=tx1, value=tx2, variable=self.rc_on_off, command=self.getChoiceDefil) self.bdefil[i].grid(row=0, column=i+1, padx=3, sticky=E) #### For INLET **** #choice for inlet velocity self.wv = Tix.Frame(self.vf, relief=FLAT) self.wv.pack(side=TOP, fill=X) self.bv = Tix.OptionMenu(self.wv) self.bv.menubutton.config(width=18, bd=2, relief=RAISED) self.bv.grid(row=0, column=0, padx=10, pady=5) self.bv.add_command('dirichlet', label=t.COMPONENT) self.bv.add_command('flow1', label=t.NORME) self.bv.config(variable=self.choiceveloce, command=self.getChoiceVelocity) # for velocity by components for inlet self.wcomp = Tix.Frame(self.vf, relief=FLAT) self.wcomp.pack(side=BOTTOM, pady=5) for (i, lab, attr, var) in [(0, 'U', 'velocity_U', self.U), (1, 'V', 'velocity_V', self.V), (2, 'W', 'velocity_W', self.W)]: vitl = Tix.Label(self.wcomp, text=lab) vitl.grid(row=i, column=0, padx=2, pady=5, sticky=W) self.ev[i] = Tix.Entry(self.wcomp, width=10, textvariable=var) self.ev[i].grid(row=i, column=1, padx=3, pady=5) self.ev[i].event_add("<>", "", "", "") self.ev[i].bind("<>",TkPage.Callback(self.getVelocity, i, attr, var)) Tix.Label(self.wcomp, text="m/s").grid(row=i, column=2, pady=5, sticky=E) # for velocity by flow self.wnorm = Tix.Frame(self.vf, relief=FLAT) self.wnorm.pack(side=BOTTOM, pady=5) norml = Tix.Label(self.wnorm, text=t.NORME_VAL) norml.grid(row=0, column=0, padx=2, pady=5, sticky=W) self.en = Tix.Entry(self.wnorm, width=10, textvariable=self.flow) self.en.grid(row=0, column=1, padx=3, pady=5) self.en.event_add("<>", "", "", "") self.en.bind("<>",self.getFlow) Tix.Label(self.wnorm, text="m3/s").grid(row=0, column=2, pady=5, sticky=E) #### For Coal INLET **** #choice for inlet flow self.coalwv = Tix.LabelFrame(self.vf, bd=2, label=t.FLOWTEMP, relief=FLAT) self.coalwv.pack(side=TOP, fill=X, padx=10, pady=10) self.coalwv.label.config(font=fT) coallabel = Tix.Label(self.coalwv.frame, text=t.TINLET) coallabel.grid(row=1, column=0, padx=10, pady=5) self.coalbv = Tix.OptionMenu(self.coalwv.frame) self.coalbv.menubutton.config(width=10, bd=2, relief=RAISED) self.coalbv.grid(row=1, column=1, padx=10, pady=5) self.coalbv.add_command('coalflow', label=t.COALFLOW) self.coalbv.add_command('airflow', label=t.AIRFLOW) self.coalbv.config(variable=self.choiceCoalFlow, command=self.getChoiceCoalFlow) #self.coalbv.config(variable=self.choiceCoalFlow ) #self.coalbv.bind("<>",TkPage.Callback(self.getChoiceCoalFlow, type, label)) # for air flow coallabel = Tix.Label(self.coalwv.frame, text=t.FAIR) coallabel.grid(row=2, column=0, padx=10, pady=5) self.coale1 = Tix.Entry(self.coalwv.frame, bd=2, width=15, textvariable=self.flow) self.coale1.grid(row=2, column=1, padx=5, pady=5, sticky=W) self.coale1.event_add("<>", "", "", "") self.coale1.bind("<>",self.getCoalAirFlow) coallabel = Tix.Label(self.coalwv.frame, text="kg/s") coallabel.grid(row=2, column=2) coallabel = Tix.Label(self.coalwv.frame, text=t.TAIR) coallabel.grid(row=2, column=3, padx=10, pady=5) self.coale2 = Tix.Entry(self.coalwv.frame, bd=2, width=15, textvariable=self.temperature) self.coale2.grid(row=2, column=4, padx=5, pady=5, sticky=W) self.coale2.event_add("<>", "", "", "") self.coale2.bind("<>",self.getTemperature) coallabel = Tix.Label(self.coalwv.frame, text="K") coallabel.grid(row=2, column=5, padx=10, pady=5) # for coal flow self.coallabel1 = [0] * self.coalNumber self.coallabel2 = [0] * self.coalNumber self.coale3 = [0] * self.coalNumber self.coale4 = [0] * self.coalNumber self.coallabel3 = [0] * self.coalNumber self.coallabel4 = [0] * self.coalNumber for coal in range(0, self.coalNumber): # Flow self.coallabel1[coal] = Tix.Label(self.coalwv.frame, text=t.FCOAL+" "+str(coal+1)) self.coallabel1[coal].grid(row= 3 + coal, column=0, padx=10, pady=5) self.coale3[coal] = Tix.Entry(self.coalwv.frame, bd=2, width=15, textvariable=self.coalFlow[coal]) self.coale3[coal].grid(row= 3 + coal, column=1, padx=5, pady=5, sticky=W) self.coale3[coal].event_add("<>", "", "", "") self.coale3[coal].bind("<>",TkPage.Callback(self.getCoale3, coal)) self.coallabel2[coal] = Tix.Label(self.coalwv.frame, text="kg/s") self.coallabel2[coal].grid(row= 3 + coal, column=2, padx=10, pady=5) # Temperature self.coallabel3[coal] = Tix.Label(self.coalwv.frame, text=t.TCOAL+" "+str(coal+1)) self.coallabel3[coal].grid(row= 3 + coal, column=3, padx=10, pady=5) self.coale4[coal] = Tix.Entry(self.coalwv.frame, bd=2, width=15, textvariable=self.coalTemperature[coal]) self.coale4[coal].grid(row= 3 + coal, column=4, padx=5, pady=5, sticky=W) self.coale4[coal].event_add("<>", "", "", "") self.coale4[coal].bind("<>",TkPage.Callback(self.getCoale4, coal)) self.coallabel4[coal] = Tix.Label(self.coalwv.frame, text="K") self.coallabel4[coal].grid(row= 3 + coal, column=5, padx=10, pady=5) self.vf2 = Tix.Frame(top.frame, height=2, bd=2, relief=FLAT) self.vf2.pack(side=TOP, padx=10, pady=5, fill=X) ##self.s3 = Tix.Frame(top.frame, height=2, bd=2, relief=SUNKEN) ##self.s3.pack(side=BOTTOM, fill=X, padx=2, pady=5) self.coalwv1 = Tix.LabelFrame(self.vf2, bd=2, label=t.MASSDIST, relief=FLAT) self.coalwv1.pack(side=BOTTOM, fill=X, padx=10, pady=10) self.coalwv1.label.config(font=fT) ## self.coalwv1 = Tix.Frame(self.vf2, relief=FLAT) ## self.coalwv1.pack(side=BOTTOM, fill=X) self.labelclass = [0] * max(self.coalClassesNumber) self.labelcoal = [0] * self.coalNumber for classe in range(0,max(self.coalClassesNumber)): name = t.CLASS+" "+str(classe+1) self.labelclass[classe] = Tix.Label(self.coalwv1.frame, text=name) self.labelclass[classe].grid(row = 1 + classe, column=0, padx=5, pady=5, sticky=W) for coal in range(0, self.coalNumber): name = t.COAL+" "+str(coal+1) self.labelcoal[coal] = Tix.Label(self.coalwv1.frame, text=name) self.labelcoal[coal].grid(row = 0 , column = 1 + 2*coal, padx=5, pady=5, sticky=W) # classes ratio self.coale5 = [0] * self.coalNumber self.coallabel5 = [0] * self.coalNumber for coal in range(0, self.coalNumber) : self.coale5[coal] = [0] * self.coalClassesNumber[coal] self.coallabel5[coal] = [0] * self.coalClassesNumber[coal] for coal in range(0, self.coalNumber) : for coalClass in range(0, self.coalClassesNumber[coal]): self.coale5[coal][coalClass] = Tix.Entry(self.coalwv1.frame, bd=2, width=8, textvariable=self.ratio[coal][coalClass]) self.coale5[coal][coalClass].grid(row= 1 + coalClass, column= 2*coal + 1 , padx=5, pady=5, sticky=W) self.coale5[coal][coalClass].event_add("<>", "", "", "") if (coalClass == self.coalClassesNumber[coal]-1) : self.coale5[coal][coalClass].bind("<>",TkPage.Callback(self.getRatioLastClass, coal)) else: self.coale5[coal][coalClass].bind("<>",TkPage.Callback(self.getCoale5, coal, coalClass)) self.coallabel5[coal][coalClass] = Tix.Label(self.coalwv1.frame, text="%") self.coallabel5[coal][coalClass].grid(row = 1 + coalClass, column = 1 + 2*coal+1, padx=5, pady=5, sticky=W) ###### Separator ##self.s2 = Tix.Frame(top.frame, height=2, bd=2, relief=SUNKEN) ##self.s2.pack(side=BOTTOM, fill=X, padx=2, pady=5) ###### Put boundaries conditions for TURBULENCE ######## ############ self.wt = Tix.LabelFrame(top.frame, bd=2, label=t.TURBULENCE, relief=FLAT) #self.wt = Tix.LabelFrame(top.frame, relief=FLAT) self.wt.pack(side=BOTTOM, padx=10, pady=5, fill=X) self.wt.label.config(font=fT) tf = Tix.Frame(self.wt.frame, relief=FLAT) tf.pack(side=TOP, fill=X) self.bt = Tix.OptionMenu(tf) self.bt.menubutton.config(width=28, bd=2, relief=RAISED) self.bt.grid(row=0, column=0, padx=10, pady=5) self.bt.add_command('hydraulic_diameter', label=t.DIAM) self.bt.add_command('turbulent_intensity', label=t.INTENSITY) self.bt.config(variable=self.choiceturbu, command=self.getChoiceTurbu) # for turbulence by hydraulic's diameter self.whd = Tix.Frame(self.wt.frame, relief=FLAT) self.whd.pack(side=BOTTOM, padx=15, pady=5) Tix.Label(self.whd, text=t.DIAMH).grid(row=0, column=0, padx=5, pady=5, sticky=W) self.hd = Tix.Entry(self.whd, width=10, textvariable=self.diam) self.hd.grid(row=0, column=1,padx=5, pady=5) self.hd.event_add("<>", "", "", "") self.hd.bind("<>", self.getDiam) Tix.Label(self.whd, text='m').grid(row=0, column=2, padx=5, pady=5, sticky=W) self.balloon.bind_widget(self.hd, balloonmsg=t.DHENT_aide) # for turbulence by turbulent intensity self.whi = Tix.Frame(self.wt.frame, relief=FLAT) self.whi.pack(side=BOTTOM, padx=15, pady=5) Tix.Label(self.whi, text=t.INTURB).grid(row=0, column=0, padx=5, pady=5, sticky=W) self.it = Tix.Entry(self.whi, width=10, textvariable=self.intens) self.it.grid(row=0, column=1,padx=5, pady=5) self.it.event_add("<>", "", "", "") self.it.bind("<>", self.getIntensity) Tix.Label(self.whi, text='%').grid(row=0, column=2, padx=5, pady=5, sticky=W) self.balloon.bind_widget(self.it, balloonmsg=t.INTENS_ENT_aide) Tix.Label(self.whi, text=t.DIAMH).grid(row=1, column=0, padx=5, pady=5, sticky=W) self.hd2 = Tix.Entry(self.whi, width=10, textvariable=self.diam) self.hd2.grid(row=1, column=1,padx=5, pady=5) self.hd2.event_add("<>", "", "", "") self.hd2.bind("<>", self.getDiam) Tix.Label(self.whi, text='m').grid(row=1, column=2, padx=5, pady=5, sticky=W) self.balloon.bind_widget(self.hd2, balloonmsg=t.DHENT_aide) def addInHlist(self, type, label): """ Create the item list associated with the new boundary definition. """ self.stbar.busy() for key in self.model.typeList.keys(): if self.model.typeList[key] == type: type = key self.entriesNumber = self.entriesNumber + 1 name = 'entry' + repr(self.entriesNumber) self.h.hlist.add(name, itemtype=Tix.TEXT, text=label, style=self.style[type+'b']) self.h.hlist.item_create(name, 1, itemtype=Tix.TEXT, text=self.model.typeList[type], style=self.style[type]) self.stbar.idle() 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. """ self.entriesNumber = 0 for (label,type) in self.model.getBoundConditions(): self.addInHlist(type,label) self.bv.config(value='dirichlet') #self.coalbv.config(value='airflow') self.s1.pack_forget() self.vf.pack_forget() self.vf2.pack_forget() self.wv.pack_forget() self.coalwv.pack_forget() self.coalwv1.pack_forget() ##self.s3.pack_forget() self.wcomp.pack_forget() self.wnorm.pack_forget() self.bt.config(value='hydraulic_diameter') ##self.s2.pack_forget() self.wt.pack_forget() self.whd.pack_forget() self.whi.pack_forget() #------------------------------------------------------------------------------- # 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.BOUNDARY_CONDITIONS = "Conditions aux limites des variables dynamiques" self.COMPONENT = " Composantes" self.DEFIL = "Vitesse de défilement" self.DHENT_aide = "diamètre hydraulique de l'entrée = "\ "4S/P avec S=surface et P=perimetre de paroi mouillée" self.DIAM = "Calcul par le diamètre hydraulique" self.DIAMH = "Diamètre hydraulique" self.DISSIP = "Dissipation" self.INLET = "entrée" self.INTENS_ENT_aide = "intensité turbulente exprimée en pourcent " self.INTENSITY = "Calcul par l'intensité turbulente" self.INTURB = "Intensité" self.GROUP = "Groupe" self.LABEL = "Étiquette" self.KEYWORD = "Mot clé Code_SATURNE : " self.NORME = " Débit massique " self.NORME_VAL = "Débit" self.OFF = "non" self.ON = "oui" self.OUTLET = "sortie" self.POPUP = "Menu popup" self.REF = "Référence(s)" self.SELECT_ALL = "Tout sélectionner" self.SELECT_TYPE = "Sélection par type" self.SYMMETRY = "symétrie" self.TURBULENCE = "Turbulence pour : " self.TYPE = "type" self.UNDEFINED = "indéfini" self.VELOCITY = "Vitesse pour : " self.WALL = "paroi" self.AIRFLOW = "air" self.COALFLOW = "air + charbon" self.COAL = "charbon" self.CLASS = "classe" self.TAIR = "Température air" self.FAIR = "Débit air" self.TCOAL = "Température charbon" self.FCOAL = "Débit charbon" self.TINLET = "Type d'entrée : " self.MASSDIST = "Distribution en masse" self.FLOWTEMP = "Débits et températures" self.TURBULENCE = "Turbulence" ## self.WALL_HEATING = "Échauffement radiatif de la paroi" else: self.BOUNDARY_CONDITIONS = "Dynamic variables boundary" self.COMPONENT = "Velocity's components" self.DEFIL = "Défilement velocity" self.DHENT_aide = "Inlet hydraulique diameter = "\ "4S/P with S=surface et P=perimeter of wet wall" self.DIAM = "Calculation by hydraulic diameter" self.DIAMH = "Hydraulic diameter" self.DISSIP = "Dissipation" self.INLET = "inlet" self.INTENS_ENT_aide = "turbulent intensity expressed in percent " self.INTENSITY = "Calculation by turbulent intensity" self.INTURB = "Intensity" self.GROUP = "Group" self.LABEL = "Label" self.KEYWORD = "Code_SATURNE Keyword: " self.NORME = "Rate of flow of mass" self.NORME_VAL = "Rate of flow" self.ON = "on" self.OFF = "off" self.OUTLET = "outlet" self.POPUP = "Menu popup" self.REF = "Referency(ies)" self.SELECT_ALL = "Select all" self.SELECT_TYPE = "Selection by type" self.SYMMETRY = "symmetry" self.TURBULENCE = "Turbulence for : " self.TYPE = "type" self.UNDEFINED = "undefined" self.VELOCITY = "Velocity for : " self.WALL = "wall" self.AIRFLOW = "air" self.COALFLOW = "air + coal" self.COAL = "coal" self.CLASS = "class" self.TAIR = "Air temperature" self.FAIR = "Air Flow" self.TCOAL = "Coal temperature" self.FCOAL = "Coal Flow" self.TINLET = "Inlet type : " self.MASSDIST = "Mass distribution" self.FLOWTEMP = "Flows and temperatures" self.TURBULENCE = "Turbulence" ## self.WALL_HEATING = "Radiative wall heating" # 2) Messages # if Tool.GuiParam.lang == 'fr': self.MSG_NOTHING = "Aucune information utilisateur n'est nécessaire" self.MSG_UNDEFINED = "Intervention utilisateur obligatoire "\ "dans le sous-programe USCLIM" self.MSG_TYPE = "Vous n'avez rien sélectionné dans la liste. "\ "(ni entrée, ni paroi)." else: self.MSG_NOTHING = "No user input is required" self.MSG_UNDEFINED = "User-coding is required "\ "in the subroutine USCLIM" self.MSG_TYPE = "You must select one wall or inlet "\ "in the list." #------------------------------------------------------------------------------- # End #-------------------------------------------------------------------------------