×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Abaqus python programming problem

Abaqus python programming problem

Abaqus python programming problem

(OP)
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:

http://speedy.sh/BuKQx/CoordError.JPG

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[i].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[i])**2)+((NewCoordsY[i+1]-NewCoordsY[i])**2)+((NewCoordsZ[i+1]-NewCoordsZ[i])**2)))


return NodsDistance

def ThirdCoordNod (elems,nods):
ThirdCoordNod=[]
for i in range(len(elems)-1):
for k in range(4):
temp=elems[i].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[i].label==thirdnods[j]):
thirdnods2.append(assembly.nodes[i])
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[i]
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[i]).values.data[1])
return forces

------------------------------------------------------------------------------
Thank a lot

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources