Salome HOME
matrice coloree
[tools/eficas.git] / VirtualPolymer / VP_Cata_V2.py
1 # coding: utf-8\r
2 import types\r
3 from Accas import *\r
4 \r
5 import lienDB\r
6 import listesDB\r
7 \r
8 monDico= { 'Equation_Liste' : ('initiation', 'propagation', 'termination', 'stabilization'),\r
9            'Modele_TechnicalUse' : ('cable', 'coating', 'pipes'),\r
10            'Aging_Factor' : { 'predefinedSimulationTime' : ('40years BR top', '40years BR bottom')},\r
11            'Boundary_Conditions' : ('flux_volume','flux_surface','constant_constration','convection_flux'),\r
12            'postTraitement_Typ' : ('chimique','mecanique','physique'),\r
13          }\r
14 \r
15 monModele=listesDB.sModele().monModele\r
16 monPost=listesDB.sModele().monPost\r
17 \r
18 import types\r
19 class Tuple:\r
20     def __init__(self,ntuple):\r
21         self.ntuple=ntuple\r
22 \r
23     def __convert__(self,valeur):\r
24         if type(valeur) == types.StringType:\r
25             return None\r
26         if len(valeur) != self.ntuple:\r
27             return None\r
28         return valeur\r
29 \r
30     def info(self):\r
31         return "Tuple de %s elements" % self.ntuple\r
32 \r
33 \r
34 JdC = JDC_CATA(code='VP',\r
35                execmodul=None,\r
36                 )\r
37 \r
38 \r
39 #---------------------------------\r
40 Equation = PROC (nom="Equation",\r
41       op=None,\r
42 #---------------------------------\r
43       Equation_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base") ),\r
44       #b_suite = BLOC(condition = "Equation_DB ==  'My data base' ",\r
45       Equation_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show equation database", "Equation creation"),),\r
46       #),\r
47       #b_suite_2 = BLOC(condition = "Equation_DB ==  'Approved data base' ",\r
48       #Equation_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show equation database", ),),\r
49       #),\r
50 \r
51 #     ---------------------------------------------------------------------------\r
52        b_type_show = BLOC(condition = " Equation_Type == 'Show equation database'",\r
53 #      ---------------------------------------------------------------------------\r
54         Equation_Liste=SIMP(statut= 'o',typ= 'TXM', into=('reaction_type','aging_type')),\r
55 \r
56          b_reaction_type =  BLOC(condition = " Equation_Liste  == 'reaction_type'",\r
57            Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=monDico['Equation_Liste'],siValide=lienDB.recupereDicoEquation),\r
58          ), # Fin b_reaction_type\r
59 \r
60          b_aging_type =  BLOC(condition = " Equation_Liste  == 'aging_type'",\r
61               Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=('All', 'thermo', 'radio'),siValide=lienDB.recupereDicoEquation),\r
62          ), # Fin b_reaction_type\r
63 \r
64          ListeEquation = SIMP(statut='o', typ='TXM',  homo='SansOrdreNiDoublon',siValide=lienDB.afficheValeurEquation),\r
65          #ListeEquation = SIMP(statut='o', typ='TXM',  homo='SansOrdreNiDoublon'),\r
66          b_modification = BLOC(condition = " ListeEquation != None ",\r
67            modification = SIMP(typ = bool, statut = 'o',defaut = False, fr='toto', ang='toto en anglais', siValide=lienDB.instancieChemicalFormulation),\r
68 \r
69            b_modif = BLOC(condition = "modification == True",\r
70             Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],),\r
71             Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),),\r
72             ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'),\r
73 \r
74             OptionnelConstituant =  FACT ( statut = 'f',max = '**',\r
75                 Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
76                 Differential_Equation =  SIMP(statut= 'o',typ= 'TXM'),\r
77                ), # fin Const_Equa\r
78             OptionnelleConstante  = FACT (statut = 'f', max = '**',\r
79                   ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
80                   ConstanteType =  SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
81                   ),# fin ConstanteOptionnelle\r
82             Commentaire =  SIMP (statut = 'f', typ = 'TXM', defaut = ' '),\r
83 \r
84 \r
85            ),# fin b_modif\r
86 \r
87          ), # fin b_modification\r
88        ), # Fin b_type_show\r
89 \r
90 \r
91 #     ---------------------------------------------------------------------------\r
92       b_type_creation = BLOC(condition = " Equation_Type == 'Equation creation'",\r
93 #         ---------------------------------------------------------------------------\r
94          Equation_Modification = FACT ( statut = 'o',\r
95 \r
96             ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'),\r
97 \r
98             Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],),\r
99             Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),),\r
100 \r
101             Constituants = FACT ( statut = 'o',\r
102                ConstituantPOOH = SIMP (statut = 'f', typ = 'TXM', into = ('POOH',)),\r
103                b_pooh =  BLOC(condition = " ConstituantPOOH == 'POOH'" ,\r
104                   Differential_Equation_POOH =  SIMP(statut= 'o',typ= 'TXM', defaut = '-ku1*POOH'),\r
105                ), # Fin b_pooh\r
106                #ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',)),\r
107                #b_p =  BLOC(condition = " ConstituantP == 'P'" ,\r
108                #  Differential_Equation_P =  SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'),\r
109                #), # Fin b_p\r
110                ConstituantP = FACT ( statut = 'f',\r
111                   ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',)),\r
112                   Differential_Equation_P =  SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'),\r
113                ), # Fin ConstituantP\r
114 \r
115             OptionnelConstituant =  FACT ( statut = 'f',max = '**',\r
116                 Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
117                 Differential_Equation =  SIMP(statut= 'o',typ= 'TXM'),\r
118                ), # fin Const_Equa\r
119             ),# Fin Constituants\r
120 \r
121             Constante = FACT ( statut = 'o',\r
122                Constanteku1 = SIMP (statut = 'f', typ = 'TXM', into = ('ku1',), defaut= 'ku1'),\r
123                b_cku1 =  BLOC(condition = "Constanteku1 == 'ku1'" ,\r
124                   ConstanteType =  SIMP(statut= 'o',typ= 'TXM', into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
125                   ),\r
126                OptionnelleConstante  = FACT (statut = 'f', max = '**',\r
127                   ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
128                   ConstanteType =  SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
129                   ),# fin ConstanteOptionnelle\r
130             ), # fin constante\r
131             Commentaire =  SIMP (statut = 'f', typ = 'TXM', defaut = ' '),\r
132 \r
133          ), # Fin Equation_Modification\r
134         ),  # fin b_type_creation\r
135 \r
136 \r
137 ) # Fin Equation\r
138 \r
139 #---------------------------------\r
140 Modele = PROC (nom="Modele",\r
141       op=None,\r
142       Modele_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base"),siValide=lienDB.recupereDicoModele ),\r
143       Modele_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show modele database", "Modele creation"),siValide=lienDB.creeListeEquation),\r
144 #     ---------------------------------------------------------------------------\r
145       b_type_creation = BLOC(condition = " Modele_Type == 'Modele creation'",\r
146 #         ---------------------------------------------------------------------------\r
147         ID=FACT(statut='o',\r
148           technicalUse= SIMP(statut= 'o',typ= 'TXM',into=monDico['Modele_TechnicalUse'],defaut=monModele.technical_use ),\r
149           modeleName=SIMP(statut='o',typ='TXM',defaut=monModele.nom,),\r
150           material=SIMP(statut='o',typ='TXM',defaut=monModele.materiaux[0],),\r
151           agingType=SIMP(statut= 'o',typ='TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'), defaut=monModele.type_vieil),\r
152           stabilizer = SIMP(typ = bool, statut = 'o',defaut = monModele.stabilise),\r
153           material_thickness = SIMP(typ = 'TXM', statut = 'o',defaut = monModele.thickness, into = ['thin','thick']),\r
154           # il faudrait que position=global_jdc fonctionne\r
155           model_developed_by_for_EDF = SIMP(typ = bool, statut = 'o',defaut = monModele.dvt_EDF[0]),\r
156           documentation=SIMP(statut='o',typ='TXM',defaut=monModele.reference,),\r
157 \r
158        ), # fin ID\r
159        # ajouter la liste des equations et le remove (il faut garder ceux qu on a enlever)\r
160 \r
161       Chemical_Equation = FACT( statut='o',\r
162        Initial_Equation_List=SIMP(statut='o',typ='TXM',max="**",homo='SansOrdreNiDoublon',into=[],defaut=[], siValide=lienDB.recupereModeleEquation),\r
163 \r
164        AjoutEquation=SIMP(statut= 'o',typ= bool, defaut=False, siValide=lienDB.recupereModeleEquation),\r
165        b_ajout_equation = BLOC(condition = " AjoutEquation == True",\r
166           listeEquation_initiation=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[],siValide=lienDB.ajoutDUneEquation ),\r
167           listeEquation_propagation=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[],siValide=lienDB.ajoutDUneEquation ),\r
168           listeEquation_termination=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[],siValide=lienDB.ajoutDUneEquation ),\r
169           listeEquation_stabilization=SIMP(statut='o',typ='TXM', homo='SansOrdreNiDoublon', max='**', min=0, defaut=[],siValide=lienDB.ajoutDUneEquation ),\r
170        ),# fin b_ajout_equation\r
171 \r
172       ), # fin Equation\r
173         # coefficients monModele.coef = liste de dictionnaire mais il faut prendre que le 0\r
174         # on enleve ceux qui commence par D, S et B(casse imprtante)\r
175         # la clef est le coef, puis les valeurs\r
176 \r
177 \r
178       #b_material_thickness =  BLOC(condition = "material_thickness == 'thick'",\r
179       # si position=global fonctionne\r
180         Transport = FACT( statut = 'o',\r
181         #Diffusion = SIMP(typ = bool, statut = 'o',defaut = monModele.diffusion,siValide = lienDB.prepareDiffusion),\r
182         Diffusion = SIMP(typ = bool, statut = 'o',defaut = False ,siValide = lienDB.prepareDiffusion),\r
183 \r
184         b_diffusion = BLOC(condition = " Diffusion == True",\r
185            listeProduitPourLaDiffusion=SIMP(statut='o', typ='TXM', max='**', min=1,homo='SansOrdreNiDoublon', into = [],siValide=lienDB.ajouteDiffusion),\r
186           ),  # fin b_diffusion\r
187 \r
188         Evaporation = SIMP(typ = bool, statut = 'o',defaut = False ,siValide = lienDB.prepareDiffusion),\r
189         b_evaporation = BLOC(condition = " Evaporation == True",\r
190            listeProduitPourLEvaporation=SIMP(statut='o', typ='TXM', max='**', min=1,homo='SansOrdreNiDoublon', into = [],siValide=lienDB.ajouteEvaporation),\r
191          ),  # fin b_evaporation\r
192 \r
193 \r
194          ),  # fin TRANSPORT\r
195        #),  # fin b_material_thickness\r
196 \r
197       Coefficients = FACT( statut = 'o',\r
198         Coef_k2  = SIMP (statut ='o', typ='R'),\r
199         Coef_ku1 = SIMP (statut ='o', typ=Tuple(2),validators = VerifTypeTuple(('R','R')),),\r
200       ),\r
201       Parametres_Initiaux = FACT( statut = 'o',\r
202         Param_POOH=SIMP (statut ='o', typ='R'),\r
203         # La liste est la meme que le INTO des listeProduitsPourlaDiffusion\r
204         # la valeur par defaut si elle existe est contenue dans modele.param_ini['POOH']\r
205       ),\r
206 \r
207 \r
208        #AjoutEquation=Fact(statut='f',\r
209        #     Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],siValide=lienDB.recupereModeleEquation),\r
210        #), # fin AjoutEquation\r
211       ), # fin Creation\r
212 #     ---------------------------------------------------------------------------\r
213       b_type_modification = BLOC(condition = " Modele_Type == 'Show modele database'",\r
214 #         ---------------------------------------------------------------------------\r
215           technicalUse= SIMP(statut= 'o',typ= 'TXM',into=monDico['Modele_TechnicalUse'],siValide=lienDB.creeListeMateriauxSelonModele),\r
216           b_technicalUse = BLOC (condition = 'technicalUse != None and technicalUse != ""',\r
217             material= SIMP (statut ='o', typ='TXM',siValide=lienDB.creeListeModelesPossibles),\r
218             modele= SIMP (statut ='o', typ='TXM',siValide=lienDB.choisitModele),\r
219             b_modele = BLOC (condition = 'modele != None and modele != ""',\r
220               action = SIMP (statut ='o', typ='TXM',into = ['display','use','modify'], siValide=lienDB.choisitActionModele),\r
221 #     ---------------------------------------------------------------------------\r
222            b_type_modify = BLOC(condition = " action == 'modify'",\r
223 #         ---------------------------------------------------------------------------\r
224           ID=FACT(statut='o',\r
225           modeleName=SIMP(statut='o',typ='TXM'),\r
226           technicalUse= SIMP(statut= 'o',typ= 'TXM', into=monDico['Modele_TechnicalUse'] ),\r
227           material=SIMP(statut='o',typ='TXM'),\r
228           agingType=SIMP(statut= 'o',typ='TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio')),\r
229           stabilizer = SIMP(typ = bool, statut = 'o',),\r
230           material_thickness = SIMP(typ = 'TXM', statut = 'o', into = ['thin','thick']),\r
231           # il faudrait que position=global_jdc fonctionne\r
232           model_developed_by_for_EDF = SIMP(typ = bool, statut = 'o',),\r
233           documentation=SIMP(statut='o',typ='TXM',),\r
234 \r
235 \r
236 # il faut recopier toute la suite en changeant eventuellement le nom du modele\r
237 # il faut cocher toutes les equations par defaut\r
238 \r
239               ), # fin ID\r
240              ), # fin b_type_modify\r
241 #     ---------------------------------------------------------------------------\r
242            b_type_use = BLOC(condition = " action == 'use'",\r
243 #         ---------------------------------------------------------------------------\r
244              simulationName=SIMP(statut='o',typ='TXM'),\r
245              outputFolder = SIMP(statut="o", typ="Repertoire",siValide=lienDB.creeCoefAModifier),\r
246             ), # fin b_type_use\r
247 #     ---------------------------------------------------------------------------\r
248            b_type_use2 = BLOC(condition = " action == 'use'",\r
249 #         ---------------------------------------------------------------------------\r
250             Aging_Factor = FACT(statut='o',\r
251                 predefinedSimulationTime = SIMP(statut='o',typ='TXM',into=monDico['Aging_Factor']['predefinedSimulationTime'],siValide=lienDB.remplirAgingFactor),\r
252                 simulationTime=SIMP(statut='o',typ='R',),\r
253                 numberOfNodes=SIMP(statut='o',typ='I',val_min=3,siValide=lienDB.creeInitialParameter),\r
254                 sampleThickness=SIMP(statut='o',typ='R',),\r
255                 #debitOfDose=SIMP(statut='o',typ='R',),\r
256                 temperature=SIMP(statut='o',typ='R',),\r
257                 oxygenPressure=SIMP(statut='o',typ='R',),\r
258                 polymerConcentration=SIMP(statut='o',typ='R',),\r
259                 ),\r
260             Initial_Parameter = FACT(statut='o',\r
261                 max='**',\r
262                 ),\r
263             Boundary_Conditions_Param = FACT(statut='o',\r
264                 diffusionSpecies=SIMP(statut='o',typ='TXM',defaut='O2', into=['O2',]),\r
265                 nodeNumber = SIMP(statut='o',typ='I',defaut=1, into=[1]), # tjours1\r
266                 Boundary_Conditions_O2_1 = SIMP(statut='o',typ='TXM',into=monDico['Boundary_Conditions']),\r
267                 BC_Value_Espece_1=SIMP(statut='o',typ='R'),\r
268                 nodeNumber_Espece_4 = SIMP(statut='o',typ='I',defaut=4, into=[4]), # numberOfNodes+1\r
269                 Boundary_Conditions_Espece_4 = SIMP(statut='o',typ='TXM',into=monDico['Boundary_Conditions']),\r
270                 BC_Value_Espece_4=SIMP(statut='o',typ='R'),\r
271                 ),\r
272 \r
273             ), # fin b_type_use2\r
274           ), # fin b_modele\r
275         ), # fin b_technicalUse\r
276       ), # fin modification\r
277 \r
278       Commentaire =  SIMP (statut = 'f', typ = 'TXM'),\r
279 ) # Fin Modele\r
280 #---------------------------------\r
281 PostTraitement = PROC (nom="PostTraitement",\r
282       op=None,\r
283       postTraitement_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base") ),\r
284       postTraitement_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show post-traitement database", "post-traitement creation"),),\r
285 #     ---------------------------------------------------------------------------\r
286       b_post_creation = BLOC(condition = " postTraitement_Type == 'post-traitement creation'",\r
287         postTraitement_Name=SIMP(statut= 'o',typ= 'TXM',defaut=monPost.nom,),\r
288         generic=SIMP(statut= 'o',typ= bool,defaut=monPost.general,),\r
289         postTraitement_Typ = SIMP(statut= 'o',typ= 'TXM', into=monDico['postTraitement_Typ'],homo='SansOrdreNiDoublon',max='**',defaut=monPost.type_post),\r
290         calculation= FACT(statut='o',\r
291         # il faut un fact horizontal\r
292         calculation_results=SIMP(statut= 'o',typ= 'TXM', min=0,max='**', intoSug=monPost.calculation_results,defaut=monPost.calculation_results),\r
293         results_units=SIMP(statut= 'o',typ= 'TXM', min=0,max='**', intoSug=monPost.results_units,defaut=monPost.results_units),\r
294         #integrate=SIMP(statut= 'o',typ= 'TXM', min=0,max='**', intoSug=monPost.results_units,defaut=monPost.results_units),\r
295         prerequisite=SIMP(statut= 'o',typ= 'TXM', min=0,max='**', intoSug=monPost.prerequisite,defaut=monPost.prerequisite),\r
296 \r
297         ),\r
298         constituant=SIMP(statut= 'o',typ= 'TXM', min=0,max='**', intoSug=monPost.constituants,defaut=monPost.constituants)\r
299 \r
300       )# fin b_post_creation\r
301 #         ---------------------------------------------------------------------------\r
302 #---------------------------------\r
303 ) #PostTraitement\r