phd-scripts/Biomaterials13/Sample_ParamSweep/OptPostB1.py

34 lines
No EOL
1.1 KiB
Python

# Import Neccesary Abaqus Modules
from abaqusConstants import *
from odbAccess import *
import sys
import os
jobName=sys.argv[-2]
resFile=sys.argv[-1]
resFile2=resFile+'.b'
odbfilename=jobName+'.odb'
odb=openOdb(path=odbfilename)
aFrame=odb.steps["Step-1"].frames[-1]
maxStrain=0.
for currentStrain in aFrame.fieldOutputs["LE"].values:
if currentStrain.instance.name=='AMESH-1':
if currentStrain.maxPrincipal>maxStrain:
maxStrain=currentStrain.maxPrincipal
outFile = open(resFile,"w")
if maxStrain>0.1256:
outFile = open(resFile,"w")
outFile2 = open(resFile2,"w")
objFn=1.+maxStrain
outFile.write("%12.6f \n " % (objFn))
outFile2.write("%12.6f \n " % (maxStrain))
outFile.close()
outFile2.close()
odb.close()
else:
outFile2 = open(resFile2,"w")
outFile2.write("%12.6f \n " % (maxStrain))
outFile2.close()
odb.close()
os.system('abaqus j=R1'+jobName+' oldjob='+jobName+' inp=Restart1 cpus=6 inter user=ALE20')
os.system('abaqus j=R2'+jobName+' oldjob=R1'+jobName+' inp=Restart2 cpus=6 inter user=ALE20')
os.system('abaqus python OptPostB2.py -- R2'+jobName+' '+resFile)