]> SALOME platform Git repositories - tools/eficas.git/blob - Aster/Cata/cataSTA9/Macro/defi_fonc_elec_ops.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Aster / Cata / cataSTA9 / Macro / defi_fonc_elec_ops.py
1 #@ MODIF defi_fonc_elec_ops Macro  DATE 09/02/2010   AUTEUR MACOCCO K.MACOCCO 
2 # -*- coding: iso-8859-1 -*-
3 #            CONFIGURATION MANAGEMENT OF EDF VERSION
4 # ======================================================================
5 # COPYRIGHT (C) 1991 - 2010  EDF R&D                  WWW.CODE-ASTER.ORG
6 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY  
7 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY  
8 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR     
9 # (AT YOUR OPTION) ANY LATER VERSION.                                                  
10 #                                                                       
11 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT   
12 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF            
13 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU      
14 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.                              
15 #                                                                       
16 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE     
17 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,         
18 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.        
19 # ======================================================================
20
21 from math import cos,exp,pi
22
23 def FcompletGR1(T,I1,I2,FR,TR,PHI1,PHI2,TAU1,TAU2) :
24     fxt= 4.E-7 * I1 * I2
25     fxt= fxt * (cos(2*pi*FR*(T-TR)+PHI1*pi/180.)-exp(-(T-TR)/TAU1)*cos(PHI1*pi/180.))
26     fxt= fxt * (cos(2*pi*FR*(T-TR)+PHI2*pi/180.)-exp(-(T-TR)/TAU2)*cos(PHI2*pi/180.))
27     return fxt
28
29 def FcontinuGR1(T,I1,I2,TR,PHI1,PHI2,TAU1,TAU2) :
30     ft1= exp(-(T-TR)*(1./TAU1+1./TAU2))
31     ft1= ft1*cos(PHI1*pi/180.)*cos(PHI2*pi/180.)
32     ft1= ft1+0.5*cos(PHI2*pi/180.-PHI1*pi/180.)
33     fxt= 4.E-7 * I1 * I2 * ft1
34     return fxt
35
36 def FcompletGR2(T,I1,I2,FR,TR,PHI1,PHI2,TAU1,TAU2,D) :
37     fxt= 4.E-7 * I1 * I2 / D
38     fxt= fxt * (cos(2*pi*FR*(T-TR)+PHI1*pi/180.)-exp(-(T-TR)/TAU1)*cos(PHI1*pi/180.))
39     fxt= fxt * (cos(2*pi*FR*(T-TR)+PHI2*pi/180.)-exp(-(T-TR)/TAU2)*cos(PHI2*pi/180.))
40     return fxt
41
42 def FcontinuGR2(T,I1,I2,TR,PHI1,PHI2,TAU1,TAU2,D) :
43     ft1= exp(-(T-TR)*(1./TAU1+1./TAU2))
44     ft1= ft1*cos(PHI1*pi/180.)*cos(PHI2*pi/180.)
45     ft1= ft1+0.5*cos(PHI2*pi/180.-PHI1*pi/180.)
46     fxt= 4.E-7 * I1 * I2 * ft1 / D
47     return fxt
48
49 ## fonction post réenclenchement, valable entre l'instant de réenclenchement et l'instant de fin de réenclenchement. Sinon 0.
50 def FcompletGR2R(T,I1R,I2R,FR,TRR,PHIR1,PHI2R,TAU1R,TAU2R,D) :
51     fxt= 4.E-7 * I1R * I2R / D
52     fxt= fxt * (cos(2*pi*FR*(T-TRR)+PHI1R*pi/180.)-exp(-(T-TRR)/TAU1R)*cos(PHI1R*pi/180.))
53     fxt= fxt * (cos(2*pi*FR*(T-TRR)+PHI2R*pi/180.)-exp(-(T-TRR)/TAU2R)*cos(PHI2R*pi/180.))
54     return fxt
55
56 ## fonction post réenclenchement, valable entre l'instant de réenclenchement et l'instant de fin de réenclenchement. Sinon 0.
57 def FcontinuGR2R(T,I1R,I2R,TRR,PHI1R,PHI2R,TAU1R,TAU2R,D) :
58     ft1= exp(-(T-TRR)*(1./TAU1R+1./TAU2R))
59     ft1= ft1*cos(PHI1R*pi/180.)*cos(PHI2R*pi/180.)
60     ft1= ft1+0.5*cos(PHI2R*pi/180.-PHI1R*pi/180.)
61     fxt= 4.E-7 * I1R * I2R * ft1 / D
62     return fxt
63
64
65
66 def defi_fonc_elec_ops(self,FREQ,SIGNAL,COUR,COUR_PRIN,COUR_SECO,**args):
67         ier=0
68         from Utilitai.Utmess     import  UTMESS
69         import Numeric
70
71         # On importe les definitions des commandes a utiliser dans la macro
72         # Le nom de la variable doit etre obligatoirement le nom de la commande
73         DEFI_FONCTION     =self.get_cmd('DEFI_FONCTION')
74         FORMULE           =self.get_cmd('FORMULE')
75         CALC_FONC_INTERP  =self.get_cmd('CALC_FONC_INTERP')
76
77         ### Comptage commandes + déclaration concept sortant
78         self.set_icmd(1)
79         self.DeclareOut('C_out',self.sd)
80 #
81         if COUR : 
82                 TINI =COUR[ 0]['INST_CC_INIT']
83                 TFIN =COUR[-1]['INST_CC_FIN']
84                 pas_t=1./(40.*FREQ)
85 #
86                 temps   = []
87                 fff     = []
88 #
89                 T2moins = COUR[0]['INST_CC_FIN']
90                 TR      = COUR[0]['INST_CC_INIT']
91                 premier = 1
92                 for k_cour in COUR :
93                         I1   = k_cour['INTE_CC_1']
94                         I2   = k_cour['INTE_CC_2']
95                         PHI1 = k_cour['PHI_CC_1']
96                         PHI2 = k_cour['PHI_CC_2']
97                         TAU1 = k_cour['TAU_CC_1']
98                         TAU2 = k_cour['TAU_CC_2']
99                         T1   = k_cour['INST_CC_INIT']
100                         T2   = k_cour['INST_CC_FIN']
101                         if (abs(T1-T2moins)<1.E-7) : pass
102                         elif (premier==1)          : pass
103                         else :
104                                 TR=T1
105                                 temps.append(T2moins)
106                                 fff.append(0.)
107                                 T2moins=T2
108                         premier=0
109                         t_k_cour=Numeric.arange((T2-T1)/pas_t)
110                         t_k_cour=t_k_cour*pas_t
111                         t_k_cour=t_k_cour+T1
112                         t_k_cour=t_k_cour.tolist()
113                         print T1,T2,FREQ
114                         temps=temps+t_k_cour
115                         if   SIGNAL=='CONTINU' :
116                                 for t in t_k_cour :
117                                   fff.append( FcontinuGR1(t,I1,I2,TR,PHI1,PHI2,TAU1,TAU2) )
118                         elif SIGNAL=='COMPLET' :
119                                 for t in t_k_cour :
120                                   fff.append(FcompletGR1(t,I1,I2,FREQ,TR,PHI1,PHI2,TAU1,TAU2))
121 #
122         elif COUR_PRIN :
123                 TINI =COUR_PRIN[0]['INST_CC_INIT']
124                 TFIN =COUR_PRIN[0]['INST_CC_FIN']
125 #
126                 TINIR = COUR_PRIN[0]['INST_RENC_INIT']
127                 TFINR = COUR_PRIN[0]['INST_RENC_FIN']
128 #
129                 pas_t=1./(40.*FREQ)
130 #
131                 temps   = []
132                 fff     = []
133                 T2moins = max(TFIN,TFINR)
134                 TR      = COUR_PRIN[0]['INST_CC_INIT']
135                 TRR     = COUR_PRIN[0]['INST_RENC_INIT']
136                 I1      = COUR_PRIN[0]['INTE_CC_1']
137                 I1R     = COUR_PRIN[0]['INTE_RENC_1']
138                 PHI1    = COUR_PRIN[0]['PHI_CC_1']
139                 PHI1R   = COUR_PRIN[0]['PHI_RENC_1']
140                 TAU1    = COUR_PRIN[0]['TAU_CC_1']
141                 TAU1R   = COUR_PRIN[0]['TAU_RENC_1']
142 #
143                 fff.append(0.)
144 #
145                 if (abs(TR-T2moins)<1.E-7) : pass
146                 else :
147                         temps.append(0)
148                         t_k_cour=Numeric.arange((T2moins-TR)/pas_t)
149                         t_k_cour=t_k_cour*pas_t
150                         t_k_cour=t_k_cour+TR
151                         t_k_cour=t_k_cour.tolist()
152                         temps=temps+t_k_cour
153 #
154                 for k_cour in COUR_SECO :
155                         I2    = k_cour['INTE_CC_2']
156                         PHI2  = k_cour['PHI_CC_2']
157                         TAU2  = k_cour['TAU_CC_2']
158                         I2R   = k_cour['INTE_RENC_2']
159                         PHI2R = k_cour['PHI_RENC_2']
160                         TAU2R = k_cour['TAU_RENC_2']
161                         DIST  = k_cour['DIST']
162 #
163                         if SIGNAL=='CONTINU' :
164                            for i in range(len(temps)) :
165                                if temps[i]>TINI :
166                                   if temps[i]<TFIN :
167                                      fff[i]=fff[i]+FcontinuGR2(temps[i],I1,I2,TR,PHI1,PHI2,TAU1,TAU2,DIST)
168                                if temps[i]>TINIR :
169                                   if temps[i]<TFINR : 
170                                      fff[i]=fff[i]+FcontinuGR2R(temps[i],I1R,I2R,TRR,PHI1R,PHI2R,TAU1R,TAU2R,DIST)
171 #
172                         if SIGNAL=='COMPLET' :
173                            for i in range(len(temps)) :
174                                if temps[i]>TINI :
175                                   if temps[i]<TFIN :
176                                      fff[i]=fff[i]+FcompletGR2(temps[i],I1,I2,TR,PHI1,PHI2,TAU1,TAU2,DIST)
177                                if temps[i]>TINIR :
178                                   if temps[i]<TFINR : 
179                                      fff[i]=fff[i]+FcompletGR2R(temps[i],I1R,I2R,TRR,PHI1R,PHI2R,TAU1R,TAU2R,DIST)
180 #
181         vale=[]
182         for i in range(len(temps)) :
183               vale.append(temps[i])
184               vale.append(fff[i])
185         vale.append(temps[-1]+2*pas_t)
186         vale.append(0.)
187 #
188         C_out=DEFI_FONCTION(NOM_PARA='INST',NOM_RESU='ELEC',
189                             VALE=vale,
190                             PROL_DROITE='CONSTANT',
191                             PROL_GAUCHE='CONSTANT',)
192         return ier