Bonjour,

j'ai un script qui contient plusieurs expressions et équations longues, je veux écrire ces équations en deux ligne mais je connais pas le symbole à mettre pour le retour à la ligne pour que l'expression soit valide.
les expressions sont dans les lignes 73 ,74 et 121,122 et 167
le script est le suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
 
# import statements
# import abaqus
 
from odbAccess import*
from abaqusConstants import*
from odbMaterial import*
from odbSection import*
from math import*
 
 
# open  text files  in which we'll put and display the results 
f10=open('GAG.txt','w')
f11=open('LMC.txt','w')
f12=open('CC.txt','w')
f13=open('OO.txt','w')
f14=open('SS.txt','w')
 
 
# open DATABASE
odb = openOdb(path='hcf.odb')
lcf = openOdb(path='lcf.odb')
 
 
# determine the number and names of instances in the odb 
myAssembly = odb.rootAssembly
for instanceName in odb.rootAssembly.instances.keys():
    print 'Instance Name : ',instanceName
 
 
# determine the materials of each instance in the odb
allMaterials = odb.materials
for materialName in allMaterials.keys():
    print 'Material Name : ',materialName
 
 
# determine the number and names of steps in the odb
for stepName in odb.steps.keys():
    print stepName
 
 
# determine the node sets and the element sets in the odb    
print 'Node sets = ',odb.rootAssembly.instances['V20110406-1-1'].nodeSets.keys()
print 'element sets = ',odb.rootAssembly.instances['V20110406-1-1'].elementSets.keys()
 
 
# define the material parameters
Rm = 470
Re = 390
sig_D_mean = 120.317804382247
 
 
# define the model chosen
modele = ['Goodman', 'Gerber', 'Soderberg']
print modele
choix = input ('Entrer le nom du modele choisi parmi la liste precedante')
def sig_Goodman(Rm, dyn, stat, alpha):
    return (Rm*dyn)/(Rm-(stat/alpha))
def sig_Gerber(Re, dyn, stat):
    return ((Re**2)*dyn)/(Re**2-(stat)**2)
def sig_Soderberg(Re, dyn, stat, alpha):
    return (Re*dyn)/(Re-(stat/alpha))
 
 
# define the Damage Tolerance curve and the Flaw Tolerance curve
Ratio = [-1,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1]
DTA1 = [66.8,64.4,61.3,57.4,52.7,47.3,39.0,32.9,27.2,16.8,0]
DTA2 = [56.3,54.3,51.7,48.4,44.4,39.8,32.9,27.8,22.9,14.2,0]
FTA = [194.2,187.4,178.4,167.0,153.4,137.5,113.6,95.8,79.0,48.9,0]
 
 
# define the safe curve
x = [1,1666,16666,100000,200000,300000,400000,500000,700000,1000000,2000000,3000000,4000000,7000000,10000000,20000000,30000000,40000000,50000000,80000000,100000000,200000000,300000000,400000000,700000000,1000000000,10000000000]
y = [333.487953502046,333.487953502046,252.023589004762,144.841143106185,134.316479532823,128.773084241854,125.091228664023,122.370855728624,118.481010326472,114.620454409826,107.826945429572,104.248768756484,101.872187428479,97.605392834564,95.113463177554,90.728357283851,88.418699099329,86.884652288088,85.751207659768,83.515504894025,82.521999403873,79.691480778685,78.200631830545,77.210428132759,75.432666212810,74.394402580963,69.148163438073]
 
 
# define the list of target cycle of HCF and LCF
T_cycle = [28555200,28555200,19036800,590140800,28555200,38073600,76147200,95184000,47592000,20000,100,40000,10000,40000]
 
