From afcd9e45a262db5ef1781399573cbc5258281006 Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Fri, 18 Dec 2009 16:19:41 +0000 Subject: [PATCH] pour generator map --- InterfaceQT4/editor.py | 5 +- InterfaceQT4/monListeParamPanel.py | 2 +- InterfaceQT4/qtEficas.py | 18 +- generator/generator_GroupMA.py | 4 +- generator/generator_SEP.py | 2 +- generator/generator_aplat.py | 2 +- generator/generator_cuve2dg.py | 2 +- generator/generator_homard.py | 2 +- generator/generator_ini.py | 2 +- generator/generator_map.py | 220 +++++++++++++++++ generator/generator_openturns.py | 2 +- generator/generator_openturns_study.py | 2 +- generator/generator_openturns_wrapper.py | 2 +- generator/generator_perfect.py | 301 +++++++++++++++++++++++ generator/generator_pyth.py | 2 +- generator/generator_python.py | 2 +- generator/generator_vers3DSalome.py | 2 +- 17 files changed, 548 insertions(+), 24 deletions(-) create mode 100644 generator/generator_map.py create mode 100644 generator/generator_perfect.py diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index 1d2e8a82..26a15fa9 100644 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -475,7 +475,7 @@ class JDCEditor(QSplitter): if generator.plugins.has_key(format): # Le generateur existe on l'utilise self.generator=generator.plugins[format]() - jdc_formate=self.generator.gener(self.jdc,format='beautifie') + jdc_formate=self.generator.gener(self.jdc,format='beautifie',configuration=self.appliEficas.CONFIGURATION) if not self.generator.cr.estvide(): self.affiche_infos("Erreur à la generation") QMessageBox.critical( self, "Erreur a la generation","EFICAS ne sait pas convertir ce JDC") @@ -550,14 +550,11 @@ class JDCEditor(QSplitter): self.tree.racine.update_node_label() try : - #if 1 : fileXML = fn[:fn.rfind(".")] + '.xml' self.generator.writeOpenturnsXML( fileXML ) except : - #else : pass - #PNPNPNPN A ecrire try : fileSTD = fn[:fn.rfind(".")] + '.py' self.generator.writeOpenturnsSTD( fileSTD ) diff --git a/InterfaceQT4/monListeParamPanel.py b/InterfaceQT4/monListeParamPanel.py index 3b9d5812..7839ec43 100644 --- a/InterfaceQT4/monListeParamPanel.py +++ b/InterfaceQT4/monListeParamPanel.py @@ -56,7 +56,7 @@ class MonListeParamPanel(DLisParam): self.dictListe[QString(repr(param))] = param def LBParamItemPressed(self): - print self.LBParam.selectedItems() + #print self.LBParam.selectedItems() i=self.LBParam.selectedItems()[0].text() self.panel.Ajout1Valeur(self.dictListe[i]) diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index 79941b2b..74f43760 100644 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -7,6 +7,7 @@ from PyQt4.QtCore import * from PyQt4.QtAssistant import * from myMain import Ui_Eficas from viewManager import MyTabview +from monChoixMap import MonChoixMap from Editeur import session @@ -15,7 +16,7 @@ class Appli(Ui_Eficas,QMainWindow): """ Class implementing the main user interface. """ - def __init__(self,code="ASTER",salome=0,parent=None): + def __init__(self,code="ASTER",salome=0,parent=None,choix="non"): """ Constructor """ @@ -30,17 +31,19 @@ class Appli(Ui_Eficas,QMainWindow): self.dict_reels={} import prefs - if salome : - import sys prefs.code=code name='prefs_'+prefs.code prefsCode=__import__(name) - nameConf='configuration_'+prefs.code - configuration=__import__(nameConf) - self.REPINI=prefsCode.REPINI self.RepIcon=prefsCode.INSTALLDIR+"/Editeur/icons" self.INSTALLDIR=prefsCode.INSTALLDIR + + if choix == "oui" : self.choisitCodeMap() + if salome : + import sys + nameConf='configuration_'+prefs.code + configuration=__import__(nameConf) + self.CONFIGURATION = configuration.make_config(self,prefsCode.REPINI) self.CONFIGStyle = configuration.make_config_style(self,prefsCode.REPINI) if hasattr(prefsCode,'encoding'): @@ -343,6 +346,9 @@ class Appli(Ui_Eficas,QMainWindow): texte="tempo"+str(self.indice) return texte + def choisitCodeMap(self): + widgetChoix=MonChoixMap(self,True) + ret=widgetChoix.exec_() if __name__=='__main__': diff --git a/generator/generator_GroupMA.py b/generator/generator_GroupMA.py index 0790e8b7..a17d1dc9 100644 --- a/generator/generator_GroupMA.py +++ b/generator/generator_GroupMA.py @@ -54,9 +54,9 @@ class GroupMAGenerator(PythonGenerator): self.listeMA=[] self.listeNO=[] - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): self.liste=[] - self.text=PythonGenerator.gener(self,obj,'brut') + self.text=PythonGenerator.gener(self,obj,'brut',config=None) return self.listeMA,self.listeNO def generMCSIMP(self,obj) : diff --git a/generator/generator_SEP.py b/generator/generator_SEP.py index b8db416f..db3ea13b 100644 --- a/generator/generator_SEP.py +++ b/generator/generator_SEP.py @@ -52,7 +52,7 @@ class SEPGenerator(PythonGenerator): # Les extensions de fichier permis? extensions=('.comm',) - def gener(self,obj,format='brut'): + 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) diff --git a/generator/generator_aplat.py b/generator/generator_aplat.py index 0361c4a0..5cd96bfe 100644 --- a/generator/generator_aplat.py +++ b/generator/generator_aplat.py @@ -84,7 +84,7 @@ class AplatGenerator: fp.write(self.text) fp.close() - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): """ Retourne une représentation du JDC obj sous une forme qui est paramétrée par format. Si format vaut 'brut', 'standard' ou 'beautifie', retourne le texte issu de generator diff --git a/generator/generator_cuve2dg.py b/generator/generator_cuve2dg.py index bfb6b444..8b559b77 100644 --- a/generator/generator_cuve2dg.py +++ b/generator/generator_cuve2dg.py @@ -593,7 +593,7 @@ class Cuve2dgGenerator(PythonGenerator): "SurfaceEchange_FluideStructure_mess" : "TRANSITOIRE", } - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): self.text='' self.textCuve='' self.dico_mot={} diff --git a/generator/generator_homard.py b/generator/generator_homard.py index e1bf2339..09a20a9d 100644 --- a/generator/generator_homard.py +++ b/generator/generator_homard.py @@ -118,7 +118,7 @@ class HomardGenerator(PythonGenerator): self.dico_mot_depend['CCSolN__'] ='self.dico_mot_clef.has_key("NITER")' self.dico_mot_depend['CCSolNP1'] ='self.dico_mot_clef.has_key("NITER")' - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): self.text=PythonGenerator.gener(self,obj,format) self.genereConfiguration() return self.text diff --git a/generator/generator_ini.py b/generator/generator_ini.py index 3e94abf7..a93dd35b 100644 --- a/generator/generator_ini.py +++ b/generator/generator_ini.py @@ -75,7 +75,7 @@ class IniGenerator: fp.write(self.text) fp.close() - def gener(self,obj): + def gener(self,obj,config=None): """ Tous les mots-clés simples du niveau haut sont mis dans la section DEFAUT Tous les mots-clés facteurs sont convertis en sections diff --git a/generator/generator_map.py b/generator/generator_map.py new file mode 100644 index 00000000..86fe0b6a --- /dev/null +++ b/generator/generator_map.py @@ -0,0 +1,220 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + 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 + +#____________________________________________________________________________________ +# PYGMEEDict contient une equivalence entre le catalogue Map et les lignes generees +# comme entete (commentaire ?) dans le fichier d'input de pygmee +# +PYGMEEDict={ + "_PYGMEE_FUSEAU1_b_forme_FICHIER" : "#fuseau 1 (entree de lecfus) format : diametre DCE croissant / fraction cumulee decroisant ", + "FUSEAU2" : "#fuseau 2 (entree de lecfus) format : diametre DCE croissant / fraction cumulee decroisant", + "_PYGMEE_TAILLE" : "# taille du VER en microns ", + "_PYGMEE_DISTANCE" : "# distance de repulsion :", + } + +#_______________________________________________________________________________________________________ +# listeOrdonneeMCPygmee contient une liste (donc ordonnee) des mots clefs pour +# imposer l'ordre des lignes generees +listeOrdonneeMCPygmee =('_PYGMEE_FUSEAU1_b_forme_FICHIER', 'FUSEAU2', '_PYGMEE_TAILLE','_PYGMEE_DISTANCE') + + +BENHURDict={ + "_BENHUR_FINESSE" : "discretisation des arretes du VER ", + } + + +def entryPoint(): + """ + Retourne les informations necessaires pour le chargeur de plugins + + Ces informations sont retournees dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'map', + # La factory pour creer une instance du plugin + 'factory' : MapGenerator, + } + + +class MapGenerator(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',configuration=None): + self.PATH_PYGMEE=configuration.PATH_PYGMEE + self.PATH_BENHUR=configuration.PATH_BENHUR + self.dictMCVal={} + self.listeTemp=[] + self.text=PythonGenerator.gener(self,obj,format) + self.generePythonMap() + return self.text + + def generePythonMap(self) : + ''' + self.dictMCVal est un dictionnaire qui est indexe par le nom du code (exple PYGMEE) + la valeur associee a la clef est egalement un dictionnaire + ce dictionnaire a pour clef la genealogie du MCSimp suivi de sa valeur + + ''' + for code in self.dictMCVal.keys(): + self.texte=apply(MapGenerator.__dict__[code],(self,)) + return 'a faire' + + def generPROC_ETAPE(self,obj): + #print "PN: generPROC_ETAPE dans generatorMap" + self.clefDico=obj.nom + if not( self.dictMCVal.has_key(self.clefDico)): + self.dictMCVal[self.clefDico]={} + self.DictTemp=self.dictMCVal[self.clefDico] + s=PythonGenerator.generPROC_ETAPE(self,obj) + return s + + + 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 + """ + s=PythonGenerator.generMCSIMP(self,obj) + clef="" + for i in obj.get_genealogie() : + clef=clef+"_"+i + self.DictTemp[clef]=obj.valeur + return s + + def PYGMEE(self) : + print "Generation de PYGMEE" + dicoPygmee=self.dictMCVal["PYGMEE"] + dicoPygmee['FUSEAU2']='toto.txt' + + txt="# fichier de mise en donnee de la generation du VER MOX" +"\n" + txt=txt+"# nombre de phases"+"\n" + txt=txt+"1"+"\n" + for mot in listeOrdonneeMCPygmee : + if mot in dicoPygmee.keys() : + txt=txt+PYGMEEDict[mot]+"\n" + txt=txt+str(dicoPygmee[mot])+"\n" + + monFichier=self.PATH_PYGMEE+"/pygmee_input.txt" + if os.path.isfile(monFichier) : + #print "je detruis pygmee_input.txt" + commande="rm -rf " + monFichier + os.system (commande) + f=open(monFichier,'wb') + f.write(txt) + f.close() + if ('_PYGMEE_LANCEMENT' in dicoPygmee.keys()) and dicoPygmee['_PYGMEE_LANCEMENT'] == 'oui': + commande="cd "+self.PATH_PYGMEE+";" + commande=commande + "python "+self.PATH_PYGMEE+"/pygmee_v1.py" + #print commande + os.system(commande) + else: + return "" + + def BENHUR(self) : + print "Generation de BENHUR" + dicoBenhur=self.dictMCVal["BENHUR"] + nom_fichier_fuseau=self.PATH_BENHUR+"/benhur_input.txt" + + nom_fichier_BHR=self.PATH_BENHUR+"/test_module.bhr" + nom_BHR_Files=self.PATH_BENHUR+"/BHR_files.txt" + + finesse=str(dicoBenhur['_BENHUR_FINESSE']) + if ("PYGMEE" in self.dictMCVal.keys()) and '_PYGMEE_TAILLE' in self.dictMCVal['PYGMEE']: + taille_VER=self.dictMCVal["PYGMEE"]['_PYGMEE_TAILLE'] + else : + taille_VER=0 + print "Attention la variable Taille_VER non definie" + nom_GMSH_in=self.PATH_BENHUR+"/regular_mesh_3D_i"+finesse+".msh" + nom_etude=self.PATH_BENHUR+"/test_module_"+finesse + nom_GMSH_out=nom_etude+".msh" + nom_LOG=nom_etude+".log" + nom_BMP=nom_etude+".bmp" + nom_LEVELSET=nom_etude+"_levelset.txt" + nom_GMSH_out=nom_etude+".msh" + nom_LOG=nom_etude+".log" + nom_BMP=nom_etude+".bmp" + nom_LEVELSET=nom_etude+"_levelset.txt" + f=open(nom_BHR_Files,'wb') + f.write(nom_fichier_BHR) + f.write("\n") + f.write("\n") + f.write("\n") + f.close() + f=open(nom_fichier_BHR,'wb') + f.write("3D BENHUR SCALE\n") + f.write("I - Morphologie (MESSALA)\n") + f.write("1) dimension du VER cubique [m] (entree)\n") + f.write(str(taille_VER)) + f.write("\n2) fraction volumique seuil écrétant le fuseau (entree)\n") + f.write(".11\n") + f.write("3) fichier decrivant le fuseau granulaire descendant (entree)\n") + f.write("-\n") + f.write("4) fichier decrivant la position et la taille des boules (sortie)\n") + f.write(nom_fichier_fuseau) + f.write("\n5) fichier CAO de la morphologie (sortie)\n") + f.write("-\n") + f.write("6) facteur de correction de fraction volumique (entree)\n") + f.write("1.0\n") + f.write(" \n") + f.write("II - Maillage (BENHUR)\n") + f.write("1) fichier entree décrivant le maillage support (entree)\n") + f.write(nom_GMSH_in); + f.write("\n2) fichier sortie du maillage (sortie)\n") + f.write(nom_GMSH_out); + f.write("\n3) fichier commentaire sur les statistiques décrivant le maillage (sortie)\n") + f.write(nom_LOG); + f.write("\n4) fichier BMP décrivant une coupe binarisée du VER (sortie)\n") + f.write(nom_BMP); + f.write("\n5) fichier TXT donnant la level set du contour aux noeuds (sortie)\n") + f.write(nom_LEVELSET) + f.write("\n") + f.write("\n") + f.write("\n") + f.close() + + if ('_BENHUR_LANCEMENT' in dicoBenhur.keys()) and dicoBenhur['_BENHUR_LANCEMENT'] == 'oui': + commande="cd "+self.PATH_BENHUR+";" + commande=commande + "./benhur" + print commande + os.system(commande) + else: + return "" + + def ASTER(self) : + print "Generation de ASTER" + diff --git a/generator/generator_openturns.py b/generator/generator_openturns.py index 08f4e0a2..202fe534 100644 --- a/generator/generator_openturns.py +++ b/generator/generator_openturns.py @@ -63,7 +63,7 @@ class OpenturnsGenerator(PythonGenerator): self.dictTempo={} self.TraiteMCSIMP=1 - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): #print "IDM: gener dans generator_openturns.py" self.initDico() self.text=PythonGenerator.gener(self,obj,format) diff --git a/generator/generator_openturns_study.py b/generator/generator_openturns_study.py index dd84bead..e743d6ec 100644 --- a/generator/generator_openturns_study.py +++ b/generator/generator_openturns_study.py @@ -68,7 +68,7 @@ class OpenturnsGenerator(PythonGenerator): sys.exit(1) """ - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): print "IDM: gener dans generator_openturns_study.py" self.initDico() self.text=PythonGenerator.gener(self,obj,format) diff --git a/generator/generator_openturns_wrapper.py b/generator/generator_openturns_wrapper.py index 1f3d4217..03990c87 100644 --- a/generator/generator_openturns_wrapper.py +++ b/generator/generator_openturns_wrapper.py @@ -69,7 +69,7 @@ class OpenturnsGenerator(PythonGenerator): """ self.wrapperXML=None - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): #print "IDM: gener dans generator_openturns_wrapper.py" self.initDico() self.text=PythonGenerator.gener(self,obj,format) diff --git a/generator/generator_perfect.py b/generator/generator_perfect.py new file mode 100644 index 00000000..edf4d174 --- /dev/null +++ b/generator/generator_perfect.py @@ -0,0 +1,301 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + 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' : 'perfect', + # La factory pour creer une instance du plugin + 'factory' : PerfectGenerator, + } + + +class PerfectGenerator(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.text=PythonGenerator.gener(self,obj,format) + self.generePythonPerfect() + return self.text + + def generePythonPerfect(self) : + ''' + ''' + import sys + sys.path.append("/home/noyret/PERFECT/perfect_platform") + print "avant import" + import PDM + import PMM + import PSM + print "apres import" +#!/usr/bin/env python + + + +# script exported from study my new study +# generated using the PSM.ExportStudy package and the script_tmpl.py +# template + + import getopt, sys, time + from PSM.PerfectStudy import ExecutionStatus + + short_opts = "dhst" + long_opts = [ + "debug", + "help", + "save", + "test", + ] + + TXT_HELP = r""" + SYNTAX: + python script.py [options] + DESCRIPTION: + will launch the exported python script + OPTIONS: + -h, --help: + print this help (and you found it!) + -d, --debug: + when enabled, if a module execution fails, the error messages of this + module will be printed (default no) + -s, --save: + will save the study (format .prf) when the computation is + finished, if it has finished with no error (default no) + -t, --test: + will automatically look for a 'return_flag' produced by a comparison + list in the current study, and will exit with a return code depending + on the return_flag: + 0 (normal exit) if the return_flag is 1 (criterion satisfied) + 1 (error exit) if the return_flag is 0 (criterion not satisfied) + This is usefull especially for non-regression tests. + """ + + START_MESSAGE = r""" + + +-------------------------+ + | PERFECT python script | + +-------------------------+ + + """ + + DEBUG_MODE = False + TEST_MODE = False + SAVE_STUDY = False + INDENT = 4*" " + + # set the options + opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts) + for opt,arg in opts: + if opt in ("-h", "--help"): + print TXT_HELP + sys.exit(0) + if opt in ("-d", "--debug"): + DEBUG_MODE = True + if opt in ("-s", "--save"): + SAVE_STUDY = True + if opt in ("-t", "--test"): + TEST_MODE = True + + # 1st: determine and write what are the packages needed for the definition + # of the input data + from PDM.BasicUnits import Flux, Energy, Temperature, Time, DamageRate, Volume, Dimension, AtomicDensity, Stress + from PDM.Crystal import IronBccCrystal + from PDM.BasicTypes import PerfectFile, String, TableCoefficient, Coefficient, StringListChoice + from PDM.Irradiation import NeutronSpectrum, OperatingConditions + + + ################################################################################ + + # 2nd: write study preferences and so on + print START_MESSAGE + print ">>> Defining study '%s'" % ("my new study") + from PSM import PerfectStudy + a_study = PerfectStudy.PerfectStudy() + a_study.set_study({'date': '12/11/09', 'description': 'no description', 'filename': '/home/noyret/PerfectStudy/studies/my_new_new_study.prf', 'name': 'my new study', 'author': 'gadjanor'}) + + # 3rd: write the study chain + print ">>> Setting the study chain" + a_study.set_chain_modules_path_list([['RPV2.IRRAD', 'PMM.RPV']]) + + # 4th: list and write all input data needed + print ">>> Defining the list of input data" + specter_path = PerfectFile() + specter_path.path = '/home/noyret/PERFECT/perfect_platform/tools/bin/specter.exe_64' + specter_path.format = '' + + neutron_spectrum = NeutronSpectrum() + neutron_spectrum.spectrum_description.value = 'Flux de neutrons total osiris' + col0 = Coefficient() + col0.name = 'Energies' + col0.value = 20.0 + col0.unit = 'MeV' + col1 = Flux() + col1.name = 'Fluxes' + col1.value = 2213561344.0 + col1.unit = 'n_per_cm2_per_s' + neutron_spectrum.spectrum.columns = [col0, col1] + neutron_spectrum.spectrum.values = [[1.6195e-08, 157854046530.125], [3.2380000000000003e-08, 50535692980.711899], [6.9749999999999999e-08, 66380592563.133797], [1.5029999999999999e-07, 85471465500.099396], [3.2370000000000002e-07, 112865380791.41], [6.9729999999999998e-07, 132262477629.74699], [1.502e-06, 125499304036.588], [3.236e-06, 155325512030.22501], [6.9709999999999998e-06, 165859614237.423], [1.502e-05, 138404454165.83801], [3.235e-05, 136094651024.06], [6.9690000000000005e-05, 125096838337.642], [0.00015009999999999999, 169481805527.93799], [0.0003234, 126382978723.40401], [0.00069669999999999997, 74648637900.179001], [0.0015009999999999999, 147792404056.47198], [0.0032330000000000002, 174136408828.793], [0.0069649999999999998, 119086100616.425], [0.015010000000000001, 151134619208.59], [0.032320000000000002, 142105388745.27701], [0.069620000000000001, 212703121893.01999], [0.14999999999999999, 321412606880.09497], [0.1832, 294202425929.60797], [0.22370000000000001, 355893418174.58698], [0.40760000000000002, 392456551998.409], [0.49790000000000001, 482468880493.14001], [0.60809999999999997, 408021475442.43402], [0.74270000000000003, 580268045337.04504], [0.90720000000000001, 680368264068.40295], [1.1080000000000001, 628730165042.75195], [1.353, 567879101212.96497], [1.653, 633883000000.0], [2.0190000000000001, 726967000000.0], [2.4660000000000002, 584931000000.0], [3.012, 627575000000.0], [3.6789999999999998, 484280000000.0], [4.4930000000000003, 354030000000.0], [5.4880000000000004, 259284000000.0], [6.7030000000000003, 214234000000.0], [8.1869999999999994, 119961000000.0], [10.0, 63117120700.0], [14.960000000000001, 24112944919.0], [20.0, 2213561344.0]] + + operating_conditions = OperatingConditions() + operating_conditions.flux_cut_off_energy.name = '' + operating_conditions.flux_cut_off_energy.value = 1.0 + operating_conditions.flux_cut_off_energy.unit = 'MeV' + operating_conditions.temp_irrad.name = 'T' + operating_conditions.temp_irrad.value = 573.0 + operating_conditions.temp_irrad.unit = 'K' + operating_conditions.time_irrad.name = '' + operating_conditions.time_irrad.value = 10000000.0 + operating_conditions.time_irrad.unit = 's' + col0 = Coefficient() + col0.name = 'relative_time' + col0.value = 1.0 + col0.unit = '' + operating_conditions.relative_time_increments.columns = [col0] + operating_conditions.relative_time_increments.values = [[1e-10], [1.0000000000000001e-09], [3e-09], [1e-08], [2.9999999999999997e-08], [9.9999999999999995e-08], [2.9999999999999999e-07], [9.9999999999999995e-07], [3.0000000000000001e-06], [1.0000000000000001e-05], [3.0000000000000001e-05], [0.0001], [0.00029999999999999997], [0.001], [0.0030000000000000001], [0.01], [0.029999999999999999], [0.10000000000000001], [0.29999999999999999], [1.0]] + operating_conditions.rescaling_flux.name = '' + operating_conditions.rescaling_flux.value = 0.0 + operating_conditions.rescaling_flux.unit = 'n_per_cm2_per_s' + operating_conditions.rescaling_NRT_damage_rate.name = '' + operating_conditions.rescaling_NRT_damage_rate.value = 0.0 + operating_conditions.rescaling_NRT_damage_rate.unit = 'dpa_per_s' + + bcc_crystal = IronBccCrystal() + bcc_crystal.atomic_volume.name = '' + bcc_crystal.atomic_volume.value = 1.18199515e-29 + bcc_crystal.atomic_volume.unit = 'm3' + bcc_crystal.lattice_parameter.name = 'Dimension' + bcc_crystal.lattice_parameter.value = 2.87 + bcc_crystal.lattice_parameter.unit = 'angstrom' + bcc_crystal.atomic_density.name = '' + bcc_crystal.atomic_density.value = 8.46027160095e+28 + bcc_crystal.atomic_density.unit = 'at_per_m3' + bcc_crystal.mu.name = 'Sigma' + bcc_crystal.mu.value = 70.0 + bcc_crystal.mu.unit = 'GPa' + bcc_crystal.structure.string_list = ['bcc', 'fcc'] + bcc_crystal.structure.value = 'bcc' + bcc_crystal.nu.name = '' + bcc_crystal.nu.value = 0.3 + bcc_crystal.nu.unit = '' + + a_study.perfect_chain.set_dict_inputs({ + 'specter_path': specter_path, + 'neutron_spectrum': neutron_spectrum, + 'operating_conditions': operating_conditions, + 'bcc_crystal': bcc_crystal, + }) + + + # 5th: checks if the study is correctly defined + print ">>> Assert if the study is correctly defined" + if not a_study.ok(): + raise AssertionError + print INDENT + "Ok." + + # 6th: initilize study execution callbacks + def current_module_changed(the_module): + print INDENT + 60*"-" + print INDENT + ">>> Module " + the_module.get_absolute_name() + pass + + a_study.on_current_module_changed = current_module_changed + + def progress_value_changed(the_progress_value): + sys.stdout.write( 2*INDENT + "- Completed: %4.1f %%\r" % (the_progress_value*100.) ) + sys.stdout.flush() + pass + + a_study.on_progress_value_changed = progress_value_changed + + # 7th: launch the study and wait till it will finish + print "creating new script" + parser_module = __import__( + 'Parser.perfect_filtre', + globals(), locals(), ['perfect_filtre'] + ) + setattr(parser_module, 'current_study', a_study) + template_py_file = '/home/noyret/PERFECT/perfect_platform/PSM/script_tmpl.py' + this_params = parser_module.analyse( template_py_file ) + print "this_params ", this_params + parser_module.perf_filter( this_params, "/home/noyret/new_script_eficas.py" ) + print "fin parser_module" + + + #a_study.run_study() + #a_study.wait() + + ## 8th: process the study execution output + #print INDENT + 60*"-" + #print ">>> Execution finished." + #print INDENT + "Final status of the execution:", a_study.get_status() + + ## if DEBUG_MODE is set, and the study is finished with an error, + ## prints information on the failed last module + #if a_study.get_execution_status() == ExecutionStatus.Failed and DEBUG_MODE: + #print ">>> Standard messages of the last module:" + #print a_study.get_execution_stack()[-1][0] + #print ">>> Error messages of the last module:" + #print a_study.get_execution_stack()[-1][1] + #sys.exit(1) + + ## if SAVE_STUDY is set, saves the study + #if SAVE_STUDY: + #print ">>> Saving the study" + #a_study.save() + + ## if TEST_MODE is set, return a code depending on the return flag + #if TEST_MODE: + #return_flag = a_study.get_final_dict()['return_flag'].value + #discrepency = a_study.get_final_dict()['discrepency'].value + #print ">>> Comparison with reference curve(s) returned the value:", \ + #discrepency + #if return_flag: + #print INDENT + "which is under the criterion" + #sys.exit( 0 ) + #else: + #print INDENT + "which is not under the criterion" + #sys.exit( 1 ) + + # End of script + + return 'a faire' + diff --git a/generator/generator_pyth.py b/generator/generator_pyth.py index 62c27729..35d9ebb1 100644 --- a/generator/generator_pyth.py +++ b/generator/generator_pyth.py @@ -77,7 +77,7 @@ class PythGenerator: fp.write(self.text) fp.close() - def gener(self,obj,format='standard'): + def gener(self,obj,format='standard',config=None): """ Tous les mots-clés simples du niveau haut sont transformés en variables diff --git a/generator/generator_python.py b/generator/generator_python.py index a5407ee4..93f6749d 100644 --- a/generator/generator_python.py +++ b/generator/generator_python.py @@ -83,7 +83,7 @@ class PythonGenerator: fp.write(self.text) fp.close() - def gener(self,obj,format='brut'): + def gener(self,obj,format='brut',config=None): """ Retourne une représentation du JDC obj sous une forme qui est paramétrée par format. diff --git a/generator/generator_vers3DSalome.py b/generator/generator_vers3DSalome.py index 7fb29fbd..59496b15 100644 --- a/generator/generator_vers3DSalome.py +++ b/generator/generator_vers3DSalome.py @@ -89,7 +89,7 @@ class vers3DSalomeGenerator(PythonGenerator): self.commande = "" self.dict_attributs = {} - def gener(self,node): + def gener(self,node,config=None): """ """ self.node=node -- 2.39.2