-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtemplate.py
More file actions
127 lines (100 loc) · 4.27 KB
/
template.py
File metadata and controls
127 lines (100 loc) · 4.27 KB
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
from abaqus import *
from abaqusConstants import *
from caeModules import *
from driverUtils import executeOnCaeStartup
executeOnCaeStartup()
openMdb(pathName='C:\\Users\\tbrosse\\.openmdao\\gui\\projects\\Stent\\ark_stent.cae')
#----------------------------------------------------------------------------
# script names.
#----------------------------------------------------------------------------
model_name='Model-1'
part_name='Ark_stent'
solid_extrude_name='Solid extrude-1'
step_name='Step-1'
job_name='Job-1'
odb_name=job_name+'.odb'
output_file='output.txt'
#----------------------------------------------------------------------------
# mesh size.
#----------------------------------------------------------------------------
seed_size=0.05
#----------------------------------------------------------------------------
# assign design variables.
#----------------------------------------------------------------------------
lenght= 3.6
radius_2= 0.3
radius_4= 4.0
alpha= 0.4
beta= 0.9
#----------------------------------------------------------------------------
# modify design variables's values.
#----------------------------------------------------------------------------
p = mdb.models['Model-1'].parts['Ark_stent']
s = p.features['Solid extrude-1'].sketch
mdb.models['Model-1'].ConstrainedSketch(name='__edit__', objectToCopy=s)
s1 = mdb.models['Model-1'].sketches['__edit__']
g, v, d, c = s1.geometry, s1.vertices, s1.dimensions, s1.constraints
s1.setPrimaryObject(option=SUPERIMPOSE)
p.projectReferencesOntoSketch(sketch=s1,
upToFeature=p.features['Solid extrude-1'], filter=COPLANAR_EDGES)
d[4].setValues(value=alpha*radius_2, )
d[3].setValues(value=radius_2, )
d[8].setValues(value=radius_4, )
d[9].setValues(value=beta*radius_4, )
d[7].setValues(value=lenght, )
d[5].setValues(value=lenght, )
s1.unsetPrimaryObject()
p = mdb.models['Model-1'].parts['Ark_stent']
p.features['Solid extrude-1'].setValues(sketch=s1)
del mdb.models['Model-1'].sketches['__edit__']
p = mdb.models['Model-1'].parts['Ark_stent']
p.regenerate()
#----------------------------------------------------------------------------
# remesh.
#----------------------------------------------------------------------------
p = mdb.models[model_name].parts[part_name]
p.seedPart(size=seed_size, deviationFactor=0.1, minSizeFactor=0.1)
p = mdb.models[model_name].parts[part_name]
p.generateMesh()
a = mdb.models[model_name].rootAssembly
a.regenerate()
#----------------------------------------------------------------------------
# job execution.
#----------------------------------------------------------------------------
#try:
mdb.jobs[job_name].submit(consistencyChecking=OFF)
mdb.jobs[job_name].waitForCompletion()
#----------------------------------------------------------------------------
# post process odb.
#----------------------------------------------------------------------------
o1 = session.openOdb(name=odb_name)
odb = session.odbs[odb_name]
last_frame = odb.steps[step_name].frames[-1]
#Von Mises max
stress_field = last_frame.fieldOutputs['S'].values
max_mises = 0.0
i = 0
for v in stress_field:
if v.mises > max_mises:
i = v.elementLabel
max_mises = max(v.mises, max_mises)
#Displacement max
displacement_field = last_frame.fieldOutputs['U'].values
max_displacement = 0.0
i = 0
for v in displacement_field:
if v.magnitude > max_displacement:
i = v.elementLabel
max_displacement = max(v.magnitude, max_displacement)
minus_max_displacement = -max_displacement
#----------------------------------------------------------------------------
# Writting output file.
#----------------------------------------------------------------------------
file = open(output_file, 'w')
file.write('max_mises \n')
file.write('%10f \n' % (max_mises))
file.write('minus_max_displacement \n')
file.write('%10f \n' % (minus_max_displacement))
file.close()
#except AbaqusException, e:
#handling error