Sri Harsha
Aerospace
- Jun 16, 2017
- 37
Hi,
I have an ABAQUS script/Macro,which I am unable to run without launching ABAQUS.
The following approach has been followed to run the ABAQUS Script,without launching GUI.
->Open ABAQUS Command line
->Change the destination there to the path of the script location.
->then I have enetered this line: "abaqus cae ScriptFile.py"
Please find my script attached below:
I am running the Mainfunction() below and rest are all sub functions,which are used in MainFunction.
def GetForceAndDisplacement(odb1,i):
DispList = []
ForceList = []
assembly = odb1.rootAssembly
elemset = assembly.elementSets['DISP_END_SET']
elementsObj = elemset.elements
for Idx in range(len(elementsObj[0])):
connecObj = elemset.elements[0][Idx].connectivity
for nds in connecObj:
xy = session.xyDataListFromField(odb=odb1, outputPosition=NODAL, variable=(('U', NODAL, ((INVARIANT, 'Magnitude'), )), ), nodeLabels=(('PART-1-1', (str(nds), )), ))
Disp = xy[0][0][1]
DispList.append(Disp)
xy2 = session.xyDataListFromField(odb=odb1, outputPosition=NODAL, variable=(('RF', NODAL, ((INVARIANT, 'Magnitude'), )), ), nodeLabels=(('PART-1-1', (str(nds), )), ))
Force = xy2[0][0][1]
ForceList.append(Force)
AvgDisp = sum(DispList)/len(DispList)
ResForce = sum(ForceList)
return AvgDisp,ResForce
def RetrieveSetStressValues(odb1,lastFrame):
SetList = []
SetList = RetrieveAllSetNames()
assembly = odb1.rootAssembly
for SetIdx in range(len(SetList)):
maximumStress = 0
elemset = assembly.elementSets[SetList[SetIdx]]
elementsObj = elemset.elements
for Idx in range(len(elementsObj[0])):
connecObj = elemset.elements[0][Idx].connectivity
for nds in connecObj:
xy = session.xyDataListFromField(odb=odb1, outputPosition=NODAL, variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Mises'), )), ), nodeLabels=(('PART-1-1', (str(nds), )), ))
Stress = xy[0][0][1]
if Stress > maximumStress:
maximumStress = Stress
if SetIdx == 0:
Set1 = maximumStress
if SetIdx == 1:
Set2 = maximumStress
if SetIdx == 2:
Set3 = maximumStress
if SetIdx == 3:
Set4 = maximumStress
return Set1,Set2,Set3,Set4
def Mainfunction():
TimeStep = []
odbNamesList = []
odbNamesList = ListODBNames()
ODBFilesList = []
StressSet1List = []
StressSet2List = []
StressSet3List = []
StressSet4List = []
DispList = []
ForceList = []
ODBFilesList = ListAllODBFiles()
for odbFileIdx in range(len(ODBFilesList)):
odb = openOdb(ODBFilesList[odbFileIdx])
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
odbName=session.viewports[session.currentViewportName].odbDisplay.name
lastStep = odb.steps['Step-1']
for i in range(len(lastStep.frames)):
lastFrame = lastStep.frames
Time1 = lastFrame.frameValue
session.odbData[odbName].setValues(activeFrames=(('Step-1', (i, )), ))
TimeStep.append(Time1)
AvgDisp,ResForce = GetForceAndDisplacement(odb,i)
DispList.append(AvgDisp)
ForceList.append(ResForce)
Set1,Set2,Set3,Set4 = RetrieveSetStressValues(odb,lastFrame)
StressSet1List.append(Set1)
StressSet2List.append(Set2)
StressSet3List.append(Set3)
StressSet4List.append(Set4)
I would be really glad,if I u can let me know the changes to be done,inorder to run the script through ABAQUS Command line without launching ABAQUS.
Thanks in Advance!
I have an ABAQUS script/Macro,which I am unable to run without launching ABAQUS.
The following approach has been followed to run the ABAQUS Script,without launching GUI.
->Open ABAQUS Command line
->Change the destination there to the path of the script location.
->then I have enetered this line: "abaqus cae ScriptFile.py"
Please find my script attached below:
I am running the Mainfunction() below and rest are all sub functions,which are used in MainFunction.
def GetForceAndDisplacement(odb1,i):
DispList = []
ForceList = []
assembly = odb1.rootAssembly
elemset = assembly.elementSets['DISP_END_SET']
elementsObj = elemset.elements
for Idx in range(len(elementsObj[0])):
connecObj = elemset.elements[0][Idx].connectivity
for nds in connecObj:
xy = session.xyDataListFromField(odb=odb1, outputPosition=NODAL, variable=(('U', NODAL, ((INVARIANT, 'Magnitude'), )), ), nodeLabels=(('PART-1-1', (str(nds), )), ))
Disp = xy[0][0][1]
DispList.append(Disp)
xy2 = session.xyDataListFromField(odb=odb1, outputPosition=NODAL, variable=(('RF', NODAL, ((INVARIANT, 'Magnitude'), )), ), nodeLabels=(('PART-1-1', (str(nds), )), ))
Force = xy2[0][0][1]
ForceList.append(Force)
AvgDisp = sum(DispList)/len(DispList)
ResForce = sum(ForceList)
return AvgDisp,ResForce
def RetrieveSetStressValues(odb1,lastFrame):
SetList = []
SetList = RetrieveAllSetNames()
assembly = odb1.rootAssembly
for SetIdx in range(len(SetList)):
maximumStress = 0
elemset = assembly.elementSets[SetList[SetIdx]]
elementsObj = elemset.elements
for Idx in range(len(elementsObj[0])):
connecObj = elemset.elements[0][Idx].connectivity
for nds in connecObj:
xy = session.xyDataListFromField(odb=odb1, outputPosition=NODAL, variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Mises'), )), ), nodeLabels=(('PART-1-1', (str(nds), )), ))
Stress = xy[0][0][1]
if Stress > maximumStress:
maximumStress = Stress
if SetIdx == 0:
Set1 = maximumStress
if SetIdx == 1:
Set2 = maximumStress
if SetIdx == 2:
Set3 = maximumStress
if SetIdx == 3:
Set4 = maximumStress
return Set1,Set2,Set3,Set4
def Mainfunction():
TimeStep = []
odbNamesList = []
odbNamesList = ListODBNames()
ODBFilesList = []
StressSet1List = []
StressSet2List = []
StressSet3List = []
StressSet4List = []
DispList = []
ForceList = []
ODBFilesList = ListAllODBFiles()
for odbFileIdx in range(len(ODBFilesList)):
odb = openOdb(ODBFilesList[odbFileIdx])
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
odbName=session.viewports[session.currentViewportName].odbDisplay.name
lastStep = odb.steps['Step-1']
for i in range(len(lastStep.frames)):
lastFrame = lastStep.frames
Time1 = lastFrame.frameValue
session.odbData[odbName].setValues(activeFrames=(('Step-1', (i, )), ))
TimeStep.append(Time1)
AvgDisp,ResForce = GetForceAndDisplacement(odb,i)
DispList.append(AvgDisp)
ForceList.append(ResForce)
Set1,Set2,Set3,Set4 = RetrieveSetStressValues(odb,lastFrame)
StressSet1List.append(Set1)
StressSet2List.append(Set2)
StressSet3List.append(Set3)
StressSet4List.append(Set4)
I would be really glad,if I u can let me know the changes to be done,inorder to run the script through ABAQUS Command line without launching ABAQUS.
Thanks in Advance!