From a0446a9358d4be68d6fb3291ceea138fc5770261 Mon Sep 17 00:00:00 2001 From: PASCALE NOYRET Date: Tue, 14 Jun 2022 11:14:24 +0200 Subject: [PATCH] maj du cata pour prise en compte demande Anthime --- ReacteurNumerique/cata_RN_EDG.py | 2 ++ ReacteurNumerique/cata_RN_UQ.py | 23 ++++++++----- ReacteurNumerique/cata_UQ.py | 59 ++++++++++++++++++++++---------- 3 files changed, 57 insertions(+), 27 deletions(-) diff --git a/ReacteurNumerique/cata_RN_EDG.py b/ReacteurNumerique/cata_RN_EDG.py index bbcf236b..3e5ddc3a 100644 --- a/ReacteurNumerique/cata_RN_EDG.py +++ b/ReacteurNumerique/cata_RN_EDG.py @@ -858,3 +858,5 @@ Scenario_data = OPER( typ=Tuple(2), # TODO: Use a triplet (parameter, physic, format) instead of a doublet validators=VerifPostTreatment(), max="**")) + +from cata_RN_UQ import * diff --git a/ReacteurNumerique/cata_RN_UQ.py b/ReacteurNumerique/cata_RN_UQ.py index a789074c..e950f9e5 100644 --- a/ReacteurNumerique/cata_RN_UQ.py +++ b/ReacteurNumerique/cata_RN_UQ.py @@ -10,22 +10,27 @@ import types from Accas import OPER, BLOC, FACT, SIMP, ASSD, JDC_CATA, Matrice, Tuple, AU_MOINS_UN, A_VALIDATOR, PROC from Noyau.N_VALIDATOR import Valid -# +# sert a activer les options d incertitude dans eficas +# et a changer le convert en convertUQ avecIncertitude=True # -dictUQ = {'initial_power' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), +dictUQ = {'initial_power' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}, {'UserDefined' :{}}), 'initial_core_inlet_temperature' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), - #'initial_boron_concentration' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), - #'initial_inlet_pressure' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), - #'initial_outlet_pressure' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), - #'assembly_width' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), + 'initial_boron_concentration' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), + 'initial_inlet_pressure' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), + 'initial_outlet_pressure' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), + 'assembly_width' : ({'Uniform' : {}}, {'TruncatedNormal' : {}}), # modifier la partie Accas pour garder une reference a l objet nomme } -listeDesSortiesPossibles = ("Average_mass_flux", "Boiling_power_fraction", "Boron_concentration", "Enthalpy", "Fuel_power_fraction", "Fuel_temperature", "Kinetic_reactivity", "Liquid_power", "Mass_flux", "Mass_fraction", "Mass_title", "Mixture_density", "Mixture_specific_enthalpy", "Mixture_temperature", "Neutronic_power", "Outlet_pressure", "Pollutant_concentration", "Pressure ", "Rowlands_fuel_effective_temp", "Thermal_power", "Water_density", "Water_temperature", "Power_level" ) +#listeDesSortiesPossibles = ("Average_mass_flux", "Boiling_power_fraction", "Boron_concentration", "Enthalpy", "Fuel_power_fraction", "Fuel_temperature", "Kinetic_reactivity", "Liquid_power", "Mass_flux", "Mass_fraction", "Mass_title", "Mixture_density", "Mixture_specific_enthalpy", "Mixture_temperature", "Neutronic_power", "Outlet_pressure", "Pollutant_concentration", "Pressure ", "Rowlands_fuel_effective_temp", "Thermal_power", "Water_density", "Water_temperature", "Power_level" ) +listeDesSortiesNeutro = ( "Boron_concentration", "Kinetic_reactivity", "Neutronic_power", ) +listeDesSortiesTherm = ("Average_mass_flux", "Boiling_power_fraction", "Enthalpy", "Fuel_temperature", "Liquid_power", "Mass_flux", "Mass_fraction", "Mass_title", "Mixture_density", "Mixture_specific_enthalpy", "Mixture_temperature", "Outlet_pressure", "Pollutant_concentration", "Pressure ", "Rowlands_fuel_effective_temp", "Thermal_power", "Water_density", "Water_temperature", ) +dicoDesSortiesPossibles={'Neutro':listeDesSortiesNeutro,'Thermo':listeDesSortiesTherm} +#dicoDesSortiesPossibles={'Neutro':listeDesSortiesNeutro} from cata_UQ import creeOperExpressionIncertitude -ExpressionIncertitude=creeOperExpressionIncertitude(dictUQ, listeDesSortiesPossibles) +ExpressionIncertitude=creeOperExpressionIncertitude(dictUQ, dicoDesSortiesPossibles) @@ -34,5 +39,5 @@ autonome=0 if autonome : from Accas import * JdC = JDC_CATA(code="UQ"); - ExpressionIncertitude = creeOperExpressionIncertitude(dictUQ, listeDesSortiesPossibles); + ExpressionIncertitude = creeOperExpressionIncertitude(dictUQ, dicoDesSortiesPossibles); diff --git a/ReacteurNumerique/cata_UQ.py b/ReacteurNumerique/cata_UQ.py index 72a81ebb..be11b53c 100644 --- a/ReacteurNumerique/cata_UQ.py +++ b/ReacteurNumerique/cata_UQ.py @@ -1574,18 +1574,18 @@ def creeUserDefined (): # # -def affineDistribution(monDico,var,loi): - nomLoi=list(monDico[var].keys())[0] +def affineDistribution(monDicoVarDeter,var,loi): + nomLoi=list(monDicoVarDeter[var].keys())[0] argsLoi=loi[nomLoi] nomFonction='cree'+nomLoi maFonction=globals()[nomFonction] bloc=maFonction(**argsLoi) -def creeDistributionsSelonVariable(monDico): +def creeDistributionsSelonVariable(monDicoVarDeter): lesBlocs={} - for var in monDico : - listeLoisComplete=monDico[var] + for var in monDicoVarDeter : + listeLoisComplete=monDicoVarDeter[var] listeChoix=[] for loi in listeLoisComplete: nomLoi=list(loi.keys())[0] @@ -1606,10 +1606,41 @@ def creeDistributionsSelonVariable(monDico): return lesBlocs +def creeOutput(monDicoVarSortie): + intoVariable=list(monDicoVarSortie.keys()) + if len(intoVariable) == 1 : + listeDesVariablesSortiePossibles = monDicoVarSortie[list(monDicoVarSortie.keys())[0]] + output = FACT (max=1, statut ='o', + VariableDeSortie = FACT ( max='**', statut ='o', + Physique = SIMP (statut = "o", typ = "TXM",into = intoVariable,defaut=intoVariable[0]), + NomDeLaVariable = SIMP ( statut = "o", typ = "TXM", into = listeDesVariablesSortiePossibles), + FonctionDAggregation = SIMP(statut = 'o', typ= 'TXM', into = ('Max', 'Min', 'Med', 'Moy', 'Sum'),defaut=('Max'), max='**', homo='SansOrdreNiDoublon'), + Unit = SIMP ( statut = "f", typ = "TXM", fr = "Unite", ang = "Unit",), + Format = SIMP ( statut = "f", typ = "TXM", fr = "Format de sortie", ang = "format", into =['med', 'csv']), + ), + ) + return output + else : + lesBlocs={} + Physique = SIMP (statut = "o", typ = "TXM",into = intoVariable,defaut=intoVariable[0]) + for phys in intoVariable : + laCondition ="Physique == '" + phys + "'" + NomDeLaVariable = SIMP ( statut = "o", typ = "TXM", into = monDicoVarSortie[phys], ) + nomBloc = 'b_physique_' + phys + lesBlocs[nomBloc] = BLOC (condition=laCondition, NomDeLaVariable = NomDeLaVariable) + FonctionDAggregation = SIMP(statut = 'o', typ= 'TXM', into = ('Max', 'Min', 'Med', 'Moy', 'Sum'),defaut=('Max'), max='**', homo='SansOrdreNiDoublon') + Unit = SIMP ( statut = "f", typ = "TXM", fr = "Unite", ang = "Unit",) + Format = SIMP ( statut = "f", typ = "TXM", fr = "Format de sortie", ang = "format", into =['med', 'csv']) + VariableDeSortie = FACT ( max='**', statut ='o', Physique=Physique, **lesBlocs, FonctionDAggregation=FonctionDAggregation, Unit=Unit,Format=Format) + output = FACT (max=1, statut ='o', VariableDeSortie=VariableDeSortie) + return output + + + -def creeOperExpressionIncertitude(monDico, maListe): - listeDesVariablesPossibles = list(monDico.keys()) - listeDesVariablesSortiePossibles = maListe +def creeOperExpressionIncertitude(monDicoVarDeter, monDicoVarSortie): + listeDesVariablesPossibles = list(monDicoVarDeter.keys()) + monOutput = creeOutput(monDicoVarSortie) modelVariable = SIMP ( statut = "o", typ = ( 'TXM'), fr = "Variable d'entrée du modèle", @@ -1620,7 +1651,7 @@ def creeOperExpressionIncertitude(monDico, maListe): ) laConsigne = SIMP(statut="o", homo="information", typ="TXM", defaut=' ') xPathVariable = SIMP(statut='d', typ='TXM', defaut=(), max='**', min=0,) - blocs=creeDistributionsSelonVariable(monDico) + blocs=creeDistributionsSelonVariable(monDicoVarDeter) # Attention # l ordre des motclefs en 3.7 a l air de dépendre de l ordre de creation des objets # et non d un dict ordonné. on retombe toujours sur ce pb @@ -1682,15 +1713,7 @@ def creeOperExpressionIncertitude(monDico, maListe): Methode = SIMP( statut = "o", typ = "TXM", max=1, into = ('SRS', 'Sobol'), defaut='Sobol'), ), # fin UraniePropagation ), # fin Propagation - Output = FACT (max=1, statut ='o', - VariableDeSortie = FACT ( max='**', statut ='o', - NomDeLaVariable = SIMP ( statut = "o", typ = "TXM", into = listeDesVariablesSortiePossibles, defaut='Average_mass_flux'), - Physique = SIMP (statut = "o", typ = "TXM",into = ('Neutronics', 'ThermoHydraulics'),defaut='Neutronics'), - FonctionDAggregation = SIMP(statut = 'o', typ= 'TXM', into = ('Max', 'Min', 'Med', 'Moy', 'Sum'),defaut=('Max'), max='**', homo='SansOrdreNiDoublon'), - Unit = SIMP ( statut = "f", typ = "TXM", fr = "Unite", ang = "Unit",), - Format = SIMP ( statut = "f", typ = "TXM", fr = "Format de sortie", ang = "format", into =['med', 'csv']), - ), - ), + Output=monOutput, Execution = FACT (max=1, statut ='o', bloc_OT = BLOC (condition = 'UncertaintyTool == "OpenTurns"', ExecutionMode = SIMP ( statut = "o", typ = "TXM", into = ['local', 'cluster']), -- 2.39.2