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.
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.
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 # ======================================================================
21 from math import cos,exp,pi
23 def FcompletGR1(T,I1,I2,FR,TR,PHI1,PHI2,TAU1,TAU2) :
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.))
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
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.))
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
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.))
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
66 def defi_fonc_elec_ops(self,FREQ,SIGNAL,COUR,COUR_PRIN,COUR_SECO,**args):
68 from Utilitai.Utmess import UTMESS
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')
77 ### Comptage commandes + déclaration concept sortant
79 self.DeclareOut('C_out',self.sd)
82 TINI =COUR[ 0]['INST_CC_INIT']
83 TFIN =COUR[-1]['INST_CC_FIN']
89 T2moins = COUR[0]['INST_CC_FIN']
90 TR = COUR[0]['INST_CC_INIT']
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
105 temps.append(T2moins)
109 t_k_cour=Numeric.arange((T2-T1)/pas_t)
110 t_k_cour=t_k_cour*pas_t
112 t_k_cour=t_k_cour.tolist()
115 if SIGNAL=='CONTINU' :
117 fff.append( FcontinuGR1(t,I1,I2,TR,PHI1,PHI2,TAU1,TAU2) )
118 elif SIGNAL=='COMPLET' :
120 fff.append(FcompletGR1(t,I1,I2,FREQ,TR,PHI1,PHI2,TAU1,TAU2))
123 TINI =COUR_PRIN[0]['INST_CC_INIT']
124 TFIN =COUR_PRIN[0]['INST_CC_FIN']
126 TINIR = COUR_PRIN[0]['INST_RENC_INIT']
127 TFINR = COUR_PRIN[0]['INST_RENC_FIN']
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']
145 if (abs(TR-T2moins)<1.E-7) : pass
148 t_k_cour=Numeric.arange((T2moins-TR)/pas_t)
149 t_k_cour=t_k_cour*pas_t
151 t_k_cour=t_k_cour.tolist()
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']
163 if SIGNAL=='CONTINU' :
164 for i in range(len(temps)) :
167 fff[i]=fff[i]+FcontinuGR2(temps[i],I1,I2,TR,PHI1,PHI2,TAU1,TAU2,DIST)
170 fff[i]=fff[i]+FcontinuGR2R(temps[i],I1R,I2R,TRR,PHI1R,PHI2R,TAU1R,TAU2R,DIST)
172 if SIGNAL=='COMPLET' :
173 for i in range(len(temps)) :
176 fff[i]=fff[i]+FcompletGR2(temps[i],I1,I2,TR,PHI1,PHI2,TAU1,TAU2,DIST)
179 fff[i]=fff[i]+FcompletGR2R(temps[i],I1R,I2R,TRR,PHI1R,PHI2R,TAU1R,TAU2R,DIST)
182 for i in range(len(temps)) :
183 vale.append(temps[i])
185 vale.append(temps[-1]+2*pas_t)
188 C_out=DEFI_FONCTION(NOM_PARA='INST',NOM_RESU='ELEC',
190 PROL_DROITE='CONSTANT',
191 PROL_GAUCHE='CONSTANT',)