1 #@ MODIF macr_spectre_ops Macro DATE 19/11/2007 AUTEUR COURTOIS M.COURTOIS
2 # -*- coding: iso-8859-1 -*-
3 # CONFIGURATION MANAGEMENT OF EDF VERSION
4 # ======================================================================
5 # COPYRIGHT (C) 1991 - 2006 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 # ======================================================================
26 from Utilitai.Utmess import UTMESS
30 def macr_spectre_ops(self,MAILLAGE,PLANCHER,NOM_CHAM,CALCUL,RESU,IMPRESSION=None,
31 FREQ=None,LIST_FREQ=None,LIST_INST=None,AMOR_SPEC=None,**args):
33 Ecriture de la macro MACR_SPECTRE
37 from types import ListType,TupleType,StringType
38 EnumType=(ListType,TupleType)
40 ### On importe les definitions des commandes a utiliser dans la macro
41 RECU_FONCTION = self.get_cmd('RECU_FONCTION')
42 CALC_FONCTION = self.get_cmd('CALC_FONCTION')
43 IMPR_FONCTION = self.get_cmd('IMPR_FONCTION')
44 CREA_TABLE = self.get_cmd('CREA_TABLE')
46 ### Comptage commandes + déclaration concept sortant
48 self.DeclareOut('tab',self.sd)
51 ### construction de la liste des noeuds à traiter
53 dic_gpno=aster.getcolljev(MAILLAGE.nom.ljust(8)+".GROUPENO")
54 l_nodes =aster.getvectjev(MAILLAGE.nom.ljust(8)+".NOMNOE")
56 for plancher in PLANCHER :
58 if plancher['NOEUD']!=None :
59 if type(plancher['NOEUD'])==StringType :
60 liste_no.append(plancher['NOEUD'])
62 for noeud in plancher['NOEUD'] :
63 liste_no.append(plancher['NOEUD'])
64 if plancher['GROUP_NO']!=None :
65 if type(plancher['GROUP_NO'])==StringType :
66 noms_no =[string.strip(l_nodes[n-1]) \
67 for n in dic_gpno[plancher['GROUP_NO'].ljust(8)]]
68 liste_no=liste_no+noms_no
70 for group_no in plancher['GROUP_NO'] :
71 noms_no =[string.strip(l_nodes[n-1]) \
72 for n in dic_gpno[group_no.ljust(8)]]
73 liste_no=liste_no+noms_no
74 planch_nodes[plancher['NOM']]=liste_no
75 l_plancher.append(plancher['NOM'])
77 if AMOR_SPEC!=None and type(AMOR_SPEC) not in EnumType :
78 AMOR_SPEC=(AMOR_SPEC,)
80 if NOM_CHAM=='ACCE' : dico_glob={}
81 if NOM_CHAM=='DEPL' : dico_glob={'DX_max' :[] ,
86 ############################################################
87 ### boucle 1 sur les planchers
88 for plancher in l_plancher :
91 __moy_x=[None]*len(planch_nodes[plancher])
92 __moy_y=[None]*len(planch_nodes[plancher])
93 __moy_z=[None]*len(planch_nodes[plancher])
96 ############################################################
97 ### boucle 2 sur les noeuds du plancher
99 for node in planch_nodes[plancher] :
101 ############################################################
102 ### boucle 3 sur les directions (X,Y,Z)
103 for dd in ('X','Y','Z') :
105 ############################################################
106 ### boucle 4 sur les résultats
109 ### Récupération des fonctions
111 if resu['RESU_GENE']!=None :
112 if CALCUL=='ABSOLU' :
113 UTMESS('F','SPECTRAL0_8')
114 motscles['RESU_GENE'] = resu['RESU_GENE']
116 if resu['RESULTAT' ]!=None :
117 motscles['RESULTAT'] = resu['RESULTAT']
119 __spo=RECU_FONCTION(NOM_CHAM = NOM_CHAM,
123 PROL_GAUCHE = 'CONSTANT',
124 PROL_DROITE = 'CONSTANT',
125 NOEUD = node , **motscles )
127 if NOM_CHAM=='ACCE' :
128 ### Accelerations relatives
129 if CALCUL=='RELATIF' :
130 ### Combinaison avec fonction d acceleration
132 if LIST_INST!=None : motscles['LIST_PARA']=LIST_INST
133 __spo=CALC_FONCTION(COMB=(_F(FONCTION=__spo,
135 _F(FONCTION=resu['ACCE_'+dd],
136 COEF= 1.0) ),**motscles )
138 ### Calcul des spectres d'oscillateur
140 if FREQ !=None : motscles['FREQ'] =FREQ
141 if LIST_FREQ!=None : motscles['LIST_FREQ']=LIST_FREQ
143 SPEC_OSCI=_F(FONCTION = __spo,
144 AMOR_REDUIT = AMOR_SPEC,
145 NORME = args['NORME'],
149 if NOM_CHAM=='DEPL' :
150 if CALCUL=='ABSOLU' :
151 ### On retranche les deplacements d entrainement
153 if LIST_INST!=None : motscles['LIST_PARA']=LIST_INST
154 __spo=CALC_FONCTION(COMB=(_F(FONCTION=__spo,
156 _F(FONCTION=resu['DEPL_'+dd],
157 COEF= -1.0) ),**motscles )
161 ### fin boucle 4 sur les résultats
162 ############################################################
164 ############################################################
165 ### calcul de la moyenne sur les resultats à noeud et direction fixes
167 if NOM_CHAM=='ACCE' :
172 mcfCMBx.append(_F(FONCTION=spo,
173 COEF=1./float(nbresu),))
174 mcfCMBy.append(_F(FONCTION=spo,
175 COEF=1./float(nbresu),))
176 mcfCMBz.append(_F(FONCTION=spo,
177 COEF=1./float(nbresu),))
179 if LIST_FREQ!=None : motscles['LIST_PARA']=LIST_FREQ
180 if dd=='X' : __moy_x[indexn]=CALC_FONCTION(COMB=mcfCMBx,**motscles)
181 if dd=='Y' : __moy_y[indexn]=CALC_FONCTION(COMB=mcfCMBy,**motscles)
182 if dd=='Z' : __moy_z[indexn]=CALC_FONCTION(COMB=mcfCMBz,**motscles)
184 if NOM_CHAM=='DEPL' :
189 vmax = aspo.extreme()['max']
190 moy = moy + vmax[-1][-1]
191 dicDmax[(node,dd)]=moy/nbresu
193 ### fin boucle 3 sur les directions
194 ############################################################
196 ################################
197 ### impressions en chaque noeud
198 if NOM_CHAM=='ACCE' and IMPRESSION!=None :
199 if IMPRESSION['TOUT']=='OUI' :
200 __moyxa=[None]*len(AMOR_SPEC)
201 __moyya=[None]*len(AMOR_SPEC)
202 __moyza=[None]*len(AMOR_SPEC)
203 for i in range(len(AMOR_SPEC)) :
205 __moyxa[i]=RECU_FONCTION(NAPPE = __moy_x[indexn],
206 VALE_PARA_FONC = AMOR_SPEC[i] )
207 __moyya[i]=RECU_FONCTION(NAPPE = __moy_y[indexn],
208 VALE_PARA_FONC = AMOR_SPEC[i] )
209 __moyza[i]=RECU_FONCTION(NAPPE = __moy_z[indexn],
210 VALE_PARA_FONC = AMOR_SPEC[i] )
212 dI = IMPRESSION[0].cree_dict_valeurs(IMPRESSION[0].mc_liste)
213 if dI.has_key('PILOTE') : motscles['PILOTE' ]=IMPRESSION['PILOTE']
214 if IMPRESSION['FORMAT']!='TABLEAU' : motscles['ECHELLE_X']='LOG'
215 if IMPRESSION['TRI']=='AMOR_SPEC' :
216 for i in range(len(AMOR_SPEC)) :
217 TITRE ='Spectres / Plancher = '+plancher+\
218 ' / amor='+str(AMOR_SPEC[i])+\
221 FORMAT=IMPRESSION['FORMAT'],
222 UNITE =IMPRESSION['UNITE' ],
223 COURBE=( _F(FONCTION=__moyxa[i], LEGENDE ='X',),
224 _F(FONCTION=__moyya[i], LEGENDE ='Y',),
225 _F(FONCTION=__moyza[i], LEGENDE ='Z',),),
228 elif IMPRESSION['TRI']=='DIRECTION' :
230 for dd in ('X','Y','Z') :
231 TITRE ='Spectres / Plancher = '+plancher+\
232 ' / direction = '+dd+\
234 if dd=='X' : l_fonc=[_F(FONCTION=__moyxa[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
235 for i in range(len(AMOR_SPEC)) ]
236 if dd=='Y' : l_fonc=[_F(FONCTION=__moyya[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
237 for i in range(len(AMOR_SPEC)) ]
238 if dd=='Z' : l_fonc=[_F(FONCTION=__moyza[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
239 for i in range(len(AMOR_SPEC)) ]
241 FORMAT=IMPRESSION['FORMAT'],
242 UNITE =IMPRESSION['UNITE' ],
247 ### increment de l'indice de noeud
250 ### fin boucle 2 sur les noeuds du plancher
251 ############################################################
253 ############################################################
254 ### Calcul des enveloppes des spectres ou des deplacements max
255 if NOM_CHAM=='ACCE' :
260 for node in planch_nodes[plancher] :
261 mcslx.append(__moy_x[indexn])
262 mcsly.append(__moy_y[indexn])
263 mcslz.append(__moy_z[indexn])
265 __snx=CALC_FONCTION(ENVELOPPE=_F(FONCTION=mcslx))
266 __sny=CALC_FONCTION(ENVELOPPE=_F(FONCTION=mcsly))
267 __snz=CALC_FONCTION(ENVELOPPE=_F(FONCTION=mcslz))
268 __snh=CALC_FONCTION(ENVELOPPE=_F(FONCTION=(__snx,__sny)))
269 if NOM_CHAM=='DEPL' :
270 DRmX = max([dicDmax[(node,'X')] for node in planch_nodes[plancher]])
271 DRmY = max([dicDmax[(node,'Y')] for node in planch_nodes[plancher]])
272 DRmZ = max([dicDmax[(node,'Z')] for node in planch_nodes[plancher]])
273 DRmH = max([DRmX,DRmY])
275 ############################################################
276 ### Renseignement de la table finale des résultats
277 if NOM_CHAM=='ACCE' :
279 for i in range(nbind) :
280 dico_glob['FREQ' ]=__snx.Valeurs()[1][i][0]
281 dico_glob['eX_%d_%s' % (i, plancher)]=__snx.Valeurs()[1][i][1]
282 dico_glob['eY_%d_%s' % (i, plancher)]=__sny.Valeurs()[1][i][1]
283 dico_glob['eZ_%d_%s' % (i, plancher)]=__snz.Valeurs()[1][i][1]
284 dico_glob['eH_%d_%s' % (i, plancher)]=__snh.Valeurs()[1][i][1]
285 elif NOM_CHAM=='DEPL' :
286 dico_glob['DX_max'].append(DRmX)
287 dico_glob['DY_max'].append(DRmY)
288 dico_glob['DZ_max'].append(DRmZ)
289 dico_glob['DH_max'].append(DRmH)
291 ############################################################
292 ### Impression des courbes
293 if NOM_CHAM=='ACCE' and IMPRESSION!=None :
295 dI = IMPRESSION[0].cree_dict_valeurs(IMPRESSION[0].mc_liste)
296 if dI.has_key('PILOTE') : motscles['PILOTE']=IMPRESSION['PILOTE']
297 if IMPRESSION['FORMAT']!='TABLEAU' : motscles['ECHELLE_X']='LOG'
298 __snxa=[None]*len(AMOR_SPEC)
299 __snya=[None]*len(AMOR_SPEC)
300 __snza=[None]*len(AMOR_SPEC)
301 __snha=[None]*len(AMOR_SPEC)
302 for i in range(nbind) :
303 __snxa[i]=RECU_FONCTION(NAPPE = __snx,
304 VALE_PARA_FONC = AMOR_SPEC[i], )
305 __snya[i]=RECU_FONCTION(NAPPE = __sny,
306 VALE_PARA_FONC = AMOR_SPEC[i], )
307 __snza[i]=RECU_FONCTION(NAPPE = __snz,
308 VALE_PARA_FONC = AMOR_SPEC[i], )
309 __snha[i]=RECU_FONCTION(NAPPE = __snh,
310 VALE_PARA_FONC = AMOR_SPEC[i], )
311 if IMPRESSION['TRI']=='AMOR_SPEC' :
312 for i in range(nbind) :
313 TITRE ='Spectres moyens / Plancher = '+plancher+' / amor='+str(AMOR_SPEC[i])
315 FORMAT=IMPRESSION['FORMAT'],
316 UNITE =IMPRESSION['UNITE' ],
317 COURBE=( _F(FONCTION=__snxa[i], LEGENDE ='X',),
318 _F(FONCTION=__snya[i], LEGENDE ='Y',),
319 _F(FONCTION=__snza[i], LEGENDE ='Z',),
320 _F(FONCTION=__snha[i], LEGENDE ='H',),),
324 elif IMPRESSION['TRI']=='DIRECTION' :
325 for dd in ('X','Y','Z','H'):
326 TITRE ='Spectres moyens / Plancher = '+plancher+' / direction = '+dd
328 if dd=='X' : l_fonc=[_F(FONCTION=__snxa[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
329 for i in range(len(AMOR_SPEC)) ]
330 if dd=='Y' : l_fonc=[_F(FONCTION=__snya[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
331 for i in range(len(AMOR_SPEC)) ]
332 if dd=='Z' : l_fonc=[_F(FONCTION=__snza[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
333 for i in range(len(AMOR_SPEC)) ]
334 if dd=='H' : l_fonc=[_F(FONCTION=__snha[i], LEGENDE ='amor='+str(AMOR_SPEC[i]),)\
335 for i in range(len(AMOR_SPEC)) ]
337 FORMAT=IMPRESSION['FORMAT'],
338 UNITE =IMPRESSION['UNITE' ],
344 ### fin boucle 1 sur les planchers
345 ############################################################
347 ############################################################
348 ### Renseignement de la table finale des résultats
350 if NOM_CHAM=='DEPL' :
351 lListe.append(_F(LISTE_K=l_plancher,PARA='PLANCHER'))
352 titre = 'Calcul des spectres enveloppes'
353 if NOM_CHAM=='ACCE' :
354 titre = ['Calcul des spectres enveloppes par planchers pour les amortissements numérotés :',]
355 b=[' %d : %g ' % (i,AMOR_SPEC[i]) for i in range(len(AMOR_SPEC)) ]
356 titre.append('/'.join(b))
357 lkeys=dico_glob.keys()
360 lListe.append(_F(LISTE_R=dico_glob[key],PARA=key))
361 tab = CREA_TABLE(LISTE=lListe,TITRE=titre)