]> SALOME platform Git repositories - tools/eficas.git/blob - Aster/Cata/cataSTA9/Macro/macr_spectre_ops.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Aster / Cata / cataSTA9 / Macro / macr_spectre_ops.py
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.                                                  
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 Accas import _F
22 import string
23
24 try:
25    import aster
26    from Utilitai.Utmess import  UTMESS
27 except:
28    pass
29
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):
32   """
33      Ecriture de la macro MACR_SPECTRE
34   """
35   ier=0
36   import string
37   from types import ListType,TupleType,StringType
38   EnumType=(ListType,TupleType)
39   
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')
45
46   ### Comptage commandes + déclaration concept sortant
47   self.set_icmd(1)
48   self.DeclareOut('tab',self.sd)
49   macro='MACR_SPECTRE'
50
51   ### construction de la liste des noeuds à traiter
52   planch_nodes={}
53   dic_gpno=aster.getcolljev(MAILLAGE.nom.ljust(8)+".GROUPENO")
54   l_nodes =aster.getvectjev(MAILLAGE.nom.ljust(8)+".NOMNOE")
55   l_plancher=[]
56   for plancher in PLANCHER :
57       liste_no=[]
58       if plancher['NOEUD']!=None :
59          if type(plancher['NOEUD'])==StringType :
60                  liste_no.append(plancher['NOEUD'])
61          else :
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
69          else :
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'])
76
77   if AMOR_SPEC!=None and type(AMOR_SPEC) not in EnumType :
78      AMOR_SPEC=(AMOR_SPEC,)
79
80   if NOM_CHAM=='ACCE' : dico_glob={}
81   if NOM_CHAM=='DEPL' : dico_glob={'DX_max'   :[] ,
82                                    'DY_max'   :[] ,
83                                    'DZ_max'   :[] ,
84                                    'DH_max'   :[] , }
85
86   ############################################################
87   ### boucle 1 sur les planchers
88   for plancher in l_plancher :
89
90       if NOM_CHAM=='ACCE' :
91          __moy_x=[None]*len(planch_nodes[plancher])
92          __moy_y=[None]*len(planch_nodes[plancher])
93          __moy_z=[None]*len(planch_nodes[plancher])
94       if NOM_CHAM=='DEPL' :
95          dicDmax={}
96   ############################################################
97   ### boucle 2 sur les noeuds du plancher
98       indexn=0
99       for node in planch_nodes[plancher] :
100
101   ############################################################
102   ### boucle 3 sur les directions (X,Y,Z)
103           for dd in ('X','Y','Z') :
104
105   ############################################################
106   ### boucle 4 sur les résultats
107               l_fonc=[]
108               for resu in RESU :
109                   ### Récupération des fonctions
110                   motscles={}
111                   if resu['RESU_GENE']!=None :
112                      if CALCUL=='ABSOLU' :
113                         UTMESS('F','SPECTRAL0_8')
114                      motscles['RESU_GENE'] = resu['RESU_GENE']
115
116                   if resu['RESULTAT' ]!=None :
117                     motscles['RESULTAT']  = resu['RESULTAT']
118                   
119                   __spo=RECU_FONCTION(NOM_CHAM     = NOM_CHAM,
120                                       TOUT_ORDRE   = 'OUI',
121                                       NOM_CMP      = 'D'+dd,
122                                       INTERPOL     = 'LIN',
123                                       PROL_GAUCHE  = 'CONSTANT',
124                                       PROL_DROITE  = 'CONSTANT',
125                                       NOEUD        = node , **motscles )
126
127                   if NOM_CHAM=='ACCE' :
128                      ### Accelerations relatives
129                      if CALCUL=='RELATIF' :
130                         ### Combinaison avec fonction d acceleration
131                         motscles={}
132                         if LIST_INST!=None : motscles['LIST_PARA']=LIST_INST
133                         __spo=CALC_FONCTION(COMB=(_F(FONCTION=__spo,
134                                                      COEF= 1.0      ),
135                                                   _F(FONCTION=resu['ACCE_'+dd],
136                                                      COEF= 1.0)              ),**motscles )
137
138                      ### Calcul des spectres d'oscillateur
139                      motscles={}
140                      if FREQ     !=None : motscles['FREQ']     =FREQ
141                      if LIST_FREQ!=None : motscles['LIST_FREQ']=LIST_FREQ
142                      __spo=CALC_FONCTION(
143                             SPEC_OSCI=_F(FONCTION    = __spo,
144                                          AMOR_REDUIT = AMOR_SPEC,
145                                          NORME       = args['NORME'],
146                                          **motscles                  ) )
147                      l_fonc.append(__spo)
148
149                   if NOM_CHAM=='DEPL' :
150                      if CALCUL=='ABSOLU' :
151                         ### On retranche les deplacements d entrainement
152                         motscles={}
153                         if LIST_INST!=None : motscles['LIST_PARA']=LIST_INST
154                         __spo=CALC_FONCTION(COMB=(_F(FONCTION=__spo,
155                                                      COEF= 1.0      ),
156                                                   _F(FONCTION=resu['DEPL_'+dd],
157                                                      COEF= -1.0)              ),**motscles )
158
159                      l_fonc.append(__spo)
160
161   ### fin boucle 4 sur les résultats
162   ############################################################
163
164   ############################################################
165   ### calcul de la moyenne sur les resultats à noeud et direction fixes
166               nbresu=len(RESU)
167               if NOM_CHAM=='ACCE' :
168                  mcfCMBx=[]
169                  mcfCMBy=[]
170                  mcfCMBz=[]
171                  for spo in l_fonc :
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),))
178                  motscles={}
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)
183
184               if NOM_CHAM=='DEPL' :
185                  moy = 0.
186                  for spo in l_fonc :
187                      fspo = spo.convert()
188                      aspo = fspo.abs()
189                      vmax  = aspo.extreme()['max']
190                      moy   = moy + vmax[-1][-1]
191                  dicDmax[(node,dd)]=moy/nbresu
192
193   ### fin boucle 3 sur les directions
194   ############################################################
195
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)) : 
204                  amor = AMOR_SPEC[i]
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]   )
211               motscles={}
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])+\
219                                        ' / noeud='+node
220                     IMPR_FONCTION(
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',),),
226                       TITRE   =TITRE,
227                       **motscles)
228               elif IMPRESSION['TRI']=='DIRECTION' :
229                  lfonc=[]
230                  for dd in ('X','Y','Z') :
231                     TITRE   ='Spectres / Plancher = '+plancher+\
232                                        ' / direction = '+dd+\
233                                        ' / noeud = '+node
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))          ]
240                     IMPR_FONCTION(
241                       FORMAT=IMPRESSION['FORMAT'],
242                       UNITE =IMPRESSION['UNITE' ],
243                       COURBE=l_fonc,
244                       TITRE   =TITRE,
245                       **motscles)
246
247           ### increment de l'indice de noeud
248           indexn=indexn+1
249
250   ### fin boucle 2 sur les noeuds du plancher
251   ############################################################
252
253   ############################################################
254   ### Calcul des enveloppes des spectres ou des deplacements max
255       if NOM_CHAM=='ACCE' :
256          mcslx=[]
257          mcsly=[]
258          mcslz=[]
259          indexn=0
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])
264              indexn=indexn+1
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])
274
275   ############################################################
276   ### Renseignement de la table finale des résultats
277       if   NOM_CHAM=='ACCE' :
278            nbind=len(AMOR_SPEC)
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)
290
291   ############################################################
292   ### Impression des courbes
293       if   NOM_CHAM=='ACCE' and IMPRESSION!=None :
294         motscles={}
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])
314               IMPR_FONCTION(
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',),),
321                  TITRE   =TITRE,
322                  **motscles
323                  )
324         elif IMPRESSION['TRI']=='DIRECTION' :
325               for dd in ('X','Y','Z','H'):
326                 TITRE   ='Spectres moyens / Plancher = '+plancher+' / direction = '+dd
327                 l_fonc  =[]
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))          ]
336                 IMPR_FONCTION(
337                    FORMAT=IMPRESSION['FORMAT'],
338                    UNITE =IMPRESSION['UNITE' ],
339                    COURBE=l_fonc,
340                    TITRE =TITRE,
341                    **motscles
342                    )
343
344   ### fin boucle 1 sur les planchers
345   ############################################################
346
347   ############################################################
348   ### Renseignement de la table finale des résultats
349   lListe=[]
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()
358   lkeys.sort()
359   for key in lkeys :
360       lListe.append(_F(LISTE_R=dico_glob[key],PARA=key))
361   tab = CREA_TABLE(LISTE=lListe,TITRE=titre)
362   return ier