# on cherche le bloc qui contient ce qui est necessaire a la loi
# on est confiant !!!! sur l adequation du catalogue et des attributs des lois persalys
# reflechir a cela
- texte="{}{} = persalys.input('{}', ot.{}(".format(indent,nomVariableInput,nomVariableInput,loiDistribution)
+ texte="{}{} = persalys.Input('{}', ot.{}(".format(indent,nomVariableInput,nomVariableInput,loiDistribution)
chaineArgs=''
leBlocDesArgs=None
for mc in v.mcListe :
def getStrVarList(l):
return reduce(lambda x,y:x+', '+y, l)
def getStrInitClass(l):
- return getStrVarList( map(lambda x:'self.{}={};'.format(x,x),l) )
+ return getStrVarList( map(lambda x:'self.{} = {};'.format(x,x),l) )
def getStrReplaceVar(l):
return getStrVarList( map(lambda x:"'@{}@': repr(self.{})".format(x,x), l) )
-
+ def getStrSelfVar(l):
+ return getStrVarList( map(lambda x:'self.{}'.format(x),l) )
wrapperDir = os.path.abspath(os.path.dirname(__file__))
wrapperName = "eficas_wrapper"
wrapperName=wrapperName
)
self.txtScriptPersalys += etudeScript.format(
- chaineDesVariablesInput =self.chaineDesVariablesInput,
- chaineInitDesVariablesInput=getStrInitClass(self.nomsDesVariablesInput),
- commFileStr = self.fichierUQBalise,
+ chaineDesVariablesInput = self.chaineDesVariablesInput,
+ chaineSelfDesVariablesInput = getStrSelfVar(self.nomsDesVariablesInput),
+ chaineInitDesVariablesInput = getStrInitClass(self.nomsDesVariablesInput),
+ commFileUQBaliseStr = self.fichierUQBalise,
+ commFileUQComm = self.fichierUQComm,
nproc = self.NbOfProcs,
replaceDataList = getStrReplaceVar(self.nomsDesVariablesInput)
)
txtFonctionPersalys = fonctionPersalys.format(
currentFile = self.fichierUQExe[:-3],
- chaineDesVariablesInput =self.chaineDesVariablesInput,
- chaineDesVariablesOutput =self.chaineDesVariablesOutput
+ chaineDesVariablesInput = self.chaineDesVariablesInput,
+ chaineDesVariablesOutput = self.chaineDesVariablesOutput
)
self.txtScriptPersalys += codePersalys.format(
fonctionPersalys =txtFonctionPersalys
inFiles.append(os.path.join(os.getcwd(),pyFile))
pyFile = self.fichierUQBalise
inFiles.append(os.path.join(os.getcwd(),pyFile))
+ scriptFile = "ib_test.sh"
+ inFiles.append(os.path.join(os.getcwd(),scriptFile))
txtYacsJobParameters=yacsJobParameters.format(
nomEtude = self.JobName,
workDirectory = self.WorkDirectory,
import os
# Chargement du module OpenTURNS #TODO : Parametrer OpenTurns/Uranie
-import openturns
+import openturns as ot
import persalys
-# Chargement de incertainty_tools
-from incertainty_tools import value_repr_name, replace_data, format_data
# from {wrapperDir} import {wrapperName}
"""
# etudeScript
etudeScript = """
class Study:
+ import os
+ print('dir() 0 : ', dir())
+ import subprocess
+ print('dir() 0b : ', dir())
+# from incertainty_tools import value_repr_name, replace_data, format_data
+
def __init__(self, {chaineDesVariablesInput}):
- {chaineInitDesVariablesInput}
+ print('--------------------------------------- 0 ---------------------------------------')
+ {chaineInitDesVariablesInput}
+
+ def do_sh(self, command, execdir=os.getcwd()):
+ print('dir() 1 : ', dir())
+ print('execdir 1 : ', execdir)
+ import subprocess
+ print('dir() 2 : ', dir())
+ sh = subprocess.Popen(command, shell=True, cwd=execdir,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ out, err = sh.communicate()
+ return out, err, sh.poll()
#TODO : Définir un décorateur pour sélectionner la fonction voulue
def define_workdirectory(self):
- self.workdir = valueReprName( [{chaineDesVariablesInput}])
+ from incertainty_tools import value_repr_name
+ print('--------------------------------------- 1 ---------------------------------------')
+ self.workdir = value_repr_name([{chaineSelfDesVariablesInput}])
def case_exists(self):
+ print('--------------------------------------- 2 ---------------------------------------')
ok = True
if os.path.isdir(self.workdir):
- try:
- ok = False #TODO
- except:
- ok = False
+ try:
+ ok = False #TODO
+ except:
+ ok = False
else:
- ok = False
+ ok = False
return ok
def prepare_case(self):
+ from incertainty_tools import replace_data
+ print('--------------------------------------- 3 ---------------------------------------')
import shutil
if not os.path.isdir(self.workdir):
os.mkdir(self.workdir)
#section spécifique au code de calcul
- comm_file = {commFileStr}
+ comm_file_uq_balise = '{commFileUQBaliseStr}'
self.nproc = {nproc}
- self.comm_file=os.path.join(self.workdir, comm_file)
+ self.comm_file_uq_balise = os.path.join(self.workdir, comm_file_uq_balise)
+ shutil.copy(comm_file_uq_balise, self.comm_file_uq_balise)
+
+ self.comm_file_uq_comm = os.path.join(self.workdir, '{commFileUQComm}')
+ replace_data(self.comm_file_uq_balise, {{ {replaceDataList} }} , self.comm_file_uq_comm)
- shutil.copy(comm_file, self.comm_file)
- replace_data(self.comm_file, {{ {replaceDataList} }})
pass
def get_results(self):
+ print('--------------------------------------- 4 ---------------------------------------')
# return self.extract_probe(2,2), self.extract_balance(2, 2)
- return None, None
+ return 1.0
+
+ def run_case(self):
+ print('--------------------------------------- 5 ---------------------------------------')
+ #os.chdir(self.workdir)
+ o,e,c = self.do_sh(command="ib_test.sh", execdir=self.workdir)
+ if o != None : print('o.decode() : ',o.decode())
+ if e != None : print('e.decode() : ',e.decode())
+ print(c)
+
"""
+# /home/C65845/VIMMP/Banc_integration.newer_odysee/environment/bin/python3 /home/C65845/VIMMP/Banc_integration.newer_odysee/environment/bin/ib-run --cocagne-neutro-solver SPN --cocagne-thermo-solver THERMOMI/TRMIC -- /home/C65845/VIMMP/Banc_integration.newer_odysee/integration_bench/tests/control_rod_ejection_small_core_cathare3_cocagne.comm /home/C65845/VIMMP/Banc_integration.newer_odysee/integration_bench/tests/control_rod_ejection_small_core_cathare3_cocagne_spn_thermomi-trmic_serial
+
+
# ------------------------
# fonctionPersalys
# ------------------------
fonctionPersalys = """
def _exec({chaineDesVariablesInput}):
+ print('--------------------------------------- 00 ---------------------------------------')
from {currentFile} import Study
{nomEtude}.add(yacsPhysicalModel)
{centralTendencyPersalys}
- Study.add(centralTendency)
+ {nomEtude}.add(centralTendency)
centralTendency.run()
{optionalResult}
"""
optionalResultTaylor={
- 'MeanFirstOrder' : 'meanFirstOrder=result.getMeanFirstOrder()',
- 'StandardDeviationFirstOrder' : 'standardDeviationFirstOrder=result.getStandardDeviation()',
- 'MeanSecondOrder' : 'meanSecondOrder=result.getMeanSecondOrder()',
- 'Variance' : 'variance=result.getVariance()'
+ 'MeanFirstOrder' : 'meanFirstOrder = result.getMeanFirstOrder()',
+ 'StandardDeviationFirstOrder' : 'standardDeviationFirstOrder = result.getStandardDeviation()',
+ 'MeanSecondOrder' : 'meanSecondOrder = result.getMeanSecondOrder()',
+ 'Variance' : 'variance = result.getVariance()'
}
+# print('result : ',result)
+# print('meanFirstOrder',meanFirstOrder)
+# print('standardDeviationFirstOrder',standardDeviationFirstOrder)
centralTendencyMC ="""
centralTendency = persalys.MonteCarloAnalysis('centralTendencyMC', yacsPhysicalModel)
yacsPhysicalModel.jobParameters().salome_parameters.work_directory = '{workDirectory}'
yacsPhysicalModel.jobParameters().salome_parameters.result_directory = '{resultDirectory}'
yacsPhysicalModel.jobParameters().salome_parameters.resource_required.name = '{resourceName}'
- yacsPhysicalModel.jobParameters().salome_parameters.resource_required.nb_proc = '{nprocs}'
+ yacsPhysicalModel.jobParameters().salome_parameters.resource_required.nb_proc = {nprocs}
yacsPhysicalModel.jobParameters().salome_parameters.wckey = '{wckey}'
yacsPhysicalModel.jobParameters().salome_parameters.in_files = {inFiles} # Chemins des fichiers locaux à copier dans work_directory
- yacsPhysicalModel.jobParameters().nb_branches = '{nprocs}' # nombre de jobs parallèles
+ yacsPhysicalModel.jobParameters().nb_branches = {nprocs} # nombre de jobs parallèles
"""
yacsJobParametersRef="""