Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Abaqus python programming problem

Status
Not open for further replies.

Galey

Structural
Joined
Mar 10, 2013
Messages
1
Hi everybody,

I have a problem with programming script in python, which is a part of my thesis.
I am trying to write script which will calculate weld fatigue life based on Verity method.
I try to get nodal forces and moments in local coordinate system.
Local system is creating based on nodes and elements path.

Everything goes ok, but when I want to read nodal forces in local coord system following error occured:


I don't know what I am doing wronge. Anybody can help me so solve this problem?

Here you have my "functions.py" file where I've put all important functions. 'GetForces' should read mentioned nodal forces.
------------------------------------------------------------------------------
from math import*
from abaqus import*
from odbAccess import*
from abaqusConstants import*
#from os import*

def GetOdbPath (nods):
temp=str(nods)
OdbPath=temp[(temp.index("'")):temp.index(')')]
return str(OdbPath)

def GetInstance (nods):
temp=str(nods)
Inst=temp[(temp.index('[')+1):temp.index(']')]
return str(Inst)

def CalcNodsDistance (nods,OdbPath,Step,Inst):
NodsDistance=[]
NewCoordsX=[]
NewCoordsY=[]
NewCoordsZ=[]
odb = session.openOdb(name='Baza', path='Test.odb', readOnly=TRUE)
step_temp = odb.steps.values()[Step-1].name
lastFrame = odb.steps[step_temp].frames[-1]
displacement=lastFrame.fieldOutputs['U']
fieldValues=displacement.values

#All paths to get nodal coordinates
assembly=odb.rootAssembly.instances[nods[0].instanceName]
for i in range(len(nods)):
for j in range (len(assembly.nodes)):
if assembly.nodes[j].label==nods.label:
NewCoordsX.append(assembly.nodes[j].coordinates[0]+fieldValues[j].data[0])
NewCoordsY.append(assembly.nodes[j].coordinates[1]+fieldValues[j].data[1])
NewCoordsZ.append(assembly.nodes[j].coordinates[2]+fieldValues[j].data[2])
elif len(NewCoordsX)==len(nods):
break
else:
continue
#NodsDistance
for i in range(len(nods)-1):
NodsDistance.append(sqrt(((NewCoordsX[i+1]-NewCoordsX)**2)+((NewCoordsY[i+1]-NewCoordsY)**2)+((NewCoordsZ[i+1]-NewCoordsZ)**2)))


return NodsDistance

def ThirdCoordNod (elems,nods):
ThirdCoordNod=[]
for i in range(len(elems)-1):
for k in range(4):
temp=elems.connectivity[k]
for j in range(4):
temp2=elems[i+1].connectivity[j]
if (temp==temp2 and temp!=nods[i+1].label):
ThirdCoordNod.append(temp2)
else:
continue
#Third Node for last element
temp=list(elems[-1].connectivity)
temp.remove(ThirdCoordNod[-1])
temp.remove(nods[-1].label)
temp.remove(nods[-2].label)
ThirdCoordNod.append(temp[0])
return ThirdCoordNod



def CreateCoordSystems (nods,thirdnods,OdbPath):
odb = session.openOdb(name='Baza', path='Test.odb', readOnly=TRUE)
#scratchOdb = session.ScratchOdb(odb)
CSYS=[]
thirdnods2=[]
assembly=odb.rootAssembly.instances[nods[0].instanceName]
for j in range(len(thirdnods)):
for i in range(len(assembly.nodes)):
if (assembly.nodes.label==thirdnods[j]):
thirdnods2.append(assembly.nodes)
else:
continue
for k in range(len(thirdnods2)):
CSYS.append('CSYS'+str(k))
#scratchOdb.rootAssembly.DatumCsysByThreeNodes(name=CSYS[k], coordSysType=CARTESIAN, origin=nods[k+1], point1=nods[k], point2=thirdnods2[k])
odb.rootAssembly.DatumCsysByThreeNodes(name=CSYS[k], coordSysType=CARTESIAN, origin=nods[k+1], point1=nods[k], point2=thirdnods2[k])
return CSYS

def GetForces(nods,Step,Csyses):
odb=session.openOdb('Test.odb')
step_temp = odb.steps.values()[Step-1].name
forces=[]
for i in range(len(nods)):
Csys_temp=Csyses
dtm=session.openOdb('Test.odb').rootAssembly.datumCsyses[Csys_temp]
forces.append(session.openOdb('Test.odb').steps[step_temp].frames[-1].fieldOutputs['NFORC2'].getTransformedField(datumCsys=dtm).getSubset(region=nods).values.data[1])
return forces

------------------------------------------------------------------------------
Thank a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top