From: pascale.noyret Date: Thu, 9 Feb 2017 15:29:12 +0000 (+0100) Subject: exceptions prints X-Git-Tag: Salome_8_3_Hydro_2_0rc1~97 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=debcf0cd8eb3cce498c13824ddf689b8a0a8b52d;p=modules%2Feficas.git exceptions prints --- diff --git a/generator/DefautASTER.py b/generator/DefautASTER.py index 8828a994..7a120f32 100644 --- a/generator/DefautASTER.py +++ b/generator/DefautASTER.py @@ -39,7 +39,7 @@ TexteSTDFIN += "\nif error_message is not None :\n" TexteSTDFIN += DecalSTD + "texte = \"\\n=================================================\"" TexteSTDFIN += DecalSTD + "texte += \"\\nMessage d'erreur : \" + str(error_message)" TexteSTDFIN += DecalSTD + "texte += \"\\n=================================================\\n\"" -TexteSTDFIN += DecalSTD + "print texte" +TexteSTDFIN += DecalSTD + "print (texte)" TexteSTDFIN += DecalSTD + "\nsys.exit(error_message)\n" # C.2. Definition de composants dans le fichier STD @@ -145,7 +145,7 @@ class MonSTDGenerateur(STDGenerateur) : Algorithm = str (self.DictMCVal["Algorithm"]) texte = "\n\n# Le resultat\n" texte += DecalSTDsaut + NomResu + " = " + NomAlgo + ".getResult()" - texte += DecalSTDsaut + "###" + "print " + NomResu + texte += DecalSTDsaut + "###" + "print ( " + NomResu+")" texte += DecalSTDsaut + "text_resu = \"Resultats\\n=======\\n\"" # Particularites des algorithmes de fiabilite @@ -222,7 +222,7 @@ class MonSTDGenerateur(STDGenerateur) : # Impression - texte += DecalSTDsaut + "print \"\\n\", text_resu, \"\\n\"" + texte += DecalSTDsaut + "print ( \"\\n\", text_resu, \" ) \\n\"" texte += DecalSTDsaut + "file_resu = open(\"" + self.fic_resu_OpenTURNS + "\", \"w\")" texte += DecalSTDsaut + "file_resu.write(text_resu)" texte += DecalSTDsaut + "file_resu.close()" diff --git a/generator/Formatage.py b/generator/Formatage.py index 0f8efaa9..31edf1ab 100644 --- a/generator/Formatage.py +++ b/generator/Formatage.py @@ -126,9 +126,9 @@ class Formatage : try: increment = len(('\n'+self.indent_courant*' ')*ind + element[0]) except: - print tr('ERREUR') - print liste - print element + print (tr('ERREUR')) + print (liste) + print (element) self.texte_etape = self.texte_etape + (u'\n'+self.indent_courant*' ')*ind + element[0] length = len(self.indent) self.indent.insert(length,self.indent[length-1]+len(element[0])) diff --git a/generator/OpenturnsBase.py b/generator/OpenturnsBase.py deleted file mode 100644 index 465c6f8d..00000000 --- a/generator/OpenturnsBase.py +++ /dev/null @@ -1,145 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -""" -Ce module contient la partie commune -aux generateurs XML et Etude d Openturns -""" - -__revision__ = "V1.0" - -import os -import sys - -path=os.getcwd() -pathDef=path+"DefautOpenturns" - -sys.path.append(pathDef) - - -#============================================= -# La classe generale -#============================================= - -class Generateur : - - ''' - Classe generale du generateur - DictMCVal : dictionnaire des mots-cles - ListeVariables : chaque variable est decrite par un dictionnaire ; cette liste les regroupe - DictLois : dictionnaires des lois - ''' - def __init__ (self, appli, DictMCVal = {}, ListeVariables = [], DictLois = {}, DictVariables = {} ) : - #---------------------------------------------------------# - self.ListeVariables = ListeVariables - self.ListeVariablesIn = [] - self.ListeVariablesOut = [] - self.DictLois = DictLois - self.DictVariables = DictVariables - self.DictMCVal = DictMCVal - self.DictTypeVar = {} - self.nbVarIn = 0 - self.nbVarOut = 0 - self.creeInfoVar() - self.appli = appli - # - # On charge eventuellement le Solver par defaut - # et les valeurs par defaut du Solver (dans l init) - # - try : - #if 1 : - Solver = self.DictMCVal["PhysicalSolver"] - import_name = "Defaut"+Solver - self.module = __import__( import_name, globals(), locals() ) - monDefaut = self.module.Defaut( self ) - #else : - except: - self.module = None - - - def getSTDGenerateur(self) : - #--------------------------# - try : - gener = self.module.__dict__["MonSTDGenerateur"] - monSTDGenerateur=gener( self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois ) - except : - from OpenturnsSTD import STDGenerateur - monSTDGenerateur = STDGenerateur( self.appli, self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois ) - return monSTDGenerateur - - def getXMLGenerateur(self) : - #--------------------------# - try : - gener = self.module.__dict__["MonXMLGenerateur"] - monXMLGenerateur=gener( self.DictMCVal, self.ListeVariables, self.DictLois ) - except : - from OpenturnsXML import XMLGenerateur - monXMLGenerateur = XMLGenerateur( self.appli, self.DictMCVal, self.DictVariables ) - return monXMLGenerateur - - def creeInfoVar (self) : - #----------------------# - """ - On repere les variables in/out et on les numerote. - """ - num = 0 - liste = [] - for DictVariable in self.ListeVariables : - if not DictVariable.has_key("Type") : DictVariable["Type"] = "in" - self.DictTypeVar[num] = DictVariable["Type"] - if DictVariable["Type"] == "in" : - self.nbVarIn = self.nbVarIn + 1 - self.ListeVariablesIn.append( DictVariable ) - print "OpenturnsBase.py: new input variable = ", DictVariable - else: - self.nbVarOut = self.nbVarOut + 1 - self.ListeVariablesOut.append( DictVariable ) - print "OpenturnsBase.py: new output variable = ", DictVariable - liste.append( DictVariable ) - num = num + 1 - self.ListeVariables = liste - - - def ajouteDictMCVal(self, dicoPlus) : - #-----------------------------------# - # Appele par le classe Defaut du python specifique au code (exple DefautASTER.py) - # enrichit self.DictMCVal avec les valeurs donnees dans dicoPlus - # si elles ne sont pas deja dans le dictionnaire - - for clef in dicoPlus.keys(): - if not self.DictMCVal.has_key(clef) : - self.DictMCVal[clef] = dicoPlus[clef] - - def ajouteInfoVariables (self, dicoVariablesIn, dicoVariablesOut) : - #-----------------------------------------------------------------# - # Appele par le classe Defaut du python specifique au code (exple DefautASTER.py) - # met a jour les dictionnaires qui decrivent les variables (regexp par exemple) - liste=[] - num = 0 - for dictVariable in self.ListeVariables: - if self.DictTypeVar[num] == "in" : - dico = dicoVariablesIn - else : - dico = dicoVariablesOut - for nouvelleVariable in dico.keys() : - if not dictVariable.has_key(nouvelleVariable): - dictVariable[nouvelleVariable] = dico[nouvelleVariable] - liste.append( dictVariable ) - num = num + 1 diff --git a/generator/OpenturnsSTD.py b/generator/OpenturnsSTD.py deleted file mode 100644 index f2659e1c..00000000 --- a/generator/OpenturnsSTD.py +++ /dev/null @@ -1,1397 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -""" -Ce module contient le generateur Etude pour Openturns -""" - -from Extensions.i18n import tr - -__revision__ = "V1.0" - -defaultSTD = """#! /usr/bin/env python - -class StudyFileGenerationError: - def __init__ (self, st): - self.st = st - def __str__(self): - return "'%s'" % self.st - -raise StudyFileGenerationError, "The study file was not generated. Check analysis type." -""" - -headerSTD = """#! /usr/bin/env python - -# Chargement du module systeme -import sys -sys.path[:0]=['%s'] - -# Chargement du module math -import math - -# Chargement du module Open TURNS -from openturns import * - -# Fonction verifiant si un echantillon contient des valeurs non valides (NaN) -def contain_nan_values(sample): - for point in sample: - for val in point: - if math.isnan(val): - return True - return False - -results = {} - -""" - -viewerSTD = """ -from openturns.viewer import View - -# Fonction de test du serveur X -import subprocess -xserver_available = None -def is_xserver_available(): - global xserver_available - if xserver_available is None: - xserver_available = True - try: - subprocess.check_call('python -c "from matplotlib import pyplot;pyplot.figure()" >/dev/null 2>&1', shell = True) - except: - xserver_available = False - return xserver_available - -""" - -footerSTD = """ - -# Flush des messages en attente -Log.Flush() - -# Terminaison du fichier -#sys.exit( 0 ) -""" - -#============================================= -# La classe de creation du fichier STD -#============================================= - -class STDGenerateur : - - ''' - Generation du fichier python - ''' - def __init__ (self, appli, DictMCVal, ListeVariablesIn, ListeVariablesOut, DictLois ) : - self.DictMCVal = DictMCVal - self.ListeVariablesIn = ListeVariablesIn - self.ListeVariablesOut = ListeVariablesOut - self.DictLois = DictLois - #print "DictMCVal=", DictMCVal - print "ListeVariablesIn= %s", ListeVariablesIn - -# A REPRENDRE DEPUIS ICI !! - print "ListeVariablesOut= %s", ListeVariablesOut - #print "DictLois=", DictLois - self.texteSTD = defaultSTD - self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path - - # Ce dictionnaire fait la correspondance entre le mot lu dans le dictionnaire des mots-clefs et la methode a appeler - self.traitement = { - "Min/Max" : - ( "MinMax", - { "Experiment Plane" : "ExperimentPlane", - "Random Sampling" : "MinMaxRandomSampling", - }, - ), - "Central Uncertainty" : - ( "CentralUncertainty", - { "Taylor Variance Decomposition" : "TaylorVarianceDecomposition", - "Random Sampling" : "CentralUncertaintyRandomSampling", - }, - ), - "Threshold Exceedence" : - ( "ThresholdExceedence", - { "Simulation" : "Simulation", - "FORM_SORM" : "Analytical", - "MonteCarlo" : "MonteCarlo", - "LHS" : "LHS", - "ImportanceSampling" : "ImportanceSampling", - "FirstOrder" : "FORM", - "SecondOrder" : "SORM", - "Cobyla" : "Cobyla", - "AbdoRackwitz" : "AbdoRackwitz", - }, - ), - } - - # Ce dictionnaire liste le nom des variables utilisees dans le script - # La clef est le nom attendu par les methodes, la valeur est le nom produit dans le fichier de sortie - # Le fait de passer par un dictionnaire permet de controler que les variables existent et sont correctement nommees - # meme si clef == valeur - self.variable = { - "n" : "n", - "p" : "p", - "wrapper" : "wrapper", - "wrapperdata" : "wrapperdata", - "frameworkdata" : "frameworkdata", - "framework" : "framework", - "studyid" : "studyid", - "studycase" : "studycase", - "componentname" : "componentname", - "model" : "model", - "scaledVector" : "scaledVector", - "translationVector" : "translationVector", - "levels" : "levels", - "myCenteredReductedGrid" : "myCenteredReductedGrid", - "myExperimentPlane" : "myExperimentPlane", - "inputSample" : "inputSample", - "outputSample" : "outputSample", - "minValue" : 'results["minValue"]', - "maxValue" : 'results["maxValue"]', - "flags" : "flags", - "inSize" : "inSize", - "distribution" : "distribution", - "marginal" : "marginal", - "collection" : "collection", - "copula" : "copula", - "correlation" : "correlation", - "R" : "R", - "vars" : "vars", - "description" : "description", - "inputRandomVector" : "inputRandomVector", - "outputRandomVector" : "outputRandomVector", - "myQuadraticCumul" : "myQuadraticCumul", - "meanFirstOrder" : 'results["meanFirstOrder"]', - "meanSecondOrder" : 'results["meanSecondOrder"]', - "standardDeviationFirstOrder" : 'results["standardDeviationFirstOrder"]', - "importanceFactors" : 'results["importanceFactors"]', - "importanceFactorsGraph" : "importanceFactorsGraph", - "importanceFactorsDrawing" : "importanceFactorsDrawing", - "empiricalMean" : 'results["empiricalMean"]', - "empiricalStandardDeviation" : 'results["empiricalStandardDeviation"]', - "empiricalQuantile" : 'results["empiricalQuantile"]', - "alpha" : "alpha", - "beta" : "beta", - "PCCcoefficient" : 'results["PCCcoefficient"]', - "PRCCcoefficient" : 'results["PRCCcoefficient"]', - "SRCcoefficient" : 'results["SRCcoefficient"]', - "SRRCcoefficient" : 'results["SRRCcoefficient"]', - "kernel" : "kernel", - "kernelSmoothedDist" : "kernelSmoothedDist", - "kernelSmoothedPDFDrawing" : "kernelSmoothedPDFDrawing", - "kernelSmoothedGraph" : "kernelSmoothedGraph", - "meanVector" : "meanVector", - "importanceDensity" : "importanceDensity", - "myEvent" : "myEvent", - "myAlgo" : "myAlgo", - "myResult" : "myResult", - "probability" : 'results["probability"]', - "standardDeviation" : 'results["standardDeviation"]', - "level" : "level", - "length" : "length", - "coefficientOfVariation" : 'results["coefficientOfVariation"]', - "convergenceGraph" : "convergenceGraph", - "convergenceDrawing" : "convergenceDrawing", - "simulationNumbers" : 'results["simulationNumbers"]', - "myOptimizer" : "myOptimizer", - "specificParameters" : "specificParameters", - "startingPoint" : "startingPoint", - "hasoferReliabilityIndex" : 'results["hasoferReliabilityIndex"]', - "standardSpaceDesignPoint" : 'results["standardSpaceDesignPoint"]', - "physicalSpaceDesignPoint" : 'results["physicalSpaceDesignPoint"]', - "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]', - "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]', - "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph", - "eventProbabilitySensitivityDrawing" : "eventProbabilitySensitivityDrawing", - "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph", - "hasoferReliabilityIndexSensitivityDrawing" : "hasoferReliabilityIndexSensitivityDrawing", - "modelEvaluationCalls" : 'results["modelEvaluationCalls"]', - "modelGradientCalls" : 'results["modelGradientCalls"]', - "modelHessianCalls" : 'results["modelHessianCalls"]', - "tvedtApproximation" : 'results["tvedtApproximation"]', - "hohenBichlerApproximation" : 'results["hohenBichlerApproximation"]', - "breitungApproximation" : 'results["breitungApproximation"]', - } - - # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque - self.logFlags = { - "DebugMessages" : "Log.DBG", - "WrapperMessages" : "Log.WRAPPER", - "UserMessages" : "Log.USER", - "InfoMessages" : "Log.INFO", - "WarningMessages" : "Log.WARN", - "ErrorMessages" : "Log.ERROR", - } - - def CreeSTD (self) : - ''' - Pilotage de la creation du fichier python - ''' - TypeAnalyse = None - if ( self.DictMCVal.has_key( 'Type' ) ): - TypeAnalyse = self.DictMCVal[ 'Type' ] - - Traitement = None - subDict = {} - if ( self.traitement.has_key( TypeAnalyse ) ): - (Traitement, subDict) = self.traitement[ TypeAnalyse ] - - if ( Traitement is not None ): - self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) ) - - return self.texteSTD - - def Header (self) : - ''' - Imprime l entete commun a tous les fichiers - ''' - txt = headerSTD % self.OpenTURNS_path - txt += viewerSTD - txt += "# Definit le niveau d'affichage de la log\n" - txt += "%s = Log.NONE\n" % self.variable["flags"] - for flag in self.logFlags.keys(): - if ( self.DictMCVal.has_key( flag ) ): - val = self.DictMCVal[ flag ] - op = "-" - if val == 'yes' : - op = "+" - txt += "%s = %s %s %s\n" % (self.variable["flags"], self.variable["flags"], op, self.logFlags[ flag ]) - txt += "Log.Show( %s )\n" % self.variable["flags"] - txt += "\n" - return txt - - def Footer (self) : - ''' - Imprime le pied de page commun a tous les fichiers - ''' - return footerSTD - - def MinMax (self, subDict): - ''' - Produit le fichier study correspondant a une analyse Min/Max - ''' - txt = self.Header() - txt += self.Model() - - Methode = None - if ( self.DictMCVal.has_key( 'Method' ) ): - Methode = self.DictMCVal[ 'Method' ] - - Traitement = None - if ( subDict.has_key( Methode ) ): - Traitement = subDict[ Methode ] - - if ( Traitement is not None ): - txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) - - txt += self.MinMaxResult() - - txt += self.Footer() - return txt - - def Model (self): - ''' - Importe le modele physique - ''' - if ( self.DictMCVal.has_key( 'FileName' ) ): - name = self.DictMCVal[ 'FileName' ] - - txt = "# Charge le modele physique\n" - txt += "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name) - txt += "%s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"]) - - txt += "# Ces lignes sont utiles pour le fonctionnement du script sous Salome\n" - txt += "if globals().has_key('%s'):\n" % self.variable["framework"] - txt += " %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"]) - txt += " %s.studyid_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studyid"]) - txt += " %s.studycase_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studycase"]) - txt += " %s.componentname_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"]) - txt += " %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"]) - txt += " %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"]) - txt += "# Fin des lignes pour Salome\n" - - txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],) - txt += "%s = %s.getInputDimension()\n" % (self.variable["n"], self.variable["model"]) - txt += "\n" - return txt - - def ExperimentPlane (self): - ''' - Etude par plan d experience - ''' - txt = "# Etude par plan d'experience\n" - txt += self.Levels() - txt += self.CenteredReductedGrid() - txt += self.ScaledVector() - txt += self.TranslationVector() - txt += "%s = %s\n" % (self.variable["inputSample"], self.variable["myExperimentPlane"]) - txt += "\n" - txt += "# Etude 'Min/Max'\n" - txt += "# Calcul\n" - txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) - txt += "if contain_nan_values( %s ):\n" % (self.variable["outputSample"]) - txt += " raise Exception('Some computations failed')\n" - txt += "\n" - return txt - - def MinMaxRandomSampling (self): - ''' - Etude par echantillonage aleatoire - ''' - size = 0 - if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): - size = self.DictMCVal[ 'SimulationsNumber' ] - - txt = "# Etude par echantillonage aleatoire\n" - txt += self.InputDistribution() - txt += self.InputRandomVector() - txt += "\n" - txt += "# Etude 'Min/Max'\n" - txt += "# Calcul\n" - txt += "%s = %d\n" % (self.variable["inSize"], size) - txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) - txt += "%s = %s.getSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"]) - txt += "if contain_nan_values( %s ):\n" % (self.variable["outputSample"]) - txt += " raise Exception('Some computations failed')\n" - return txt - - def InputDistribution (self): - ''' - Cree la loi jointe des variables d entree - ''' - txt = "# Definit la loi jointe des variables d'entree\n" - txt += "%s = DistributionCollection( %s )\n" % (self.variable["collection"], self.variable["n"]) - txt += "%s = Description( %s )\n" % (self.variable["description"], self.variable["n"]) - txt += "\n" - - dictVariables = {} - for variable in self.ListeVariablesIn: - nomVar = variable['ModelVariable'].get_name() - dictVariables[ nomVar ] = variable['Distribution'] - - i = 0 - sortedVarNames = dictVariables.keys() - sortedVarNames.sort() - for variable in sortedVarNames: - conceptloi = dictVariables[ variable ] - loi = self.DictLois[ conceptloi ] - if loi.has_key( 'Kind' ): - marginale = "%s_%d" % (self.variable["marginal"], i) - txt += "# Definit la loi marginale de la composante %d\n" % i - txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) )) - txt += "%s.setName( '%s' )\n" % (marginale, conceptloi.get_name()) - txt += "%s[ %d ] = '%s'\n" % (self.variable["description"], i, variable) - txt += "%s[ %d ] = Distribution( %s )\n" % (self.variable["collection"], i, marginale) - txt += "\n" - i += 1 - - txt += self.Copula() - - txt += "# Definit la loi jointe\n" - txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"]) - txt += "%s.setDescription( %s )\n" % (self.variable["distribution"], self.variable["description"]) - txt += "\n" - return txt - - def Copula (self): - ''' - Cree la copule de la loi jointe - ''' - txt = "# Definit la copule de la loi jointe\n" - - if ( not self.DictMCVal.has_key( 'Copula' ) ): - self.DictMCVal[ 'Copula' ] = 'Independent' - - if ( self.DictMCVal[ 'Copula' ] in ( 'Independent', ) ): - txt += "%s = IndependentCopula( %s )\n" % (self.variable["copula"], self.variable["n"]) - elif ( self.DictMCVal[ 'Copula' ] in ( 'Normal', ) ): - varList = self.DictMCVal[ 'CorrelationMatrix' ][0] - dimension = len(varList) - txt += "%s = {}\n" % self.variable["correlation"] - for i in range( dimension ): - txt += "%s['%s'] = {}\n" % (self.variable["correlation"], varList[i]) - for j in range ( dimension ): - txt += "%s['%s']['%s'] = %g\n" % (self.variable["correlation"], varList[i], varList[j], self.DictMCVal[ 'CorrelationMatrix' ][i+1][j]) - txt += "%s = getCorrelationMatrixFromMap( %s.getVariableList(), %s )\n" % (self.variable["R"], self.variable["wrapperdata"], self.variable["correlation"]) - txt += "%s = NormalCopula( %s )\n" % (self.variable["copula"], self.variable["R"]) - - txt += "\n" - return txt - - def InputRandomVector (self): - ''' - Cree le vector aleatoire d entree - ''' - txt = "# Definit le vecteur aleatoire d'entree\n" - txt += "%s = RandomVector( %s )\n" % (self.variable["inputRandomVector"], self.variable["distribution"]) - txt += "\n" - return txt - - def OutputRandomVector (self): - ''' - Cree le vector aleatoire de sortie - ''' - nomVar = "output" - for variable in self.ListeVariablesOut: - nomVar = variable['ModelVariable'].get_name() - - txt = "# Definit le vecteur aleatoire de sortie\n" - txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) - txt += "%s.setName( '%s' )\n" % (self.variable["outputRandomVector"], nomVar) - txt += "\n" - return txt - - def ScaledVector (self): - ''' - Definit les coefficients multiplicateurs par composante du vecteur - ''' - dimension = 0 - if ( self.DictMCVal.has_key( 'UnitsPerDimension' ) ): - unitsPerDimension = self.DictMCVal[ 'UnitsPerDimension' ] - dimension = len( unitsPerDimension ) - - txt = "# Definit les facteurs d'echelle dans chaque direction\n" - txt += "%s = NumericalPoint( %s )\n" % (self.variable["scaledVector"], self.variable["n"]) - for i in range(dimension): - txt += "%s[%d] = %g\n" % (self.variable["scaledVector"], i, unitsPerDimension[i]) - txt += "%s.scale( %s )\n" % (self.variable["myExperimentPlane"], self.variable["scaledVector"]) - txt += "\n" - return txt - - def TranslationVector (self): - ''' - Definit le vecteur de translation - ''' - dimension = 0 - if ( self.DictMCVal.has_key( 'Center' ) ): - center = self.DictMCVal[ 'Center' ] - dimension = len( center ) - - txt = "# Definit le vecteur de translation\n" - txt += "%s = NumericalPoint( %s )\n" % (self.variable["translationVector"], self.variable["n"]) - for i in range(dimension): - txt += "%s[%d] = %g\n" % (self.variable["translationVector"], i, center[i]) - txt += "%s.translate( %s )\n" % (self.variable["myExperimentPlane"], self.variable["translationVector"]) - txt += "\n" - return txt - - def Levels (self): - ''' - Definit les niveaux du plan d experience - ''' - dimension = 0 - if ( self.DictMCVal.has_key( 'Levels' ) ): - levels = self.DictMCVal[ 'Levels' ] - dimension = len( levels ) - - txt = "# Definit les niveaux de la structure de grille\n" - txt += "%s = NumericalPoint( %d )\n" % (self.variable["levels"], dimension) - for i in range(dimension): - txt += "%s[%d] = %g\n" % (self.variable["levels"], i, levels[i]) - txt += "\n" - return txt - - def CenteredReductedGrid (self): - ''' - Definit la grille reduite du plan d experience - ''' - plane = None - if ( self.DictMCVal.has_key( 'ExperimentPlane' ) ): - plane = self.DictMCVal[ 'ExperimentPlane' ] - - txt = "# Cree le plan d'experience centre reduit\n" - txt += "%s = %s(%s, %s)\n" % (self.variable["myCenteredReductedGrid"], plane, self.variable["n"], self.variable["levels"]) - txt += "%s = %s.generate()\n" % (self.variable["myExperimentPlane"], self.variable["myCenteredReductedGrid"]) - txt += "\n" - return txt - - def MinMaxResult (self): - ''' - Produit les resultats de l etude - ''' - txt = "# Resultats\n" - txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"]) - txt += "print '%s = ', %s\n" % ("minValue", self.variable["minValue"]) - txt += "\n" - txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"]) - txt += "print '%s = ', %s\n" % ("maxValue", self.variable["maxValue"]) - txt += "\n" - return txt - - def CentralUncertainty (self, subDict): - ''' - Produit le fichier study correspondant a une analyse d incertitude en valeur centrale - ''' - txt = self.Header() - txt += self.Model() - txt += self.InputDistribution() - txt += self.InputRandomVector() - txt += self.OutputRandomVector() - - Methode = None - if ( self.DictMCVal.has_key( 'Method' ) ): - Methode = self.DictMCVal[ 'Method' ] - - Traitement = None - if ( subDict.has_key( Methode ) ): - Traitement = subDict[ Methode ] - - if ( Traitement is not None ): - txt += "# Etude 'Central Uncertainty'\n" - txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) - - txt += self.Footer() - return txt - - - def TaylorVarianceDecomposition (self): - ''' - Etude par decomposition de Taylor - ''' - txt = "# Cumul quadratique (decomposition de Taylor)\n" - txt += "%s = QuadraticCumul( %s )\n" % (self.variable["myQuadraticCumul"], self.variable["outputRandomVector"]) - txt += "\n" - txt += "# Resultats\n" - - if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ): - if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ): - txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"]) - txt += "print '%s = ', %s\n" % ("mean First Order", self.variable["meanFirstOrder"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ): - if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ): - txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"]) - txt += "print '%s = ', %s\n" % ("mean Second Order", self.variable["meanSecondOrder"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ): - if ( self.DictMCVal[ 'StandardDeviationFirstOrder' ] == "yes" ): - txt += "%s = %s.getCovariance()\n" % (self.variable["standardDeviationFirstOrder"], self.variable["myQuadraticCumul"]) - txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"] - txt += "for i in range( dim ):\n" - txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"]) - txt += " print '%s = ', %s[ i, i ]\n" % ("standard Deviation First Order", self.variable["standardDeviationFirstOrder"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ): - if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ): - txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"]) - txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"] - txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"]) - txt += "\n" - txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"]) - txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ]) - txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) - txt += "#if is_xserver_available():\n" - txt += "# view = View(%s)\n" % self.variable["importanceFactorsGraph"] - txt += "# view.show(block=True)\n" - txt += "#else:\n" - txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["importanceFactorsGraph"] - txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] - txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] - txt += "\n" - - txt += "\n" - return txt - - def CentralUncertaintyRandomSampling (self): - ''' - Etude par echantillonage aleatoire - ''' - size = 0 - if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): - size = self.DictMCVal[ 'SimulationsNumber' ] - - txt = "# Echantillonnage aleatoire de la variable de sortie\n" - txt += "%s = %d\n" % (self.variable["inSize"], size) - txt += "%s = %s.getSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"]) - txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) - txt += "if contain_nan_values( %s ):\n" % (self.variable["outputSample"]) - txt += " raise Exception('Some computations failed')\n" - txt += "\n" - - if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ): - if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ): - txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"]) - txt += "print '%s =', %s[0]\n" % ("empirical Mean", self.variable["empiricalMean"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ): - if ( self.DictMCVal[ 'EmpiricalStandardDeviation' ] == "yes" ): - txt += "%s = %s.computeCovariance()\n" % (self.variable["empiricalStandardDeviation"], self.variable["outputSample"]) - txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"] - txt += "for i in range( dim ):\n" - txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"]) - txt += " print '%s = ', %s[ i, i ]\n" % ("empirical Standard Deviation", self.variable["empiricalStandardDeviation"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ): - ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ] - txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre) - txt += "print '%s ( %s ) =', %s\n" % ("empirical Quantile", ordre, self.variable["empiricalQuantile"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'CorrelationAnalysis' ) ): - if ( self.DictMCVal[ 'CorrelationAnalysis' ] == "yes" ): - txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] - txt += " %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += " print 'PCC Coefficients:'\n" - txt += " for i in range( %s ):\n" % self.variable["n"] - txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PCCcoefficient"]) - txt += "\n" - txt += " %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += " print 'PRCC Coefficients:'\n" - txt += " for i in range( %s ):\n" % self.variable["n"] - txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PRCCcoefficient"]) - txt += "\n" - txt += " %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += " print 'SRC Coefficients:'\n" - txt += " for i in range( %s ):\n" % self.variable["n"] - txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRCcoefficient"]) - txt += "\n" - txt += " %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += " print 'SRRC Coefficients:'\n" - txt += " for i in range( %s ):\n" % self.variable["n"] - txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRRCcoefficient"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ): - if ( self.DictMCVal[ 'KernelSmoothing' ] == "yes" ): - txt += "# Kernel Smoohing\n" - txt += "%s = KernelSmoothing()\n" % self.variable["kernel"] - txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] - txt += " %s.setName( 'Output' )\n" % self.variable["outputSample"] - txt += " %s = %s.build( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"]) - txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedDist"]) - txt += " %s = '%s'\n" % (self.variable["kernelSmoothedPDFDrawing"], self.DictMCVal[ 'KernelSmoothingDrawingFilename' ]) - txt += " %s.draw( %s )\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedPDFDrawing"]) - txt += " #if is_xserver_available():\n" - txt += " # view = View(%s)\n" % self.variable["kernelSmoothedGraph"] - txt += " # view.show(block=True)\n" - txt += " #else:\n" - txt += " # print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["kernelSmoothedGraph"] - txt += " print 'bitmap =', %s.getBitmap()\n" % self.variable["kernelSmoothedGraph"] - txt += " print 'postscript =', %s.getPostscript()\n" % self.variable["kernelSmoothedGraph"] - txt += "\n" - - return txt - - def ThresholdExceedence (self, subDict): - ''' - Produit le fichier study correspondant a une analyse de depassement de seuil - ''' - txt = self.Header() - txt += "# Etude 'Threshold Exceedence'\n" - - txt += self.RandomGenerator() - txt += self.Model() - txt += self.InputDistribution() - txt += self.InputRandomVector() - txt += self.OutputRandomVector() - txt += self.Event() - - Methode = None - if ( self.DictMCVal.has_key( 'Method' ) ): - Methode = self.DictMCVal[ 'Method' ] - - Traitement = None - if ( subDict.has_key( Methode ) ): - Traitement = subDict[ Methode ] - - if ( Traitement is not None ): - txt += apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) ) - - txt += self.Footer() - return txt - - def Simulation (self, subDict): - ''' - Methodes de simulation - ''' - Algorithme = None - if ( self.DictMCVal.has_key( 'Algorithm' ) ): - Algorithme = self.DictMCVal[ 'Algorithm' ] - - Traitement = None - if ( subDict.has_key( Algorithme ) ): - Traitement = subDict[ Algorithme ] - - if ( Traitement is not None ): - txt = apply( STDGenerateur.__dict__[ Traitement ], (self,) ) - - maxOuterSampling = None - if ( self.DictMCVal.has_key( 'MaximumOuterSampling' ) ): - maxOuterSampling = self.DictMCVal[ 'MaximumOuterSampling' ] - txt += "%s.setMaximumOuterSampling( %s )\n" % (self.variable["myAlgo"], maxOuterSampling) - - blockSize = None - if ( self.DictMCVal.has_key( 'BlockSize' ) ): - blockSize = self.DictMCVal[ 'BlockSize' ] - txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize) - - maxCoefficientOfVariation = None - if ( self.DictMCVal.has_key( 'MaximumCoefficientOfVariation' ) ): - maxCoefficientOfVariation = self.DictMCVal[ 'MaximumCoefficientOfVariation' ] - txt += "%s.setMaximumCoefficientOfVariation( %s )\n" % (self.variable["myAlgo"], maxCoefficientOfVariation) - - txt += "%s.run()\n" % self.variable["myAlgo"] - txt += "\n" - txt += "# Resultats de la simulation\n" - txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'Probability' ) ): - if ( self.DictMCVal[ 'Probability' ] == "yes" ): - txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("probability", self.variable["probability"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'StandardDeviation' ) ): - if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ): - txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("standard Deviation", self.variable["standardDeviation"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ): - if ( ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) and ( self.DictMCVal[ 'Probability' ] == "yes" ) ): - level = self.DictMCVal[ 'Level' ] - txt += "%s = %s.getConfidenceLength( %s )\n" % (self.variable["length"], self.variable["myResult"], level) - txt += "print 'confidence interval at %s = [', %s-0.5*%s, ',', %s+0.5*%s, ']'\n" % (level, self.variable["probability"], self.variable["length"], self.variable["probability"], self.variable["length"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ): - if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ): - txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("coefficient of Variation", self.variable["coefficientOfVariation"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): - if ( self.DictMCVal[ 'SimulationsNumber' ] == "yes" ): - txt += "%s = %s.getOuterSampling()\n" % (self.variable["simulationNumbers"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("simulation Numbers", self.variable["simulationNumbers"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) and self.DictMCVal.has_key( 'ConfidenceInterval' ) ): - if ( ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ) and ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) ): - txt += "%s = %s\n" % (self.variable["alpha"], self.DictMCVal[ 'Level' ]) - txt += "%s = %s.drawProbabilityConvergence( %s )\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"], self.variable["alpha"]) - txt += "%s = '%s'\n" % (self.variable["convergenceDrawing"], self.DictMCVal[ 'ConvergenceDrawingFilename' ]) - txt += "%s.draw( %s )\n" % (self.variable["convergenceGraph"], self.variable["convergenceDrawing"]) - txt += "#if is_xserver_available():\n" - txt += "# view = View(%s)\n" % self.variable["convergenceGraph"] - txt += "# view.show(block=True)\n" - txt += "#else:\n" - txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["convergenceGraph"] - txt += "\n" - - return txt - - def Analytical (self, subDict): - ''' - Methodes analytiques - ''' - txt = "" - - OptimizationAlgo = None - if ( self.DictMCVal.has_key( 'OptimizationAlgorithm' ) ): - OptimizationAlgo = self.DictMCVal[ 'OptimizationAlgorithm' ] - - Traitement = None - if ( subDict.has_key( OptimizationAlgo ) ): - Traitement = subDict[ OptimizationAlgo ] - - if ( Traitement is not None ): - txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) - - txt += self.OptimizerSettings() - txt += self.PhysicalStartingPoint() - - Approximation = None - if ( self.DictMCVal.has_key( 'Approximation' ) ): - Approximation = self.DictMCVal[ 'Approximation' ] - - Traitement = None - if ( subDict.has_key( Approximation ) ): - Traitement = subDict[ Approximation ] - - if ( Traitement is not None ): - txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) - - txt += self.RunAlgorithm() - txt += self.AnalyticalResult() - - return txt - - def OptimizerSettings (self): - ''' - Parametrage de l optimiseur - ''' - txt = "" - - simulationNumbers = None - if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ): - simulationNumbers = self.DictMCVal[ 'MaximumIterationsNumber' ] - txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], simulationNumbers) - - absoluteError = None - if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ): - absoluteError = self.DictMCVal[ 'MaximumAbsoluteError' ] - txt += "%s.setMaximumAbsoluteError( %s )\n" % (self.variable["myOptimizer"], absoluteError) - - relativeError = None - if ( self.DictMCVal.has_key( 'MaximumRelativeError' ) ): - relativeError = self.DictMCVal[ 'MaximumRelativeError' ] - txt += "%s.setMaximumRelativeError( %s )\n" % (self.variable["myOptimizer"], relativeError) - - residualError = None - if ( self.DictMCVal.has_key( 'MaximumResidualError' ) ): - residualError = self.DictMCVal[ 'MaximumResidualError' ] - txt += "%s.setMaximumResidualError( %s )\n" % (self.variable["myOptimizer"], residualError) - - constraintError = None - if ( self.DictMCVal.has_key( 'MaximumConstraintError' ) ): - constraintError = self.DictMCVal[ 'MaximumConstraintError' ] - txt += "%s.setMaximumConstraintError( %s )\n" % (self.variable["myOptimizer"], constraintError) - - txt += "\n" - - return txt - - def PhysicalStartingPoint (self): - ''' - Point physique de depart - ''' - txt = "# Point physique de depart\n" - - if ( self.DictMCVal.has_key( 'PhysicalStartingPoint' ) ): - point = self.DictMCVal[ 'PhysicalStartingPoint' ] - dimension = len( point ) - txt += "%s = NumericalPoint( %d )\n" % (self.variable["startingPoint"], dimension) - for i in range( dimension ): - txt += "%s[ %d ] = %g\n" % (self.variable["startingPoint"], i, point[i]) - else: - txt += "%s = %s.getMean()\n" % (self.variable["startingPoint"], self.variable["inputRandomVector"]) - - txt += "\n" - - return txt - - def AnalyticalResult (self): - ''' - Resultat des methodes analytiques - ''' - txt = "# Resultat des methodes analytiques\n" - txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"]) - - if ( self.DictMCVal.has_key( 'Probability' ) ): - if ( self.DictMCVal[ 'Probability' ] == "yes" ): - txt += "%s = %s.getEventProbability()\n" % (self.variable["probability"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ): - if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ): - txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("hasofer Reliability Index", self.variable["hasoferReliabilityIndex"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'DesignPoint' ) ): - if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ): - txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("standard Space Design Point", self.variable["standardSpaceDesignPoint"]) - txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("physical Space Design Point", self.variable["physicalSpaceDesignPoint"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ): - if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ): - txt += "print 'Importance Factors:'\n" - txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"]) - txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"] - txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"]) - txt += "\n" - txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"]) - txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ]) - txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) - txt += "#if is_xserver_available():\n" - txt += "# view = View(%s)\n" % self.variable["importanceFactorsGraph"] - txt += "# view.show(block=True)\n" - txt += "#else:\n" - txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["importanceFactorsGraph"] - txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] - txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] - txt += "\n" - - if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivity' ) ): - if ( self.DictMCVal[ 'FORMEventProbabilitySensitivity' ] == "yes" ): - txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"]) - txt += "print 'FORM Event Probability Sensitivity:'\n" - txt += "for i in range( %s ):\n" % self.variable["n"] - txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"] - txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["eventProbabilitySensitivity"] - txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"]) - txt += "\n" - txt += "%s = %s.drawEventProbabilitySensitivity()[0]\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"]) - txt += "%s = '%s'\n" % (self.variable["eventProbabilitySensitivityDrawing"], self.DictMCVal[ 'FORMEventProbabilitySensitivityDrawingFilename' ]) - txt += "%s.draw( %s )\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["eventProbabilitySensitivityDrawing"]) - txt += "#if is_xserver_available():\n" - txt += "# view = View(%s)\n" % self.variable["eventProbabilitySensitivityGraph"] - txt += "# view.show(block=True)\n" - txt += "#else:\n" - txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["eventProbabilitySensitivityGraph"] - txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["eventProbabilitySensitivityGraph"] - txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["eventProbabilitySensitivityGraph"] - txt += "\n" - - if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivity' ) ): - if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivity' ] == "yes" ): - txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"]) - txt += "print 'Hasofer Reliability Index Sensitivity:'\n" - txt += "for i in range( %s ):\n" % self.variable["n"] - txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"] - txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["hasoferReliabilityIndexSensitivity"] - txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"]) - txt += "\n" - txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()[0]\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"]) - txt += "%s = '%s'\n" % (self.variable["hasoferReliabilityIndexSensitivityDrawing"], self.DictMCVal[ 'HasoferReliabilityIndexSensitivityDrawingFilename' ]) - txt += "%s.draw( %s )\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["hasoferReliabilityIndexSensitivityDrawing"]) - txt += "#if is_xserver_available():\n" - txt += "# view = View(%s)\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] - txt += "# view.show(block=True)\n" - txt += "#else:\n" - txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] - txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] - txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] - txt += "\n" - - if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ): - if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ): - txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("Tvedt Approximation", self.variable["tvedtApproximation"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ): - if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ): - txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("HohenBichler Approximation", self.variable["tvedtApproximation"]) - txt += "\n" - - if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ): - if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ): - txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % ("Breitung Approximation", self.variable["breitungApproximation"]) - txt += "\n" - - - return txt - - def RandomGenerator (self): - ''' - Generateur Aleatoire - ''' - txt = "" - - seed = None - if ( self.DictMCVal.has_key( 'RandomGeneratorSeed' ) ): - seed = self.DictMCVal[ 'RandomGeneratorSeed' ] - txt += "# Initialise le generateur aleatoire\n" - txt += "RandomGenerator.SetSeed( %s )\n" % seed - txt += "\n" - - return txt - - def Event (self): - ''' - Definition de l evenement de defaillance - ''' - operator = None - if ( self.DictMCVal.has_key( 'ComparisonOperator' ) ): - operator = self.DictMCVal[ 'ComparisonOperator' ] - - threshold = None - if ( self.DictMCVal.has_key( 'Threshold' ) ): - threshold = self.DictMCVal[ 'Threshold' ] - - txt = "# Evenement de defaillance\n" - txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold) - txt += "%s.setName( '%s' )\n" % (self.variable["myEvent"], "myEvent") - txt += "\n" - return txt - - def MonteCarlo (self): - ''' - Methode de MonteCarlo - ''' - txt = "# Simulation par MonteCarlo\n" - txt += "%s = MonteCarlo( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) - txt += "\n" - - return txt - - def LHS (self): - ''' - Methode LHS - ''' - txt = "# Simulation par LHS\n" - txt += "%s = LHS( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) - txt += "\n" - - return txt - - def ImportanceSampling (self): - ''' - Methode de tirage d importance - ''' - dimension = 0 - if ( self.DictMCVal.has_key( 'MeanVector' ) ): - meanVector = self.DictMCVal[ 'MeanVector' ] - dimension = len( meanVector ) - - txt = "# Simulation par Tirage d'importance\n" - txt += "# Densite d'importance\n" - txt += "%s = NumericalPoint( %s )\n" % (self.variable["meanVector"], self.variable["n"]) - for i in range(dimension): - txt += "%s[%d] = %g\n" % (self.variable["meanVector"], i, meanVector[i]) - - txt += "%s = Normal( %s, CovarianceMatrix( IdentityMatrix( %s ) ) )\n" % (self.variable["importanceDensity"], self.variable["meanVector"], self.variable["n"]) - txt += "%s = ImportanceSampling( %s, Distribution( %s ) )\n" % (self.variable["myAlgo"], self.variable["myEvent"], self.variable["importanceDensity"]) - txt += "\n" - - return txt - - def FORM (self): - ''' - Methode FORM - ''' - txt = "# Algorithme FORM\n" - txt += "%s = FORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"]) - txt += "\n" - - return txt - - def SORM (self): - ''' - Methode SORM - ''' - txt = "# Algorithme SORM\n" - txt += "%s = SORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"]) - txt += "\n" - - return txt - - def RunAlgorithm (self): - ''' - Do the computation - ''' - txt = "" - if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): - if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): - txt += "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"]) - txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"]) - txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"]) - txt += "\n" - - txt += "# Perform the computation\n" - txt += "%s.run()\n" % self.variable["myAlgo"] - txt += "\n" - - - if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): - if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): - txt += "%s = %s.getEvaluationCallsNumber() - %s\n" % (self.variable["modelEvaluationCalls"], self.variable["model"], self.variable["modelEvaluationCalls"]) - txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"]) - txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"]) - txt += "\n" - txt += "print '%s =', %s\n" % ("model Evaluation Calls", self.variable["modelEvaluationCalls"]) - txt += "print '%s =', %s\n" % ("model Gradient Calls", self.variable["modelGradientCalls"]) - txt += "print '%s =', %s\n" % ("model Hessian Calls", self.variable["modelHessianCalls"]) - txt += "\n" - - return txt - - def Cobyla (self): - ''' - Methode Cobyla - ''' - txt = "# Optimisation par Cobyla\n" - txt += "%s = Cobyla()\n" % self.variable["myOptimizer"] - txt += "#%s = CobylaSpecificParameters()\n" % self.variable["specificParameters"] - txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"]) - txt += "\n" - - return txt - - def AbdoRackwitz (self): - ''' - Methode AbdoRackwitz - ''' - txt = "# Optimisation par AbdoRackwitz\n" - txt += "%s = AbdoRackwitz()\n" % self.variable["myOptimizer"] - txt += "#%s = AbdoRackwitzSpecificParameters()\n" % self.variable["specificParameters"] - txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"]) - txt += "\n" - return txt - - def Beta (self, loi): - ''' - Definition de la loi Beta - ''' - settings = { - "RT" : "Beta.RT", - "MuSigma" : "Beta.MUSIGMA", - } - if loi[ 'Settings' ] == 'RT' : - arg1 = loi[ 'R' ] - arg2 = loi[ 'T' ] - else : - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Sigma' ] - - arg3 = loi[ 'A' ] - arg4 = loi[ 'B' ] - txt = "Beta( %g, %g, %g, %g, %s )" % (arg1, arg2, arg3, arg4, settings[ loi[ 'Settings' ] ]) - return txt - - def Exponential (self, loi): - ''' - Definition de la loi Exponential - ''' - arg1 = loi[ 'Lambda' ] - arg2 = loi[ 'Gamma' ] - txt = "Exponential( %g, %g )" % (arg1, arg2) - return txt - - def Gamma (self, loi): - ''' - Definition de la loi Gamma - ''' - settings = { - "KLambda" : "Gamma.KLAMBDA", - "MuSigma" : "Gamma.MUSIGMA", - } - if loi[ 'Settings' ] == 'KLambda' : - arg1 = loi[ 'K' ] - arg2 = loi[ 'Lambda' ] - else : - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Sigma' ] - - arg3 = loi[ 'Gamma' ] - txt = "Gamma( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) - return txt - - def Geometric (self, loi): - ''' - Definition de la loi Geometric - ''' - txt = "Geometric( %g )" % loi[ 'P' ] - return txt - - def Gumbel (self, loi): - ''' - Definition de la loi Gumbel - ''' - settings = { - "AlphaBeta" : "Gumbel.ALPHABETA", - "MuSigma" : "Gumbel.MUSIGMA", - } - if loi[ 'Settings' ] == 'AlphaBeta' : - arg1 = loi[ 'Alpha' ] - arg2 = loi[ 'Beta' ] - else : - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Sigma' ] - - txt = "Gumbel( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ]) - return txt - - def Histogram (self, loi): - ''' - Definition de la loi Histogram - ''' - arg1 = loi[ 'First' ] - arg2 = loi[ 'Values' ] - txt = "Histogram( %g, %s )" % (arg1, arg2) - return txt - - def Laplace (self, loi): - ''' - Definition de la loi Laplace - ''' - arg1 = loi[ 'Lambda' ] - arg2 = loi[ 'Mu' ] - txt = "Laplace( %g, %g )" % (arg1, arg2) - return txt - - def Logistic (self, loi): - ''' - Definition de la loi Logistic - ''' - arg1 = loi[ 'Alpha' ] - arg2 = loi[ 'Beta' ] - txt = "Logistic( %g, %g )" % (arg1, arg2) - return txt - - def LogNormal (self, loi): - ''' - Definition de la loi LogNormal - ''' - settings = { - "MuSigmaLog" : "LogNormal.MUSIGMA_LOG", - "MuSigma" : "LogNormal.MUSIGMA", - "MuSigmaOverMu" : "LogNormal.MU_SIGMAOVERMU", - } - if loi[ 'Settings' ] == 'MuSigmaLog' : - arg1 = loi[ 'MuLog' ] - arg2 = loi[ 'SigmaLog' ] - elif loi[ 'Settings' ] == 'MuSigmaOverMu' : - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'SigmaOverMu' ] - else : - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Sigma' ] - - arg3 = loi[ 'Gamma' ] - txt = "LogNormal( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) - return txt - - def MultiNomial (self, loi): - ''' - Definition de la loi MultiNomial - ''' - arg1 = loi[ 'Values' ] - arg2 = loi[ 'N' ] - txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2) - return txt - - def NonCentralStudent (self, loi): - ''' - Definition de la loi NonCentralStudent - ''' - arg1 = loi[ 'Nu' ] - arg2 = loi[ 'Delta' ] - arg3 = loi[ 'Gamma' ] - txt = "NonCentralStudent( %g, %g )" % (arg1, arg2, arg3) - return txt - - def Normal (self, loi): - ''' - Definition de la loi Normal - ''' - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Sigma' ] - txt = "Normal( %g, %g )" % (arg1, arg2) - return txt - - def TruncatedNormal (self, loi): - ''' - Definition de la loi TruncatedNormal - ''' - arg1 = loi[ 'MuN' ] - arg2 = loi[ 'SigmaN' ] - arg3 = loi[ 'A' ] - arg4 = loi[ 'B' ] - txt = "TruncatedNormal( %g, %g, %g, %g )" % (arg1, arg2, arg3, arg4) - return txt - - def Poisson (self, loi): - ''' - Definition de la loi Poisson - ''' - txt = "Poisson( %g )" % loi[ 'Lambda' ] - return txt - - def Rayleigh (self, loi): - ''' - Definition de la loi Rayleigh - ''' - arg1 = loi[ 'Sigma' ] - arg2 = loi[ 'Gamma' ] - txt = "Rayleigh( %g, %g )" % (arg1, arg2) - return txt - - def Student (self, loi): - ''' - Definition de la loi Student - ''' - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Nu' ] - arg3 = loi[ 'Sigma' ] - txt = "Student( %g, %g, %g )" % (arg1, arg2, arg3) - return txt - - def Triangular (self, loi): - ''' - Definition de la loi Triangular - ''' - arg1 = loi[ 'A' ] - arg2 = loi[ 'M' ] - arg3 = loi[ 'B' ] - txt = "Triangular( %g, %g, %g )" % (arg1, arg2, arg3) - return txt - - def Uniform (self, loi): - ''' - Definition de la loi Uniform - ''' - arg1 = loi[ 'A' ] - arg2 = loi[ 'B' ] - txt = "Uniform( %g, %g )" % (arg1, arg2) - return txt - - def UserDefined (self, loi): - ''' - Definition de la loi UserDefined - ''' - txt = "** UserDefined not defined yet **" - return txt - - def Weibull (self, loi): - ''' - Definition de la loi Weibull - ''' - settings = { - "AlphaBeta" : "Weibull.ALPHABETA", - "MuSigma" : "Weibull.MUSIGMA", - } - if loi[ 'Settings' ] == 'AlphaBeta' : - arg1 = loi[ 'Alpha' ] - arg2 = loi[ 'Beta' ] - else : - arg1 = loi[ 'Mu' ] - arg2 = loi[ 'Sigma' ] - - arg3 = loi[ 'Gamma' ] - txt = "Weibull( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) - return txt - - - - def GraphiquePDF (self, loi, chemin, fichier): - ''' - Produit une image PNG representant la PDF de la loi - ''' - txt = headerSTD % self.OpenTURNS_path - txt += "dist = %s\n" % apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) ) - txt += "graph = dist.drawPDF()\n" - txt += "graph.draw( '%s/%s' , 640, 480, GraphImplementation.PNG)\n" % (chemin, fichier) - txt += footerSTD - return txt - diff --git a/generator/OpenturnsXML.py b/generator/OpenturnsXML.py deleted file mode 100644 index 860508de..00000000 --- a/generator/OpenturnsXML.py +++ /dev/null @@ -1,243 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -""" -Ce module contient le generateur XML pour Openturns -""" -import sys -print sys.path -from Extensions.i18n import tr -import openturns - -# Dictionnaires de conversion des valeurs lues dans EFICAS -# en valeurs reconnues par Open TURNS -# Les clefs 'None' sont les valeurs par defaut - -VariableTypeByName = { - "in" : openturns.WrapperDataVariableType.IN, - "out" : openturns.WrapperDataVariableType.OUT, - None : openturns.WrapperDataVariableType.IN, - } - -FileTypeByName = { - "in" : openturns.WrapperDataFileType.IN, - "out" : openturns.WrapperDataFileType.OUT, - None : openturns.WrapperDataFileType.IN, - } - -SymbolProvidedByName = { - "no" : openturns.WrapperSymbolProvided.NO, - "yes" : openturns.WrapperSymbolProvided.YES, - None : openturns.WrapperSymbolProvided.NO, - } - -WrapperStateByName = { - "shared" : openturns.WrapperState.SHARED, - "specific" : openturns.WrapperState.SPECIFIC, - None : openturns.WrapperState.SPECIFIC, - } - -WrapperModeByName = { - "static-link" : openturns.WrapperMode.STATICLINK, - "dynamic-link" : openturns.WrapperMode.DYNAMICLINK, - "fork" : openturns.WrapperMode.FORK, - None : openturns.WrapperMode.FORK, - } - -WrapperDataTransferByName = { - "files" : openturns.WrapperDataTransfer.FILES, - "pipe" : openturns.WrapperDataTransfer.PIPE, - "arguments" : openturns.WrapperDataTransfer.ARGUMENTS, - "socket" : openturns.WrapperDataTransfer.SOCKET, - "corba" : openturns.WrapperDataTransfer.CORBA, - None : openturns.WrapperDataTransfer.FILES, - } - -#========================== -# La classe de creation XML -#========================== - -class XMLGenerateur : - - ''' - Generation du fichier XML - ''' - def __init__ (self, appli, DictMCVal, DictVariables ) : - self.DictMCVal = DictMCVal - self.DictVariables = DictVariables - self.appli = appli - - def CreeXML (self) : - ''' - Pilotage general de la creation du fichier XML - ''' - data = openturns.WrapperData() - data.setLibraryPath( self.GetMCVal('WrapperPath','') ) - data.setVariableList( self.VariableList() ) - data.setFunctionDescription( self.FunctionDefinition() ) - data.setGradientDescription( self.GradientDefinition() ) - data.setHessianDescription( self.HessianDefinition() ) - data.setFileList( self.FileList() ) - data.setParameters( self.Parameters() ) - #data.setFrameworkData( self.FrameworkData() ) - - wrapper=openturns.WrapperFile() - wrapper.setWrapperData( data ) - - return wrapper - - - class __variable_ordering: - def __init__ (self, dictVar) : - self.dictVar = dictVar - - def __call__(self, a, b): - return self.dictVar[a]['numOrdre'] - self.dictVar[b]['numOrdre'] - - def VariableList (self) : - ''' - Ecrit la liste des variables - ''' - varList = openturns.WrapperDataVariableCollection() - for var in sorted( self.DictVariables.keys(), self.__variable_ordering( self.DictVariables ) ) : - varList.add( self.Variable( var, self.DictVariables[var] ) ) - return varList - - def Variable (self, var, dictVar) : - ''' - Ecrit le parametrage d une variable - ''' - variable = openturns.WrapperDataVariable() - variable.id_ = var - if dictVar[ 'Type' ] in VariableTypeByName.keys() : - variable.type_ = VariableTypeByName[ dictVar[ 'Type' ] ] - if dictVar.has_key('Comment') : variable.comment_ = dictVar[ 'Comment' ] - if dictVar.has_key('Unit') : variable.unit_ = dictVar[ 'Unit' ] - if dictVar.has_key('Regexp') : variable.regexp_ = dictVar[ 'Regexp' ] - if dictVar.has_key('Format') : variable.format_ = dictVar[ 'Format' ] - return variable - - def FunctionDefinition (self) : - ''' - Ecrit la description de la Fonction - ''' - func = openturns.WrapperFunctionDescription() - func.name_ = self.GetMCVal( 'FunctionName', '' ) - if (len(func.name_) != 0) : func.provided_ = SymbolProvidedByName[ 'yes' ] - return func - - def GradientDefinition (self) : - ''' - Ecrit la description du Gradient - ''' - grad = openturns.WrapperFunctionDescription() - grad.name_ = self.GetMCVal( 'GradientName', '' ) - if (len(grad.name_) != 0) : grad.provided_ = SymbolProvidedByName[ 'yes' ] - return grad - - def HessianDefinition (self) : - ''' - Ecrit la description de la Hessienne - ''' - hess = openturns.WrapperFunctionDescription() - hess.name_ = self.GetMCVal( 'HessianName', '' ) - if (len(hess.name_) != 0) : hess.provided_ = SymbolProvidedByName[ 'yes' ] - return hess - - - - def FileList (self) : - ''' - Ecrit la liste des fichiers - ''' - fileList = openturns.WrapperDataFileCollection() - for dictFile in self.GetMCVal('Files', []) : - fileList.add( self.File( dictFile ) ) - return fileList - - def File (self, dictFile ) : - ''' - Ecrit le parametrage d un fichier - ''' - fich = openturns.WrapperDataFile() - fich.id_ = dictFile[ 'Id' ] - if dictFile[ 'Type' ] in FileTypeByName.keys() : - fich.type_ = FileTypeByName[ dictFile[ 'Type' ] ] - if dictFile.has_key('Name') : fich.name_ = dictFile[ 'Name' ] - if dictFile.has_key('Path') : fich.path_ = dictFile[ 'Path' ] - if dictFile.has_key('Subst') : - import string - fich.subst_ = string.join( dictFile[ 'Subst' ], ',' ) - return fich - - def Parameters (self) : - ''' - Ecrit les parametres de couplage au code externe - ''' - parameters = openturns.WrapperParameter() - parameters.mode_ = WrapperModeByName[ self.GetMCVal('WrapCouplingMode') ] - if (parameters.mode_ == openturns.WrapperMode.FORK ): - parameters.command_ = self.GetMCVal('Command') - userPrefix = self.GetMCVal('UserPrefix', None) - if userPrefix != None : parameters.userPrefix_ = userPrefix - parameters.state_ = WrapperStateByName[ self.GetMCVal('State') ] - parameters.in_ = WrapperDataTransferByName[ self.GetMCVal('InDataTransfer') ] - parameters.out_ = WrapperDataTransferByName[ self.GetMCVal('OutDataTransfer') ] - return parameters - - def FrameworkData (self) : - ''' - Ecrit les donnees liees a l utilisation d un framework englobant - ''' - framework = openturns.WrapperFrameworkData() -# framework.studycase_ = "12:23:34" -# framework.componentname_ = self.GetMCVal('SolverComponentName', 'UNDEFINED') - CN = self.GetMCVal('SolverComponentName', 'UNDEFINED') - print 'CN = %s', CN - framework.componentname_ = CN - return framework - - - # --------------------------------------------------------------------------------- - - - def GetTag (self, tag) : - ''' - Recupere la chaine associee au tag dans la table dictTagsXML. - Leve une exception si le tag n est pas trouve - ''' - if ( dictTagsXML.has_key(tag) ) : - return dictTagsXML[tag] - else : - raise KeyError, tr("Tag %s non-defini. Ceci est un bogue interne. en informer les developpeurs.", tag) - pass - - def GetMCVal (self, MC, default = None, mandatory = False) : - ''' - Recupere la chaine associee au MC dans la table DictMCVal. - Leve une exception si le MC n est pas trouve et mandatory vaut True - ''' - if ( self.DictMCVal.has_key(MC) and self.DictMCVal[MC] != None ) : - return self.DictMCVal[MC] - else : - if ( mandatory ) : - raise KeyError, tr(" Le mot-cle %s est obligatoire.", MC) - else : - return default - pass diff --git a/generator/generator_Creation.py b/generator/generator_Creation.py deleted file mode 100644 index 8b427f73..00000000 --- a/generator/generator_Creation.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -""" - Ce module contient le plugin generateur de fichier au format - CARMEL3D pour EFICAS. - -""" -import traceback -import types,string,re,os -from Extensions.i18n import tr -from generator_python import PythonGenerator -debut=""" -lqdkqmldk -""" - - -def entryPoint(): - """ - Retourne les informations necessaires pour le chargeur de plugins - - Ces informations sont retournees dans un dictionnaire - """ - return { - # Le nom du plugin - 'name' : 'Creation', - # La factory pour creer une instance du plugin - 'factory' : CreationGenerator, - } - - -class CreationGenerator(PythonGenerator): - """ - - """ - # Les extensions de fichier permis? - - def gener(self,obj,format='brut',config=None): - - self.initDico(obj) - # Cette instruction genère le contenu du fichier de commandes (persistance) - self.text=PythonGenerator.gener(self,obj,format) - if obj.isvalid() : self.genereDescription() - return self.text - - - def genereParam(self): - listeParam=[] - for monParam in self.dictParam.keys(): - if self.dico.has_key(monParam) : continue - listeParam.append(self.dictParam[monParam]) - - if len(listeParam)== 0 : return - try: - jdcDict=self.jdc.jdcDict - except: - raise ValueError,tr("toutes les donnees ne sont pas connues") - for param in listeParam: - obj=None - for etape in self.jdc.jdcDict.etapes: - if str(etape.sdnom) != str(param) : - continue - obj=etape - break - - if obj==None: - raise ValueError,tr("toutes les donnees ne sont pas connues") - return - - texteEtape=self.generETAPE(obj) - - def genereDescription(self) : - ''' - ''' - self.texte=debut - self.genereParam() - - def initDico(self,obj) : - self.dicoCourant={} - self.dico={} - self.dictParam={} - self.listeParam=[] - self.jdc=obj.get_jdc_root() - try : - self.texte_jdc_aux=self.jdc.recorded_units[999] - except : - self.texte_jdc_aux="" - - - def generMCSIMP(self,obj) : - """ - Convertit un objet MCSIMP en texte python - Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable - """ - - #print "MCSIMP", obj.nom, " ", obj.valeur - from cree_map_cata import param_map - if isinstance(obj.valeur,param_map): - self.dicoCourant[obj.nom]=obj.valeur.nom - self.dictParam[obj.valeur.nom]=obj.valeur - else : - self.dicoCourant[obj.nom]=obj.valeur - s=PythonGenerator.generMCSIMP(self,obj) - return s - - def generPROC_ETAPE(self,obj): - self.dicoCourant={} - s=PythonGenerator.generPROC_ETAPE(self,obj) - self.dico[obj.nom]=self.dicoCourant - return s - - def generETAPE(self,obj): - #print "ETAPE", obj.nom, " ",obj.sdnom - self.dicoCourant={} - s=PythonGenerator.generETAPE(self,obj) - self.dico[obj.sdnom]=self.dicoCourant - return s - diff --git a/generator/generator_SEP.py b/generator/generator_SEP.py deleted file mode 100644 index 241d0bd9..00000000 --- a/generator/generator_SEP.py +++ /dev/null @@ -1,163 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -""" - Ce module contient le plugin generateur de fichier au format - SEP pour EFICAS. - -""" -import traceback -import types,string,re,os - -from generator_python import PythonGenerator - -def entryPoint(): - """ - Retourne les informations necessaires pour le chargeur de plugins - - Ces informations sont retournees dans un dictionnaire - """ - return { - # Le nom du plugin - 'name' : 'SEP', - # La factory pour creer une instance du plugin - 'factory' : SEPGenerator, - } - - -class SEPGenerator(PythonGenerator): - """ - Ce generateur parcourt un objet de type JDC et produit - un texte au format eficas et - un texte au format py - - """ - # Les extensions de fichier permis? - extensions=('.comm',) - - def gener(self,obj,format='brut',config=None): - self.initDico() - # Cette instruction génère le contenu du fichier de commandes (persistance) - self.text=PythonGenerator.gener(self,obj,format) - # Cette instruction génère le contenu du fichier de paramètres python - self.genereSEP() - return self.text - - def getTubePy(self) : - return self.texteTubePy - - def genereSEP(self) : - ''' - Prépare le contenu du fichier de paramètres python. Le contenu - peut ensuite être obtenu au moyen de la fonction getTubePy(). - ''' - #self.__genereSEP_withVariables() - self.__genereSEP_withDico() - - def __genereSEP_withVariables(self) : - ''' - Les paramètres sont transcrits sous forme de variables nom=valeur. - ''' - self.texteTubePy="# Parametres generes par Eficas \n" - for MC in self.dictMCVal.keys(): - ligne = MC +"="+ repr(self.dictMCVal[MC])+'\n' - self.texteTubePy=self.texteTubePy+ligne - - print self.texteTubePy - - # __GBO__: Tester self.tube pour aiguiller en fonction du cas (au besoin) - fichier=os.path.join(os.path.dirname(__file__),"tube.py") - f=open(fichier,'r') - for ligne in f.readlines(): - self.texteTubePy=self.texteTubePy+ligne - f.close - - def __genereSEP_withDico(self) : - """ - Les paramètres sont transcrits sous la forme d'un dictionnaire nom=valeur. - """ - from Sep import properties - self.texteTubePy="# -*- coding: utf-8 -*-\n" - self.texteTubePy+="# ======================================================================================\n" - self.texteTubePy+="# FICHIER GENERE PAR EFICAS - OUTIL MÉTIER SOUS-EPAISSEUR - " - self.texteTubePy+="VERSION "+str(properties.version)+" du "+str(properties.date)+"\n" - self.texteTubePy+="# ======================================================================================\n" - self.texteTubePy+="\n" - self.texteTubePy+="# Parametres Utilisateur Eficas \n" - self.texteTubePy+="parameters={}\n" - - for MC in self.dictMCVal.keys(): - ligne = "parameters['"+MC+"']="+ repr(self.dictMCVal[MC])+'\n' - self.texteTubePy=self.texteTubePy+ligne - - # On ajoute des paramètres de configuration pour contrôle de - # cohérence avec la procédure outil métier - self.texteTubePy+="# Parametres de Configuration Eficas \n" - ligne = "parameters['OMVERSION']="+str(properties.version)+"\n" - self.texteTubePy+=ligne - - # __GBO__: Tester self.tube pour aiguiller en fonction du cas (au besoin) - self.texteTubePy+="\n" - self.texteTubePy+="# Exécution de la procédure outil métier \n" - self.texteTubePy+="import os,sys\n" - self.texteTubePy+="sys.path.insert(0,os.environ['OM_ROOT_DIR'])\n" - self.texteTubePy+="import om_data\n" - self.texteTubePy+="om_data.setParameters(parameters)\n" - self.texteTubePy+="def run():\n" - self.texteTubePy+=" import om_smeca\n" - self.texteTubePy+="\n" - self.texteTubePy+='if __name__ == "__main__":\n' - self.texteTubePy+=" run()\n" - - # For debug only - print self.texteTubePy - - - def initDico(self) : - self.tube=0 - self.coude=0 - self.dictMCVal={} - self.texteTubePy="" - - # __GBO__: surcharge de PythonGenerator: - # voir example generator_cuve2dg.py (genea) - def generMCSIMP(self,obj) : - """ - Convertit un objet MCSIMP en texte python - Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable - """ - clef="" - for i in obj.get_genealogie() : - clef=clef+"__"+i - #self.dictMCVal[obj.nom]=obj.valeur - self.dictMCVal[clef]=obj.valeur - - s=PythonGenerator.generMCSIMP(self,obj) - return s - - # __GBO__: surcharge de PythonGenerator - def generMACRO_ETAPE(self,obj): - print obj.nom - if obj.nom == "S_EP_INTERNE" : - self.tube=1 - if obj.nom == "M_COUDE" : - self.coude=1 - s=PythonGenerator.generMACRO_ETAPE(self,obj) - return s - diff --git a/generator/generator_TELEMAC.py b/generator/generator_TELEMAC.py index 9e01ebf1..570de154 100644 --- a/generator/generator_TELEMAC.py +++ b/generator/generator_TELEMAC.py @@ -138,8 +138,6 @@ class TELEMACGenerator(PythonGenerator): self.texteDico += '/\t\t\t'+obj.nom +'\n' self.texteDico += '/------------------------------------------------------/\n' s=PythonGenerator.generPROC_ETAPE(self,obj) - #print obj - #print obj.nom if obj.nom in TELEMACGenerator.__dict__.keys() : apply(TELEMACGenerator.__dict__[obj.nom],(self,obj)) return s @@ -147,10 +145,6 @@ class TELEMACGenerator(PythonGenerator): def generMCSIMP(self,obj) : """recuperation de l objet MCSIMP""" s=PythonGenerator.generMCSIMP(self,obj) - #if obj.nom == "Title" : - #print s - # print str(obj.valeur) - #print repr(obj.valeur) # Attention pas sur --> ds certains cas non traite par MCFACT ? @@ -172,15 +166,14 @@ class TELEMACGenerator(PythonGenerator): if not( type(obj.valeur) in (types.TupleType,types.ListType) ): if obj.nom in DicoEnumCasEnInverse.keys(): try : sTelemac=str(DicoEnumCasEnInverse[obj.nom][obj.valeur]) - except : print "generMCSIMP Pb valeur avec ", obj.nom, obj.valeur + except : print ("generMCSIMP Pb valeur avec ", obj.nom, obj.valeur) if type(obj.valeur) in (types.TupleType,types.ListType) : - #print "je passe pour", obj.nom if obj.nom in DicoEnumCasEnInverse.keys(): #sT = "'" sT='' for v in obj.valeur: try : sT +=str(DicoEnumCasEnInverse[obj.nom][v]) +";" - except : print "generMCSIMP Pb Tuple avec ", obj.nom, v, obj.valeur + except : print ("generMCSIMP Pb Tuple avec ", obj.nom, v, obj.valeur) #sTelemac=sT[0:-1]+"'" sTelemac=sT[0:-1] else : @@ -207,7 +200,6 @@ class TELEMACGenerator(PythonGenerator): if obj.nom not in self.dicoCataToCas : if obj.nom == 'Consigne' : return "" - print obj.nom , ' non traite' return s nom=self.dicoCataToCas[obj.nom] @@ -217,11 +209,6 @@ class TELEMACGenerator(PythonGenerator): ligne=nom+ " : " + s3 + "\n" if len(ligne) > 72 : ligne=self.redecoupeLigne(nom,s3) self.texteDico+=ligne - #print "_______________________" - #print s - #print ligne - #print "_______________________" - return s def generMCFACT(self,obj): """ @@ -256,7 +243,6 @@ class TELEMACGenerator(PythonGenerator): self.VE=True self.textVE += str(valeur) +"; " else : self.textVE += "0.; " - print self.textPE, self.textFE,self.textVE def BOUNDARY_CONDITIONS(self,obj): # sans '; ' @@ -269,8 +255,8 @@ class TELEMACGenerator(PythonGenerator): def NAME_OF_TRACER(self,obj): - print dir(obj) - print obj.get_genealogie_precise() + print (dir(obj) ) + print (obj.get_genealogie_precise()) def Validation(self,obj): self.texteDico += "VALIDATION : True \n" @@ -279,14 +265,12 @@ class TELEMACGenerator(PythonGenerator): an=obj.get_child('Year').valeur mois=obj.get_child('Month').valeur jour=obj.get_child('Day').valeur - #print an, mois, jour self.texteDico += "ORIGINAL DATE OF TIME :"+ str(an)+ " ,"+str(mois)+ "," +str(jour)+ "\n" def Original_Hour_Of_Time (self,obj): hh=obj.get_child('Hour').valeur mm=obj.get_child('Minute').valeur ss=obj.get_child('Second').valeur - #print hh, mm, ss self.texteDico += "ORIGINAL HOUR OF TIME :"+str(hh)+" ,"+str(mm)+ ","+str(ss)+"\n" def Type_Of_Advection(self,obj): @@ -297,12 +281,9 @@ class TELEMACGenerator(PythonGenerator): self.chercheChildren(obj) dicoSuf={ 'U_And_V' : 0, 'H' : 1, 'K_And_Epsilon' : 2, 'Tracers' : 3} for c in self.listeMCAdvection: - #print c.nom if c.nom[0:18] == 'Type_Of_Advection_' and c.valeur!=None: suf=c.nom[18:] index=dicoSuf[suf] - #print c.valeur - #print DicoEnumCasEnInverse['Type_Of_Advection'] listeAdvection[index]=DicoEnumCasEnInverse['Type_Of_Advection'][c.valeur] if c.nom[0:13] == 'Supg_Option_' and c.valeur!=None: suf=c.nom[13:] diff --git a/generator/generator_ZCracks.py b/generator/generator_ZCracks.py index 17ce5e0c..eb3324bf 100644 --- a/generator/generator_ZCracks.py +++ b/generator/generator_ZCracks.py @@ -80,7 +80,7 @@ class ZCrackGenerator(PythonGenerator): def writeDefault(self,fn) : fileZcrack = fn[:fn.rfind(".")] + '.z7p' f = open( str(fileZcrack), 'wb') - print self.textePourRun + print (self.textePourRun) self.ajoutRun() self.textePourRunAvecDouble=self.textePourRun.replace("'",'"') diff --git a/generator/generator_cuve2dg.py b/generator/generator_cuve2dg.py deleted file mode 100644 index 94f901da..00000000 --- a/generator/generator_cuve2dg.py +++ /dev/null @@ -1,1723 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -""" - Ce module contient le plugin generateur de fichier au format - DefaillCUVE pour EFICAS. - -""" -import traceback -import types,string,re - -from Noyau import N_CR -from Accas import MCSIMP -from generator_python import PythonGenerator - -def entryPoint(): - """ - Retourne les informations nécessaires pour le chargeur de plugins - - Ces informations sont retournées dans un dictionnaire - """ - return { - # Le nom du plugin - 'name' : 'cuve2dg', - # La factory pour créer une instance du plugin - 'factory' : Cuve2dgGenerator, - } - - -class Cuve2dgGenerator(PythonGenerator): - """ - Ce generateur parcourt un objet de type JDC et produit - un texte au format eficas et - un texte au format DefaillCUVE - - """ - # Les extensions de fichier préconisées - extensions=('.comm',) - - def __init__(self,cr=None): - # Si l'objet compte-rendu n'est pas fourni, on utilise le compte-rendu standard - if cr : - self.cr=cr - else: - self.cr=N_CR.CR(debut='CR generateur format DefaillCUVE pour DefaillCUVE', - fin='fin CR format DefaillCUVE pour DefaillCUVE') - # Le texte au format DefaillCUVE est stocké dans l'attribut textCuve - self.textCuve='' - - # Ce dictionnaire liste le nom des variables utilisees dans le script - self.variable = { - "NiveauImpression" : "MESSAGE_LEVEL", - "FichierDataIn" : "DATARESUME_FILE", - "FichierTempSigma" : "TEMPSIG_FILE", - "FichierCSV" : "CSV_FILE", - "FichierRESTART" : "RESTART_FILE", - "FichierEXTR" : "EXTR_FILE", - "ChoixPlugin" : "CHOIPLUG", - "GrandeurEvaluee" : "GRANDEUR", - "IncrementTemporel" : "INCRTPS", - "IncrementMaxTemperature" : "DTPREC", - "ChoixExtractionTransitoires" : "CHOIEXTR", - "IncrementMaxTempsAffichage" : "DTARCH", - "TraitementGeometrie" : "TYPEGEOM", - "RayonInterne" : "RINT", - "RayonInterne_mess" : "RINT_MESSAGE", - "RayonExterne" : "REXT", - "RayonExterne_mess" : "REXT_MESSAGE", - "EpaisseurRevetement" : "LREV", - "EpaisseurRevetement_mess" : "LREV_MESSAGE", - "LigamentExterneMin" : "LIGMIN", - "LigamentExterneMin_mess" : "LIGMIN_MESSAGE", - "NombreNoeudsMaillage" : "NBNO", - "TypeInitial" : "TYPEDEF", - "Orientation" : "ORIEDEF", - "Position" : "POSDEF", - "ProfondeurRadiale" : "PROFDEF", - "ProfondeurRadiale_mess" : "PROFDEF_MESSAGE", - "ModeCalculLongueur" : "OPTLONG", - "Longueur" : "LONGDEF", - "Longueur_mess" : "LONGDEF_MESSAGE", - "CoefDirecteur" : "PROFSURLONG", - "CoefDirecteur_mess" : "PROFSURLONG_MESSAGE", - "Constante" : "LONGCONST", - "ModeCalculDecalage" : "DECATYP", - "DecalageNormalise" : "DECANOR", - "DecalageNormalise_mess" : "DECANOR_MESSAGE", - "DecalageRadial" : "DECADEF", - "DecalageRadial_mess" : "DECADEF_MESSAGE", - "Azimut" : "ANGLDEF", - "Azimut_mess" : "ANGLDEF_MESSAGE", - "Altitude_mess" : "ANGLDEF_MESSAGE", - "Altitude" : "ALTIDEF", - "Altitude_mess" : "ALTIDEF_MESSAGE", - "Pointe" : "POINDEF", - "ModeleFluence" : "MODELFLUENCE", - "ZoneActiveCoeur_AltitudeSup" : "H1COEUR", - "ZoneActiveCoeur_AltitudeInf" : "H2COEUR", - "FluenceMax" : "fmax", - "KPFrance" : "KPFRANCE", - "KPUS" : "KPUS", - "Azimut_0deg" : "COEFFLUENCE1", - "Azimut_5deg" : "COEFFLUENCE2", - "Azimut_10deg" : "COEFFLUENCE3", - "Azimut_15deg" : "COEFFLUENCE4", - "Azimut_20deg" : "COEFFLUENCE5", - "Azimut_25deg" : "COEFFLUENCE6", - "Azimut_30deg" : "COEFFLUENCE7", - "Azimut_35deg" : "COEFFLUENCE8", - "Azimut_40deg" : "COEFFLUENCE9", - "Azimut_45deg" : "COEFFLUENCE10", - "TypeIrradiation" : "TYPEIRR", - "RTNDT" : "RTNDT", - "ModeleIrradiation" : "MODELIRR", - "TeneurCuivre" : "CU", - "TeneurCuivre_mess" : "CU_MESSAGE", - "TeneurNickel" : "NI", - "TeneurNickel_mess" : "NI_MESSAGE", - "TeneurPhosphore" : "P", - "TeneurPhosphore_mess" : "P_MESSAGE", - "MoyenneRTndt" : "RTimoy", - "MoyenneRTndt_mess" : "RTimoy_MESSAGE", - "CoefVariationRTndt" : "RTicov", - "CoefVariationRTndt_mess" : "RTicov_MESSAGE", - "EcartTypeRTndt" : "USectDRT", - "EcartTypeRTndt_mess" : "USectDRT_MESSAGE", - "NombreEcartTypeRTndt" : "nbectDRTNDT", - "NombreEcartTypeRTndt_mess" : "nbectDRTNDT_MESSAGE", - "ModeleTenacite" : "MODELKIC", - "NombreCaracteristique" : "NBCARAC", - "NbEcartType_MoyKIc" : "nbectKIc", - "NbEcartType_MoyKIc_mess" : "nbectKIc_MESSAGE", - "PalierDuctile_KIc" : "KICPAL", - "CoefficientVariation_KIc" : "KICCDV", - "Fractile_KIc" : "fractKIc", - "Fractile_KIc_mess" : "fractKIc_MESSAGE", - "Temperature_KIc100" : "T0WALLIN", - "A1" : "A1", - "A2" : "A2", - "A3" : "A3", - "B1" : "B1", - "B2" : "B2", - "B3" : "B3", - "C1" : "C1", - "C2" : "C2", - "C3" : "C3", - "ChoixCorrectionLongueur" : "CHOIXCL", - "AttnCorrBeta" : "ATTNCORRBETA", - "CorrIrwin" : "CORRIRWIN", - "ArretDeFissure" : "ARRETFISSURE", - "IncrementTailleFissure" : "INCRDEF", - "IncrementTailleFissure_mess" : "INCRDEF_MESSAGE", - "NbEcartType_MoyKIa" : "nbectKIa", - "PalierDuctile_KIa" : "KIAPAL", - "CoefficientVariation_KIa" : "KIACDV", - "ChoixCoefficientChargement" : "CHOIXSIGM", - "CoefficientDuctile" : "COEFSIGM1", - "CoefficientFragile" : "COEFSIGM2", - "InstantInitialisation" : "INSTINIT", - "ConditionLimiteThermiqueREV" : "KTHREV", - "TemperatureDeformationNulleREV" : "TREFREV", - "TemperaturePourCoefDilatThermREV" : "TDETREV", - "CoefficientPoissonREV" : "NUREV", - "ConditionLimiteThermiqueMDB" : "KTHMDB", - "TemperatureDeformationNulleMDB" : "TREFMDB", - "TemperaturePourCoefDilatThermMDB" : "TDETMDB", - "CoefficientPoissonMDB" : "NUMDB", - "TypeConditionLimiteThermique" : "TYPCLTH", - "Instant_1" : "INSTANT1", - "Instant_2" : "INSTANT2", - "Instant_3" : "INSTANT3", - "DebitAccumule" : "QACCU", - "DebitInjectionSecurite" : "QIS", - "TempInjectionSecurite" : "TIS", - "TempInjectionSecurite_mess" : "TIS_MESSAGE", - "DiametreHydraulique" : "DH", - "DiametreHydraulique_mess" : "DH_MESSAGE", - "SectionEspaceAnnulaire" : "SECTION", - "SectionEspaceAnnulaire_mess" : "SECTION_MESSAGE", - "HauteurCaracConvectionNaturelle" : "DELTA", - "HauteurCaracConvectionNaturelle_mess" : "DELTA_MESSAGE", - "CritereConvergenceRelative" : "EPS", - "CoefficientsVestale" : "COEFVESTALE", - "VolumeMelange_CREARE" : "VMTAB", - "TemperatureInitiale_CREARE" : "T0", - "TemperatureInitiale_CREARE_mess" : "T0_MESSAGE", - "SurfaceEchange_FluideStructure" : "SE", - "SurfaceEchange_FluideStructure_mess" : "SE_MESSAGE", - "InstantPerteCirculationNaturelle" : "INST_PCN", - } - - # Ce dictionnaire liste le nom des valeurs proposées utilisees dans le script - self.valeurproposee = { - "Aucune impression" : "0", - "Temps total" : "1", - "Temps intermediaires" : "2", - "Facteur de marge KIc/KCP" : "FM_KICSURKCP", - "Marge KIc-KI" : "MARGE_KI", - "Marge KIc-KCP" : "MARGE_KCP", - "Topologie" : "GEOMETRIE", - "Maillage" : "MAILLAGE", - "Defaut Sous Revetement" : "DSR", - "Defaut Decale" : "DECALE", - "Defaut Debouchant" : "DEBOUCHANT", - "Longitudinale" : "LONGITUD", - "Circonferentielle" : "CIRCONF", - "Virole" : "VIROLE", - "Joint soude" : "JSOUDE", - "Valeur" : "VALEUR", - "Fonction affine de la profondeur" : "FCTAFFINE", - "Valeur normalisee" : "NORMALISE", - "A" : "A", - "B" : "B", - "A et B" : "BOTH", - "Exponentiel sans revetement k=9.7 (Reglementaire)" : "Reglementaire", - "Exponentiel sans revetement k=12.7 (France)" : "France", - "Exponentiel sans revetement k=0. (ValeurImposee)" : "ValeurImposee", - "Donnees francaises du palier CPY (SDM)" : "SDM", - "Regulatory Guide 1.99 rev 2 (USNRC)" : "USNRC", - "Dossier 900 MWe AP9701 rev 2 (REV_2)" : "REV_2", - "Lissage du modele ajuste (SDM_Lissage)" : "SDM_Lissage", - "Donnees francaises du palier CPY ajustees par secteur angulaire (GrandeDev)" : "GrandeDev", - "Grand developpement (GD_Cuve)" : "GD_Cuve", - "Exponentiel sans revetement k=9.7 (Reglementaire CUVE1D)" : "Cuve1D", - "RTndt de la cuve a l instant de l analyse" : "RTNDT", - "Modele d irradiation" : "FLUENCE", - "Formule de FIM/FIS Lefebvre modifiee" : "LEFEBnew", - "Metal de Base : formule de FIM/FIS Houssin" : "HOUSSIN", - "Metal de Base : formule de FIM/FIS Persoz" : "PERSOZ", - "Metal de Base : formule de FIM/FIS Lefebvre" : "LEFEBVRE", - "Metal de Base : Regulatory Guide 1.00 rev 2" : "USNRCmdb", - "Joint Soude : formulation de FIM/FIS Brillaud" : "BRILLAUD", - "Joint Soude : Regulatory Guide 1.00 rev 2" : "USNRCsoud", - "RCC-M/ASME coefficient=2" : "RCC-M", - "RCC-M/ASME coefficient=2 CUVE1D" : "RCC-M_simpl", - "RCC-M/ASME coefficient=2.33 (Houssin)" : "Houssin_RC", - "RCC-M/ASME avec KI=KIpalier" : "RCC-M_pal", - "RCC-M/ASME avec KI~exponentiel" : "RCC-M_exp", - "Weibull basee sur la master cuve" : "Wallin", - "Weibull basee sur la master cuve (REME)" : "REME", - "Weibull n\xb01 (etude ORNL)" : "ORNL", - "Weibull n\xb02" : "WEIB2", - "Weibull n\xb03" : "WEIB3", - "Weibull generalisee" : "WEIB-GEN", - "Exponentielle n\xb01 (Frama)" : "Frama", - "Exponentielle n\xb02 (LOGWOLF)" : "LOGWOLF", - "Quantile" : "QUANTILE", - "Ordre" : "ORDRE", - "Enthalpie" : "ENTHALPIE", - "Chaleur" : "CHALEUR", - "Temperature imposee en paroi" : "TEMP_IMPO", - "Flux de chaleur impose en paroi" : "FLUX_REP", - "Temperature imposee du fluide et coefficient echange" : "ECHANGE", - "Debit massique et temperature d injection de securite" : "DEBIT", - "Temperature imposee du fluide et debit d injection de securite" : "TEMP_FLU", - "Courbe APRP" : "APRP", - "Calcul TEMPFLU puis DEBIT" : "TFDEBIT", - } - - # Ce dictionnaire liste le commentaire des variables utilisees dans le script - self.comment = { - "NiveauImpression" : "Niveau d impression des messages a l ecran (=0 : rien, =1 : temps calcul total, =2 : temps intermediaires)", - "FichierDataIn" : "sortie du fichier recapitulatif des donnees d entree {OUI ; NON}", - "FichierTempSigma" : "sortie des fichiers temperature et contraintes {OUI ; NON}", - "FichierCSV" : "sortie du fichier resultat template_DEFAILLCUVE.CSV {OUI ; NON}", - "FichierRESTART" : "sortie du fichier de re-demarrage", - "FichierEXTR" : "sortie du fichier d extraction des transitoires", - "ChoixPlugin" : "choix d'un repertoire de plug-in", - "GrandeurEvaluee" : "choix de la grandeur sous critere evaluee {FM_KICSURKCP ; MARGE_KI ; MARGE_KCP}", - "IncrementTemporel" : "increment temporel pour l analyse PROBABILISTE (si DETERMINISTE, fixer a 1)", - "IncrementMaxTemperature" : "increment max de temp/noeud/instant (degC)", - "ChoixExtractionTransitoires" : "choix d'extraction de transitoires de temp et contraintes", - "IncrementMaxTempsAffichage" : "increment max de temps pour affichage (s)", - "TraitementGeometrie" : "traitement de la geometrie de la cuve : {GEOMETRIE, MAILLAGE}", - "RayonInterne" : "rayon interne (m)", - "RayonInterne_mess" : "affichage ecran du rayon interne (m)", - "RayonExterne" : "rayon externe (m)", - "RayonExterne_mess" : "affichage ecran du rayon externe (m)", - "EpaisseurRevetement" : "epaisseur revetement (m)", - "EpaisseurRevetement_mess" : "affichage ecran de l epaisseur revetement (m)", - "LigamentExterneMin" : "ligament externe minimal avant rupture (% de l'epaisseur de cuve)", - "LigamentExterneMin_mess" : "affichage ecran du ligament externe minimal avant rupture (% de l'epaisseur de cuve)", - "NombreNoeudsMaillage" : "nbre de noeuds dans l'epaisseur de la cuve", - "TypeInitial" : "type initial du defaut : DEBOUCHANT=Defaut Debouchant, DSR=Defaut Sous Revetement, DECALE=Defaut Decale", - "Orientation" : "orientation (LONGITUD / CIRCONF)", - "Position" : "Position du defaut (VIROLE / JSOUDE)", - "ProfondeurRadiale" : "profondeur radiale ou encore hauteur (m)", - "ProfondeurRadiale_mess" : "affichage ecran de la profondeur radiale ou encore hauteur (m)", - "ModeCalculLongueur" : "option pour definir la longueur du defaut (VALEUR pour une valeur fixe, FCTAFFINE pour une fct affine de la profondeur)", - "Longueur" : "longueur (m) pour defaut Sous Revetement", - "Longueur_mess" : "affichage ecran de la longueur (m) pour defaut Sous Revetement", - "CoefDirecteur" : "pente de la fonction affine l = h/profsurlong + a0", - "CoefDirecteur_mess" : "affichage ecran de la pente de la fonction affine l = h/profsurlong + a0", - "Constante" : "constante de la fonction affine a0", - "ModeCalculDecalage" : "type de decalage : normalise (NORMALISE) ou reel (VALEUR)", - "DecalageNormalise" : "decalage radial normalise (valeur comprise entre 0. et 1.) pour defaut Sous Revetement", - "DecalageNormalise_mess" : "affichage ecran du decalage radial normalise (valeur comprise entre 0. et 1.) pour defaut Sous Revetement", - "DecalageRadial" : "decalage radial reel (m) pour defaut decale", - "DecalageRadial_mess" : "affichage ecran du decalage radial reel (m) pour defaut decale", - "Azimut" : "coordonnee angulaire (degre)", - "Azimut_mess" : "affichage ecran de la coordonnee angulaire (degre)", - "Altitude" : "altitude (m) : valeur negative", - "Altitude_mess" : "affichage ecran de l altitude (m) : valeur negative", - "Pointe" : "choix du(des) point(s) du defaut considere {'A','B','BOTH'} pour DSR et DECALE (pour DEBOUCHANT : automatiquement 'B')", - "ModeleFluence" : "modele de fluence : {Reglementaire, France, ValeurImposee, SDM, USNRC, REV_2, SDM_Lissage, GrandeDev, GD_Cuve, Cuve1D}", - "ZoneActiveCoeur_AltitudeSup" : "cote superieure de la zone active de coeur (ici pour cuve palier 900Mw)", - "ZoneActiveCoeur_AltitudeInf" : "cote inferieure de la zone active de coeur (ici pour cuve palier 900Mw)", - "FluenceMax" : "fluence maximale assimilee par la cuve (n/cm2)", - "KPFrance" : "parametre exponentiel du modele France", - "KPUS" : "parametre exponentiel du modele US", - "Azimut_0deg" : "fluence a l'azimut 0 (10^19 n/cm)", - "Azimut_5deg" : "fluence a l'azimut 5 (10^19 n/cm)", - "Azimut_10deg" : "fluence a l'azimut 10 (10^19 n/cm)", - "Azimut_15deg" : "fluence a l'azimut 15 (10^19 n/cm)", - "Azimut_20deg" : "fluence a l'azimut 20 (10^19 n/cm)", - "Azimut_25deg" : "fluence a l'azimut 25 (10^19 n/cm)", - "Azimut_30deg" : "fluence a l'azimut 30 (10^19 n/cm)", - "Azimut_35deg" : "fluence a l'azimut 35 (10^19 n/cm)", - "Azimut_40deg" : "fluence a l'azimut 40 (10^19 n/cm)", - "Azimut_45deg" : "fluence a l'azimut 45 (10^19 n/cm)", - "TypeIrradiation" : "type irradiation : {RTNDT, FLUENCE}", - "RTNDT" : "RTNDT finale (degC)", - "ModeleIrradiation" : "modele d irradiation : LEFEBnew, ou {HOUSSIN, PERSOZ, LEFEBVRE, USNRCmdb} pour virole et {BRILLAUD,USNRCsoud} pour jointsoude", - "TeneurCuivre" : "teneur en cuivre (%)", - "TeneurCuivre_mess" : "affichage ecran de la teneur en cuivre (%)", - "TeneurNickel" : "teneur en nickel (%)", - "TeneurNickel_mess" : "affichage ecran de la teneur en nickel (%)", - "TeneurPhosphore" : "teneur en phosphore (%)", - "TeneurPhosphore_mess" : "affichage ecran de la teneur en phosphore (%)", - "MoyenneRTndt" : "moyenne de la RTNDT initiale : virole C1 de cuve Chinon : mdb=>-17.degC et js=>42.degC (HT-56/05/038 : p.52)", - "MoyenneRTndt_mess" : "affichage ecran de la moyenne de la RTNDT initiale", - "CoefVariationRTndt" : "coef de variation de la RTNDT initiale", - "CoefVariationRTndt_mess" : "affichage ecran du coef de variation de la RTNDT initiale", - "EcartTypeRTndt" : "pour modeles USNRCsoud ou USNRCmdb, ecart-type du decalage de RTNDT (°F) (28. pour js et 17. pour mdb)", - "EcartTypeRTndt_mess" : "affichage ecran, pour modeles USNRCsoud ou USNRCmdb, ecart-type du decalage de RTNDT (°F) (28. pour js et 17. pour mdb)", - "NombreEcartTypeRTndt" : "Nbre d ecart-type par rapport a la moyenne de DRTNDT si analyse PROBABILISTE (en DETERMINISTE, fixer a 2.)", - "NombreEcartTypeRTndt_mess" : "affichage ecran du nbre d ecart-type par rapport a la moyenne de DRTNDT si analyse PROBABILISTE", - "ModeleTenacite" : "modele de tenacite : {RCC-M, RCC-M_pal, RCC-M_exp, RCC-M_simpl, Houssin_RC, Wallin, REME, ORNL, Frama, WEIB3, WEIB2, LOGWOLF, WEIB-GEN}", - "NombreCaracteristique" : "Nb caracteristique : ORDRE ou QUANTILE", - "NbEcartType_MoyKIc" : "Nbre d ecart-type par rapport a la moyenne de KIc si analyse PROBABILISTE (en DETERMINISTE, fixer a -2.)", - "NbEcartType_MoyKIc_mess" : "affichage ecran du nbre d ecart-type par rapport a la moyenne de KIc si analyse PROBABILISTE", - "PalierDuctile_KIc" : "palier deterministe de K1c (MPa(m^0.5))", - "CoefficientVariation_KIc" : "coef de variation de la loi normale de K1c", - "Fractile_KIc" : "valeur caracteristique de KIc exprimee en ordre de fractile (%)", - "Fractile_KIc_mess" : "affichage ecran de la valeur caracteristique de KIc exprimee en ordre de fractile (%)", - "Temperature_KIc100" : "parametre T0 du modele Wallin (degC)", - "A1" : "coef des coefs d une WEIBULL generale", - "A2" : "", - "A3" : "", - "B1" : "", - "B2" : "", - "B3" : "", - "C1" : "", - "C2" : "", - "C3" : "", - "ChoixCorrectionLongueur" : "Activation ou non de la correction de longueur {OUI ; NON}", - "AttnCorrBeta" : "Attenuation de la correction plastique : {OUI, NON} ==> uniquement pour DSR ou DECALE", - "CorrIrwin" : "Correction plastique IRWIN : {OUI, NON} ==> uniquement pour DEBOUCHANT", - "ArretDeFissure" : "prise en compte de l arret de fissure {OUI, NON} (en PROBABILISTE, fixer a NON)", - "IncrementTailleFissure" : "increment de la taille de fissure (m)", - "IncrementTailleFissure_mess" : "affichage ecran de l increment de la taille de fissure (m)", - "NbEcartType_MoyKIa" : "Nbre d ecart-type par rapport a la moyenne de KIa (nb sigma)", - "PalierDuctile_KIa" : "palier deterministe de K1a quand modele RCC-M (MPa(m^0.5))", - "CoefficientVariation_KIa" : "coef de variation de la loi normale de K1a", - "ChoixCoefficientChargement" : "prise en compte de coefficients sur le chargement (OUI/NON)", - "CoefficientDuctile" : "coefficient multiplicateur pour rupture ductile", - "CoefficientFragile" : "coefficient multiplicateur pour rupture fragile", - "InstantInitialisation" : "instant initial (s)", - "ConditionLimiteThermiqueREV" : "Option 'ENTHALPIE' ou 'CHALEUR'", - "TemperatureDeformationNulleREV" : "temperature de deformation nulle (degC)", - "TemperaturePourCoefDilatThermREV" : "temperature de definition du coefficient de dilatation thermique (degC)", - "CoefficientPoissonREV" : "coefficient de Poisson", - "ConditionLimiteThermiqueMDB" : "Option 'ENTHALPIE' ou 'CHALEUR'", - "TemperatureDeformationNulleMDB" : "temperature de deformation nulle (degC)", - "TemperaturePourCoefDilatThermMDB" : "temperature de definition du coefficient de dilatation thermique (degC)", - "CoefficientPoissonMDB" : "coefficient de Poisson", - "TypeConditionLimiteThermique" : "Type de condition thermique en paroi interne {TEMP_IMPO,FLUX_REP,ECHANGE,DEBIT,TEMP_FLU,APRP}", - "Instant_1" : "Borne superieure de l intervalle de temps du 1er palier TACCU", - "Instant_2" : "Borne superieure de l intervalle de temps du 2nd palier T1", - "Instant_3" : "Borne superieure de l intervalle de temps du 3eme palier TIS", - "DebitAccumule" : "Debit accumule (en m3/h)", - "DebitInjectionSecurite" : "Debit injection de securite (en m3/h)", - "TempInjectionSecurite" : "Temperature injection de securite (en degC)", - "TempInjectionSecurite_mess" : "affichage ecran de la temperature injection de securite", - "DiametreHydraulique" : "Diametre hydraulique (m)", - "DiametreHydraulique_mess" : "affichage ecran du diametre hydraulique (m)", - "SectionEspaceAnnulaire" : "Section espace annulaire (m2)", - "SectionEspaceAnnulaire_mess" : "affichage ecran de la section espace annulaire (m2)", - "HauteurCaracConvectionNaturelle" : "Hauteur caracteristique convection naturelle (m)", - "HauteurCaracConvectionNaturelle_mess" : "affichage ecran de la hauteur caracteristique convection naturelle (m)", - "CritereConvergenceRelative" : "Critere convergence relative (-)", - "CoefficientsVestale" : "Application des coefs de Vestale {OUI;NON}", - "VolumeMelange_CREARE" : "Transitoire de volume de melange CREARE (m3)", - "TemperatureInitiale_CREARE" : "Temperature initiale CREARE (degC)", - "TemperatureInitiale_CREARE_mess" : "affichage ecran de la temperature initiale CREARE (degC)", - "SurfaceEchange_FluideStructure" : "Surface d'echange fluide/structure (m2)", - "SurfaceEchange_FluideStructure_mess" : "affichage ecran de la surface d'echange fluide/structure (m2)", - "InstantPerteCirculationNaturelle" : "Instant de perte de circulation naturelle", - } - - # Ce dictionnaire liste la valeur par defaut des variables utilisees dans le script - self.default = { - "NiveauImpression" : "1", - "FichierDataIn" : "NON", - "FichierTempSigma" : "NON", - "FichierCSV" : "NON", - "FichierRESTART" : "NON", - "FichierEXTR" : "NON", - "ChoixPlugin" : "NON", - "GrandeurEvaluee" : "FM_KICSURKCP", - "IncrementTemporel" : "1", - "IncrementMaxTemperature" : "0.1", - "ChoixExtractionTransitoires" : "NON", - "IncrementMaxTempsAffichage" : "1000.", - "TraitementGeometrie" : "GEOMETRIE", - "RayonInterne" : "1.994", - "RayonInterne_mess" : "NON", - "RayonExterne" : "2.2015", - "RayonExterne_mess" : "NON", - "EpaisseurRevetement" : "0.0075", - "EpaisseurRevetement_mess" : "NON", - "LigamentExterneMin" : "0.75", - "LigamentExterneMin_mess" : "NON", - "NombreNoeudsMaillage" : "300", - "TypeInitial" : "DSR", - "Position" : "VIROLE", - "ProfondeurRadiale" : "0.006", - "ProfondeurRadiale_mess" : "NON", - "ModeCalculLongueur" : "VALEUR", - "Longueur" : "0.060", - "Longueur_mess" : "NON", - "CoefDirecteur" : "10.", - "CoefDirecteur_mess" : "NON", - "Constante" : "0.", - "ModeCalculDecalage" : "VALEUR", - "DecalageNormalise" : "0.1", - "DecalageNormalise_mess" : "NON", - "DecalageRadial" : "0.", - "DecalageRadial_mess" : "NON", - "Azimut" : "0.", - "Azimut_mess" : "NON", - "Altitude" : "-4.", - "Altitude_mess" : "NON", - "Pointe" : "B", - "ModeleFluence" : "Reglementaire", - "ZoneActiveCoeur_AltitudeSup" : "-3.536", - "ZoneActiveCoeur_AltitudeInf" : "-7.194", - "FluenceMax" : "6.5", - "KPFrance" : "12.7", - "KPUS" : "9.4488", - "Azimut_0deg" : "5.8", - "Azimut_5deg" : "5.48", - "Azimut_10deg" : "4.46", - "Azimut_15deg" : "3.41", - "Azimut_20deg" : "3.37", - "Azimut_25deg" : "3.16", - "Azimut_30deg" : "2.74", - "Azimut_35deg" : "2.25", - "Azimut_40deg" : "1.89", - "Azimut_45deg" : "1.78", - "TypeIrradiation" : "RTNDT", - "RTNDT" : "64.", - "ModeleIrradiation" : "HOUSSIN", - "TeneurCuivre" : "0.0972", - "TeneurCuivre_mess" : "NON", - "TeneurNickel" : "0.72", - "TeneurNickel_mess" : "NON", - "TeneurPhosphore" : "0.00912", - "TeneurPhosphore_mess" : "NON", - "MoyenneRTndt" : "-12.0", - "MoyenneRTndt_mess" : "NON", - "CoefVariationRTndt" : "0.1", - "CoefVariationRTndt_mess" : "NON", - "EcartTypeRTndt" : "-2.", - "EcartTypeRTndt_mess" : "NON", - "NombreEcartTypeRTndt" : "2.", - "NombreEcartTypeRTndt_mess" : "NON", - "ModeleTenacite" : "RCC-M", - "NombreCaracteristique" : "Quantile", - "NbEcartType_MoyKIc" : "-2.", - "NbEcartType_MoyKIc_mess" : "NON", - "PalierDuctile_KIc" : "195.", - "CoefficientVariation_KIc" : "0.15", - "Fractile_KIc" : "5.", - "Fractile_KIc_mess" : "NON", - "Temperature_KIc100" : "-27.", - "A1" : "21.263", - "A2" : "9.159", - "A3" : "0.04057", - "B1" : "17.153", - "B2" : "55.089", - "B3" : "0.0144", - "C1" : "4.", - "C2" : "0.", - "C3" : "0.", - "ChoixCorrectionLongueur" : "OUI", - "AttnCorrBeta" : "NON", - "CorrIrwin" : "NON", - "ArretDeFissure" : "NON", - "IncrementTailleFissure" : "0.", - "IncrementTailleFissure_mess" : "NON", - "NbEcartType_MoyKIa" : "0.", - "PalierDuctile_KIa" : "0.", - "CoefficientVariation_KIa" : "0.", - "ChoixCoefficientChargement" : "NON", - "CoefficientDuctile" : "1.0", - "CoefficientFragile" : "1.0", - "InstantInitialisation" : "-1.", - "ConditionLimiteThermiqueREV" : "CHALEUR", - "TemperatureDeformationNulleREV" : "20.", - "TemperaturePourCoefDilatThermREV" : "287.", - "CoefficientPoissonREV" : "0.3", - "ConditionLimiteThermiqueMDB" : "CHALEUR", - "TemperatureDeformationNulleMDB" : "20.", - "TemperaturePourCoefDilatThermMDB" : "287.", - "CoefficientPoissonMDB" : "0.3", - "TypeConditionLimiteThermique" : "TEMP_IMPO", - "Instant_1" : "21.", - "Instant_2" : "45.", - "Instant_3" : "5870.", - "DebitAccumule" : "2.3", - "DebitInjectionSecurite" : "0.375", - "TempInjectionSecurite" : "9.", - "TempInjectionSecurite_mess" : "NON", - "DiametreHydraulique" : "0.3816", - "DiametreHydraulique_mess" : "NON", - "SectionEspaceAnnulaire" : "0.21712", - "SectionEspaceAnnulaire_mess" : "NON", - "HauteurCaracConvectionNaturelle" : "6.", - "HauteurCaracConvectionNaturelle_mess" : "NON", - "CritereConvergenceRelative" : "0.00001", - "CoefficientsVestale" : "NON", -# "VolumeMelange_CREARE" : "14.9", - "TemperatureInitiale_CREARE" : "250.", - "TemperatureInitiale_CREARE_mess" : "NON", - "SurfaceEchange_FluideStructure" : "0.", - "SurfaceEchange_FluideStructure_mess" : "NON", - "InstantPerteCirculationNaturelle" : "400.", - } - - # Ce dictionnaire liste la rubrique d'appartenance des variables utilisees dans le script - self.bloc = { - "NiveauImpression" : "OPTIONS", - "FichierDataIn" : "OPTIONS", - "FichierTempSigma" : "OPTIONS", - "FichierCSV" : "OPTIONS", - "FichierRESTART" : "OPTIONS", - "FichierEXTR" : "OPTIONS", - "ChoixPlugin" : "OPTIONS", - "GrandeurEvaluee" : "OPTIONS", - "IncrementTemporel" : "OPTIONS", - "IncrementMaxTemperature" : "OPTIONS", - "ChoixExtractionTransitoires" : "OPTIONS", - "IncrementMaxTempsAffichage" : "OPTIONS", - "TraitementGeometrie" : "DONNEES DE LA CUVE", - "RayonInterne" : "DONNEES DE LA CUVE", - "RayonInterne_mess" : "DONNEES DE LA CUVE", - "RayonExterne" : "DONNEES DE LA CUVE", - "RayonExterne_mess" : "DONNEES DE LA CUVE", - "EpaisseurRevetement" : "DONNEES DE LA CUVE", - "EpaisseurRevetement_mess" : "DONNEES DE LA CUVE", - "LigamentExterneMin" : "DONNEES DE LA CUVE", - "LigamentExterneMin_mess" : "DONNEES DE LA CUVE", - "NombreNoeudsMaillage" : "DONNEES DE LA CUVE", - "TypeInitial" : "CARACTERISTIQUES DU DEFAUT", - "Orientation" : "CARACTERISTIQUES DU DEFAUT", - "Position" : "CARACTERISTIQUES DU DEFAUT", - "ProfondeurRadiale" : "CARACTERISTIQUES DU DEFAUT", - "ProfondeurRadiale_mess" : "CARACTERISTIQUES DU DEFAUT", - "ModeCalculLongueur" : "CARACTERISTIQUES DU DEFAUT", - "Longueur" : "CARACTERISTIQUES DU DEFAUT", - "Longueur_mess" : "CARACTERISTIQUES DU DEFAUT", - "CoefDirecteur" : "CARACTERISTIQUES DU DEFAUT", - "CoefDirecteur_mess" : "CARACTERISTIQUES DU DEFAUT", - "Constante" : "CARACTERISTIQUES DU DEFAUT", - "ModeCalculDecalage" : "CARACTERISTIQUES DU DEFAUT", - "DecalageNormalise" : "CARACTERISTIQUES DU DEFAUT", - "DecalageNormalise_mess" : "CARACTERISTIQUES DU DEFAUT", - "DecalageRadial" : "CARACTERISTIQUES DU DEFAUT", - "DecalageRadial_mess" : "CARACTERISTIQUES DU DEFAUT", - "Azimut" : "CARACTERISTIQUES DU DEFAUT", - "Azimut_mess" : "CARACTERISTIQUES DU DEFAUT", - "Altitude" : "CARACTERISTIQUES DU DEFAUT", - "Altitude_mess" : "CARACTERISTIQUES DU DEFAUT", - "Pointe" : "CARACTERISTIQUES DU DEFAUT", - "ModeleFluence" : "MODELES", - "ZoneActiveCoeur_AltitudeSup" : "MODELES", - "ZoneActiveCoeur_AltitudeInf" : "MODELES", - "FluenceMax" : "MODELES", - "KPFrance" : "MODELES", - "KPUS" : "MODELES", - "Azimut_0deg" : "MODELES", - "Azimut_5deg" : "MODELES", - "Azimut_10deg" : "MODELES", - "Azimut_15deg" : "MODELES", - "Azimut_20deg" : "MODELES", - "Azimut_25deg" : "MODELES", - "Azimut_30deg" : "MODELES", - "Azimut_35deg" : "MODELES", - "Azimut_40deg" : "MODELES", - "Azimut_45deg" : "MODELES", - "TypeIrradiation" : "MODELES", - "RTNDT" : "MODELES", - "ModeleIrradiation" : "MODELES", - "TeneurCuivre" : "MODELES", - "TeneurCuivre_mess" : "MODELES", - "TeneurNickel" : "MODELES", - "TeneurNickel_mess" : "MODELES", - "TeneurPhosphore" : "MODELES", - "TeneurPhosphore_mess" : "MODELES", - "MoyenneRTndt" : "MODELES", - "MoyenneRTndt_mess" : "MODELES", - "CoefVariationRTndt" : "MODELES", - "CoefVariationRTndt_mess" : "MODELES", - "EcartTypeRTndt" : "MODELES", - "EcartTypeRTndt_mess" : "MODELES", - "NombreEcartTypeRTndt" : "MODELES", - "NombreEcartTypeRTndt_mess" : "MODELES", - "ModeleTenacite" : "MODELES", - "NombreCaracteristique" : "MODELES", - "NbEcartType_MoyKIc" : "MODELES", - "NbEcartType_MoyKIc_mess" : "MODELES", - "PalierDuctile_KIc" : "MODELES", - "CoefficientVariation_KIc" : "MODELES", - "Fractile_KIc" : "MODELES", - "Fractile_KIc_mess" : "MODELES", - "Temperature_KIc100" : "MODELES", - "A1" : "MODELES", - "A2" : "MODELES", - "A3" : "MODELES", - "B1" : "MODELES", - "B2" : "MODELES", - "B3" : "MODELES", - "C1" : "MODELES", - "C2" : "MODELES", - "C3" : "MODELES", - "ChoixCorrectionLongueur" : "MODELES", - "AttnCorrBeta" : "MODELES", - "CorrIrwin" : "MODELES", - "ArretDeFissure" : "MODELES", - "IncrementTailleFissure" : "MODELES", - "IncrementTailleFissure_mess" : "MODELES", - "NbEcartType_MoyKIa" : "MODELES", - "PalierDuctile_KIa" : "MODELES", - "CoefficientVariation_KIa" : "MODELES", - "ChoixCoefficientChargement" : "ETAT INITIAL", - "CoefficientDuctile" : "ETAT INITIAL", - "CoefficientFragile" : "ETAT INITIAL", - "InstantInitialisation" : "ETAT INITIAL", - "ConditionLimiteThermiqueREV" : "CARACTERISTIQUES DU REVETEMENT", - "TemperatureDeformationNulleREV" : "CARACTERISTIQUES DU REVETEMENT", - "TemperaturePourCoefDilatThermREV" : "CARACTERISTIQUES DU REVETEMENT", - "CoefficientPoissonREV" : "CARACTERISTIQUES DU REVETEMENT", - "ConditionLimiteThermiqueMDB" : "CARACTERISTIQUES DU MDB", - "TemperatureDeformationNulleMDB" : "CARACTERISTIQUES DU MDB", - "TemperaturePourCoefDilatThermMDB" : "CARACTERISTIQUES DU MDB", - "CoefficientPoissonMDB" : "CARACTERISTIQUES DU MDB", - "TypeConditionLimiteThermique" : "TRANSITOIRE", - "Instant_1" : "TRANSITOIRE", - "Instant_2" : "TRANSITOIRE", - "Instant_3" : "TRANSITOIRE", - "DebitAccumule" : "TRANSITOIRE", - "DebitInjectionSecurite" : "TRANSITOIRE", - "TempInjectionSecurite" : "TRANSITOIRE", - "TempInjectionSecurite_mess" : "TRANSITOIRE", - "DiametreHydraulique" : "TRANSITOIRE", - "DiametreHydraulique_mess" : "TRANSITOIRE", - "SectionEspaceAnnulaire" : "TRANSITOIRE", - "SectionEspaceAnnulaire_mess" : "TRANSITOIRE", - "HauteurCaracConvectionNaturelle" : "TRANSITOIRE", - "HauteurCaracConvectionNaturelle_mess" : "TRANSITOIRE", - "CritereConvergenceRelative" : "TRANSITOIRE", - "CoefficientsVestale" : "TRANSITOIRE", - "VolumeMelange_CREARE" : "TRANSITOIRE", - "TemperatureInitiale_CREARE" : "TRANSITOIRE", - "TemperatureInitiale_CREARE_mess" : "TRANSITOIRE", - "SurfaceEchange_FluideStructure" : "TRANSITOIRE", - "SurfaceEchange_FluideStructure_mess" : "TRANSITOIRE", - "InstantPerteCirculationNaturelle" : "TRANSITOIRE", - } - - def gener(self,obj,format='brut'): - self.text='' - self.textCuve='' - self.texteTFDEBIT='' - self.dico_mot={} - self.dico_genea={} - self.text=PythonGenerator.gener(self,obj,format) - return self.text - - def generMCSIMP(self,obj) : - self.dico_mot[obj.nom]=obj.valeur - clef="" - for i in obj.get_genealogie() : - clef=clef+"_"+i - self.dico_genea[clef]=obj.valeur - s=PythonGenerator.generMCSIMP(self,obj) - return s - - def writeCuve2DG(self, filename, file2): - print "je passe dans writeCuve2DG" - self.genereTexteCuve() - f = open( filename, 'wb') - print self.texteCuve - f.write( self.texteCuve ) - f.close() - ftmp = open( "/tmp/data_template", 'wb') - ftmp.write( self.texteCuve ) - ftmp.close() - - self.genereTexteTFDEBIT() - f2 = open( file2, 'wb') - print self.texteTFDEBIT - f2.write( self.texteTFDEBIT ) - f2.close() - - - def entete(self): - ''' - Ecrit l'entete du fichier data_template - ''' - texte = "############################################################################################"+"\n" - texte += "#"+"\n" - texte += "# OUTIL D'ANALYSE PROBABILISTE DE LA DUREE DE VIE DES CUVES REP"+"\n" - texte += "# ---------------"+"\n" - texte += "# FICHIER DE MISE EN DONNEES"+"\n" - texte += "#"+"\n" - texte += "# SI CALCUL DETERMINISTE :"+"\n" - texte += "# - fixer INCRTPS=1, nbectDRTNDT=2., nbectKIc=-2."+"\n" - texte += "# - les calculs ne sont possibles qu'en une seule pointe du defaut (POINDEF<>BOTH)"+"\n" - texte += "# SI CALCUL PROBABILISTE :"+"\n" - texte += "# - fixer ARRETFISSURE=NON"+"\n" - texte += "#"+"\n" - texte += "############################################################################################"+"\n" - texte += "#"+"\n" - return texte - - def rubrique(self, titre): - ''' - Rubrique - ''' - texte = "#"+"\n" - texte += "############################################################################################"+"\n" - texte += "# " + titre + "\n" - texte += "############################################################################################"+"\n" - texte += "#"+"\n" - return texte - - def sousRubrique(self, soustitre, numtitre): - ''' - Sous-rubrique - ''' - texte = "#"+"\n" - texte += "# " + numtitre + soustitre + "\n" - texte += "#==========================================================================================="+"\n" - texte += "#"+"\n" - return texte - - def ecritLigne(self, variablelue): - ''' - Ecrit l'affectation d'une valeur a sa variable, suivie d'un commentaire - ''' - texte = "%s = %s # %s\n" % (self.variable[variablelue], str(self.dico_mot[variablelue]), self.comment[variablelue]) - return texte - - def affecteValeurDefaut(self, variablelue): - ''' - Affecte une valeur par defaut a une variable, suivie d'un commentaire - ''' - print "Warning ==> Dans la rubrique",self.bloc[variablelue],", valeur par defaut pour ",variablelue," = ",self.default[variablelue] - texte = "%s = %s # %s\n" % (self.variable[variablelue], self.default[variablelue], self.comment[variablelue]) - return texte - - def affecteValeur(self, variablelue, valeuraffectee): - ''' - Affecte une valeur a une variable, suivie d'un commentaire - ''' - texte = "%s = %s # %s\n" % (self.variable[variablelue], valeuraffectee, self.comment[variablelue]) - return texte - - def ecritVariable(self, variablelue): - if self.dico_mot.has_key(variablelue): - texte = self.ecritLigne(variablelue) - else : - texte = self.affecteValeurDefaut(variablelue) - return texte - - def amontAval(self, amont, aval): - if str(self.dico_mot[amont])=='Continu': - if str(self.dico_mot[aval])=='Continu': - texte = 'CC'+"\n" - if str(self.dico_mot[aval])=='Lineaire': - texte = 'CL'+"\n" - if str(self.dico_mot[aval])=='Exclu': - texte = 'CE'+"\n" - if str(self.dico_mot[amont])=='Lineaire': - if str(self.dico_mot[aval])=='Continu': - texte = 'LC'+"\n" - if str(self.dico_mot[aval])=='Lineaire': - texte = 'LL'+"\n" - if str(self.dico_mot[aval])=='Exclu': - texte = 'LE'+"\n" - if str(self.dico_mot[amont])=='Exclu': - if str(self.dico_mot[aval])=='Continu': - texte = 'EC'+"\n" - if str(self.dico_mot[aval])=='Lineaire': - texte = 'EL'+"\n" - if str(self.dico_mot[aval])=='Exclu': - texte = 'EE'+"\n" - return texte - - def genereTexteCuve(self): - self.texteCuve = "" - self.texteCuve += self.entete() - - # Rubrique OPTIONS - self.texteCuve += self.rubrique('OPTIONS') - - self.texteCuve += self.sousRubrique('Impression a l ecran', '') - if self.dico_mot.has_key('NiveauImpression'): - self.texteCuve += self.affecteValeur('NiveauImpression', self.valeurproposee[str(self.dico_mot["NiveauImpression"])]) - - self.texteCuve += self.sousRubrique('Generation de fichiers', '') - self.texteCuve += self.ecritVariable('FichierDataIn') - self.texteCuve += self.ecritVariable('FichierTempSigma') - self.texteCuve += self.ecritVariable('FichierCSV') - self.texteCuve += self.ecritVariable('FichierRESTART') - self.texteCuve += self.ecritVariable('FichierEXTR') - self.texteCuve += self.ecritVariable('ChoixPlugin') - - self.texteCuve += self.sousRubrique('Grandeur evaluee', '') - if self.dico_mot.has_key('GrandeurEvaluee'): - self.texteCuve += self.affecteValeur('GrandeurEvaluee', self.valeurproposee[str(self.dico_mot["GrandeurEvaluee"])]) - - self.texteCuve += self.sousRubrique('Divers', '') - self.texteCuve += self.ecritVariable('IncrementTemporel') - self.texteCuve += self.ecritVariable('IncrementMaxTemperature') - - #self.texteCuve += self.ecritVariable('ChoixExtractionTransitoires') - if self.dico_mot.has_key('ChoixExtractionTransitoires'): - self.texteCuve += self.ecritVariable('ChoixExtractionTransitoires') - if str(self.dico_mot["ChoixExtractionTransitoires"])=='OUI': - if self.dico_mot.has_key('ListeAbscisses'): - self.texteCuve += "# liste des abscisses pour ecriture des transitoires de T et SIG (5 ou moins)"+"\n" - self.imprime(1,(self.dico_mot["ListeAbscisses"])) - self.texteCuve+="#"+"\n" - else : - print "Warning ==> Dans la rubrique OPTIONS, fournir ListeAbscisses." - self.texteCuve += "# liste des abscisses pour ecriture des transitoires de T et SIG (5 ou moins)"+"\n" - self.texteCuve += " 1.994\n" - self.texteCuve += " 2.000\n" - self.texteCuve+="#"+"\n" - else : - self.texteCuve+="#"+"\n" - - self.texteCuve += self.ecritVariable('IncrementMaxTempsAffichage') - if self.dico_mot.has_key('ListeInstants'): - self.texteCuve += "# liste des instants pour ecriture des resultats (s)"+"\n" - if str(self.dico_mot["TypeConditionLimiteThermique"])=='Calcul TEMPFLU puis DEBIT': - self.texteCuve+="#BLOC_TFDEBIT"+"\n" - self.imprime(1,(self.dico_mot["ListeInstants"])) - if str(self.dico_mot["TypeConditionLimiteThermique"])=='Calcul TEMPFLU puis DEBIT': - self.texteCuve+="#BLOC_TFDEBIT"+"\n" - self.texteCuve+="#"+"\n" - else : - print "Warning ==> Dans la rubrique OPTIONS, fournir ListeInstants." - self.texteCuve += "# liste des instants pour ecriture des resultats (s)"+"\n" - self.texteCuve += " 0.\n" - self.texteCuve += " 1.\n" - self.texteCuve+="#"+"\n" - - - # Rubrique DONNEES DE LA CUVE - self.texteCuve += self.rubrique('DONNEES DE LA CUVE') - if self.dico_mot.has_key('TraitementGeometrie'): - self.texteCuve += self.affecteValeur('TraitementGeometrie', self.valeurproposee[str(self.dico_mot["TraitementGeometrie"])]) - if str(self.dico_mot["TraitementGeometrie"])=='Topologie': - self.texteCuve+="# - si MAILLAGE, fournir NBNO et liste des abscisses (m)"+"\n" - self.texteCuve+="# - si GEOMETRIE, fournir (RINT, RINT_MESSAGE),"+"\n" - self.texteCuve+="# (REXT, REXT_MESSAGE),"+"\n" - self.texteCuve+="# (LREV, LREV_MESSAGE),"+"\n" - self.texteCuve+="# (LIGMIN, LIGMIN_MESSAGE),"+"\n" - self.texteCuve+="# NBNO"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('RayonInterne') - self.texteCuve += self.ecritVariable('RayonInterne_mess') - self.texteCuve += self.ecritVariable('RayonExterne') - self.texteCuve += self.ecritVariable('RayonExterne_mess') - self.texteCuve += self.ecritVariable('EpaisseurRevetement') - self.texteCuve += self.ecritVariable('EpaisseurRevetement_mess') - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('LigamentExterneMin') - self.texteCuve += self.ecritVariable('LigamentExterneMin_mess') - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('NombreNoeudsMaillage') - if str(self.dico_mot["TraitementGeometrie"])=='Maillage': - self.texteCuve+="# - si MAILLAGE, fournir NBNO et liste des abscisses (m)"+"\n" - self.texteCuve+="# - si GEOMETRIE, fournir (RINT, RINT_MESSAGE),"+"\n" - self.texteCuve+="# (REXT, REXT_MESSAGE),"+"\n" - self.texteCuve+="# (LREV, LREV_MESSAGE),"+"\n" - self.texteCuve+="# (LIGMIN, LIGMIN_MESSAGE),"+"\n" - self.texteCuve+="# NBNO"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('NombreNoeudsMaillage') - self.imprime(1,(self.dico_mot["ListeAbscisses"])) - else : - self.texteCuve += self.affecteValeurDefaut('TraitementGeometrie') - self.texteCuve+="# - si MAILLAGE, fournir NBNO et liste des abscisses (m)"+"\n" - self.texteCuve+="# - si GEOMETRIE, fournir (RINT, RINT_MESSAGE),"+"\n" - self.texteCuve+="# (REXT, REXT_MESSAGE),"+"\n" - self.texteCuve+="# (LREV, LREV_MESSAGE),"+"\n" - self.texteCuve+="# (LIGMIN, LIGMIN_MESSAGE),"+"\n" - self.texteCuve+="# NBNO"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve += self.affecteValeurDefaut('RayonInterne') - self.texteCuve += self.affecteValeurDefaut('RayonInterne_mess') - self.texteCuve += self.affecteValeurDefaut('RayonExterne') - self.texteCuve += self.affecteValeurDefaut('RayonExterne_mess') - self.texteCuve += self.affecteValeurDefaut('EpaisseurRevetement') - self.texteCuve += self.affecteValeurDefaut('EpaisseurRevetement_mess') - self.texteCuve+="#"+"\n" - self.texteCuve += self.affecteValeurDefaut('LigamentExterneMin') - self.texteCuve += self.affecteValeurDefaut('LigamentExterneMin_mess') - self.texteCuve+="#"+"\n" - self.texteCuve += self.affecteValeurDefaut('NombreNoeudsMaillage') - - - # Rubrique CARACTERISTIQUES DU DEFAUT - self.texteCuve += self.rubrique('CARACTERISTIQUES DU DEFAUT') - - if self.dico_mot.has_key('TypeInitial'): - self.texteCuve += self.affecteValeur('TypeInitial', self.valeurproposee[str(self.dico_mot["TypeInitial"])]) - else : - self.texteCuve += self.affecteValeurDefaut('TypeInitial') - - self.texteCuve+="# Fournir ORIEDEF, (PROFDEF, PROFDEF_MESSAGE)"+"\n" - self.texteCuve+="# - Si DSR, fournir OPTLONG, (LONGDEF,LONGDEF_MESSAGE) ou (PROFSURLONG,PROFSURLONG_MESSAGE,LONGCONST)"+"\n" - self.texteCuve+="# - Si DECALE, fournir OPTLONG, (LONGDEF,LONGDEF_MESSAGE) ou (PROFSURLONG,PROFSURLONG_MESSAGE,LONGCONST), DECATYP, (DECANOR,DECANOR_MESSAGE) ou (DECADEF,DECADEF_MESSAGE)"+"\n" - self.texteCuve+="# - Si DEBOUCHANT, fournir IRWIN"+"\n" - self.texteCuve+="# Fournir (ANGLDEF, ANGLDEF_MESSAGE), (ALTIDEF, ALTIDEF_MESSAGE)"+"\n" - self.texteCuve+="# - Si DSR ou DECALE, fournir POINDEF"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve+="# Remarque :"+"\n" - self.texteCuve+="# - si DSR ou DECALE, dans la rubrique 'Modele de tenacite', fournir ATTNCORRBETA (ne pas fournir CORRIRWIN)"+"\n" - self.texteCuve+="# - si DEBOUCHANT, dans la rubrique 'Modele de tenacite', fournir CORRIRWIN (ne pas fournir ATTNCORRBETA)"+"\n" - - self.texteCuve+="#"+"\n" - - if self.dico_mot.has_key('Orientation'): - self.texteCuve += self.affecteValeur('Orientation', self.valeurproposee[str(self.dico_mot["Orientation"])]) - else : - self.texteCuve += self.affecteValeurDefaut('Orientation') - - if self.dico_mot.has_key('Position'): - self.texteCuve += self.affecteValeur('Position', self.valeurproposee[str(self.dico_mot["Position"])]) - else : - self.texteCuve += self.affecteValeurDefaut('Position') - - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('ProfondeurRadiale') - self.texteCuve += self.ecritVariable('ProfondeurRadiale_mess') - - self.texteCuve+="#"+"\n" - if self.dico_mot.has_key('TypeInitial'): - if str(self.dico_mot["TypeInitial"])!='Defaut Debouchant': - if self.dico_mot.has_key('ModeCalculLongueur'): - self.texteCuve += self.affecteValeur('ModeCalculLongueur', self.valeurproposee[str(self.dico_mot["ModeCalculLongueur"])]) - if str(self.dico_mot["ModeCalculLongueur"])=='Valeur': - self.texteCuve+="# - Si VALEUR, fournir (LONGDEF, LONGDEF_MESSAGE)"+"\n" - self.texteCuve+="# - Si FCTAFFINE, fournir (PROFSURLONG, PROFSURLONG_MESSAGE) et LONGCONST : LONGDEF=PROFDEF/PROFSURLONG + LONGCONST"+"\n" - self.texteCuve += self.ecritVariable('Longueur') - self.texteCuve += self.ecritVariable('Longueur_mess') - if str(self.dico_mot["ModeCalculLongueur"])=='Fonction affine de la profondeur': - self.texteCuve+="# - Si VALEUR, fournir (LONGDEF, LONGDEF_MESSAGE)"+"\n" - self.texteCuve+="# - Si FCTAFFINE, fournir (PROFSURLONG, PROFSURLONG_MESSAGE) et LONGCONST : LONGDEF=PROFDEF/PROFSURLONG + LONGCONST"+"\n" - self.texteCuve += self.ecritVariable('CoefDirecteur') - self.texteCuve += self.ecritVariable('CoefDirecteur_mess') - self.texteCuve += self.ecritVariable('Constante') - else : - self.texteCuve += self.affecteValeurDefaut('ModeCalculLongueur') - self.texteCuve+="# - Si VALEUR, fournir (LONGDEF, LONGDEF_MESSAGE)"+"\n" - self.texteCuve+="# - Si FCTAFFINE, fournir (PROFSURLONG, PROFSURLONG_MESSAGE) et LONGCONST : LONGDEF=PROFDEF/PROFSURLONG + LONGCONST"+"\n" - self.texteCuve += self.affecteValeurDefaut('Longueur') - self.texteCuve += self.affecteValeurDefaut('Longueur_mess') - - if self.dico_mot.has_key('TypeInitial'): - if str(self.dico_mot["TypeInitial"])=='Defaut Decale': - self.texteCuve+="#"+"\n" - if self.dico_mot.has_key('ModeCalculDecalage'): - self.texteCuve += self.affecteValeur('ModeCalculDecalage', self.valeurproposee[str(self.dico_mot["ModeCalculDecalage"])]) - if str(self.dico_mot["ModeCalculDecalage"])=='Valeur normalisee': - self.texteCuve+="# - Si NORMALISE, fournir (DECANOR, DECANOR_MESSAGE)"+"\n" - self.texteCuve+="# - Si VALEUR, fournir (DECADEF, DECADEF_MESSAGE)"+"\n" - self.texteCuve += self.ecritVariable('DecalageNormalise') - self.texteCuve += self.ecritVariable('DecalageNormalise_mess') - if str(self.dico_mot["ModeCalculDecalage"])=='Valeur': - self.texteCuve+="# - Si NORMALISE, fournir (DECANOR, DECANOR_MESSAGE)"+"\n" - self.texteCuve+="# - Si VALEUR, fournir (DECADEF, DECADEF_MESSAGE)"+"\n" - self.texteCuve += self.ecritVariable('DecalageRadial') - self.texteCuve += self.ecritVariable('DecalageRadial_mess') - else : - self.texteCuve += self.affecteValeurDefaut('ModeCalculDecalage') - self.texteCuve+="# - Si NORMALISE, fournir (DECANOR, DECANOR_MESSAGE)"+"\n" - self.texteCuve+="# - Si VALEUR, fournir (DECADEF, DECADEF_MESSAGE)"+"\n" - self.texteCuve += self.affecteValeurDefaut('DecalageRadial') - self.texteCuve += self.affecteValeurDefaut('DecalageRadial_mess') - - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('Azimut') - self.texteCuve += self.ecritVariable('Azimut_mess') - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('Altitude') - self.texteCuve += self.ecritVariable('Altitude_mess') - self.texteCuve+="#"+"\n" - if self.dico_mot.has_key('Pointe'): - self.texteCuve += self.affecteValeur('Pointe', self.valeurproposee[str(self.dico_mot["Pointe"])]) - #else : - # self.texteCuve += self.affecteValeurDefaut('Pointe') - - # Rubrique MODELES FLUENCE, IRRADIATION, TENACITE - self.texteCuve += self.rubrique('MODELES FLUENCE, IRRADIATION, TENACITE') - self.texteCuve += self.sousRubrique('Modele d attenuation de la fluence dans l epaisseur','A.') - - if self.dico_mot.has_key('ModeleFluence'): - self.texteCuve += self.affecteValeur('ModeleFluence', self.valeurproposee[str(self.dico_mot["ModeleFluence"])]) - else : - self.texteCuve += self.affecteValeurDefaut('ModeleFluence') - - self.texteCuve+="# - si France, fournir KPFRANCE"+"\n" - self.texteCuve+="# - si USNRC, fournir KPUS"+"\n" - self.texteCuve+="# - si modele GD_Cuve, fournir COEFFLUENCE1, COEFFLUENCE2, ..., COEFFLUENCE9, COEFFLUENCE10"+"\n" - self.texteCuve+="#"+"\n" - - self.texteCuve += self.ecritVariable('ZoneActiveCoeur_AltitudeSup') - self.texteCuve += self.ecritVariable('ZoneActiveCoeur_AltitudeInf') - self.texteCuve += self.ecritVariable('FluenceMax') - if self.dico_mot.has_key('ModeleFluence'): - if str(self.dico_mot["ModeleFluence"])=='Exponentiel sans revetement k=12.7 (France)': - self.texteCuve += self.ecritVariable('KPFrance') - if str(self.dico_mot["ModeleFluence"])=='Regulatory Guide 1.99 rev 2 (USNRC)': - self.texteCuve += self.ecritVariable('KPUS') - if str(self.dico_mot["ModeleFluence"])=='Grand developpement (GD_Cuve)': - self.texteCuve += self.ecritVariable('Azimut_0deg') - self.texteCuve += self.ecritVariable('Azimut_5deg') - self.texteCuve += self.ecritVariable('Azimut_10deg') - self.texteCuve += self.ecritVariable('Azimut_15deg') - self.texteCuve += self.ecritVariable('Azimut_20deg') - self.texteCuve += self.ecritVariable('Azimut_25deg') - self.texteCuve += self.ecritVariable('Azimut_30deg') - self.texteCuve += self.ecritVariable('Azimut_35deg') - self.texteCuve += self.ecritVariable('Azimut_40deg') - self.texteCuve += self.ecritVariable('Azimut_45deg') - - self.texteCuve += self.sousRubrique('Irradiation','B.') - - if self.dico_mot.has_key('TypeIrradiation'): - self.texteCuve += self.affecteValeur('TypeIrradiation', self.valeurproposee[str(self.dico_mot["TypeIrradiation"])]) - - if str(self.dico_mot["TypeIrradiation"])=='RTndt de la cuve a l instant de l analyse': - self.texteCuve+="# - si RTNDT, fournir RTNDT"+"\n" - self.texteCuve+="# - si FLUENCE, fournir MODELIRR, et autres parametres selon MODELIRR (voir ci-dessous)"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('RTNDT') - - if str(self.dico_mot["TypeIrradiation"])=='Modele d irradiation': - self.texteCuve+="# - si RTNDT, fournir RTNDT"+"\n" - self.texteCuve+="# - si FLUENCE, fournir MODELIRR, et autres parametres selon MODELIRR (voir ci-dessous)"+"\n" - self.texteCuve+="#"+"\n" - if self.dico_mot.has_key('ModeleIrradiation'): - self.texteCuve += self.affecteValeur('ModeleIrradiation', self.valeurproposee[str(self.dico_mot["ModeleIrradiation"])]) - else : - self.texteCuve += self.affecteValeurDefaut('ModeleIrradiation') - self.texteCuve+="# - pour tout modele, fournir (CU, CU_MESSAGE),"+"\n" - self.texteCuve+="# (NI, NI_MESSAGE),"+"\n" - self.texteCuve+="# - si HOUSSIN, PERSOZ, LEFEBVRE, BRILLAUD, LEFEBnew, fournir (P, P_MESSAGE)"+"\n" - self.texteCuve+="# - pour tout modele, fournir (RTimoy, RTimoy_MESSAGE),"+"\n" - self.texteCuve+="# - si USNRCsoud ou USNRCmdb, fournir (RTicov, RTicov_MESSAGE)"+"\n" - self.texteCuve+="# (USectDRT, USectDRT_MESSAGE)"+"\n" - self.texteCuve+="# - pour tout modele, fournir (nbectDRTNDT, nbectDRTNDT_MESSAGE)"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve += self.ecritVariable('TeneurCuivre') - self.texteCuve += self.ecritVariable('TeneurCuivre_mess') - self.texteCuve += self.ecritVariable('TeneurNickel') - self.texteCuve += self.ecritVariable('TeneurNickel_mess') - if str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : formule de FIM/FIS Houssin' or str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : formule de FIM/FIS Persoz' or str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : formule de FIM/FIS Lefebvre' or str(self.dico_mot["ModeleIrradiation"])=='Joint Soude : formulation de FIM/FIS Brillaud' or str(self.dico_mot["ModeleIrradiation"])=='Formule de FIM/FIS Lefebvre modifiee': - self.texteCuve += self.ecritVariable('TeneurPhosphore') - self.texteCuve += self.ecritVariable('TeneurPhosphore_mess') - self.texteCuve += self.ecritVariable('MoyenneRTndt') - self.texteCuve += self.ecritVariable('MoyenneRTndt_mess') - if str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : Regulatory Guide 1.00 rev 2' or str(self.dico_mot["ModeleIrradiation"])=='Joint Soude : Regulatory Guide 1.00 rev 2': - self.texteCuve += self.ecritVariable('CoefVariationRTndt') - self.texteCuve += self.ecritVariable('CoefVariationRTndt_mess') - self.texteCuve += self.ecritVariable('EcartTypeRTndt') - self.texteCuve += self.ecritVariable('EcartTypeRTndt_mess') - self.texteCuve += self.ecritVariable('NombreEcartTypeRTndt') - self.texteCuve += self.ecritVariable('NombreEcartTypeRTndt_mess') - else : - self.texteCuve += self.affecteValeurDefaut('TypeIrradiation') - self.texteCuve+="# - si RTNDT, fournir RTNDT"+"\n" - self.texteCuve+="# - si FLUENCE, fournir MODELIRR, et autres parametres selon MODELIRR (voir ci-dessous)"+"\n" - self.texteCuve+="#"+"\n" - self.texteCuve += self.affecteValeurDefaut('RTNDT') - - self.texteCuve += self.sousRubrique('Modele de tenacite','C.') - self.texteCuve+="# tenacite d amorcage"+"\n" - - if self.dico_mot.has_key('ModeleTenacite'): - self.texteCuve += self.affecteValeur('ModeleTenacite', self.valeurproposee[str(self.dico_mot["ModeleTenacite"])]) - else : - self.texteCuve += self.affecteValeurDefaut('ModeleTenacite') - self.texteCuve+="# - si RCC-M, RCC-M_pal, Houssin_RC, fournir (nbectKIc, nbectKIc_MESSAGE), KICPAL, KICCDV"+"\n" - self.texteCuve+="# - si RCC-M_exp, fournir (nbectKIc, nbectKIc_MESSAGE), KICCDV"+"\n" - self.texteCuve+="# - si RCC-M_simpl, ne rien fournir"+"\n" - self.texteCuve+="# - si Frama, LOGWOLF, fournir (nbectKIc, nbectKIc_MESSAGE)"+"\n" - self.texteCuve+="# - si REME, ORNL, WEIB3, WEIB2, fournir NBCARAC, puis (nbectKIc, nbectKIc_MESSAGE) ou (fractKIc, fractKIc_MESSAGE) selon valeur de NBCARAC"+"\n" - self.texteCuve+="# - si Wallin, fournir NBCARAC, puis (nbectKIc, nbectKIc_MESSAGE) ou (fractKIc, fractKIc_MESSAGE) selon valeur de NBCARAC,"+"\n" - self.texteCuve+="# puis T0WALLIN"+"\n" - self.texteCuve+="# - si WEIB-GEN, fournir NBCARAC, puis (nbectKIc, nbectKIc_MESSAGE) ou (fractKIc, fractKIc_MESSAGE) selon valeur de NBCARAC,"+"\n" - self.texteCuve+="# puis A1, A2, A3, B1, B2, B3, C1, C2, C3"+"\n" - self.texteCuve+="# loi de Weibull P(K= 1: s = '(' + s + '),' if obj.valeur==[] or obj.valeur==() : s="()," @@ -560,13 +557,11 @@ class PythonGenerator: else : obj.valeurFormatee=obj.valeur s=self.format_item(obj.valeur,obj.etape,obj) + ',' - #print s return s def formatColonnes(self,nbrColonnes,listeValeurs,obj): #try : - #print listeValeurs if 1 == 1 : indice=0 textformat="(" @@ -589,5 +584,4 @@ class PythonGenerator: #except : else : textformat=str(obj.valeur) - #print textformat return textformat diff --git a/generator/generator_vers3DSalome.py b/generator/generator_vers3DSalome.py index f1be205b..09582f21 100644 --- a/generator/generator_vers3DSalome.py +++ b/generator/generator_vers3DSalome.py @@ -38,14 +38,14 @@ from generator_python import PythonGenerator def entryPoint(): """ - Retourne les informations nécessaires pour le chargeur de plugins + Retourne les informations necessaires pour le chargeur de plugins - Ces informations sont retournées dans un dictionnaire + Ces informations sont retournees dans un dictionnaire """ return { # Le nom du plugin 'name' : 'vers3DSalome', - # La factory pour créer une instance du plugin + # La factory pour creer une instance du plugin 'factory' : vers3DSalomeGenerator, } @@ -94,7 +94,6 @@ class vers3DSalomeGenerator(PythonGenerator): self.node=node self.list_commandes=[]; self.generator(self.node.object) - #print self.list_commandes return self.list_commandes def generator(self,obj): @@ -150,7 +149,7 @@ class vers3DSalomeGenerator(PythonGenerator): def generMCFACT(self,obj): """ - Convertit un objet MCFACT en une liste de chaines de caractères à la + Convertit un objet MCFACT en une liste de chaines de caracteres a la syntaxe python """ self.init_ligne() @@ -205,12 +204,12 @@ class vers3DSalomeGenerator(PythonGenerator): val = val[0] if isinstance (val, Extensions.parametre.PARAMETRE): val=val.valeur - print val.__class__ + print ( val.__class) context={} if type(val) == type("aaa") : for p in self.jdc.params: context[p.nom]=eval(p.val,self.jdc.const_context, context) - print context[p.nom] + print (context[p.nom]) res=eval(val,self.jdc.const_context, context) val=res self.dict_attributs[clef]=val diff --git a/generator/oldCodes/OpenturnsBase.py b/generator/oldCodes/OpenturnsBase.py new file mode 100644 index 00000000..465c6f8d --- /dev/null +++ b/generator/oldCodes/OpenturnsBase.py @@ -0,0 +1,145 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +""" +Ce module contient la partie commune +aux generateurs XML et Etude d Openturns +""" + +__revision__ = "V1.0" + +import os +import sys + +path=os.getcwd() +pathDef=path+"DefautOpenturns" + +sys.path.append(pathDef) + + +#============================================= +# La classe generale +#============================================= + +class Generateur : + + ''' + Classe generale du generateur + DictMCVal : dictionnaire des mots-cles + ListeVariables : chaque variable est decrite par un dictionnaire ; cette liste les regroupe + DictLois : dictionnaires des lois + ''' + def __init__ (self, appli, DictMCVal = {}, ListeVariables = [], DictLois = {}, DictVariables = {} ) : + #---------------------------------------------------------# + self.ListeVariables = ListeVariables + self.ListeVariablesIn = [] + self.ListeVariablesOut = [] + self.DictLois = DictLois + self.DictVariables = DictVariables + self.DictMCVal = DictMCVal + self.DictTypeVar = {} + self.nbVarIn = 0 + self.nbVarOut = 0 + self.creeInfoVar() + self.appli = appli + # + # On charge eventuellement le Solver par defaut + # et les valeurs par defaut du Solver (dans l init) + # + try : + #if 1 : + Solver = self.DictMCVal["PhysicalSolver"] + import_name = "Defaut"+Solver + self.module = __import__( import_name, globals(), locals() ) + monDefaut = self.module.Defaut( self ) + #else : + except: + self.module = None + + + def getSTDGenerateur(self) : + #--------------------------# + try : + gener = self.module.__dict__["MonSTDGenerateur"] + monSTDGenerateur=gener( self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois ) + except : + from OpenturnsSTD import STDGenerateur + monSTDGenerateur = STDGenerateur( self.appli, self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois ) + return monSTDGenerateur + + def getXMLGenerateur(self) : + #--------------------------# + try : + gener = self.module.__dict__["MonXMLGenerateur"] + monXMLGenerateur=gener( self.DictMCVal, self.ListeVariables, self.DictLois ) + except : + from OpenturnsXML import XMLGenerateur + monXMLGenerateur = XMLGenerateur( self.appli, self.DictMCVal, self.DictVariables ) + return monXMLGenerateur + + def creeInfoVar (self) : + #----------------------# + """ + On repere les variables in/out et on les numerote. + """ + num = 0 + liste = [] + for DictVariable in self.ListeVariables : + if not DictVariable.has_key("Type") : DictVariable["Type"] = "in" + self.DictTypeVar[num] = DictVariable["Type"] + if DictVariable["Type"] == "in" : + self.nbVarIn = self.nbVarIn + 1 + self.ListeVariablesIn.append( DictVariable ) + print "OpenturnsBase.py: new input variable = ", DictVariable + else: + self.nbVarOut = self.nbVarOut + 1 + self.ListeVariablesOut.append( DictVariable ) + print "OpenturnsBase.py: new output variable = ", DictVariable + liste.append( DictVariable ) + num = num + 1 + self.ListeVariables = liste + + + def ajouteDictMCVal(self, dicoPlus) : + #-----------------------------------# + # Appele par le classe Defaut du python specifique au code (exple DefautASTER.py) + # enrichit self.DictMCVal avec les valeurs donnees dans dicoPlus + # si elles ne sont pas deja dans le dictionnaire + + for clef in dicoPlus.keys(): + if not self.DictMCVal.has_key(clef) : + self.DictMCVal[clef] = dicoPlus[clef] + + def ajouteInfoVariables (self, dicoVariablesIn, dicoVariablesOut) : + #-----------------------------------------------------------------# + # Appele par le classe Defaut du python specifique au code (exple DefautASTER.py) + # met a jour les dictionnaires qui decrivent les variables (regexp par exemple) + liste=[] + num = 0 + for dictVariable in self.ListeVariables: + if self.DictTypeVar[num] == "in" : + dico = dicoVariablesIn + else : + dico = dicoVariablesOut + for nouvelleVariable in dico.keys() : + if not dictVariable.has_key(nouvelleVariable): + dictVariable[nouvelleVariable] = dico[nouvelleVariable] + liste.append( dictVariable ) + num = num + 1 diff --git a/generator/oldCodes/OpenturnsSTD.py b/generator/oldCodes/OpenturnsSTD.py new file mode 100644 index 00000000..f2659e1c --- /dev/null +++ b/generator/oldCodes/OpenturnsSTD.py @@ -0,0 +1,1397 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +""" +Ce module contient le generateur Etude pour Openturns +""" + +from Extensions.i18n import tr + +__revision__ = "V1.0" + +defaultSTD = """#! /usr/bin/env python + +class StudyFileGenerationError: + def __init__ (self, st): + self.st = st + def __str__(self): + return "'%s'" % self.st + +raise StudyFileGenerationError, "The study file was not generated. Check analysis type." +""" + +headerSTD = """#! /usr/bin/env python + +# Chargement du module systeme +import sys +sys.path[:0]=['%s'] + +# Chargement du module math +import math + +# Chargement du module Open TURNS +from openturns import * + +# Fonction verifiant si un echantillon contient des valeurs non valides (NaN) +def contain_nan_values(sample): + for point in sample: + for val in point: + if math.isnan(val): + return True + return False + +results = {} + +""" + +viewerSTD = """ +from openturns.viewer import View + +# Fonction de test du serveur X +import subprocess +xserver_available = None +def is_xserver_available(): + global xserver_available + if xserver_available is None: + xserver_available = True + try: + subprocess.check_call('python -c "from matplotlib import pyplot;pyplot.figure()" >/dev/null 2>&1', shell = True) + except: + xserver_available = False + return xserver_available + +""" + +footerSTD = """ + +# Flush des messages en attente +Log.Flush() + +# Terminaison du fichier +#sys.exit( 0 ) +""" + +#============================================= +# La classe de creation du fichier STD +#============================================= + +class STDGenerateur : + + ''' + Generation du fichier python + ''' + def __init__ (self, appli, DictMCVal, ListeVariablesIn, ListeVariablesOut, DictLois ) : + self.DictMCVal = DictMCVal + self.ListeVariablesIn = ListeVariablesIn + self.ListeVariablesOut = ListeVariablesOut + self.DictLois = DictLois + #print "DictMCVal=", DictMCVal + print "ListeVariablesIn= %s", ListeVariablesIn + +# A REPRENDRE DEPUIS ICI !! + print "ListeVariablesOut= %s", ListeVariablesOut + #print "DictLois=", DictLois + self.texteSTD = defaultSTD + self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path + + # Ce dictionnaire fait la correspondance entre le mot lu dans le dictionnaire des mots-clefs et la methode a appeler + self.traitement = { + "Min/Max" : + ( "MinMax", + { "Experiment Plane" : "ExperimentPlane", + "Random Sampling" : "MinMaxRandomSampling", + }, + ), + "Central Uncertainty" : + ( "CentralUncertainty", + { "Taylor Variance Decomposition" : "TaylorVarianceDecomposition", + "Random Sampling" : "CentralUncertaintyRandomSampling", + }, + ), + "Threshold Exceedence" : + ( "ThresholdExceedence", + { "Simulation" : "Simulation", + "FORM_SORM" : "Analytical", + "MonteCarlo" : "MonteCarlo", + "LHS" : "LHS", + "ImportanceSampling" : "ImportanceSampling", + "FirstOrder" : "FORM", + "SecondOrder" : "SORM", + "Cobyla" : "Cobyla", + "AbdoRackwitz" : "AbdoRackwitz", + }, + ), + } + + # Ce dictionnaire liste le nom des variables utilisees dans le script + # La clef est le nom attendu par les methodes, la valeur est le nom produit dans le fichier de sortie + # Le fait de passer par un dictionnaire permet de controler que les variables existent et sont correctement nommees + # meme si clef == valeur + self.variable = { + "n" : "n", + "p" : "p", + "wrapper" : "wrapper", + "wrapperdata" : "wrapperdata", + "frameworkdata" : "frameworkdata", + "framework" : "framework", + "studyid" : "studyid", + "studycase" : "studycase", + "componentname" : "componentname", + "model" : "model", + "scaledVector" : "scaledVector", + "translationVector" : "translationVector", + "levels" : "levels", + "myCenteredReductedGrid" : "myCenteredReductedGrid", + "myExperimentPlane" : "myExperimentPlane", + "inputSample" : "inputSample", + "outputSample" : "outputSample", + "minValue" : 'results["minValue"]', + "maxValue" : 'results["maxValue"]', + "flags" : "flags", + "inSize" : "inSize", + "distribution" : "distribution", + "marginal" : "marginal", + "collection" : "collection", + "copula" : "copula", + "correlation" : "correlation", + "R" : "R", + "vars" : "vars", + "description" : "description", + "inputRandomVector" : "inputRandomVector", + "outputRandomVector" : "outputRandomVector", + "myQuadraticCumul" : "myQuadraticCumul", + "meanFirstOrder" : 'results["meanFirstOrder"]', + "meanSecondOrder" : 'results["meanSecondOrder"]', + "standardDeviationFirstOrder" : 'results["standardDeviationFirstOrder"]', + "importanceFactors" : 'results["importanceFactors"]', + "importanceFactorsGraph" : "importanceFactorsGraph", + "importanceFactorsDrawing" : "importanceFactorsDrawing", + "empiricalMean" : 'results["empiricalMean"]', + "empiricalStandardDeviation" : 'results["empiricalStandardDeviation"]', + "empiricalQuantile" : 'results["empiricalQuantile"]', + "alpha" : "alpha", + "beta" : "beta", + "PCCcoefficient" : 'results["PCCcoefficient"]', + "PRCCcoefficient" : 'results["PRCCcoefficient"]', + "SRCcoefficient" : 'results["SRCcoefficient"]', + "SRRCcoefficient" : 'results["SRRCcoefficient"]', + "kernel" : "kernel", + "kernelSmoothedDist" : "kernelSmoothedDist", + "kernelSmoothedPDFDrawing" : "kernelSmoothedPDFDrawing", + "kernelSmoothedGraph" : "kernelSmoothedGraph", + "meanVector" : "meanVector", + "importanceDensity" : "importanceDensity", + "myEvent" : "myEvent", + "myAlgo" : "myAlgo", + "myResult" : "myResult", + "probability" : 'results["probability"]', + "standardDeviation" : 'results["standardDeviation"]', + "level" : "level", + "length" : "length", + "coefficientOfVariation" : 'results["coefficientOfVariation"]', + "convergenceGraph" : "convergenceGraph", + "convergenceDrawing" : "convergenceDrawing", + "simulationNumbers" : 'results["simulationNumbers"]', + "myOptimizer" : "myOptimizer", + "specificParameters" : "specificParameters", + "startingPoint" : "startingPoint", + "hasoferReliabilityIndex" : 'results["hasoferReliabilityIndex"]', + "standardSpaceDesignPoint" : 'results["standardSpaceDesignPoint"]', + "physicalSpaceDesignPoint" : 'results["physicalSpaceDesignPoint"]', + "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]', + "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]', + "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph", + "eventProbabilitySensitivityDrawing" : "eventProbabilitySensitivityDrawing", + "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph", + "hasoferReliabilityIndexSensitivityDrawing" : "hasoferReliabilityIndexSensitivityDrawing", + "modelEvaluationCalls" : 'results["modelEvaluationCalls"]', + "modelGradientCalls" : 'results["modelGradientCalls"]', + "modelHessianCalls" : 'results["modelHessianCalls"]', + "tvedtApproximation" : 'results["tvedtApproximation"]', + "hohenBichlerApproximation" : 'results["hohenBichlerApproximation"]', + "breitungApproximation" : 'results["breitungApproximation"]', + } + + # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque + self.logFlags = { + "DebugMessages" : "Log.DBG", + "WrapperMessages" : "Log.WRAPPER", + "UserMessages" : "Log.USER", + "InfoMessages" : "Log.INFO", + "WarningMessages" : "Log.WARN", + "ErrorMessages" : "Log.ERROR", + } + + def CreeSTD (self) : + ''' + Pilotage de la creation du fichier python + ''' + TypeAnalyse = None + if ( self.DictMCVal.has_key( 'Type' ) ): + TypeAnalyse = self.DictMCVal[ 'Type' ] + + Traitement = None + subDict = {} + if ( self.traitement.has_key( TypeAnalyse ) ): + (Traitement, subDict) = self.traitement[ TypeAnalyse ] + + if ( Traitement is not None ): + self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) ) + + return self.texteSTD + + def Header (self) : + ''' + Imprime l entete commun a tous les fichiers + ''' + txt = headerSTD % self.OpenTURNS_path + txt += viewerSTD + txt += "# Definit le niveau d'affichage de la log\n" + txt += "%s = Log.NONE\n" % self.variable["flags"] + for flag in self.logFlags.keys(): + if ( self.DictMCVal.has_key( flag ) ): + val = self.DictMCVal[ flag ] + op = "-" + if val == 'yes' : + op = "+" + txt += "%s = %s %s %s\n" % (self.variable["flags"], self.variable["flags"], op, self.logFlags[ flag ]) + txt += "Log.Show( %s )\n" % self.variable["flags"] + txt += "\n" + return txt + + def Footer (self) : + ''' + Imprime le pied de page commun a tous les fichiers + ''' + return footerSTD + + def MinMax (self, subDict): + ''' + Produit le fichier study correspondant a une analyse Min/Max + ''' + txt = self.Header() + txt += self.Model() + + Methode = None + if ( self.DictMCVal.has_key( 'Method' ) ): + Methode = self.DictMCVal[ 'Method' ] + + Traitement = None + if ( subDict.has_key( Methode ) ): + Traitement = subDict[ Methode ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + txt += self.MinMaxResult() + + txt += self.Footer() + return txt + + def Model (self): + ''' + Importe le modele physique + ''' + if ( self.DictMCVal.has_key( 'FileName' ) ): + name = self.DictMCVal[ 'FileName' ] + + txt = "# Charge le modele physique\n" + txt += "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name) + txt += "%s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"]) + + txt += "# Ces lignes sont utiles pour le fonctionnement du script sous Salome\n" + txt += "if globals().has_key('%s'):\n" % self.variable["framework"] + txt += " %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"]) + txt += " %s.studyid_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studyid"]) + txt += " %s.studycase_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studycase"]) + txt += " %s.componentname_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"]) + txt += " %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"]) + txt += " %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"]) + txt += "# Fin des lignes pour Salome\n" + + txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],) + txt += "%s = %s.getInputDimension()\n" % (self.variable["n"], self.variable["model"]) + txt += "\n" + return txt + + def ExperimentPlane (self): + ''' + Etude par plan d experience + ''' + txt = "# Etude par plan d'experience\n" + txt += self.Levels() + txt += self.CenteredReductedGrid() + txt += self.ScaledVector() + txt += self.TranslationVector() + txt += "%s = %s\n" % (self.variable["inputSample"], self.variable["myExperimentPlane"]) + txt += "\n" + txt += "# Etude 'Min/Max'\n" + txt += "# Calcul\n" + txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) + txt += "if contain_nan_values( %s ):\n" % (self.variable["outputSample"]) + txt += " raise Exception('Some computations failed')\n" + txt += "\n" + return txt + + def MinMaxRandomSampling (self): + ''' + Etude par echantillonage aleatoire + ''' + size = 0 + if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): + size = self.DictMCVal[ 'SimulationsNumber' ] + + txt = "# Etude par echantillonage aleatoire\n" + txt += self.InputDistribution() + txt += self.InputRandomVector() + txt += "\n" + txt += "# Etude 'Min/Max'\n" + txt += "# Calcul\n" + txt += "%s = %d\n" % (self.variable["inSize"], size) + txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) + txt += "%s = %s.getSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"]) + txt += "if contain_nan_values( %s ):\n" % (self.variable["outputSample"]) + txt += " raise Exception('Some computations failed')\n" + return txt + + def InputDistribution (self): + ''' + Cree la loi jointe des variables d entree + ''' + txt = "# Definit la loi jointe des variables d'entree\n" + txt += "%s = DistributionCollection( %s )\n" % (self.variable["collection"], self.variable["n"]) + txt += "%s = Description( %s )\n" % (self.variable["description"], self.variable["n"]) + txt += "\n" + + dictVariables = {} + for variable in self.ListeVariablesIn: + nomVar = variable['ModelVariable'].get_name() + dictVariables[ nomVar ] = variable['Distribution'] + + i = 0 + sortedVarNames = dictVariables.keys() + sortedVarNames.sort() + for variable in sortedVarNames: + conceptloi = dictVariables[ variable ] + loi = self.DictLois[ conceptloi ] + if loi.has_key( 'Kind' ): + marginale = "%s_%d" % (self.variable["marginal"], i) + txt += "# Definit la loi marginale de la composante %d\n" % i + txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) )) + txt += "%s.setName( '%s' )\n" % (marginale, conceptloi.get_name()) + txt += "%s[ %d ] = '%s'\n" % (self.variable["description"], i, variable) + txt += "%s[ %d ] = Distribution( %s )\n" % (self.variable["collection"], i, marginale) + txt += "\n" + i += 1 + + txt += self.Copula() + + txt += "# Definit la loi jointe\n" + txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"]) + txt += "%s.setDescription( %s )\n" % (self.variable["distribution"], self.variable["description"]) + txt += "\n" + return txt + + def Copula (self): + ''' + Cree la copule de la loi jointe + ''' + txt = "# Definit la copule de la loi jointe\n" + + if ( not self.DictMCVal.has_key( 'Copula' ) ): + self.DictMCVal[ 'Copula' ] = 'Independent' + + if ( self.DictMCVal[ 'Copula' ] in ( 'Independent', ) ): + txt += "%s = IndependentCopula( %s )\n" % (self.variable["copula"], self.variable["n"]) + elif ( self.DictMCVal[ 'Copula' ] in ( 'Normal', ) ): + varList = self.DictMCVal[ 'CorrelationMatrix' ][0] + dimension = len(varList) + txt += "%s = {}\n" % self.variable["correlation"] + for i in range( dimension ): + txt += "%s['%s'] = {}\n" % (self.variable["correlation"], varList[i]) + for j in range ( dimension ): + txt += "%s['%s']['%s'] = %g\n" % (self.variable["correlation"], varList[i], varList[j], self.DictMCVal[ 'CorrelationMatrix' ][i+1][j]) + txt += "%s = getCorrelationMatrixFromMap( %s.getVariableList(), %s )\n" % (self.variable["R"], self.variable["wrapperdata"], self.variable["correlation"]) + txt += "%s = NormalCopula( %s )\n" % (self.variable["copula"], self.variable["R"]) + + txt += "\n" + return txt + + def InputRandomVector (self): + ''' + Cree le vector aleatoire d entree + ''' + txt = "# Definit le vecteur aleatoire d'entree\n" + txt += "%s = RandomVector( %s )\n" % (self.variable["inputRandomVector"], self.variable["distribution"]) + txt += "\n" + return txt + + def OutputRandomVector (self): + ''' + Cree le vector aleatoire de sortie + ''' + nomVar = "output" + for variable in self.ListeVariablesOut: + nomVar = variable['ModelVariable'].get_name() + + txt = "# Definit le vecteur aleatoire de sortie\n" + txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) + txt += "%s.setName( '%s' )\n" % (self.variable["outputRandomVector"], nomVar) + txt += "\n" + return txt + + def ScaledVector (self): + ''' + Definit les coefficients multiplicateurs par composante du vecteur + ''' + dimension = 0 + if ( self.DictMCVal.has_key( 'UnitsPerDimension' ) ): + unitsPerDimension = self.DictMCVal[ 'UnitsPerDimension' ] + dimension = len( unitsPerDimension ) + + txt = "# Definit les facteurs d'echelle dans chaque direction\n" + txt += "%s = NumericalPoint( %s )\n" % (self.variable["scaledVector"], self.variable["n"]) + for i in range(dimension): + txt += "%s[%d] = %g\n" % (self.variable["scaledVector"], i, unitsPerDimension[i]) + txt += "%s.scale( %s )\n" % (self.variable["myExperimentPlane"], self.variable["scaledVector"]) + txt += "\n" + return txt + + def TranslationVector (self): + ''' + Definit le vecteur de translation + ''' + dimension = 0 + if ( self.DictMCVal.has_key( 'Center' ) ): + center = self.DictMCVal[ 'Center' ] + dimension = len( center ) + + txt = "# Definit le vecteur de translation\n" + txt += "%s = NumericalPoint( %s )\n" % (self.variable["translationVector"], self.variable["n"]) + for i in range(dimension): + txt += "%s[%d] = %g\n" % (self.variable["translationVector"], i, center[i]) + txt += "%s.translate( %s )\n" % (self.variable["myExperimentPlane"], self.variable["translationVector"]) + txt += "\n" + return txt + + def Levels (self): + ''' + Definit les niveaux du plan d experience + ''' + dimension = 0 + if ( self.DictMCVal.has_key( 'Levels' ) ): + levels = self.DictMCVal[ 'Levels' ] + dimension = len( levels ) + + txt = "# Definit les niveaux de la structure de grille\n" + txt += "%s = NumericalPoint( %d )\n" % (self.variable["levels"], dimension) + for i in range(dimension): + txt += "%s[%d] = %g\n" % (self.variable["levels"], i, levels[i]) + txt += "\n" + return txt + + def CenteredReductedGrid (self): + ''' + Definit la grille reduite du plan d experience + ''' + plane = None + if ( self.DictMCVal.has_key( 'ExperimentPlane' ) ): + plane = self.DictMCVal[ 'ExperimentPlane' ] + + txt = "# Cree le plan d'experience centre reduit\n" + txt += "%s = %s(%s, %s)\n" % (self.variable["myCenteredReductedGrid"], plane, self.variable["n"], self.variable["levels"]) + txt += "%s = %s.generate()\n" % (self.variable["myExperimentPlane"], self.variable["myCenteredReductedGrid"]) + txt += "\n" + return txt + + def MinMaxResult (self): + ''' + Produit les resultats de l etude + ''' + txt = "# Resultats\n" + txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"]) + txt += "print '%s = ', %s\n" % ("minValue", self.variable["minValue"]) + txt += "\n" + txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"]) + txt += "print '%s = ', %s\n" % ("maxValue", self.variable["maxValue"]) + txt += "\n" + return txt + + def CentralUncertainty (self, subDict): + ''' + Produit le fichier study correspondant a une analyse d incertitude en valeur centrale + ''' + txt = self.Header() + txt += self.Model() + txt += self.InputDistribution() + txt += self.InputRandomVector() + txt += self.OutputRandomVector() + + Methode = None + if ( self.DictMCVal.has_key( 'Method' ) ): + Methode = self.DictMCVal[ 'Method' ] + + Traitement = None + if ( subDict.has_key( Methode ) ): + Traitement = subDict[ Methode ] + + if ( Traitement is not None ): + txt += "# Etude 'Central Uncertainty'\n" + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + txt += self.Footer() + return txt + + + def TaylorVarianceDecomposition (self): + ''' + Etude par decomposition de Taylor + ''' + txt = "# Cumul quadratique (decomposition de Taylor)\n" + txt += "%s = QuadraticCumul( %s )\n" % (self.variable["myQuadraticCumul"], self.variable["outputRandomVector"]) + txt += "\n" + txt += "# Resultats\n" + + if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ): + if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ): + txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"]) + txt += "print '%s = ', %s\n" % ("mean First Order", self.variable["meanFirstOrder"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ): + if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ): + txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"]) + txt += "print '%s = ', %s\n" % ("mean Second Order", self.variable["meanSecondOrder"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ): + if ( self.DictMCVal[ 'StandardDeviationFirstOrder' ] == "yes" ): + txt += "%s = %s.getCovariance()\n" % (self.variable["standardDeviationFirstOrder"], self.variable["myQuadraticCumul"]) + txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"] + txt += "for i in range( dim ):\n" + txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"]) + txt += " print '%s = ', %s[ i, i ]\n" % ("standard Deviation First Order", self.variable["standardDeviationFirstOrder"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ): + if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ): + txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"]) + txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"] + txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"]) + txt += "\n" + txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"]) + txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) + txt += "#if is_xserver_available():\n" + txt += "# view = View(%s)\n" % self.variable["importanceFactorsGraph"] + txt += "# view.show(block=True)\n" + txt += "#else:\n" + txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["importanceFactorsGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] + txt += "\n" + + txt += "\n" + return txt + + def CentralUncertaintyRandomSampling (self): + ''' + Etude par echantillonage aleatoire + ''' + size = 0 + if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): + size = self.DictMCVal[ 'SimulationsNumber' ] + + txt = "# Echantillonnage aleatoire de la variable de sortie\n" + txt += "%s = %d\n" % (self.variable["inSize"], size) + txt += "%s = %s.getSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"]) + txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) + txt += "if contain_nan_values( %s ):\n" % (self.variable["outputSample"]) + txt += " raise Exception('Some computations failed')\n" + txt += "\n" + + if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ): + if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ): + txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"]) + txt += "print '%s =', %s[0]\n" % ("empirical Mean", self.variable["empiricalMean"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ): + if ( self.DictMCVal[ 'EmpiricalStandardDeviation' ] == "yes" ): + txt += "%s = %s.computeCovariance()\n" % (self.variable["empiricalStandardDeviation"], self.variable["outputSample"]) + txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"] + txt += "for i in range( dim ):\n" + txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"]) + txt += " print '%s = ', %s[ i, i ]\n" % ("empirical Standard Deviation", self.variable["empiricalStandardDeviation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ): + ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ] + txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre) + txt += "print '%s ( %s ) =', %s\n" % ("empirical Quantile", ordre, self.variable["empiricalQuantile"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'CorrelationAnalysis' ) ): + if ( self.DictMCVal[ 'CorrelationAnalysis' ] == "yes" ): + txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] + txt += " %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'PCC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PCCcoefficient"]) + txt += "\n" + txt += " %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'PRCC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PRCCcoefficient"]) + txt += "\n" + txt += " %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'SRC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRCcoefficient"]) + txt += "\n" + txt += " %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'SRRC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRRCcoefficient"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ): + if ( self.DictMCVal[ 'KernelSmoothing' ] == "yes" ): + txt += "# Kernel Smoohing\n" + txt += "%s = KernelSmoothing()\n" % self.variable["kernel"] + txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] + txt += " %s.setName( 'Output' )\n" % self.variable["outputSample"] + txt += " %s = %s.build( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"]) + txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedDist"]) + txt += " %s = '%s'\n" % (self.variable["kernelSmoothedPDFDrawing"], self.DictMCVal[ 'KernelSmoothingDrawingFilename' ]) + txt += " %s.draw( %s )\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedPDFDrawing"]) + txt += " #if is_xserver_available():\n" + txt += " # view = View(%s)\n" % self.variable["kernelSmoothedGraph"] + txt += " # view.show(block=True)\n" + txt += " #else:\n" + txt += " # print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["kernelSmoothedGraph"] + txt += " print 'bitmap =', %s.getBitmap()\n" % self.variable["kernelSmoothedGraph"] + txt += " print 'postscript =', %s.getPostscript()\n" % self.variable["kernelSmoothedGraph"] + txt += "\n" + + return txt + + def ThresholdExceedence (self, subDict): + ''' + Produit le fichier study correspondant a une analyse de depassement de seuil + ''' + txt = self.Header() + txt += "# Etude 'Threshold Exceedence'\n" + + txt += self.RandomGenerator() + txt += self.Model() + txt += self.InputDistribution() + txt += self.InputRandomVector() + txt += self.OutputRandomVector() + txt += self.Event() + + Methode = None + if ( self.DictMCVal.has_key( 'Method' ) ): + Methode = self.DictMCVal[ 'Method' ] + + Traitement = None + if ( subDict.has_key( Methode ) ): + Traitement = subDict[ Methode ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) ) + + txt += self.Footer() + return txt + + def Simulation (self, subDict): + ''' + Methodes de simulation + ''' + Algorithme = None + if ( self.DictMCVal.has_key( 'Algorithm' ) ): + Algorithme = self.DictMCVal[ 'Algorithm' ] + + Traitement = None + if ( subDict.has_key( Algorithme ) ): + Traitement = subDict[ Algorithme ] + + if ( Traitement is not None ): + txt = apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + maxOuterSampling = None + if ( self.DictMCVal.has_key( 'MaximumOuterSampling' ) ): + maxOuterSampling = self.DictMCVal[ 'MaximumOuterSampling' ] + txt += "%s.setMaximumOuterSampling( %s )\n" % (self.variable["myAlgo"], maxOuterSampling) + + blockSize = None + if ( self.DictMCVal.has_key( 'BlockSize' ) ): + blockSize = self.DictMCVal[ 'BlockSize' ] + txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize) + + maxCoefficientOfVariation = None + if ( self.DictMCVal.has_key( 'MaximumCoefficientOfVariation' ) ): + maxCoefficientOfVariation = self.DictMCVal[ 'MaximumCoefficientOfVariation' ] + txt += "%s.setMaximumCoefficientOfVariation( %s )\n" % (self.variable["myAlgo"], maxCoefficientOfVariation) + + txt += "%s.run()\n" % self.variable["myAlgo"] + txt += "\n" + txt += "# Resultats de la simulation\n" + txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'Probability' ) ): + if ( self.DictMCVal[ 'Probability' ] == "yes" ): + txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("probability", self.variable["probability"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'StandardDeviation' ) ): + if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ): + txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("standard Deviation", self.variable["standardDeviation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ): + if ( ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) and ( self.DictMCVal[ 'Probability' ] == "yes" ) ): + level = self.DictMCVal[ 'Level' ] + txt += "%s = %s.getConfidenceLength( %s )\n" % (self.variable["length"], self.variable["myResult"], level) + txt += "print 'confidence interval at %s = [', %s-0.5*%s, ',', %s+0.5*%s, ']'\n" % (level, self.variable["probability"], self.variable["length"], self.variable["probability"], self.variable["length"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ): + if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ): + txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("coefficient of Variation", self.variable["coefficientOfVariation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): + if ( self.DictMCVal[ 'SimulationsNumber' ] == "yes" ): + txt += "%s = %s.getOuterSampling()\n" % (self.variable["simulationNumbers"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("simulation Numbers", self.variable["simulationNumbers"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) and self.DictMCVal.has_key( 'ConfidenceInterval' ) ): + if ( ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ) and ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) ): + txt += "%s = %s\n" % (self.variable["alpha"], self.DictMCVal[ 'Level' ]) + txt += "%s = %s.drawProbabilityConvergence( %s )\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"], self.variable["alpha"]) + txt += "%s = '%s'\n" % (self.variable["convergenceDrawing"], self.DictMCVal[ 'ConvergenceDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["convergenceGraph"], self.variable["convergenceDrawing"]) + txt += "#if is_xserver_available():\n" + txt += "# view = View(%s)\n" % self.variable["convergenceGraph"] + txt += "# view.show(block=True)\n" + txt += "#else:\n" + txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["convergenceGraph"] + txt += "\n" + + return txt + + def Analytical (self, subDict): + ''' + Methodes analytiques + ''' + txt = "" + + OptimizationAlgo = None + if ( self.DictMCVal.has_key( 'OptimizationAlgorithm' ) ): + OptimizationAlgo = self.DictMCVal[ 'OptimizationAlgorithm' ] + + Traitement = None + if ( subDict.has_key( OptimizationAlgo ) ): + Traitement = subDict[ OptimizationAlgo ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + txt += self.OptimizerSettings() + txt += self.PhysicalStartingPoint() + + Approximation = None + if ( self.DictMCVal.has_key( 'Approximation' ) ): + Approximation = self.DictMCVal[ 'Approximation' ] + + Traitement = None + if ( subDict.has_key( Approximation ) ): + Traitement = subDict[ Approximation ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + txt += self.RunAlgorithm() + txt += self.AnalyticalResult() + + return txt + + def OptimizerSettings (self): + ''' + Parametrage de l optimiseur + ''' + txt = "" + + simulationNumbers = None + if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ): + simulationNumbers = self.DictMCVal[ 'MaximumIterationsNumber' ] + txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], simulationNumbers) + + absoluteError = None + if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ): + absoluteError = self.DictMCVal[ 'MaximumAbsoluteError' ] + txt += "%s.setMaximumAbsoluteError( %s )\n" % (self.variable["myOptimizer"], absoluteError) + + relativeError = None + if ( self.DictMCVal.has_key( 'MaximumRelativeError' ) ): + relativeError = self.DictMCVal[ 'MaximumRelativeError' ] + txt += "%s.setMaximumRelativeError( %s )\n" % (self.variable["myOptimizer"], relativeError) + + residualError = None + if ( self.DictMCVal.has_key( 'MaximumResidualError' ) ): + residualError = self.DictMCVal[ 'MaximumResidualError' ] + txt += "%s.setMaximumResidualError( %s )\n" % (self.variable["myOptimizer"], residualError) + + constraintError = None + if ( self.DictMCVal.has_key( 'MaximumConstraintError' ) ): + constraintError = self.DictMCVal[ 'MaximumConstraintError' ] + txt += "%s.setMaximumConstraintError( %s )\n" % (self.variable["myOptimizer"], constraintError) + + txt += "\n" + + return txt + + def PhysicalStartingPoint (self): + ''' + Point physique de depart + ''' + txt = "# Point physique de depart\n" + + if ( self.DictMCVal.has_key( 'PhysicalStartingPoint' ) ): + point = self.DictMCVal[ 'PhysicalStartingPoint' ] + dimension = len( point ) + txt += "%s = NumericalPoint( %d )\n" % (self.variable["startingPoint"], dimension) + for i in range( dimension ): + txt += "%s[ %d ] = %g\n" % (self.variable["startingPoint"], i, point[i]) + else: + txt += "%s = %s.getMean()\n" % (self.variable["startingPoint"], self.variable["inputRandomVector"]) + + txt += "\n" + + return txt + + def AnalyticalResult (self): + ''' + Resultat des methodes analytiques + ''' + txt = "# Resultat des methodes analytiques\n" + txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"]) + + if ( self.DictMCVal.has_key( 'Probability' ) ): + if ( self.DictMCVal[ 'Probability' ] == "yes" ): + txt += "%s = %s.getEventProbability()\n" % (self.variable["probability"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ): + if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ): + txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("hasofer Reliability Index", self.variable["hasoferReliabilityIndex"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'DesignPoint' ) ): + if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ): + txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("standard Space Design Point", self.variable["standardSpaceDesignPoint"]) + txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("physical Space Design Point", self.variable["physicalSpaceDesignPoint"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ): + if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ): + txt += "print 'Importance Factors:'\n" + txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"]) + txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"] + txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"]) + txt += "\n" + txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"]) + txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) + txt += "#if is_xserver_available():\n" + txt += "# view = View(%s)\n" % self.variable["importanceFactorsGraph"] + txt += "# view.show(block=True)\n" + txt += "#else:\n" + txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["importanceFactorsGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] + txt += "\n" + + if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivity' ) ): + if ( self.DictMCVal[ 'FORMEventProbabilitySensitivity' ] == "yes" ): + txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"]) + txt += "print 'FORM Event Probability Sensitivity:'\n" + txt += "for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"] + txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["eventProbabilitySensitivity"] + txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"]) + txt += "\n" + txt += "%s = %s.drawEventProbabilitySensitivity()[0]\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"]) + txt += "%s = '%s'\n" % (self.variable["eventProbabilitySensitivityDrawing"], self.DictMCVal[ 'FORMEventProbabilitySensitivityDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["eventProbabilitySensitivityDrawing"]) + txt += "#if is_xserver_available():\n" + txt += "# view = View(%s)\n" % self.variable["eventProbabilitySensitivityGraph"] + txt += "# view.show(block=True)\n" + txt += "#else:\n" + txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["eventProbabilitySensitivityGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["eventProbabilitySensitivityGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["eventProbabilitySensitivityGraph"] + txt += "\n" + + if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivity' ) ): + if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivity' ] == "yes" ): + txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"]) + txt += "print 'Hasofer Reliability Index Sensitivity:'\n" + txt += "for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"] + txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["hasoferReliabilityIndexSensitivity"] + txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"]) + txt += "\n" + txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()[0]\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"]) + txt += "%s = '%s'\n" % (self.variable["hasoferReliabilityIndexSensitivityDrawing"], self.DictMCVal[ 'HasoferReliabilityIndexSensitivityDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["hasoferReliabilityIndexSensitivityDrawing"]) + txt += "#if is_xserver_available():\n" + txt += "# view = View(%s)\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "# view.show(block=True)\n" + txt += "#else:\n" + txt += "# print 'Warning: cannot display image', %s.getBitmap(), '(probably because no X server was found)'\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "\n" + + if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ): + if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ): + txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("Tvedt Approximation", self.variable["tvedtApproximation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ): + if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ): + txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("HohenBichler Approximation", self.variable["tvedtApproximation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ): + if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ): + txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("Breitung Approximation", self.variable["breitungApproximation"]) + txt += "\n" + + + return txt + + def RandomGenerator (self): + ''' + Generateur Aleatoire + ''' + txt = "" + + seed = None + if ( self.DictMCVal.has_key( 'RandomGeneratorSeed' ) ): + seed = self.DictMCVal[ 'RandomGeneratorSeed' ] + txt += "# Initialise le generateur aleatoire\n" + txt += "RandomGenerator.SetSeed( %s )\n" % seed + txt += "\n" + + return txt + + def Event (self): + ''' + Definition de l evenement de defaillance + ''' + operator = None + if ( self.DictMCVal.has_key( 'ComparisonOperator' ) ): + operator = self.DictMCVal[ 'ComparisonOperator' ] + + threshold = None + if ( self.DictMCVal.has_key( 'Threshold' ) ): + threshold = self.DictMCVal[ 'Threshold' ] + + txt = "# Evenement de defaillance\n" + txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold) + txt += "%s.setName( '%s' )\n" % (self.variable["myEvent"], "myEvent") + txt += "\n" + return txt + + def MonteCarlo (self): + ''' + Methode de MonteCarlo + ''' + txt = "# Simulation par MonteCarlo\n" + txt += "%s = MonteCarlo( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) + txt += "\n" + + return txt + + def LHS (self): + ''' + Methode LHS + ''' + txt = "# Simulation par LHS\n" + txt += "%s = LHS( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) + txt += "\n" + + return txt + + def ImportanceSampling (self): + ''' + Methode de tirage d importance + ''' + dimension = 0 + if ( self.DictMCVal.has_key( 'MeanVector' ) ): + meanVector = self.DictMCVal[ 'MeanVector' ] + dimension = len( meanVector ) + + txt = "# Simulation par Tirage d'importance\n" + txt += "# Densite d'importance\n" + txt += "%s = NumericalPoint( %s )\n" % (self.variable["meanVector"], self.variable["n"]) + for i in range(dimension): + txt += "%s[%d] = %g\n" % (self.variable["meanVector"], i, meanVector[i]) + + txt += "%s = Normal( %s, CovarianceMatrix( IdentityMatrix( %s ) ) )\n" % (self.variable["importanceDensity"], self.variable["meanVector"], self.variable["n"]) + txt += "%s = ImportanceSampling( %s, Distribution( %s ) )\n" % (self.variable["myAlgo"], self.variable["myEvent"], self.variable["importanceDensity"]) + txt += "\n" + + return txt + + def FORM (self): + ''' + Methode FORM + ''' + txt = "# Algorithme FORM\n" + txt += "%s = FORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"]) + txt += "\n" + + return txt + + def SORM (self): + ''' + Methode SORM + ''' + txt = "# Algorithme SORM\n" + txt += "%s = SORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"]) + txt += "\n" + + return txt + + def RunAlgorithm (self): + ''' + Do the computation + ''' + txt = "" + if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): + if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): + txt += "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"]) + txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"]) + txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"]) + txt += "\n" + + txt += "# Perform the computation\n" + txt += "%s.run()\n" % self.variable["myAlgo"] + txt += "\n" + + + if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): + if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): + txt += "%s = %s.getEvaluationCallsNumber() - %s\n" % (self.variable["modelEvaluationCalls"], self.variable["model"], self.variable["modelEvaluationCalls"]) + txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"]) + txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"]) + txt += "\n" + txt += "print '%s =', %s\n" % ("model Evaluation Calls", self.variable["modelEvaluationCalls"]) + txt += "print '%s =', %s\n" % ("model Gradient Calls", self.variable["modelGradientCalls"]) + txt += "print '%s =', %s\n" % ("model Hessian Calls", self.variable["modelHessianCalls"]) + txt += "\n" + + return txt + + def Cobyla (self): + ''' + Methode Cobyla + ''' + txt = "# Optimisation par Cobyla\n" + txt += "%s = Cobyla()\n" % self.variable["myOptimizer"] + txt += "#%s = CobylaSpecificParameters()\n" % self.variable["specificParameters"] + txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"]) + txt += "\n" + + return txt + + def AbdoRackwitz (self): + ''' + Methode AbdoRackwitz + ''' + txt = "# Optimisation par AbdoRackwitz\n" + txt += "%s = AbdoRackwitz()\n" % self.variable["myOptimizer"] + txt += "#%s = AbdoRackwitzSpecificParameters()\n" % self.variable["specificParameters"] + txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"]) + txt += "\n" + return txt + + def Beta (self, loi): + ''' + Definition de la loi Beta + ''' + settings = { + "RT" : "Beta.RT", + "MuSigma" : "Beta.MUSIGMA", + } + if loi[ 'Settings' ] == 'RT' : + arg1 = loi[ 'R' ] + arg2 = loi[ 'T' ] + else : + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Sigma' ] + + arg3 = loi[ 'A' ] + arg4 = loi[ 'B' ] + txt = "Beta( %g, %g, %g, %g, %s )" % (arg1, arg2, arg3, arg4, settings[ loi[ 'Settings' ] ]) + return txt + + def Exponential (self, loi): + ''' + Definition de la loi Exponential + ''' + arg1 = loi[ 'Lambda' ] + arg2 = loi[ 'Gamma' ] + txt = "Exponential( %g, %g )" % (arg1, arg2) + return txt + + def Gamma (self, loi): + ''' + Definition de la loi Gamma + ''' + settings = { + "KLambda" : "Gamma.KLAMBDA", + "MuSigma" : "Gamma.MUSIGMA", + } + if loi[ 'Settings' ] == 'KLambda' : + arg1 = loi[ 'K' ] + arg2 = loi[ 'Lambda' ] + else : + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Sigma' ] + + arg3 = loi[ 'Gamma' ] + txt = "Gamma( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) + return txt + + def Geometric (self, loi): + ''' + Definition de la loi Geometric + ''' + txt = "Geometric( %g )" % loi[ 'P' ] + return txt + + def Gumbel (self, loi): + ''' + Definition de la loi Gumbel + ''' + settings = { + "AlphaBeta" : "Gumbel.ALPHABETA", + "MuSigma" : "Gumbel.MUSIGMA", + } + if loi[ 'Settings' ] == 'AlphaBeta' : + arg1 = loi[ 'Alpha' ] + arg2 = loi[ 'Beta' ] + else : + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Sigma' ] + + txt = "Gumbel( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ]) + return txt + + def Histogram (self, loi): + ''' + Definition de la loi Histogram + ''' + arg1 = loi[ 'First' ] + arg2 = loi[ 'Values' ] + txt = "Histogram( %g, %s )" % (arg1, arg2) + return txt + + def Laplace (self, loi): + ''' + Definition de la loi Laplace + ''' + arg1 = loi[ 'Lambda' ] + arg2 = loi[ 'Mu' ] + txt = "Laplace( %g, %g )" % (arg1, arg2) + return txt + + def Logistic (self, loi): + ''' + Definition de la loi Logistic + ''' + arg1 = loi[ 'Alpha' ] + arg2 = loi[ 'Beta' ] + txt = "Logistic( %g, %g )" % (arg1, arg2) + return txt + + def LogNormal (self, loi): + ''' + Definition de la loi LogNormal + ''' + settings = { + "MuSigmaLog" : "LogNormal.MUSIGMA_LOG", + "MuSigma" : "LogNormal.MUSIGMA", + "MuSigmaOverMu" : "LogNormal.MU_SIGMAOVERMU", + } + if loi[ 'Settings' ] == 'MuSigmaLog' : + arg1 = loi[ 'MuLog' ] + arg2 = loi[ 'SigmaLog' ] + elif loi[ 'Settings' ] == 'MuSigmaOverMu' : + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'SigmaOverMu' ] + else : + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Sigma' ] + + arg3 = loi[ 'Gamma' ] + txt = "LogNormal( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) + return txt + + def MultiNomial (self, loi): + ''' + Definition de la loi MultiNomial + ''' + arg1 = loi[ 'Values' ] + arg2 = loi[ 'N' ] + txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2) + return txt + + def NonCentralStudent (self, loi): + ''' + Definition de la loi NonCentralStudent + ''' + arg1 = loi[ 'Nu' ] + arg2 = loi[ 'Delta' ] + arg3 = loi[ 'Gamma' ] + txt = "NonCentralStudent( %g, %g )" % (arg1, arg2, arg3) + return txt + + def Normal (self, loi): + ''' + Definition de la loi Normal + ''' + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Sigma' ] + txt = "Normal( %g, %g )" % (arg1, arg2) + return txt + + def TruncatedNormal (self, loi): + ''' + Definition de la loi TruncatedNormal + ''' + arg1 = loi[ 'MuN' ] + arg2 = loi[ 'SigmaN' ] + arg3 = loi[ 'A' ] + arg4 = loi[ 'B' ] + txt = "TruncatedNormal( %g, %g, %g, %g )" % (arg1, arg2, arg3, arg4) + return txt + + def Poisson (self, loi): + ''' + Definition de la loi Poisson + ''' + txt = "Poisson( %g )" % loi[ 'Lambda' ] + return txt + + def Rayleigh (self, loi): + ''' + Definition de la loi Rayleigh + ''' + arg1 = loi[ 'Sigma' ] + arg2 = loi[ 'Gamma' ] + txt = "Rayleigh( %g, %g )" % (arg1, arg2) + return txt + + def Student (self, loi): + ''' + Definition de la loi Student + ''' + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Nu' ] + arg3 = loi[ 'Sigma' ] + txt = "Student( %g, %g, %g )" % (arg1, arg2, arg3) + return txt + + def Triangular (self, loi): + ''' + Definition de la loi Triangular + ''' + arg1 = loi[ 'A' ] + arg2 = loi[ 'M' ] + arg3 = loi[ 'B' ] + txt = "Triangular( %g, %g, %g )" % (arg1, arg2, arg3) + return txt + + def Uniform (self, loi): + ''' + Definition de la loi Uniform + ''' + arg1 = loi[ 'A' ] + arg2 = loi[ 'B' ] + txt = "Uniform( %g, %g )" % (arg1, arg2) + return txt + + def UserDefined (self, loi): + ''' + Definition de la loi UserDefined + ''' + txt = "** UserDefined not defined yet **" + return txt + + def Weibull (self, loi): + ''' + Definition de la loi Weibull + ''' + settings = { + "AlphaBeta" : "Weibull.ALPHABETA", + "MuSigma" : "Weibull.MUSIGMA", + } + if loi[ 'Settings' ] == 'AlphaBeta' : + arg1 = loi[ 'Alpha' ] + arg2 = loi[ 'Beta' ] + else : + arg1 = loi[ 'Mu' ] + arg2 = loi[ 'Sigma' ] + + arg3 = loi[ 'Gamma' ] + txt = "Weibull( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) + return txt + + + + def GraphiquePDF (self, loi, chemin, fichier): + ''' + Produit une image PNG representant la PDF de la loi + ''' + txt = headerSTD % self.OpenTURNS_path + txt += "dist = %s\n" % apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) ) + txt += "graph = dist.drawPDF()\n" + txt += "graph.draw( '%s/%s' , 640, 480, GraphImplementation.PNG)\n" % (chemin, fichier) + txt += footerSTD + return txt + diff --git a/generator/oldCodes/OpenturnsXML.py b/generator/oldCodes/OpenturnsXML.py new file mode 100644 index 00000000..860508de --- /dev/null +++ b/generator/oldCodes/OpenturnsXML.py @@ -0,0 +1,243 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +Ce module contient le generateur XML pour Openturns +""" +import sys +print sys.path +from Extensions.i18n import tr +import openturns + +# Dictionnaires de conversion des valeurs lues dans EFICAS +# en valeurs reconnues par Open TURNS +# Les clefs 'None' sont les valeurs par defaut + +VariableTypeByName = { + "in" : openturns.WrapperDataVariableType.IN, + "out" : openturns.WrapperDataVariableType.OUT, + None : openturns.WrapperDataVariableType.IN, + } + +FileTypeByName = { + "in" : openturns.WrapperDataFileType.IN, + "out" : openturns.WrapperDataFileType.OUT, + None : openturns.WrapperDataFileType.IN, + } + +SymbolProvidedByName = { + "no" : openturns.WrapperSymbolProvided.NO, + "yes" : openturns.WrapperSymbolProvided.YES, + None : openturns.WrapperSymbolProvided.NO, + } + +WrapperStateByName = { + "shared" : openturns.WrapperState.SHARED, + "specific" : openturns.WrapperState.SPECIFIC, + None : openturns.WrapperState.SPECIFIC, + } + +WrapperModeByName = { + "static-link" : openturns.WrapperMode.STATICLINK, + "dynamic-link" : openturns.WrapperMode.DYNAMICLINK, + "fork" : openturns.WrapperMode.FORK, + None : openturns.WrapperMode.FORK, + } + +WrapperDataTransferByName = { + "files" : openturns.WrapperDataTransfer.FILES, + "pipe" : openturns.WrapperDataTransfer.PIPE, + "arguments" : openturns.WrapperDataTransfer.ARGUMENTS, + "socket" : openturns.WrapperDataTransfer.SOCKET, + "corba" : openturns.WrapperDataTransfer.CORBA, + None : openturns.WrapperDataTransfer.FILES, + } + +#========================== +# La classe de creation XML +#========================== + +class XMLGenerateur : + + ''' + Generation du fichier XML + ''' + def __init__ (self, appli, DictMCVal, DictVariables ) : + self.DictMCVal = DictMCVal + self.DictVariables = DictVariables + self.appli = appli + + def CreeXML (self) : + ''' + Pilotage general de la creation du fichier XML + ''' + data = openturns.WrapperData() + data.setLibraryPath( self.GetMCVal('WrapperPath','') ) + data.setVariableList( self.VariableList() ) + data.setFunctionDescription( self.FunctionDefinition() ) + data.setGradientDescription( self.GradientDefinition() ) + data.setHessianDescription( self.HessianDefinition() ) + data.setFileList( self.FileList() ) + data.setParameters( self.Parameters() ) + #data.setFrameworkData( self.FrameworkData() ) + + wrapper=openturns.WrapperFile() + wrapper.setWrapperData( data ) + + return wrapper + + + class __variable_ordering: + def __init__ (self, dictVar) : + self.dictVar = dictVar + + def __call__(self, a, b): + return self.dictVar[a]['numOrdre'] - self.dictVar[b]['numOrdre'] + + def VariableList (self) : + ''' + Ecrit la liste des variables + ''' + varList = openturns.WrapperDataVariableCollection() + for var in sorted( self.DictVariables.keys(), self.__variable_ordering( self.DictVariables ) ) : + varList.add( self.Variable( var, self.DictVariables[var] ) ) + return varList + + def Variable (self, var, dictVar) : + ''' + Ecrit le parametrage d une variable + ''' + variable = openturns.WrapperDataVariable() + variable.id_ = var + if dictVar[ 'Type' ] in VariableTypeByName.keys() : + variable.type_ = VariableTypeByName[ dictVar[ 'Type' ] ] + if dictVar.has_key('Comment') : variable.comment_ = dictVar[ 'Comment' ] + if dictVar.has_key('Unit') : variable.unit_ = dictVar[ 'Unit' ] + if dictVar.has_key('Regexp') : variable.regexp_ = dictVar[ 'Regexp' ] + if dictVar.has_key('Format') : variable.format_ = dictVar[ 'Format' ] + return variable + + def FunctionDefinition (self) : + ''' + Ecrit la description de la Fonction + ''' + func = openturns.WrapperFunctionDescription() + func.name_ = self.GetMCVal( 'FunctionName', '' ) + if (len(func.name_) != 0) : func.provided_ = SymbolProvidedByName[ 'yes' ] + return func + + def GradientDefinition (self) : + ''' + Ecrit la description du Gradient + ''' + grad = openturns.WrapperFunctionDescription() + grad.name_ = self.GetMCVal( 'GradientName', '' ) + if (len(grad.name_) != 0) : grad.provided_ = SymbolProvidedByName[ 'yes' ] + return grad + + def HessianDefinition (self) : + ''' + Ecrit la description de la Hessienne + ''' + hess = openturns.WrapperFunctionDescription() + hess.name_ = self.GetMCVal( 'HessianName', '' ) + if (len(hess.name_) != 0) : hess.provided_ = SymbolProvidedByName[ 'yes' ] + return hess + + + + def FileList (self) : + ''' + Ecrit la liste des fichiers + ''' + fileList = openturns.WrapperDataFileCollection() + for dictFile in self.GetMCVal('Files', []) : + fileList.add( self.File( dictFile ) ) + return fileList + + def File (self, dictFile ) : + ''' + Ecrit le parametrage d un fichier + ''' + fich = openturns.WrapperDataFile() + fich.id_ = dictFile[ 'Id' ] + if dictFile[ 'Type' ] in FileTypeByName.keys() : + fich.type_ = FileTypeByName[ dictFile[ 'Type' ] ] + if dictFile.has_key('Name') : fich.name_ = dictFile[ 'Name' ] + if dictFile.has_key('Path') : fich.path_ = dictFile[ 'Path' ] + if dictFile.has_key('Subst') : + import string + fich.subst_ = string.join( dictFile[ 'Subst' ], ',' ) + return fich + + def Parameters (self) : + ''' + Ecrit les parametres de couplage au code externe + ''' + parameters = openturns.WrapperParameter() + parameters.mode_ = WrapperModeByName[ self.GetMCVal('WrapCouplingMode') ] + if (parameters.mode_ == openturns.WrapperMode.FORK ): + parameters.command_ = self.GetMCVal('Command') + userPrefix = self.GetMCVal('UserPrefix', None) + if userPrefix != None : parameters.userPrefix_ = userPrefix + parameters.state_ = WrapperStateByName[ self.GetMCVal('State') ] + parameters.in_ = WrapperDataTransferByName[ self.GetMCVal('InDataTransfer') ] + parameters.out_ = WrapperDataTransferByName[ self.GetMCVal('OutDataTransfer') ] + return parameters + + def FrameworkData (self) : + ''' + Ecrit les donnees liees a l utilisation d un framework englobant + ''' + framework = openturns.WrapperFrameworkData() +# framework.studycase_ = "12:23:34" +# framework.componentname_ = self.GetMCVal('SolverComponentName', 'UNDEFINED') + CN = self.GetMCVal('SolverComponentName', 'UNDEFINED') + print 'CN = %s', CN + framework.componentname_ = CN + return framework + + + # --------------------------------------------------------------------------------- + + + def GetTag (self, tag) : + ''' + Recupere la chaine associee au tag dans la table dictTagsXML. + Leve une exception si le tag n est pas trouve + ''' + if ( dictTagsXML.has_key(tag) ) : + return dictTagsXML[tag] + else : + raise KeyError, tr("Tag %s non-defini. Ceci est un bogue interne. en informer les developpeurs.", tag) + pass + + def GetMCVal (self, MC, default = None, mandatory = False) : + ''' + Recupere la chaine associee au MC dans la table DictMCVal. + Leve une exception si le MC n est pas trouve et mandatory vaut True + ''' + if ( self.DictMCVal.has_key(MC) and self.DictMCVal[MC] != None ) : + return self.DictMCVal[MC] + else : + if ( mandatory ) : + raise KeyError, tr(" Le mot-cle %s est obligatoire.", MC) + else : + return default + pass diff --git a/generator/oldCodes/generator_SEP.py b/generator/oldCodes/generator_SEP.py new file mode 100644 index 00000000..241d0bd9 --- /dev/null +++ b/generator/oldCodes/generator_SEP.py @@ -0,0 +1,163 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + Ce module contient le plugin generateur de fichier au format + SEP pour EFICAS. + +""" +import traceback +import types,string,re,os + +from generator_python import PythonGenerator + +def entryPoint(): + """ + Retourne les informations necessaires pour le chargeur de plugins + + Ces informations sont retournees dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'SEP', + # La factory pour creer une instance du plugin + 'factory' : SEPGenerator, + } + + +class SEPGenerator(PythonGenerator): + """ + Ce generateur parcourt un objet de type JDC et produit + un texte au format eficas et + un texte au format py + + """ + # Les extensions de fichier permis? + extensions=('.comm',) + + def gener(self,obj,format='brut',config=None): + self.initDico() + # Cette instruction génère le contenu du fichier de commandes (persistance) + self.text=PythonGenerator.gener(self,obj,format) + # Cette instruction génère le contenu du fichier de paramètres python + self.genereSEP() + return self.text + + def getTubePy(self) : + return self.texteTubePy + + def genereSEP(self) : + ''' + Prépare le contenu du fichier de paramètres python. Le contenu + peut ensuite être obtenu au moyen de la fonction getTubePy(). + ''' + #self.__genereSEP_withVariables() + self.__genereSEP_withDico() + + def __genereSEP_withVariables(self) : + ''' + Les paramètres sont transcrits sous forme de variables nom=valeur. + ''' + self.texteTubePy="# Parametres generes par Eficas \n" + for MC in self.dictMCVal.keys(): + ligne = MC +"="+ repr(self.dictMCVal[MC])+'\n' + self.texteTubePy=self.texteTubePy+ligne + + print self.texteTubePy + + # __GBO__: Tester self.tube pour aiguiller en fonction du cas (au besoin) + fichier=os.path.join(os.path.dirname(__file__),"tube.py") + f=open(fichier,'r') + for ligne in f.readlines(): + self.texteTubePy=self.texteTubePy+ligne + f.close + + def __genereSEP_withDico(self) : + """ + Les paramètres sont transcrits sous la forme d'un dictionnaire nom=valeur. + """ + from Sep import properties + self.texteTubePy="# -*- coding: utf-8 -*-\n" + self.texteTubePy+="# ======================================================================================\n" + self.texteTubePy+="# FICHIER GENERE PAR EFICAS - OUTIL MÉTIER SOUS-EPAISSEUR - " + self.texteTubePy+="VERSION "+str(properties.version)+" du "+str(properties.date)+"\n" + self.texteTubePy+="# ======================================================================================\n" + self.texteTubePy+="\n" + self.texteTubePy+="# Parametres Utilisateur Eficas \n" + self.texteTubePy+="parameters={}\n" + + for MC in self.dictMCVal.keys(): + ligne = "parameters['"+MC+"']="+ repr(self.dictMCVal[MC])+'\n' + self.texteTubePy=self.texteTubePy+ligne + + # On ajoute des paramètres de configuration pour contrôle de + # cohérence avec la procédure outil métier + self.texteTubePy+="# Parametres de Configuration Eficas \n" + ligne = "parameters['OMVERSION']="+str(properties.version)+"\n" + self.texteTubePy+=ligne + + # __GBO__: Tester self.tube pour aiguiller en fonction du cas (au besoin) + self.texteTubePy+="\n" + self.texteTubePy+="# Exécution de la procédure outil métier \n" + self.texteTubePy+="import os,sys\n" + self.texteTubePy+="sys.path.insert(0,os.environ['OM_ROOT_DIR'])\n" + self.texteTubePy+="import om_data\n" + self.texteTubePy+="om_data.setParameters(parameters)\n" + self.texteTubePy+="def run():\n" + self.texteTubePy+=" import om_smeca\n" + self.texteTubePy+="\n" + self.texteTubePy+='if __name__ == "__main__":\n' + self.texteTubePy+=" run()\n" + + # For debug only + print self.texteTubePy + + + def initDico(self) : + self.tube=0 + self.coude=0 + self.dictMCVal={} + self.texteTubePy="" + + # __GBO__: surcharge de PythonGenerator: + # voir example generator_cuve2dg.py (genea) + def generMCSIMP(self,obj) : + """ + Convertit un objet MCSIMP en texte python + Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable + """ + clef="" + for i in obj.get_genealogie() : + clef=clef+"__"+i + #self.dictMCVal[obj.nom]=obj.valeur + self.dictMCVal[clef]=obj.valeur + + s=PythonGenerator.generMCSIMP(self,obj) + return s + + # __GBO__: surcharge de PythonGenerator + def generMACRO_ETAPE(self,obj): + print obj.nom + if obj.nom == "S_EP_INTERNE" : + self.tube=1 + if obj.nom == "M_COUDE" : + self.coude=1 + s=PythonGenerator.generMACRO_ETAPE(self,obj) + return s + diff --git a/generator/oldCodes/generator_cuve2dg.py b/generator/oldCodes/generator_cuve2dg.py new file mode 100644 index 00000000..94f901da --- /dev/null +++ b/generator/oldCodes/generator_cuve2dg.py @@ -0,0 +1,1723 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + Ce module contient le plugin generateur de fichier au format + DefaillCUVE pour EFICAS. + +""" +import traceback +import types,string,re + +from Noyau import N_CR +from Accas import MCSIMP +from generator_python import PythonGenerator + +def entryPoint(): + """ + Retourne les informations nécessaires pour le chargeur de plugins + + Ces informations sont retournées dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'cuve2dg', + # La factory pour créer une instance du plugin + 'factory' : Cuve2dgGenerator, + } + + +class Cuve2dgGenerator(PythonGenerator): + """ + Ce generateur parcourt un objet de type JDC et produit + un texte au format eficas et + un texte au format DefaillCUVE + + """ + # Les extensions de fichier préconisées + extensions=('.comm',) + + def __init__(self,cr=None): + # Si l'objet compte-rendu n'est pas fourni, on utilise le compte-rendu standard + if cr : + self.cr=cr + else: + self.cr=N_CR.CR(debut='CR generateur format DefaillCUVE pour DefaillCUVE', + fin='fin CR format DefaillCUVE pour DefaillCUVE') + # Le texte au format DefaillCUVE est stocké dans l'attribut textCuve + self.textCuve='' + + # Ce dictionnaire liste le nom des variables utilisees dans le script + self.variable = { + "NiveauImpression" : "MESSAGE_LEVEL", + "FichierDataIn" : "DATARESUME_FILE", + "FichierTempSigma" : "TEMPSIG_FILE", + "FichierCSV" : "CSV_FILE", + "FichierRESTART" : "RESTART_FILE", + "FichierEXTR" : "EXTR_FILE", + "ChoixPlugin" : "CHOIPLUG", + "GrandeurEvaluee" : "GRANDEUR", + "IncrementTemporel" : "INCRTPS", + "IncrementMaxTemperature" : "DTPREC", + "ChoixExtractionTransitoires" : "CHOIEXTR", + "IncrementMaxTempsAffichage" : "DTARCH", + "TraitementGeometrie" : "TYPEGEOM", + "RayonInterne" : "RINT", + "RayonInterne_mess" : "RINT_MESSAGE", + "RayonExterne" : "REXT", + "RayonExterne_mess" : "REXT_MESSAGE", + "EpaisseurRevetement" : "LREV", + "EpaisseurRevetement_mess" : "LREV_MESSAGE", + "LigamentExterneMin" : "LIGMIN", + "LigamentExterneMin_mess" : "LIGMIN_MESSAGE", + "NombreNoeudsMaillage" : "NBNO", + "TypeInitial" : "TYPEDEF", + "Orientation" : "ORIEDEF", + "Position" : "POSDEF", + "ProfondeurRadiale" : "PROFDEF", + "ProfondeurRadiale_mess" : "PROFDEF_MESSAGE", + "ModeCalculLongueur" : "OPTLONG", + "Longueur" : "LONGDEF", + "Longueur_mess" : "LONGDEF_MESSAGE", + "CoefDirecteur" : "PROFSURLONG", + "CoefDirecteur_mess" : "PROFSURLONG_MESSAGE", + "Constante" : "LONGCONST", + "ModeCalculDecalage" : "DECATYP", + "DecalageNormalise" : "DECANOR", + "DecalageNormalise_mess" : "DECANOR_MESSAGE", + "DecalageRadial" : "DECADEF", + "DecalageRadial_mess" : "DECADEF_MESSAGE", + "Azimut" : "ANGLDEF", + "Azimut_mess" : "ANGLDEF_MESSAGE", + "Altitude_mess" : "ANGLDEF_MESSAGE", + "Altitude" : "ALTIDEF", + "Altitude_mess" : "ALTIDEF_MESSAGE", + "Pointe" : "POINDEF", + "ModeleFluence" : "MODELFLUENCE", + "ZoneActiveCoeur_AltitudeSup" : "H1COEUR", + "ZoneActiveCoeur_AltitudeInf" : "H2COEUR", + "FluenceMax" : "fmax", + "KPFrance" : "KPFRANCE", + "KPUS" : "KPUS", + "Azimut_0deg" : "COEFFLUENCE1", + "Azimut_5deg" : "COEFFLUENCE2", + "Azimut_10deg" : "COEFFLUENCE3", + "Azimut_15deg" : "COEFFLUENCE4", + "Azimut_20deg" : "COEFFLUENCE5", + "Azimut_25deg" : "COEFFLUENCE6", + "Azimut_30deg" : "COEFFLUENCE7", + "Azimut_35deg" : "COEFFLUENCE8", + "Azimut_40deg" : "COEFFLUENCE9", + "Azimut_45deg" : "COEFFLUENCE10", + "TypeIrradiation" : "TYPEIRR", + "RTNDT" : "RTNDT", + "ModeleIrradiation" : "MODELIRR", + "TeneurCuivre" : "CU", + "TeneurCuivre_mess" : "CU_MESSAGE", + "TeneurNickel" : "NI", + "TeneurNickel_mess" : "NI_MESSAGE", + "TeneurPhosphore" : "P", + "TeneurPhosphore_mess" : "P_MESSAGE", + "MoyenneRTndt" : "RTimoy", + "MoyenneRTndt_mess" : "RTimoy_MESSAGE", + "CoefVariationRTndt" : "RTicov", + "CoefVariationRTndt_mess" : "RTicov_MESSAGE", + "EcartTypeRTndt" : "USectDRT", + "EcartTypeRTndt_mess" : "USectDRT_MESSAGE", + "NombreEcartTypeRTndt" : "nbectDRTNDT", + "NombreEcartTypeRTndt_mess" : "nbectDRTNDT_MESSAGE", + "ModeleTenacite" : "MODELKIC", + "NombreCaracteristique" : "NBCARAC", + "NbEcartType_MoyKIc" : "nbectKIc", + "NbEcartType_MoyKIc_mess" : "nbectKIc_MESSAGE", + "PalierDuctile_KIc" : "KICPAL", + "CoefficientVariation_KIc" : "KICCDV", + "Fractile_KIc" : "fractKIc", + "Fractile_KIc_mess" : "fractKIc_MESSAGE", + "Temperature_KIc100" : "T0WALLIN", + "A1" : "A1", + "A2" : "A2", + "A3" : "A3", + "B1" : "B1", + "B2" : "B2", + "B3" : "B3", + "C1" : "C1", + "C2" : "C2", + "C3" : "C3", + "ChoixCorrectionLongueur" : "CHOIXCL", + "AttnCorrBeta" : "ATTNCORRBETA", + "CorrIrwin" : "CORRIRWIN", + "ArretDeFissure" : "ARRETFISSURE", + "IncrementTailleFissure" : "INCRDEF", + "IncrementTailleFissure_mess" : "INCRDEF_MESSAGE", + "NbEcartType_MoyKIa" : "nbectKIa", + "PalierDuctile_KIa" : "KIAPAL", + "CoefficientVariation_KIa" : "KIACDV", + "ChoixCoefficientChargement" : "CHOIXSIGM", + "CoefficientDuctile" : "COEFSIGM1", + "CoefficientFragile" : "COEFSIGM2", + "InstantInitialisation" : "INSTINIT", + "ConditionLimiteThermiqueREV" : "KTHREV", + "TemperatureDeformationNulleREV" : "TREFREV", + "TemperaturePourCoefDilatThermREV" : "TDETREV", + "CoefficientPoissonREV" : "NUREV", + "ConditionLimiteThermiqueMDB" : "KTHMDB", + "TemperatureDeformationNulleMDB" : "TREFMDB", + "TemperaturePourCoefDilatThermMDB" : "TDETMDB", + "CoefficientPoissonMDB" : "NUMDB", + "TypeConditionLimiteThermique" : "TYPCLTH", + "Instant_1" : "INSTANT1", + "Instant_2" : "INSTANT2", + "Instant_3" : "INSTANT3", + "DebitAccumule" : "QACCU", + "DebitInjectionSecurite" : "QIS", + "TempInjectionSecurite" : "TIS", + "TempInjectionSecurite_mess" : "TIS_MESSAGE", + "DiametreHydraulique" : "DH", + "DiametreHydraulique_mess" : "DH_MESSAGE", + "SectionEspaceAnnulaire" : "SECTION", + "SectionEspaceAnnulaire_mess" : "SECTION_MESSAGE", + "HauteurCaracConvectionNaturelle" : "DELTA", + "HauteurCaracConvectionNaturelle_mess" : "DELTA_MESSAGE", + "CritereConvergenceRelative" : "EPS", + "CoefficientsVestale" : "COEFVESTALE", + "VolumeMelange_CREARE" : "VMTAB", + "TemperatureInitiale_CREARE" : "T0", + "TemperatureInitiale_CREARE_mess" : "T0_MESSAGE", + "SurfaceEchange_FluideStructure" : "SE", + "SurfaceEchange_FluideStructure_mess" : "SE_MESSAGE", + "InstantPerteCirculationNaturelle" : "INST_PCN", + } + + # Ce dictionnaire liste le nom des valeurs proposées utilisees dans le script + self.valeurproposee = { + "Aucune impression" : "0", + "Temps total" : "1", + "Temps intermediaires" : "2", + "Facteur de marge KIc/KCP" : "FM_KICSURKCP", + "Marge KIc-KI" : "MARGE_KI", + "Marge KIc-KCP" : "MARGE_KCP", + "Topologie" : "GEOMETRIE", + "Maillage" : "MAILLAGE", + "Defaut Sous Revetement" : "DSR", + "Defaut Decale" : "DECALE", + "Defaut Debouchant" : "DEBOUCHANT", + "Longitudinale" : "LONGITUD", + "Circonferentielle" : "CIRCONF", + "Virole" : "VIROLE", + "Joint soude" : "JSOUDE", + "Valeur" : "VALEUR", + "Fonction affine de la profondeur" : "FCTAFFINE", + "Valeur normalisee" : "NORMALISE", + "A" : "A", + "B" : "B", + "A et B" : "BOTH", + "Exponentiel sans revetement k=9.7 (Reglementaire)" : "Reglementaire", + "Exponentiel sans revetement k=12.7 (France)" : "France", + "Exponentiel sans revetement k=0. (ValeurImposee)" : "ValeurImposee", + "Donnees francaises du palier CPY (SDM)" : "SDM", + "Regulatory Guide 1.99 rev 2 (USNRC)" : "USNRC", + "Dossier 900 MWe AP9701 rev 2 (REV_2)" : "REV_2", + "Lissage du modele ajuste (SDM_Lissage)" : "SDM_Lissage", + "Donnees francaises du palier CPY ajustees par secteur angulaire (GrandeDev)" : "GrandeDev", + "Grand developpement (GD_Cuve)" : "GD_Cuve", + "Exponentiel sans revetement k=9.7 (Reglementaire CUVE1D)" : "Cuve1D", + "RTndt de la cuve a l instant de l analyse" : "RTNDT", + "Modele d irradiation" : "FLUENCE", + "Formule de FIM/FIS Lefebvre modifiee" : "LEFEBnew", + "Metal de Base : formule de FIM/FIS Houssin" : "HOUSSIN", + "Metal de Base : formule de FIM/FIS Persoz" : "PERSOZ", + "Metal de Base : formule de FIM/FIS Lefebvre" : "LEFEBVRE", + "Metal de Base : Regulatory Guide 1.00 rev 2" : "USNRCmdb", + "Joint Soude : formulation de FIM/FIS Brillaud" : "BRILLAUD", + "Joint Soude : Regulatory Guide 1.00 rev 2" : "USNRCsoud", + "RCC-M/ASME coefficient=2" : "RCC-M", + "RCC-M/ASME coefficient=2 CUVE1D" : "RCC-M_simpl", + "RCC-M/ASME coefficient=2.33 (Houssin)" : "Houssin_RC", + "RCC-M/ASME avec KI=KIpalier" : "RCC-M_pal", + "RCC-M/ASME avec KI~exponentiel" : "RCC-M_exp", + "Weibull basee sur la master cuve" : "Wallin", + "Weibull basee sur la master cuve (REME)" : "REME", + "Weibull n\xb01 (etude ORNL)" : "ORNL", + "Weibull n\xb02" : "WEIB2", + "Weibull n\xb03" : "WEIB3", + "Weibull generalisee" : "WEIB-GEN", + "Exponentielle n\xb01 (Frama)" : "Frama", + "Exponentielle n\xb02 (LOGWOLF)" : "LOGWOLF", + "Quantile" : "QUANTILE", + "Ordre" : "ORDRE", + "Enthalpie" : "ENTHALPIE", + "Chaleur" : "CHALEUR", + "Temperature imposee en paroi" : "TEMP_IMPO", + "Flux de chaleur impose en paroi" : "FLUX_REP", + "Temperature imposee du fluide et coefficient echange" : "ECHANGE", + "Debit massique et temperature d injection de securite" : "DEBIT", + "Temperature imposee du fluide et debit d injection de securite" : "TEMP_FLU", + "Courbe APRP" : "APRP", + "Calcul TEMPFLU puis DEBIT" : "TFDEBIT", + } + + # Ce dictionnaire liste le commentaire des variables utilisees dans le script + self.comment = { + "NiveauImpression" : "Niveau d impression des messages a l ecran (=0 : rien, =1 : temps calcul total, =2 : temps intermediaires)", + "FichierDataIn" : "sortie du fichier recapitulatif des donnees d entree {OUI ; NON}", + "FichierTempSigma" : "sortie des fichiers temperature et contraintes {OUI ; NON}", + "FichierCSV" : "sortie du fichier resultat template_DEFAILLCUVE.CSV {OUI ; NON}", + "FichierRESTART" : "sortie du fichier de re-demarrage", + "FichierEXTR" : "sortie du fichier d extraction des transitoires", + "ChoixPlugin" : "choix d'un repertoire de plug-in", + "GrandeurEvaluee" : "choix de la grandeur sous critere evaluee {FM_KICSURKCP ; MARGE_KI ; MARGE_KCP}", + "IncrementTemporel" : "increment temporel pour l analyse PROBABILISTE (si DETERMINISTE, fixer a 1)", + "IncrementMaxTemperature" : "increment max de temp/noeud/instant (degC)", + "ChoixExtractionTransitoires" : "choix d'extraction de transitoires de temp et contraintes", + "IncrementMaxTempsAffichage" : "increment max de temps pour affichage (s)", + "TraitementGeometrie" : "traitement de la geometrie de la cuve : {GEOMETRIE, MAILLAGE}", + "RayonInterne" : "rayon interne (m)", + "RayonInterne_mess" : "affichage ecran du rayon interne (m)", + "RayonExterne" : "rayon externe (m)", + "RayonExterne_mess" : "affichage ecran du rayon externe (m)", + "EpaisseurRevetement" : "epaisseur revetement (m)", + "EpaisseurRevetement_mess" : "affichage ecran de l epaisseur revetement (m)", + "LigamentExterneMin" : "ligament externe minimal avant rupture (% de l'epaisseur de cuve)", + "LigamentExterneMin_mess" : "affichage ecran du ligament externe minimal avant rupture (% de l'epaisseur de cuve)", + "NombreNoeudsMaillage" : "nbre de noeuds dans l'epaisseur de la cuve", + "TypeInitial" : "type initial du defaut : DEBOUCHANT=Defaut Debouchant, DSR=Defaut Sous Revetement, DECALE=Defaut Decale", + "Orientation" : "orientation (LONGITUD / CIRCONF)", + "Position" : "Position du defaut (VIROLE / JSOUDE)", + "ProfondeurRadiale" : "profondeur radiale ou encore hauteur (m)", + "ProfondeurRadiale_mess" : "affichage ecran de la profondeur radiale ou encore hauteur (m)", + "ModeCalculLongueur" : "option pour definir la longueur du defaut (VALEUR pour une valeur fixe, FCTAFFINE pour une fct affine de la profondeur)", + "Longueur" : "longueur (m) pour defaut Sous Revetement", + "Longueur_mess" : "affichage ecran de la longueur (m) pour defaut Sous Revetement", + "CoefDirecteur" : "pente de la fonction affine l = h/profsurlong + a0", + "CoefDirecteur_mess" : "affichage ecran de la pente de la fonction affine l = h/profsurlong + a0", + "Constante" : "constante de la fonction affine a0", + "ModeCalculDecalage" : "type de decalage : normalise (NORMALISE) ou reel (VALEUR)", + "DecalageNormalise" : "decalage radial normalise (valeur comprise entre 0. et 1.) pour defaut Sous Revetement", + "DecalageNormalise_mess" : "affichage ecran du decalage radial normalise (valeur comprise entre 0. et 1.) pour defaut Sous Revetement", + "DecalageRadial" : "decalage radial reel (m) pour defaut decale", + "DecalageRadial_mess" : "affichage ecran du decalage radial reel (m) pour defaut decale", + "Azimut" : "coordonnee angulaire (degre)", + "Azimut_mess" : "affichage ecran de la coordonnee angulaire (degre)", + "Altitude" : "altitude (m) : valeur negative", + "Altitude_mess" : "affichage ecran de l altitude (m) : valeur negative", + "Pointe" : "choix du(des) point(s) du defaut considere {'A','B','BOTH'} pour DSR et DECALE (pour DEBOUCHANT : automatiquement 'B')", + "ModeleFluence" : "modele de fluence : {Reglementaire, France, ValeurImposee, SDM, USNRC, REV_2, SDM_Lissage, GrandeDev, GD_Cuve, Cuve1D}", + "ZoneActiveCoeur_AltitudeSup" : "cote superieure de la zone active de coeur (ici pour cuve palier 900Mw)", + "ZoneActiveCoeur_AltitudeInf" : "cote inferieure de la zone active de coeur (ici pour cuve palier 900Mw)", + "FluenceMax" : "fluence maximale assimilee par la cuve (n/cm2)", + "KPFrance" : "parametre exponentiel du modele France", + "KPUS" : "parametre exponentiel du modele US", + "Azimut_0deg" : "fluence a l'azimut 0 (10^19 n/cm)", + "Azimut_5deg" : "fluence a l'azimut 5 (10^19 n/cm)", + "Azimut_10deg" : "fluence a l'azimut 10 (10^19 n/cm)", + "Azimut_15deg" : "fluence a l'azimut 15 (10^19 n/cm)", + "Azimut_20deg" : "fluence a l'azimut 20 (10^19 n/cm)", + "Azimut_25deg" : "fluence a l'azimut 25 (10^19 n/cm)", + "Azimut_30deg" : "fluence a l'azimut 30 (10^19 n/cm)", + "Azimut_35deg" : "fluence a l'azimut 35 (10^19 n/cm)", + "Azimut_40deg" : "fluence a l'azimut 40 (10^19 n/cm)", + "Azimut_45deg" : "fluence a l'azimut 45 (10^19 n/cm)", + "TypeIrradiation" : "type irradiation : {RTNDT, FLUENCE}", + "RTNDT" : "RTNDT finale (degC)", + "ModeleIrradiation" : "modele d irradiation : LEFEBnew, ou {HOUSSIN, PERSOZ, LEFEBVRE, USNRCmdb} pour virole et {BRILLAUD,USNRCsoud} pour jointsoude", + "TeneurCuivre" : "teneur en cuivre (%)", + "TeneurCuivre_mess" : "affichage ecran de la teneur en cuivre (%)", + "TeneurNickel" : "teneur en nickel (%)", + "TeneurNickel_mess" : "affichage ecran de la teneur en nickel (%)", + "TeneurPhosphore" : "teneur en phosphore (%)", + "TeneurPhosphore_mess" : "affichage ecran de la teneur en phosphore (%)", + "MoyenneRTndt" : "moyenne de la RTNDT initiale : virole C1 de cuve Chinon : mdb=>-17.degC et js=>42.degC (HT-56/05/038 : p.52)", + "MoyenneRTndt_mess" : "affichage ecran de la moyenne de la RTNDT initiale", + "CoefVariationRTndt" : "coef de variation de la RTNDT initiale", + "CoefVariationRTndt_mess" : "affichage ecran du coef de variation de la RTNDT initiale", + "EcartTypeRTndt" : "pour modeles USNRCsoud ou USNRCmdb, ecart-type du decalage de RTNDT (°F) (28. pour js et 17. pour mdb)", + "EcartTypeRTndt_mess" : "affichage ecran, pour modeles USNRCsoud ou USNRCmdb, ecart-type du decalage de RTNDT (°F) (28. pour js et 17. pour mdb)", + "NombreEcartTypeRTndt" : "Nbre d ecart-type par rapport a la moyenne de DRTNDT si analyse PROBABILISTE (en DETERMINISTE, fixer a 2.)", + "NombreEcartTypeRTndt_mess" : "affichage ecran du nbre d ecart-type par rapport a la moyenne de DRTNDT si analyse PROBABILISTE", + "ModeleTenacite" : "modele de tenacite : {RCC-M, RCC-M_pal, RCC-M_exp, RCC-M_simpl, Houssin_RC, Wallin, REME, ORNL, Frama, WEIB3, WEIB2, LOGWOLF, WEIB-GEN}", + "NombreCaracteristique" : "Nb caracteristique : ORDRE ou QUANTILE", + "NbEcartType_MoyKIc" : "Nbre d ecart-type par rapport a la moyenne de KIc si analyse PROBABILISTE (en DETERMINISTE, fixer a -2.)", + "NbEcartType_MoyKIc_mess" : "affichage ecran du nbre d ecart-type par rapport a la moyenne de KIc si analyse PROBABILISTE", + "PalierDuctile_KIc" : "palier deterministe de K1c (MPa(m^0.5))", + "CoefficientVariation_KIc" : "coef de variation de la loi normale de K1c", + "Fractile_KIc" : "valeur caracteristique de KIc exprimee en ordre de fractile (%)", + "Fractile_KIc_mess" : "affichage ecran de la valeur caracteristique de KIc exprimee en ordre de fractile (%)", + "Temperature_KIc100" : "parametre T0 du modele Wallin (degC)", + "A1" : "coef des coefs d une WEIBULL generale", + "A2" : "", + "A3" : "", + "B1" : "", + "B2" : "", + "B3" : "", + "C1" : "", + "C2" : "", + "C3" : "", + "ChoixCorrectionLongueur" : "Activation ou non de la correction de longueur {OUI ; NON}", + "AttnCorrBeta" : "Attenuation de la correction plastique : {OUI, NON} ==> uniquement pour DSR ou DECALE", + "CorrIrwin" : "Correction plastique IRWIN : {OUI, NON} ==> uniquement pour DEBOUCHANT", + "ArretDeFissure" : "prise en compte de l arret de fissure {OUI, NON} (en PROBABILISTE, fixer a NON)", + "IncrementTailleFissure" : "increment de la taille de fissure (m)", + "IncrementTailleFissure_mess" : "affichage ecran de l increment de la taille de fissure (m)", + "NbEcartType_MoyKIa" : "Nbre d ecart-type par rapport a la moyenne de KIa (nb sigma)", + "PalierDuctile_KIa" : "palier deterministe de K1a quand modele RCC-M (MPa(m^0.5))", + "CoefficientVariation_KIa" : "coef de variation de la loi normale de K1a", + "ChoixCoefficientChargement" : "prise en compte de coefficients sur le chargement (OUI/NON)", + "CoefficientDuctile" : "coefficient multiplicateur pour rupture ductile", + "CoefficientFragile" : "coefficient multiplicateur pour rupture fragile", + "InstantInitialisation" : "instant initial (s)", + "ConditionLimiteThermiqueREV" : "Option 'ENTHALPIE' ou 'CHALEUR'", + "TemperatureDeformationNulleREV" : "temperature de deformation nulle (degC)", + "TemperaturePourCoefDilatThermREV" : "temperature de definition du coefficient de dilatation thermique (degC)", + "CoefficientPoissonREV" : "coefficient de Poisson", + "ConditionLimiteThermiqueMDB" : "Option 'ENTHALPIE' ou 'CHALEUR'", + "TemperatureDeformationNulleMDB" : "temperature de deformation nulle (degC)", + "TemperaturePourCoefDilatThermMDB" : "temperature de definition du coefficient de dilatation thermique (degC)", + "CoefficientPoissonMDB" : "coefficient de Poisson", + "TypeConditionLimiteThermique" : "Type de condition thermique en paroi interne {TEMP_IMPO,FLUX_REP,ECHANGE,DEBIT,TEMP_FLU,APRP}", + "Instant_1" : "Borne superieure de l intervalle de temps du 1er palier TACCU", + "Instant_2" : "Borne superieure de l intervalle de temps du 2nd palier T1", + "Instant_3" : "Borne superieure de l intervalle de temps du 3eme palier TIS", + "DebitAccumule" : "Debit accumule (en m3/h)", + "DebitInjectionSecurite" : "Debit injection de securite (en m3/h)", + "TempInjectionSecurite" : "Temperature injection de securite (en degC)", + "TempInjectionSecurite_mess" : "affichage ecran de la temperature injection de securite", + "DiametreHydraulique" : "Diametre hydraulique (m)", + "DiametreHydraulique_mess" : "affichage ecran du diametre hydraulique (m)", + "SectionEspaceAnnulaire" : "Section espace annulaire (m2)", + "SectionEspaceAnnulaire_mess" : "affichage ecran de la section espace annulaire (m2)", + "HauteurCaracConvectionNaturelle" : "Hauteur caracteristique convection naturelle (m)", + "HauteurCaracConvectionNaturelle_mess" : "affichage ecran de la hauteur caracteristique convection naturelle (m)", + "CritereConvergenceRelative" : "Critere convergence relative (-)", + "CoefficientsVestale" : "Application des coefs de Vestale {OUI;NON}", + "VolumeMelange_CREARE" : "Transitoire de volume de melange CREARE (m3)", + "TemperatureInitiale_CREARE" : "Temperature initiale CREARE (degC)", + "TemperatureInitiale_CREARE_mess" : "affichage ecran de la temperature initiale CREARE (degC)", + "SurfaceEchange_FluideStructure" : "Surface d'echange fluide/structure (m2)", + "SurfaceEchange_FluideStructure_mess" : "affichage ecran de la surface d'echange fluide/structure (m2)", + "InstantPerteCirculationNaturelle" : "Instant de perte de circulation naturelle", + } + + # Ce dictionnaire liste la valeur par defaut des variables utilisees dans le script + self.default = { + "NiveauImpression" : "1", + "FichierDataIn" : "NON", + "FichierTempSigma" : "NON", + "FichierCSV" : "NON", + "FichierRESTART" : "NON", + "FichierEXTR" : "NON", + "ChoixPlugin" : "NON", + "GrandeurEvaluee" : "FM_KICSURKCP", + "IncrementTemporel" : "1", + "IncrementMaxTemperature" : "0.1", + "ChoixExtractionTransitoires" : "NON", + "IncrementMaxTempsAffichage" : "1000.", + "TraitementGeometrie" : "GEOMETRIE", + "RayonInterne" : "1.994", + "RayonInterne_mess" : "NON", + "RayonExterne" : "2.2015", + "RayonExterne_mess" : "NON", + "EpaisseurRevetement" : "0.0075", + "EpaisseurRevetement_mess" : "NON", + "LigamentExterneMin" : "0.75", + "LigamentExterneMin_mess" : "NON", + "NombreNoeudsMaillage" : "300", + "TypeInitial" : "DSR", + "Position" : "VIROLE", + "ProfondeurRadiale" : "0.006", + "ProfondeurRadiale_mess" : "NON", + "ModeCalculLongueur" : "VALEUR", + "Longueur" : "0.060", + "Longueur_mess" : "NON", + "CoefDirecteur" : "10.", + "CoefDirecteur_mess" : "NON", + "Constante" : "0.", + "ModeCalculDecalage" : "VALEUR", + "DecalageNormalise" : "0.1", + "DecalageNormalise_mess" : "NON", + "DecalageRadial" : "0.", + "DecalageRadial_mess" : "NON", + "Azimut" : "0.", + "Azimut_mess" : "NON", + "Altitude" : "-4.", + "Altitude_mess" : "NON", + "Pointe" : "B", + "ModeleFluence" : "Reglementaire", + "ZoneActiveCoeur_AltitudeSup" : "-3.536", + "ZoneActiveCoeur_AltitudeInf" : "-7.194", + "FluenceMax" : "6.5", + "KPFrance" : "12.7", + "KPUS" : "9.4488", + "Azimut_0deg" : "5.8", + "Azimut_5deg" : "5.48", + "Azimut_10deg" : "4.46", + "Azimut_15deg" : "3.41", + "Azimut_20deg" : "3.37", + "Azimut_25deg" : "3.16", + "Azimut_30deg" : "2.74", + "Azimut_35deg" : "2.25", + "Azimut_40deg" : "1.89", + "Azimut_45deg" : "1.78", + "TypeIrradiation" : "RTNDT", + "RTNDT" : "64.", + "ModeleIrradiation" : "HOUSSIN", + "TeneurCuivre" : "0.0972", + "TeneurCuivre_mess" : "NON", + "TeneurNickel" : "0.72", + "TeneurNickel_mess" : "NON", + "TeneurPhosphore" : "0.00912", + "TeneurPhosphore_mess" : "NON", + "MoyenneRTndt" : "-12.0", + "MoyenneRTndt_mess" : "NON", + "CoefVariationRTndt" : "0.1", + "CoefVariationRTndt_mess" : "NON", + "EcartTypeRTndt" : "-2.", + "EcartTypeRTndt_mess" : "NON", + "NombreEcartTypeRTndt" : "2.", + "NombreEcartTypeRTndt_mess" : "NON", + "ModeleTenacite" : "RCC-M", + "NombreCaracteristique" : "Quantile", + "NbEcartType_MoyKIc" : "-2.", + "NbEcartType_MoyKIc_mess" : "NON", + "PalierDuctile_KIc" : "195.", + "CoefficientVariation_KIc" : "0.15", + "Fractile_KIc" : "5.", + "Fractile_KIc_mess" : "NON", + "Temperature_KIc100" : "-27.", + "A1" : "21.263", + "A2" : "9.159", + "A3" : "0.04057", + "B1" : "17.153", + "B2" : "55.089", + "B3" : "0.0144", + "C1" : "4.", + "C2" : "0.", + "C3" : "0.", + "ChoixCorrectionLongueur" : "OUI", + "AttnCorrBeta" : "NON", + "CorrIrwin" : "NON", + "ArretDeFissure" : "NON", + "IncrementTailleFissure" : "0.", + "IncrementTailleFissure_mess" : "NON", + "NbEcartType_MoyKIa" : "0.", + "PalierDuctile_KIa" : "0.", + "CoefficientVariation_KIa" : "0.", + "ChoixCoefficientChargement" : "NON", + "CoefficientDuctile" : "1.0", + "CoefficientFragile" : "1.0", + "InstantInitialisation" : "-1.", + "ConditionLimiteThermiqueREV" : "CHALEUR", + "TemperatureDeformationNulleREV" : "20.", + "TemperaturePourCoefDilatThermREV" : "287.", + "CoefficientPoissonREV" : "0.3", + "ConditionLimiteThermiqueMDB" : "CHALEUR", + "TemperatureDeformationNulleMDB" : "20.", + "TemperaturePourCoefDilatThermMDB" : "287.", + "CoefficientPoissonMDB" : "0.3", + "TypeConditionLimiteThermique" : "TEMP_IMPO", + "Instant_1" : "21.", + "Instant_2" : "45.", + "Instant_3" : "5870.", + "DebitAccumule" : "2.3", + "DebitInjectionSecurite" : "0.375", + "TempInjectionSecurite" : "9.", + "TempInjectionSecurite_mess" : "NON", + "DiametreHydraulique" : "0.3816", + "DiametreHydraulique_mess" : "NON", + "SectionEspaceAnnulaire" : "0.21712", + "SectionEspaceAnnulaire_mess" : "NON", + "HauteurCaracConvectionNaturelle" : "6.", + "HauteurCaracConvectionNaturelle_mess" : "NON", + "CritereConvergenceRelative" : "0.00001", + "CoefficientsVestale" : "NON", +# "VolumeMelange_CREARE" : "14.9", + "TemperatureInitiale_CREARE" : "250.", + "TemperatureInitiale_CREARE_mess" : "NON", + "SurfaceEchange_FluideStructure" : "0.", + "SurfaceEchange_FluideStructure_mess" : "NON", + "InstantPerteCirculationNaturelle" : "400.", + } + + # Ce dictionnaire liste la rubrique d'appartenance des variables utilisees dans le script + self.bloc = { + "NiveauImpression" : "OPTIONS", + "FichierDataIn" : "OPTIONS", + "FichierTempSigma" : "OPTIONS", + "FichierCSV" : "OPTIONS", + "FichierRESTART" : "OPTIONS", + "FichierEXTR" : "OPTIONS", + "ChoixPlugin" : "OPTIONS", + "GrandeurEvaluee" : "OPTIONS", + "IncrementTemporel" : "OPTIONS", + "IncrementMaxTemperature" : "OPTIONS", + "ChoixExtractionTransitoires" : "OPTIONS", + "IncrementMaxTempsAffichage" : "OPTIONS", + "TraitementGeometrie" : "DONNEES DE LA CUVE", + "RayonInterne" : "DONNEES DE LA CUVE", + "RayonInterne_mess" : "DONNEES DE LA CUVE", + "RayonExterne" : "DONNEES DE LA CUVE", + "RayonExterne_mess" : "DONNEES DE LA CUVE", + "EpaisseurRevetement" : "DONNEES DE LA CUVE", + "EpaisseurRevetement_mess" : "DONNEES DE LA CUVE", + "LigamentExterneMin" : "DONNEES DE LA CUVE", + "LigamentExterneMin_mess" : "DONNEES DE LA CUVE", + "NombreNoeudsMaillage" : "DONNEES DE LA CUVE", + "TypeInitial" : "CARACTERISTIQUES DU DEFAUT", + "Orientation" : "CARACTERISTIQUES DU DEFAUT", + "Position" : "CARACTERISTIQUES DU DEFAUT", + "ProfondeurRadiale" : "CARACTERISTIQUES DU DEFAUT", + "ProfondeurRadiale_mess" : "CARACTERISTIQUES DU DEFAUT", + "ModeCalculLongueur" : "CARACTERISTIQUES DU DEFAUT", + "Longueur" : "CARACTERISTIQUES DU DEFAUT", + "Longueur_mess" : "CARACTERISTIQUES DU DEFAUT", + "CoefDirecteur" : "CARACTERISTIQUES DU DEFAUT", + "CoefDirecteur_mess" : "CARACTERISTIQUES DU DEFAUT", + "Constante" : "CARACTERISTIQUES DU DEFAUT", + "ModeCalculDecalage" : "CARACTERISTIQUES DU DEFAUT", + "DecalageNormalise" : "CARACTERISTIQUES DU DEFAUT", + "DecalageNormalise_mess" : "CARACTERISTIQUES DU DEFAUT", + "DecalageRadial" : "CARACTERISTIQUES DU DEFAUT", + "DecalageRadial_mess" : "CARACTERISTIQUES DU DEFAUT", + "Azimut" : "CARACTERISTIQUES DU DEFAUT", + "Azimut_mess" : "CARACTERISTIQUES DU DEFAUT", + "Altitude" : "CARACTERISTIQUES DU DEFAUT", + "Altitude_mess" : "CARACTERISTIQUES DU DEFAUT", + "Pointe" : "CARACTERISTIQUES DU DEFAUT", + "ModeleFluence" : "MODELES", + "ZoneActiveCoeur_AltitudeSup" : "MODELES", + "ZoneActiveCoeur_AltitudeInf" : "MODELES", + "FluenceMax" : "MODELES", + "KPFrance" : "MODELES", + "KPUS" : "MODELES", + "Azimut_0deg" : "MODELES", + "Azimut_5deg" : "MODELES", + "Azimut_10deg" : "MODELES", + "Azimut_15deg" : "MODELES", + "Azimut_20deg" : "MODELES", + "Azimut_25deg" : "MODELES", + "Azimut_30deg" : "MODELES", + "Azimut_35deg" : "MODELES", + "Azimut_40deg" : "MODELES", + "Azimut_45deg" : "MODELES", + "TypeIrradiation" : "MODELES", + "RTNDT" : "MODELES", + "ModeleIrradiation" : "MODELES", + "TeneurCuivre" : "MODELES", + "TeneurCuivre_mess" : "MODELES", + "TeneurNickel" : "MODELES", + "TeneurNickel_mess" : "MODELES", + "TeneurPhosphore" : "MODELES", + "TeneurPhosphore_mess" : "MODELES", + "MoyenneRTndt" : "MODELES", + "MoyenneRTndt_mess" : "MODELES", + "CoefVariationRTndt" : "MODELES", + "CoefVariationRTndt_mess" : "MODELES", + "EcartTypeRTndt" : "MODELES", + "EcartTypeRTndt_mess" : "MODELES", + "NombreEcartTypeRTndt" : "MODELES", + "NombreEcartTypeRTndt_mess" : "MODELES", + "ModeleTenacite" : "MODELES", + "NombreCaracteristique" : "MODELES", + "NbEcartType_MoyKIc" : "MODELES", + "NbEcartType_MoyKIc_mess" : "MODELES", + "PalierDuctile_KIc" : "MODELES", + "CoefficientVariation_KIc" : "MODELES", + "Fractile_KIc" : "MODELES", + "Fractile_KIc_mess" : "MODELES", + "Temperature_KIc100" : "MODELES", + "A1" : "MODELES", + "A2" : "MODELES", + "A3" : "MODELES", + "B1" : "MODELES", + "B2" : "MODELES", + "B3" : "MODELES", + "C1" : "MODELES", + "C2" : "MODELES", + "C3" : "MODELES", + "ChoixCorrectionLongueur" : "MODELES", + "AttnCorrBeta" : "MODELES", + "CorrIrwin" : "MODELES", + "ArretDeFissure" : "MODELES", + "IncrementTailleFissure" : "MODELES", + "IncrementTailleFissure_mess" : "MODELES", + "NbEcartType_MoyKIa" : "MODELES", + "PalierDuctile_KIa" : "MODELES", + "CoefficientVariation_KIa" : "MODELES", + "ChoixCoefficientChargement" : "ETAT INITIAL", + "CoefficientDuctile" : "ETAT INITIAL", + "CoefficientFragile" : "ETAT INITIAL", + "InstantInitialisation" : "ETAT INITIAL", + "ConditionLimiteThermiqueREV" : "CARACTERISTIQUES DU REVETEMENT", + "TemperatureDeformationNulleREV" : "CARACTERISTIQUES DU REVETEMENT", + "TemperaturePourCoefDilatThermREV" : "CARACTERISTIQUES DU REVETEMENT", + "CoefficientPoissonREV" : "CARACTERISTIQUES DU REVETEMENT", + "ConditionLimiteThermiqueMDB" : "CARACTERISTIQUES DU MDB", + "TemperatureDeformationNulleMDB" : "CARACTERISTIQUES DU MDB", + "TemperaturePourCoefDilatThermMDB" : "CARACTERISTIQUES DU MDB", + "CoefficientPoissonMDB" : "CARACTERISTIQUES DU MDB", + "TypeConditionLimiteThermique" : "TRANSITOIRE", + "Instant_1" : "TRANSITOIRE", + "Instant_2" : "TRANSITOIRE", + "Instant_3" : "TRANSITOIRE", + "DebitAccumule" : "TRANSITOIRE", + "DebitInjectionSecurite" : "TRANSITOIRE", + "TempInjectionSecurite" : "TRANSITOIRE", + "TempInjectionSecurite_mess" : "TRANSITOIRE", + "DiametreHydraulique" : "TRANSITOIRE", + "DiametreHydraulique_mess" : "TRANSITOIRE", + "SectionEspaceAnnulaire" : "TRANSITOIRE", + "SectionEspaceAnnulaire_mess" : "TRANSITOIRE", + "HauteurCaracConvectionNaturelle" : "TRANSITOIRE", + "HauteurCaracConvectionNaturelle_mess" : "TRANSITOIRE", + "CritereConvergenceRelative" : "TRANSITOIRE", + "CoefficientsVestale" : "TRANSITOIRE", + "VolumeMelange_CREARE" : "TRANSITOIRE", + "TemperatureInitiale_CREARE" : "TRANSITOIRE", + "TemperatureInitiale_CREARE_mess" : "TRANSITOIRE", + "SurfaceEchange_FluideStructure" : "TRANSITOIRE", + "SurfaceEchange_FluideStructure_mess" : "TRANSITOIRE", + "InstantPerteCirculationNaturelle" : "TRANSITOIRE", + } + + def gener(self,obj,format='brut'): + self.text='' + self.textCuve='' + self.texteTFDEBIT='' + self.dico_mot={} + self.dico_genea={} + self.text=PythonGenerator.gener(self,obj,format) + return self.text + + def generMCSIMP(self,obj) : + self.dico_mot[obj.nom]=obj.valeur + clef="" + for i in obj.get_genealogie() : + clef=clef+"_"+i + self.dico_genea[clef]=obj.valeur + s=PythonGenerator.generMCSIMP(self,obj) + return s + + def writeCuve2DG(self, filename, file2): + print "je passe dans writeCuve2DG" + self.genereTexteCuve() + f = open( filename, 'wb') + print self.texteCuve + f.write( self.texteCuve ) + f.close() + ftmp = open( "/tmp/data_template", 'wb') + ftmp.write( self.texteCuve ) + ftmp.close() + + self.genereTexteTFDEBIT() + f2 = open( file2, 'wb') + print self.texteTFDEBIT + f2.write( self.texteTFDEBIT ) + f2.close() + + + def entete(self): + ''' + Ecrit l'entete du fichier data_template + ''' + texte = "############################################################################################"+"\n" + texte += "#"+"\n" + texte += "# OUTIL D'ANALYSE PROBABILISTE DE LA DUREE DE VIE DES CUVES REP"+"\n" + texte += "# ---------------"+"\n" + texte += "# FICHIER DE MISE EN DONNEES"+"\n" + texte += "#"+"\n" + texte += "# SI CALCUL DETERMINISTE :"+"\n" + texte += "# - fixer INCRTPS=1, nbectDRTNDT=2., nbectKIc=-2."+"\n" + texte += "# - les calculs ne sont possibles qu'en une seule pointe du defaut (POINDEF<>BOTH)"+"\n" + texte += "# SI CALCUL PROBABILISTE :"+"\n" + texte += "# - fixer ARRETFISSURE=NON"+"\n" + texte += "#"+"\n" + texte += "############################################################################################"+"\n" + texte += "#"+"\n" + return texte + + def rubrique(self, titre): + ''' + Rubrique + ''' + texte = "#"+"\n" + texte += "############################################################################################"+"\n" + texte += "# " + titre + "\n" + texte += "############################################################################################"+"\n" + texte += "#"+"\n" + return texte + + def sousRubrique(self, soustitre, numtitre): + ''' + Sous-rubrique + ''' + texte = "#"+"\n" + texte += "# " + numtitre + soustitre + "\n" + texte += "#==========================================================================================="+"\n" + texte += "#"+"\n" + return texte + + def ecritLigne(self, variablelue): + ''' + Ecrit l'affectation d'une valeur a sa variable, suivie d'un commentaire + ''' + texte = "%s = %s # %s\n" % (self.variable[variablelue], str(self.dico_mot[variablelue]), self.comment[variablelue]) + return texte + + def affecteValeurDefaut(self, variablelue): + ''' + Affecte une valeur par defaut a une variable, suivie d'un commentaire + ''' + print "Warning ==> Dans la rubrique",self.bloc[variablelue],", valeur par defaut pour ",variablelue," = ",self.default[variablelue] + texte = "%s = %s # %s\n" % (self.variable[variablelue], self.default[variablelue], self.comment[variablelue]) + return texte + + def affecteValeur(self, variablelue, valeuraffectee): + ''' + Affecte une valeur a une variable, suivie d'un commentaire + ''' + texte = "%s = %s # %s\n" % (self.variable[variablelue], valeuraffectee, self.comment[variablelue]) + return texte + + def ecritVariable(self, variablelue): + if self.dico_mot.has_key(variablelue): + texte = self.ecritLigne(variablelue) + else : + texte = self.affecteValeurDefaut(variablelue) + return texte + + def amontAval(self, amont, aval): + if str(self.dico_mot[amont])=='Continu': + if str(self.dico_mot[aval])=='Continu': + texte = 'CC'+"\n" + if str(self.dico_mot[aval])=='Lineaire': + texte = 'CL'+"\n" + if str(self.dico_mot[aval])=='Exclu': + texte = 'CE'+"\n" + if str(self.dico_mot[amont])=='Lineaire': + if str(self.dico_mot[aval])=='Continu': + texte = 'LC'+"\n" + if str(self.dico_mot[aval])=='Lineaire': + texte = 'LL'+"\n" + if str(self.dico_mot[aval])=='Exclu': + texte = 'LE'+"\n" + if str(self.dico_mot[amont])=='Exclu': + if str(self.dico_mot[aval])=='Continu': + texte = 'EC'+"\n" + if str(self.dico_mot[aval])=='Lineaire': + texte = 'EL'+"\n" + if str(self.dico_mot[aval])=='Exclu': + texte = 'EE'+"\n" + return texte + + def genereTexteCuve(self): + self.texteCuve = "" + self.texteCuve += self.entete() + + # Rubrique OPTIONS + self.texteCuve += self.rubrique('OPTIONS') + + self.texteCuve += self.sousRubrique('Impression a l ecran', '') + if self.dico_mot.has_key('NiveauImpression'): + self.texteCuve += self.affecteValeur('NiveauImpression', self.valeurproposee[str(self.dico_mot["NiveauImpression"])]) + + self.texteCuve += self.sousRubrique('Generation de fichiers', '') + self.texteCuve += self.ecritVariable('FichierDataIn') + self.texteCuve += self.ecritVariable('FichierTempSigma') + self.texteCuve += self.ecritVariable('FichierCSV') + self.texteCuve += self.ecritVariable('FichierRESTART') + self.texteCuve += self.ecritVariable('FichierEXTR') + self.texteCuve += self.ecritVariable('ChoixPlugin') + + self.texteCuve += self.sousRubrique('Grandeur evaluee', '') + if self.dico_mot.has_key('GrandeurEvaluee'): + self.texteCuve += self.affecteValeur('GrandeurEvaluee', self.valeurproposee[str(self.dico_mot["GrandeurEvaluee"])]) + + self.texteCuve += self.sousRubrique('Divers', '') + self.texteCuve += self.ecritVariable('IncrementTemporel') + self.texteCuve += self.ecritVariable('IncrementMaxTemperature') + + #self.texteCuve += self.ecritVariable('ChoixExtractionTransitoires') + if self.dico_mot.has_key('ChoixExtractionTransitoires'): + self.texteCuve += self.ecritVariable('ChoixExtractionTransitoires') + if str(self.dico_mot["ChoixExtractionTransitoires"])=='OUI': + if self.dico_mot.has_key('ListeAbscisses'): + self.texteCuve += "# liste des abscisses pour ecriture des transitoires de T et SIG (5 ou moins)"+"\n" + self.imprime(1,(self.dico_mot["ListeAbscisses"])) + self.texteCuve+="#"+"\n" + else : + print "Warning ==> Dans la rubrique OPTIONS, fournir ListeAbscisses." + self.texteCuve += "# liste des abscisses pour ecriture des transitoires de T et SIG (5 ou moins)"+"\n" + self.texteCuve += " 1.994\n" + self.texteCuve += " 2.000\n" + self.texteCuve+="#"+"\n" + else : + self.texteCuve+="#"+"\n" + + self.texteCuve += self.ecritVariable('IncrementMaxTempsAffichage') + if self.dico_mot.has_key('ListeInstants'): + self.texteCuve += "# liste des instants pour ecriture des resultats (s)"+"\n" + if str(self.dico_mot["TypeConditionLimiteThermique"])=='Calcul TEMPFLU puis DEBIT': + self.texteCuve+="#BLOC_TFDEBIT"+"\n" + self.imprime(1,(self.dico_mot["ListeInstants"])) + if str(self.dico_mot["TypeConditionLimiteThermique"])=='Calcul TEMPFLU puis DEBIT': + self.texteCuve+="#BLOC_TFDEBIT"+"\n" + self.texteCuve+="#"+"\n" + else : + print "Warning ==> Dans la rubrique OPTIONS, fournir ListeInstants." + self.texteCuve += "# liste des instants pour ecriture des resultats (s)"+"\n" + self.texteCuve += " 0.\n" + self.texteCuve += " 1.\n" + self.texteCuve+="#"+"\n" + + + # Rubrique DONNEES DE LA CUVE + self.texteCuve += self.rubrique('DONNEES DE LA CUVE') + if self.dico_mot.has_key('TraitementGeometrie'): + self.texteCuve += self.affecteValeur('TraitementGeometrie', self.valeurproposee[str(self.dico_mot["TraitementGeometrie"])]) + if str(self.dico_mot["TraitementGeometrie"])=='Topologie': + self.texteCuve+="# - si MAILLAGE, fournir NBNO et liste des abscisses (m)"+"\n" + self.texteCuve+="# - si GEOMETRIE, fournir (RINT, RINT_MESSAGE),"+"\n" + self.texteCuve+="# (REXT, REXT_MESSAGE),"+"\n" + self.texteCuve+="# (LREV, LREV_MESSAGE),"+"\n" + self.texteCuve+="# (LIGMIN, LIGMIN_MESSAGE),"+"\n" + self.texteCuve+="# NBNO"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('RayonInterne') + self.texteCuve += self.ecritVariable('RayonInterne_mess') + self.texteCuve += self.ecritVariable('RayonExterne') + self.texteCuve += self.ecritVariable('RayonExterne_mess') + self.texteCuve += self.ecritVariable('EpaisseurRevetement') + self.texteCuve += self.ecritVariable('EpaisseurRevetement_mess') + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('LigamentExterneMin') + self.texteCuve += self.ecritVariable('LigamentExterneMin_mess') + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('NombreNoeudsMaillage') + if str(self.dico_mot["TraitementGeometrie"])=='Maillage': + self.texteCuve+="# - si MAILLAGE, fournir NBNO et liste des abscisses (m)"+"\n" + self.texteCuve+="# - si GEOMETRIE, fournir (RINT, RINT_MESSAGE),"+"\n" + self.texteCuve+="# (REXT, REXT_MESSAGE),"+"\n" + self.texteCuve+="# (LREV, LREV_MESSAGE),"+"\n" + self.texteCuve+="# (LIGMIN, LIGMIN_MESSAGE),"+"\n" + self.texteCuve+="# NBNO"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('NombreNoeudsMaillage') + self.imprime(1,(self.dico_mot["ListeAbscisses"])) + else : + self.texteCuve += self.affecteValeurDefaut('TraitementGeometrie') + self.texteCuve+="# - si MAILLAGE, fournir NBNO et liste des abscisses (m)"+"\n" + self.texteCuve+="# - si GEOMETRIE, fournir (RINT, RINT_MESSAGE),"+"\n" + self.texteCuve+="# (REXT, REXT_MESSAGE),"+"\n" + self.texteCuve+="# (LREV, LREV_MESSAGE),"+"\n" + self.texteCuve+="# (LIGMIN, LIGMIN_MESSAGE),"+"\n" + self.texteCuve+="# NBNO"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve += self.affecteValeurDefaut('RayonInterne') + self.texteCuve += self.affecteValeurDefaut('RayonInterne_mess') + self.texteCuve += self.affecteValeurDefaut('RayonExterne') + self.texteCuve += self.affecteValeurDefaut('RayonExterne_mess') + self.texteCuve += self.affecteValeurDefaut('EpaisseurRevetement') + self.texteCuve += self.affecteValeurDefaut('EpaisseurRevetement_mess') + self.texteCuve+="#"+"\n" + self.texteCuve += self.affecteValeurDefaut('LigamentExterneMin') + self.texteCuve += self.affecteValeurDefaut('LigamentExterneMin_mess') + self.texteCuve+="#"+"\n" + self.texteCuve += self.affecteValeurDefaut('NombreNoeudsMaillage') + + + # Rubrique CARACTERISTIQUES DU DEFAUT + self.texteCuve += self.rubrique('CARACTERISTIQUES DU DEFAUT') + + if self.dico_mot.has_key('TypeInitial'): + self.texteCuve += self.affecteValeur('TypeInitial', self.valeurproposee[str(self.dico_mot["TypeInitial"])]) + else : + self.texteCuve += self.affecteValeurDefaut('TypeInitial') + + self.texteCuve+="# Fournir ORIEDEF, (PROFDEF, PROFDEF_MESSAGE)"+"\n" + self.texteCuve+="# - Si DSR, fournir OPTLONG, (LONGDEF,LONGDEF_MESSAGE) ou (PROFSURLONG,PROFSURLONG_MESSAGE,LONGCONST)"+"\n" + self.texteCuve+="# - Si DECALE, fournir OPTLONG, (LONGDEF,LONGDEF_MESSAGE) ou (PROFSURLONG,PROFSURLONG_MESSAGE,LONGCONST), DECATYP, (DECANOR,DECANOR_MESSAGE) ou (DECADEF,DECADEF_MESSAGE)"+"\n" + self.texteCuve+="# - Si DEBOUCHANT, fournir IRWIN"+"\n" + self.texteCuve+="# Fournir (ANGLDEF, ANGLDEF_MESSAGE), (ALTIDEF, ALTIDEF_MESSAGE)"+"\n" + self.texteCuve+="# - Si DSR ou DECALE, fournir POINDEF"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve+="# Remarque :"+"\n" + self.texteCuve+="# - si DSR ou DECALE, dans la rubrique 'Modele de tenacite', fournir ATTNCORRBETA (ne pas fournir CORRIRWIN)"+"\n" + self.texteCuve+="# - si DEBOUCHANT, dans la rubrique 'Modele de tenacite', fournir CORRIRWIN (ne pas fournir ATTNCORRBETA)"+"\n" + + self.texteCuve+="#"+"\n" + + if self.dico_mot.has_key('Orientation'): + self.texteCuve += self.affecteValeur('Orientation', self.valeurproposee[str(self.dico_mot["Orientation"])]) + else : + self.texteCuve += self.affecteValeurDefaut('Orientation') + + if self.dico_mot.has_key('Position'): + self.texteCuve += self.affecteValeur('Position', self.valeurproposee[str(self.dico_mot["Position"])]) + else : + self.texteCuve += self.affecteValeurDefaut('Position') + + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('ProfondeurRadiale') + self.texteCuve += self.ecritVariable('ProfondeurRadiale_mess') + + self.texteCuve+="#"+"\n" + if self.dico_mot.has_key('TypeInitial'): + if str(self.dico_mot["TypeInitial"])!='Defaut Debouchant': + if self.dico_mot.has_key('ModeCalculLongueur'): + self.texteCuve += self.affecteValeur('ModeCalculLongueur', self.valeurproposee[str(self.dico_mot["ModeCalculLongueur"])]) + if str(self.dico_mot["ModeCalculLongueur"])=='Valeur': + self.texteCuve+="# - Si VALEUR, fournir (LONGDEF, LONGDEF_MESSAGE)"+"\n" + self.texteCuve+="# - Si FCTAFFINE, fournir (PROFSURLONG, PROFSURLONG_MESSAGE) et LONGCONST : LONGDEF=PROFDEF/PROFSURLONG + LONGCONST"+"\n" + self.texteCuve += self.ecritVariable('Longueur') + self.texteCuve += self.ecritVariable('Longueur_mess') + if str(self.dico_mot["ModeCalculLongueur"])=='Fonction affine de la profondeur': + self.texteCuve+="# - Si VALEUR, fournir (LONGDEF, LONGDEF_MESSAGE)"+"\n" + self.texteCuve+="# - Si FCTAFFINE, fournir (PROFSURLONG, PROFSURLONG_MESSAGE) et LONGCONST : LONGDEF=PROFDEF/PROFSURLONG + LONGCONST"+"\n" + self.texteCuve += self.ecritVariable('CoefDirecteur') + self.texteCuve += self.ecritVariable('CoefDirecteur_mess') + self.texteCuve += self.ecritVariable('Constante') + else : + self.texteCuve += self.affecteValeurDefaut('ModeCalculLongueur') + self.texteCuve+="# - Si VALEUR, fournir (LONGDEF, LONGDEF_MESSAGE)"+"\n" + self.texteCuve+="# - Si FCTAFFINE, fournir (PROFSURLONG, PROFSURLONG_MESSAGE) et LONGCONST : LONGDEF=PROFDEF/PROFSURLONG + LONGCONST"+"\n" + self.texteCuve += self.affecteValeurDefaut('Longueur') + self.texteCuve += self.affecteValeurDefaut('Longueur_mess') + + if self.dico_mot.has_key('TypeInitial'): + if str(self.dico_mot["TypeInitial"])=='Defaut Decale': + self.texteCuve+="#"+"\n" + if self.dico_mot.has_key('ModeCalculDecalage'): + self.texteCuve += self.affecteValeur('ModeCalculDecalage', self.valeurproposee[str(self.dico_mot["ModeCalculDecalage"])]) + if str(self.dico_mot["ModeCalculDecalage"])=='Valeur normalisee': + self.texteCuve+="# - Si NORMALISE, fournir (DECANOR, DECANOR_MESSAGE)"+"\n" + self.texteCuve+="# - Si VALEUR, fournir (DECADEF, DECADEF_MESSAGE)"+"\n" + self.texteCuve += self.ecritVariable('DecalageNormalise') + self.texteCuve += self.ecritVariable('DecalageNormalise_mess') + if str(self.dico_mot["ModeCalculDecalage"])=='Valeur': + self.texteCuve+="# - Si NORMALISE, fournir (DECANOR, DECANOR_MESSAGE)"+"\n" + self.texteCuve+="# - Si VALEUR, fournir (DECADEF, DECADEF_MESSAGE)"+"\n" + self.texteCuve += self.ecritVariable('DecalageRadial') + self.texteCuve += self.ecritVariable('DecalageRadial_mess') + else : + self.texteCuve += self.affecteValeurDefaut('ModeCalculDecalage') + self.texteCuve+="# - Si NORMALISE, fournir (DECANOR, DECANOR_MESSAGE)"+"\n" + self.texteCuve+="# - Si VALEUR, fournir (DECADEF, DECADEF_MESSAGE)"+"\n" + self.texteCuve += self.affecteValeurDefaut('DecalageRadial') + self.texteCuve += self.affecteValeurDefaut('DecalageRadial_mess') + + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('Azimut') + self.texteCuve += self.ecritVariable('Azimut_mess') + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('Altitude') + self.texteCuve += self.ecritVariable('Altitude_mess') + self.texteCuve+="#"+"\n" + if self.dico_mot.has_key('Pointe'): + self.texteCuve += self.affecteValeur('Pointe', self.valeurproposee[str(self.dico_mot["Pointe"])]) + #else : + # self.texteCuve += self.affecteValeurDefaut('Pointe') + + # Rubrique MODELES FLUENCE, IRRADIATION, TENACITE + self.texteCuve += self.rubrique('MODELES FLUENCE, IRRADIATION, TENACITE') + self.texteCuve += self.sousRubrique('Modele d attenuation de la fluence dans l epaisseur','A.') + + if self.dico_mot.has_key('ModeleFluence'): + self.texteCuve += self.affecteValeur('ModeleFluence', self.valeurproposee[str(self.dico_mot["ModeleFluence"])]) + else : + self.texteCuve += self.affecteValeurDefaut('ModeleFluence') + + self.texteCuve+="# - si France, fournir KPFRANCE"+"\n" + self.texteCuve+="# - si USNRC, fournir KPUS"+"\n" + self.texteCuve+="# - si modele GD_Cuve, fournir COEFFLUENCE1, COEFFLUENCE2, ..., COEFFLUENCE9, COEFFLUENCE10"+"\n" + self.texteCuve+="#"+"\n" + + self.texteCuve += self.ecritVariable('ZoneActiveCoeur_AltitudeSup') + self.texteCuve += self.ecritVariable('ZoneActiveCoeur_AltitudeInf') + self.texteCuve += self.ecritVariable('FluenceMax') + if self.dico_mot.has_key('ModeleFluence'): + if str(self.dico_mot["ModeleFluence"])=='Exponentiel sans revetement k=12.7 (France)': + self.texteCuve += self.ecritVariable('KPFrance') + if str(self.dico_mot["ModeleFluence"])=='Regulatory Guide 1.99 rev 2 (USNRC)': + self.texteCuve += self.ecritVariable('KPUS') + if str(self.dico_mot["ModeleFluence"])=='Grand developpement (GD_Cuve)': + self.texteCuve += self.ecritVariable('Azimut_0deg') + self.texteCuve += self.ecritVariable('Azimut_5deg') + self.texteCuve += self.ecritVariable('Azimut_10deg') + self.texteCuve += self.ecritVariable('Azimut_15deg') + self.texteCuve += self.ecritVariable('Azimut_20deg') + self.texteCuve += self.ecritVariable('Azimut_25deg') + self.texteCuve += self.ecritVariable('Azimut_30deg') + self.texteCuve += self.ecritVariable('Azimut_35deg') + self.texteCuve += self.ecritVariable('Azimut_40deg') + self.texteCuve += self.ecritVariable('Azimut_45deg') + + self.texteCuve += self.sousRubrique('Irradiation','B.') + + if self.dico_mot.has_key('TypeIrradiation'): + self.texteCuve += self.affecteValeur('TypeIrradiation', self.valeurproposee[str(self.dico_mot["TypeIrradiation"])]) + + if str(self.dico_mot["TypeIrradiation"])=='RTndt de la cuve a l instant de l analyse': + self.texteCuve+="# - si RTNDT, fournir RTNDT"+"\n" + self.texteCuve+="# - si FLUENCE, fournir MODELIRR, et autres parametres selon MODELIRR (voir ci-dessous)"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('RTNDT') + + if str(self.dico_mot["TypeIrradiation"])=='Modele d irradiation': + self.texteCuve+="# - si RTNDT, fournir RTNDT"+"\n" + self.texteCuve+="# - si FLUENCE, fournir MODELIRR, et autres parametres selon MODELIRR (voir ci-dessous)"+"\n" + self.texteCuve+="#"+"\n" + if self.dico_mot.has_key('ModeleIrradiation'): + self.texteCuve += self.affecteValeur('ModeleIrradiation', self.valeurproposee[str(self.dico_mot["ModeleIrradiation"])]) + else : + self.texteCuve += self.affecteValeurDefaut('ModeleIrradiation') + self.texteCuve+="# - pour tout modele, fournir (CU, CU_MESSAGE),"+"\n" + self.texteCuve+="# (NI, NI_MESSAGE),"+"\n" + self.texteCuve+="# - si HOUSSIN, PERSOZ, LEFEBVRE, BRILLAUD, LEFEBnew, fournir (P, P_MESSAGE)"+"\n" + self.texteCuve+="# - pour tout modele, fournir (RTimoy, RTimoy_MESSAGE),"+"\n" + self.texteCuve+="# - si USNRCsoud ou USNRCmdb, fournir (RTicov, RTicov_MESSAGE)"+"\n" + self.texteCuve+="# (USectDRT, USectDRT_MESSAGE)"+"\n" + self.texteCuve+="# - pour tout modele, fournir (nbectDRTNDT, nbectDRTNDT_MESSAGE)"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve += self.ecritVariable('TeneurCuivre') + self.texteCuve += self.ecritVariable('TeneurCuivre_mess') + self.texteCuve += self.ecritVariable('TeneurNickel') + self.texteCuve += self.ecritVariable('TeneurNickel_mess') + if str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : formule de FIM/FIS Houssin' or str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : formule de FIM/FIS Persoz' or str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : formule de FIM/FIS Lefebvre' or str(self.dico_mot["ModeleIrradiation"])=='Joint Soude : formulation de FIM/FIS Brillaud' or str(self.dico_mot["ModeleIrradiation"])=='Formule de FIM/FIS Lefebvre modifiee': + self.texteCuve += self.ecritVariable('TeneurPhosphore') + self.texteCuve += self.ecritVariable('TeneurPhosphore_mess') + self.texteCuve += self.ecritVariable('MoyenneRTndt') + self.texteCuve += self.ecritVariable('MoyenneRTndt_mess') + if str(self.dico_mot["ModeleIrradiation"])=='Metal de Base : Regulatory Guide 1.00 rev 2' or str(self.dico_mot["ModeleIrradiation"])=='Joint Soude : Regulatory Guide 1.00 rev 2': + self.texteCuve += self.ecritVariable('CoefVariationRTndt') + self.texteCuve += self.ecritVariable('CoefVariationRTndt_mess') + self.texteCuve += self.ecritVariable('EcartTypeRTndt') + self.texteCuve += self.ecritVariable('EcartTypeRTndt_mess') + self.texteCuve += self.ecritVariable('NombreEcartTypeRTndt') + self.texteCuve += self.ecritVariable('NombreEcartTypeRTndt_mess') + else : + self.texteCuve += self.affecteValeurDefaut('TypeIrradiation') + self.texteCuve+="# - si RTNDT, fournir RTNDT"+"\n" + self.texteCuve+="# - si FLUENCE, fournir MODELIRR, et autres parametres selon MODELIRR (voir ci-dessous)"+"\n" + self.texteCuve+="#"+"\n" + self.texteCuve += self.affecteValeurDefaut('RTNDT') + + self.texteCuve += self.sousRubrique('Modele de tenacite','C.') + self.texteCuve+="# tenacite d amorcage"+"\n" + + if self.dico_mot.has_key('ModeleTenacite'): + self.texteCuve += self.affecteValeur('ModeleTenacite', self.valeurproposee[str(self.dico_mot["ModeleTenacite"])]) + else : + self.texteCuve += self.affecteValeurDefaut('ModeleTenacite') + self.texteCuve+="# - si RCC-M, RCC-M_pal, Houssin_RC, fournir (nbectKIc, nbectKIc_MESSAGE), KICPAL, KICCDV"+"\n" + self.texteCuve+="# - si RCC-M_exp, fournir (nbectKIc, nbectKIc_MESSAGE), KICCDV"+"\n" + self.texteCuve+="# - si RCC-M_simpl, ne rien fournir"+"\n" + self.texteCuve+="# - si Frama, LOGWOLF, fournir (nbectKIc, nbectKIc_MESSAGE)"+"\n" + self.texteCuve+="# - si REME, ORNL, WEIB3, WEIB2, fournir NBCARAC, puis (nbectKIc, nbectKIc_MESSAGE) ou (fractKIc, fractKIc_MESSAGE) selon valeur de NBCARAC"+"\n" + self.texteCuve+="# - si Wallin, fournir NBCARAC, puis (nbectKIc, nbectKIc_MESSAGE) ou (fractKIc, fractKIc_MESSAGE) selon valeur de NBCARAC,"+"\n" + self.texteCuve+="# puis T0WALLIN"+"\n" + self.texteCuve+="# - si WEIB-GEN, fournir NBCARAC, puis (nbectKIc, nbectKIc_MESSAGE) ou (fractKIc, fractKIc_MESSAGE) selon valeur de NBCARAC,"+"\n" + self.texteCuve+="# puis A1, A2, A3, B1, B2, B3, C1, C2, C3"+"\n" + self.texteCuve+="# loi de Weibull P(K