# -*- 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 gas combustion thermal flow modelling management.
This module contains the following classes and function:
- GasCombustionModel
- GasCombustionView
- PageText
- GasCombustionTestCase
"""
#-------------------------------------------------------------------------------
# Library modules import
#-------------------------------------------------------------------------------
import sys, unittest
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
#-------------------------------------------------------------------------------
# Gas combustion model class
#-------------------------------------------------------------------------------
class GasCombustionModel(Variables):
"""
"""
def __init__(self, case):
"""
Constructor.
"""
self.case = case
nModels = self.case.xmlGetNode('thermophysical_models')
self.node_turb = nModels.xmlGetNode('turbulence', 'model')
self.node_gas = nModels.xmlGetNode('gas_combustion', 'model')
self.node_coal = nModels.xmlGetNode('pulverized_coal', 'model')
self.node_joule = nModels.xmlGetNode('joule_effect', 'model')
self.node_therm = nModels.xmlGetNode('thermal_scalar', 'model')
self.gasCombustionModel = ('off', 'ebu', 'd3p')
def defaultGasCombustionValues(self):
"""
Return in a dictionnary which contains default values.
"""
default = {}
default['model'] = "off"
return default
def getAllGasCombustionModels(self):
"""
Return all defined gas combustion models in a tuple.
"""
return self.gasCombustionModel
def gasCombustionModelsList(self):
"""
Create a tuple with the gas combustion models allowed
by the analysis features.
"""
gasCombustionList = self.gasCombustionModel
if self.node_turb['model'] not in ('k-epsilon',
'k-epsilon-PL',
'Rij-epsilon',
'Rij-SSG',
'v2f-phi',
'k-omega-SST'):
gasCombustionList = ('off',)
return gasCombustionList
def setGasCombustionModel(self, model):
"""
Update the gas combustion model markup from the XML document.
"""
if model not in self.gasCombustionModelsList():
sys.exit(1)
if model == 'off':
self.node_gas['model'] = model
return
else:
self.node_gas['model'] = model
self.node_coal['model'] = 'off'
self.node_joule['model'] = 'off'
self.node_therm['model'] = 'off'
#FIXME
# if model == 'ebu':
# self.node_gas.xmlInitNodeList('scalar', name='frac melange', type='model')[0]
# self.node_gas.xmlInitNodeList('scalar', name='frac massique', type='model')[0]
# self.node_gas.xmlInitNodeList('scalar', name='enthalpie melange', type='model')[0]
#FIXME
def getGasCombustionModel(self):
"""
Return the current gas combustion model.
"""
model = self.node_gas['model']
if model not in self.gasCombustionModelsList():
model = self.defaultGasCombustionValues()['model']
self.setGasCombustionModel(model)
return model
#-------------------------------------------------------------------------------
# Main view class
#-------------------------------------------------------------------------------
class GasCombustionView(TkPage.Page):
"""
Class to open gas combustion Page.
"""
def _dependsPages(self, name):
"""
Construction of the list of dependencies Pages.
"""
pass
def _tkControlVariables(self):
"""
Tkinter variables declaration.
"""
self.gas_combustion = StringVar()
def _pageControl(self):
"""
Instantiate the lagrangian modelling class.
"""
self.model = gasCombustionModel(self.case)
def putgasCombustionModel(self, event=None):
"""
"""
self.model.setGasCombustionModel(self.gas_combustion.get())
def _createWidgets(self):
"""
Create the Page layout.
"""
t = PageText()
lf = Tix.LabelFrame(self.myPage, bd=2,
label=t.GASCOMBUSTION, relief=FLAT)
lf.label.config(font=fT)
lf.pack(side=TOP, fill=X, padx=10, pady=10)
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.
"""
pass
#-------------------------------------------------------------------------------
# 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.KEYWORD = "Mots clé Code_Saturne : "
self.GASCOMBUSTION = "Combustion Gas"
else:
self.KEYWORD = "Code_Saturne key words: "
self.GASCOMBUSTION = "Gas Combustion"
# 2) Messages
#
if Tool.GuiParam.lang == 'fr':
self.MSG_GAS = "Sélectionner un modèle"
else:
self.MSG_GAS = "Select a model"
#-------------------------------------------------------------------------------
# Gas combustion test case
#-------------------------------------------------------------------------------
class GasCombustionTestCase(unittest.TestCase):
"""
"""
def setUp(self):
"""
This method is executed before all "check" methods.
"""
from Base.XMLengine import Case
self.case = Case()
def tearDown(self):
"""
This method is executed after all "check" methods.
"""
del self.case
def checkgasCombustionInstantiation(self):
"""
Check whether the gasCombustionModel class could be instantiated
"""
model = None
model = gasCombustionModel(self.case)
assert model != None, 'Could not instantiate GasCombustionModel'
def suite():
testSuite = unittest.makeSuite(GasCombustionTestCase, "check")
return testSuite
def runTest():
runner = unittest.TextTestRunner()
runner.run(suite())
#-------------------------------------------------------------------------------
# End
#-------------------------------------------------------------------------------
syntax highlighted by Code2HTML, v. 0.9.1