-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcompileumat.py
58 lines (48 loc) · 2.18 KB
/
compileumat.py
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
os.chdir('x:/workfolder/abaqusfolder/umat')
from abqimport import *
import subprocess, copy
# Taken from abaqus_v6.env
compile_fortran=['ifort',
'/c','/DABQ_WIN86_64', '/extend-source',
'/iface:cref', '/recursive', '/Qauto-scalar',
'/QxSSE3', '/QaxAVX',
'/heap-arrays:1',
# '/Od', '/Ob0' # <-- Optimization
# '/Zi', # <-- Debugging
'/include:%I']
def combine_modules(codename_list, objname):
umatfname = objname.replace('.obj', '.f90')
with open(umatfname, 'w') as fwrite:
for codename in codename_list:
with open(codename, 'r') as fread:
fwrite.write(fread.read())
fwrite.write('\n\n')
return umatfname
def compile_umat(umatfname):
assert compile_fortran[0] == 'ifort', 'This code only works with IVF.'
compile_args = copy.deepcopy(compile_fortran)
compile_args.append(umatfname)
assert subprocess.call(compile_args) == 0, \
'Compilation error. See the command line window for more details.'
return
def run_umat(codename_list, jobname, objname, wait=False):
umatfname = combine_modules(codename_list, objname)
compile_umat(umatfname)
mdb.jobs[jobname].setValues(userSubroutine=objname)
mdb.jobs[jobname].submit(consistencyChecking=OFF)
if wait:
mdb.jobs[jobname].waitForCompletion()
return
if __name__ == '__main__':
# codename_list = ['umatutils.f90', 'psimod_neo.f90', 'numerichyper.f90', 'nhinterface.f90']
# codename_list = ['umatutils.f90', 'psimod_hgo.f90', 'numerichyper.f90', 'nhinterface.f90']
# codename_list = ['umatutils.f90', 'psimod_hg.f90', 'numerichyper.f90', 'nhinterface.f90']
# codename_list = ['umatutils.f90', 'psimod_hg.f90', 'numerichyper.f90', 'nhcylinterface.f90']
codename_list = ['umatutils.f90', 'psimod_hgo.f90', 'numerichyper.f90', 'nhcylinterface.f90']
objname = 'umat.obj'
# jobname = 'SingleElem'
# jobname = 'SingleElemShearNumeric'
# jobname = 'HolzapfelNumeric'
# jobname = 'numeric_circ_k0_displ'
jobname = 'ArteryInflSymmNumeric'
run_umat(codename_list, jobname, objname)