# calculate the mean, alternating and equivalent stresses
# and the service life and the damage
def calcul(k,f):
    maxStress=0
    for idx, value in enumerate(Stress) :
        S11 = value.data[0]
        S22 = value.data[1]
        S12 = value.data[3]
        e = Stress1[idx]
        S_11 = e.data[0]
        S_22 = e.data[1]
        S_12 = e.data[3]
        # calculate the alternating stress tensor and its eigenvalues
        D11 = (S11-S_11)/2
        D22 = (S22-S_22)/2
        D12 = (S12-S_12)/2
        Dyn1 = ((D11+D22)-sqrt(D11**2+D22**2+4*D12**2-2*D11*D22))/2
        Dyn2 = ((D11+D22)+sqrt(D11**2+D22**2+4*D12**2-2*D11*D22))/2
        # calculate the mean stress tensor and its eigenvalues
        St11 = (S11+S_11)/2
        St22 = (S22+S_22)/2
        St12 = (S12+S_12)/2
        Stat1 = ((St11+St22)+sqrt(St11**2+St22**2+4*St12**2-2*St11*St22))/2
        Stat2 = ((St11+St22)-sqrt(St11**2+St22**2+4*St12**2-2*St11*St22))/2
        # calculate the alternating stress and the mean stress
        if abs(Dyn1)>=abs(Dyn2):
            sig_dyn = abs(Dyn1)
        else:
            sig_dyn = abs(Dyn2)
 
        if abs(Stat1)>=abs(Stat2):
            signe = Stat1/abs(Stat1)
            sig_stat = signe*sqrt(Stat1**2-Stat1*Stat2+Stat2**2)
        else:
            signe = Stat2/abs(Stat2)
            sig_stat = signe*sqrt(Stat2**2-Stat1*Stat2+Stat1**2)
        # calculate the maximum and minimum stress and the ratio
        Max = sig_dyn+sig_stat
        Min = sig_stat-sig_dyn
        R = Min/Max
        # calculate the equivalent stress
        alpha_G = abs(sig_D_mean/((sig_dyn/sig_stat)+(sig_D_mean/Rm)))*((1+(sig_dyn/sig_stat)**2)/(sig_dyn**2+sig_stat**2))**0.5
        alpha_S = abs(sig_D_mean/((sig_dyn/sig_stat)+(sig_D_mean/Re)))*((1+(sig_dyn/sig_stat)**2)/(sig_dyn**2+sig_stat**2))**0.5
        if choix == 'Goodman':
            sig_eq = sig_Goodman(Rm, sig_dyn, sig_stat, alpha_G)
        elif choix == 'Gerber':
            sig_eq = sig_Gerber(Re, sig_dyn, sig_stat)
        elif choix == 'Soderberg':
            sig_eq = sig_Soderberg(Re, sig_dyn, sig_stat, alpha_S)
        else:
            print ('Votre choix n appartient pas a la liste precedante')
        if sig_eq > maxStress:
            maxStress = sig_eq
        # determination of the service life
        if sig_eq > y[0]:
            N_cycle = 0
        elif sig_eq <= y[-1]:
            N_cycle = 1.0E+10
        else:
            i=0
            len_y=len(y)
            while (i < len_y - 1):
                if (sig_eq < y[i]) and (sig_eq > y[i+1]):
                    N_cycle = x[i+1]-((y[i+1]-sig_eq)*(x[i+1]-x[i])/(y[i+1]-y[i]))
                    break
                i=i+1
        # calculate the damage
        Damage = T_cycle[k-1]/N_cycle
        # projection of the alternating stresses on the DTA and FTA curves
        if (R<-1) or (R>1):
            propa_DTA1=-1.0E-01
            propa_DTA2=-1.0E-01
            propa_FTA=-1.0E-01
        else:
            j =0
            len_DTA1 = len(DTA1)
            while (j < len_DTA1 - 1):
                if (R > Ratio[j]) and (R < Ratio[j+1]):
                    sig_DTA1 = DTA1[j+1]-((Ratio[j+1]-R)*(DTA1[j+1]-DTA1[j])/(Ratio[j+1]-Ratio[j]))
                    propa_DTA1 = sig_dyn-sig_DTA1
                    sig_DTA2 = DTA2[j+1]-((Ratio[j+1]-R)*(DTA2[j+1]-DTA2[j])/(Ratio[j+1]-Ratio[j]))
                    propa_DTA2 = sig_dyn-sig_DTA2
                    sig_FTA = FTA[j+1]-((Ratio[j+1]-R)*(FTA[j+1]-FTA[j])/(Ratio[j+1]-Ratio[j]))
                    propa_FTA = sig_dyn-sig_FTA
                    break
                j=j+1
 
        f.write('Instance:\t %s\tElement:\t %6d\tSig_stat:\t %E\tSig_dyn:\t %E\tMax:\t %E\tMin:\t %E\tR:\t %E\tSig_eq:\t %E\tN_cycle:\t %E\tMaxStress:\t %E\tDamage:\t %E\tpropa_DTA1:\t %E\tpropa_DTA2:\t %E\tpropa_FTA:\t %E\n'%(value.instance.name,value.elementLabel,sig_stat,sig_dyn,Max,Min,R,sig_eq,N_cycle,maxStress,Damage,propa_DTA1,propa_DTA2,propa_FTA))
 
 
