Problem:
1. My script creates multiple jobs and completes the simulation. **But, the properties in all the input files are the same (Only the last combination of for loop is in all input files). Why my for loop is not updating the properties in the jobs? ** 2. The Foce-Time file has different job names as expected, but all the values are the same.
for i in arange(0.05, 0.25, 0.05):
for j in arange(0.35, 0.36, 0.01):
for m in arange(1.67e-08, 1.68e-08, 1e-10):
mdb.models['Model-1'].Material(name='Material-1')
mdb.models['Model-1'].materials['Material-1'].Elastic(table=((i, j), ))
mdb.models['Model-1'].materials['Material-1'].Permeability(
inertialDragCoefficient=0.142887, specificWeight=9.81e-06, table=((
m, 4.0), ))
a = mdb.models['Model-1'].rootAssembly
session.viewports['Viewport: 1'].setValues(displayedObject=a)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(
optimizationTasks=OFF, geometricRestrictions=OFF, stopConditions=OFF)
for k in range(5, 25, 5):
for l in range(35, 36, 1):
for n in range(167, 168, 1):
mdb.Job(name='Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n), model='Model-1', description='', type=ANALYSIS,
atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90,
memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True,
explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF,
modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='',
scratch='', resultsFormat=ODB, numThreadsPerMpiProcess=1,
multiprocessingMode=DEFAULT, numCpus=1, numGPUs=0)
mdb.jobs['Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n)].submit(consistencyChecking=OFF)
mdb.jobs['Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n)].waitForCompletion()
o3 = session.openOdb(
name='Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n)+'.odb')
session.viewports['Viewport: 1'].setValues(displayedObject=o3)
session.viewports['Viewport: 1'].makeCurrent()
a = mdb.models['Model-1'].rootAssembly
session.viewports['Viewport: 1'].setValues(displayedObject=a)
session.viewports['Viewport: 1'].setValues(
displayedObject=session.odbs['Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n)+'.odb'])
odb = session.odbs['Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n)+'.odb']
session.XYDataFromHistory(name='RF2 PI: rootAssembly N: 1 NSET RP-1', odb=odb,
outputVariableName='Reaction force: RF2 PI: rootAssembly Node 1 in NSET RP',
steps=('Step-1', 'Step-2', ), __linkedVpName__='Viewport: 1')
x0 = session.xyDataObjects['RF2 PI: rootAssembly N: 1 NSET RP-1']
session.writeXYReport(fileName='Job_'+'ym'+str(k)+'_'+'pr'+str(l)+'_'+'pe'+str(n)+'.txt', xyData=(x0, ))
I tried adding a wait comment after the for loop, but that is not working.
In you first three for
loops (of i
, j
, m
), you are updating the material values. So, after the completion of these loops, the model will have the last material values.
After that, in next three for
loops (of k
, l
, n
), you are creating the job from the same model which has lastly updated material values. Hence, you are getting the same input file.
Solution:
Merge both for loops - do material updating and job submission in the same for
loops.
Try following updated code (modify further if required):
viewport = session.viewports['Viewport: 1']
for i in arange(0.05, 0.25, 0.05):
for j in arange(0.35, 0.36, 0.01):
for m in arange(1.67e-08, 1.68e-08, 1e-10):
# k - i 100 - , l - j 100, n - m 1e8
i_ = int(i*100)
j_ = int(j*100)
m_ = int(m*1e8)
# Create job name based on loop values
job_name = 'Job_ym%d_pr%d_pe%d' % (i_, j_, m_)
# Update model - update material properties
mat = mdb.models['Model-1'].Material(name='Material-1')
mat.Elastic(table=((i, j), ))
mat.Permeability(inertialDragCoefficient=0.142887,
specificWeight=9.81e-06, table=((m, 4.0), ))
a = mdb.models['Model-1'].rootAssembly
viewport.setValues(displayedObject=a)
viewport.assemblyDisplay.setValues(optimizationTasks=OFF,
geometricRestrictions=OFF,
stopConditions=OFF)
# Create the job with updated model
mdb.Job(name=job_name, model='Model-1', description='', type=ANALYSIS,
atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90,
memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True,
explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF,
modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='',
scratch='', resultsFormat=ODB, numThreadsPerMpiProcess=1,
multiprocessingMode=DEFAULT, numCpus=1, numGPUs=0)
# Submit the job
mdb.jobs[job_name].submit(consistencyChecking=OFF)
mdb.jobs[job_name].waitForCompletion()
odb = session.openOdb(name=job_name+'.odb')
viewport.setValues(displayedObject=odb)
viewport.makeCurrent()
session.XYDataFromHistory(
name='RF2 PI: rootAssembly N: 1 NSET RP-1', odb=odb,
outputVariableName='Reaction force: RF2 PI: rootAssembly Node 1 in NSET RP',
steps=('Step-1', 'Step-2', ), __linkedVpName__='Viewport: 1')
x0 = session.xyDataObjects['RF2 PI: rootAssembly N: 1 NSET RP-1']
session.writeXYReport(fileName=job_name+'.txt', xyData=(x0, ))