Reputation: 11
I am trying to run multiple jobs using abaqus python where different models are run for each of the umat subroutine available but the loop exits after the first job is executed
import os
import shutil
import subprocess
current_Path = os.getcwd()
umat_Path = current_Path+'\\'+'UMATS'
umat_list = os.listdir(umat_Path)
print(umat_list)
model_Path = current_Path+'\\'+'Models'
model_list = os.listdir(model_Path)
print(model_list)
os.chdir(model_Path)
for umat in umat_list:
umat = umat_Path+'\\'+umat
for model in model_list:
model=os.path.splitext(model)[0]
odbname=umat+model
os.system('cmd /k "abaqus job=%s user=%s globalmodel=%s interactive"'%(model,umat,odbname))
Upvotes: 1
Views: 1316
Reputation: 904
Basically, you have to use waitForCompletion()
method.
And I think, you cannot use 'cmd' command to submit the job. Instead, create job from input file using JobFromInputFile()
as you have input file. Then submit the job using submit()
method. and at the end you can use waitForCompletion()
to wait for the submitted job to either complete or abort.
Find the snippet of code:
import os
import shutil
import subprocess
import job # to access job related commands
current_Path = os.getcwd()
umat_Path = current_Path+'\\'+'UMATS'
umat_list = os.listdir(umat_Path)
model_Path = current_Path+'\\'+'Models'
model_list = os.listdir(model_Path)
os.chdir(model_Path)
for umat in umat_list:
umat = umat_Path+'\\'+umat
for model in model_list:
model=os.path.splitext(model)[0]
odbname=umat+model
myJob = mdb.JobFromInputFile(name=model,
inputFileName=odbname, type=ANALYSIS,
atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90,
memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True,
explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, userSubroutine=umat,
scratch='', parallelizationMethodExplicit=DOMAIN, numDomains=1,
activateLoadBalancing=False, multiprocessingMode=DEFAULT, numCpus=1)
myJob.submit()
myJob.waitForCompletion()
Upvotes: 1