#------------------------------------------------Analyse_frequentielle: HCF-------------------------------------------------------
 
nb_loadcase = 9
i = 1
while i <= nb_loadcase:
    #print "HCF%i" %i 
    stressField = odb.steps['Load'].frames[i+1].fieldOutputs['S']
    stressField1 = odb.steps['Load'].frames[i+2].fieldOutputs['S']
    topCenter = odb.rootAssembly.instances['V20110406-1-1'].elementSets['SKIN']
    Stress = stressField.getSubset(region=topCenter, position=CENTROID).values
    Stress1 = stressField1.getSubset(region=topCenter, position=CENTROID).values
    f=open('HCF%i'%i + '.txt','w')
    calcul(i,f)
    i=i+1    
 
 
#------------------------------------------------Analyse_temporelle: LCF-------------------------------------------------------
 
 
#-----------------------------------------------------------GAG-----------------------------------------------------------------
 
 
# determine the stress value at the frame number 2 and 11  of the second step
# in the "SKIN" element set (GAG)
stressField = lcf.steps['Load'].frames[2].fieldOutputs['S']
stressField1 = lcf.steps['Load'].frames[11].fieldOutputs['S']
topCenter = lcf.rootAssembly.instances['V20110406-1-1'].elementSets['SKIN']
Stress = stressField.getSubset(region=topCenter, position=CENTROID).values
Stress1 = stressField1.getSubset(region=topCenter, position=CENTROID).values
calcul(nb_loadcase+1, f10)
 
 
#-----------------------------------------------------------LMC-----------------------------------------------------------------
 
 
# determine the stress value at the frame number 2 and 17 of the second step
# in the "SKIN" element set (LMC)
stressField = lcf.steps['Load'].frames[2].fieldOutputs['S']
stressField1 = lcf.steps['Load'].frames[17].fieldOutputs['S']
topCenter = lcf.rootAssembly.instances['V20110406-1-1'].elementSets['SKIN']
Stress = stressField.getSubset(region=topCenter, position=CENTROID).values
Stress1 = stressField1.getSubset(region=topCenter, position=CENTROID).values
calcul(nb_loadcase+2, f11)
 
 
#-----------------------------------------------------------CC-----------------------------------------------------------------
 
 
# determine the stress value at the third and forth frame of the second step
# in the "SKIN" element set (CC)
stressField = lcf.steps['Load'].frames[3].fieldOutputs['S']
stressField1 = lcf.steps['Load'].frames[4].fieldOutputs['S']
topCenter = lcf.rootAssembly.instances['V20110406-1-1'].elementSets['SKIN']
Stress = stressField.getSubset(region=topCenter, position=CENTROID).values
Stress1 = stressField1.getSubset(region=topCenter, position=CENTROID).values
calcul(nb_loadcase+3, f12)
 
 
#-----------------------------------------------------------OO-----------------------------------------------------------------
 
 
# determine the stress value at the frame nuber 2 and 13 of the second step
# in the "SKIN" element set (OO)
stressField = lcf.steps['Load'].frames[2].fieldOutputs['S']
stressField1 = lcf.steps['Load'].frames[13].fieldOutputs['S']
topCenter = lcf.rootAssembly.instances['V20110406-1-1'].elementSets['SKIN']
Stress = stressField.getSubset(region=topCenter, position=CENTROID).values
Stress1 = stressField1.getSubset(region=topCenter, position=CENTROID).values
calcul(nb_loadcase+4, f13)
 
 
#-----------------------------------------------------------SS-----------------------------------------------------------------
 
 
# determine the stress value at the frame number 5 and 7 of the second step
# in the "SKIN" element set (SS)
stressField = lcf.steps['Load'].frames[5].fieldOutputs['S']
stressField1 = lcf.steps['Load'].frames[7].fieldOutputs['S']
topCenter = lcf.rootAssembly.instances['V20110406-1-1'].elementSets['SKIN']
Stress = stressField.getSubset(region=topCenter, position=CENTROID).values
Stress1 = stressField1.getSubset(region=topCenter, position=CENTROID).values
calcul(nb_loadcase+5, f14)

merci d'avance

Cordialement