During my stay at Harvard University I have worked a lot with Abaqus. I was the first to start using the Python Script interface of Abaqus. Several colleagues asked me to show them how the scripting worked, so I decided to write an introduction manual to the Abaqus Script interface. In this manual I provide a quick way of getting familiar with the Python interface. Since then, the manual has been used in an advanced course for Abaqus at Harvard University.
Download the pdf: Learn Abaqus Script In One Hour
I have used Abaqus scripting to be able to connect Abaqus with Matlab. I have seen colleagues struggling when writing large text files for the Abaqus input files. This can be avoided by scripting! To show you how to run Abaqus from Matlab and how these programmes can interact with each other, you can download the Python script and Matlab files from an example.
Download the files: Abaqus Matlab Connection
To give some more feeling with the Abaqus script interface, I have also added my Matlab and Python files from my project on buckling of periodic structures. These files are only meant to give an example.
Download the files: Example Abaqus Script

Hello,
I developped a python script which creates random fibers embedded into a matrix. I used the *embedded function.
Si I’d like to develop a Post-process python script which gives me the principal stress in the region where my fiber is embedded into the matrix.
But I have a problem to access to those elements. How can I get those specific elements in order to extract the principal values?
I tried to use “clashSets() function in ordre to define an intersection region between my fibers and the matrix but I’m a little bit lost how to use it and I don’t know if it’s the proper way.
Can you please help me?
Thanks,
Romain
Easiest way is to define a set of elements at the beginning of you script file, and acces them later during your postprocess step.
This is an example for accessing a set of nodes, the same should be possible for elements.
————————————-
odb = openOdb(path=’JOBNAME.odb’)
lastFrame = odb.steps['STEPNAME'].frames[1]
displacement=lastFrame.fieldOutputs['U']
regS1 = odb.rootAssembly.instances[INSTNAME1].nodeSets['NODESET1']
eps11 = displacement.getSubset(region=regS1).values[0].data[0]/AREA
eps22 = displacement.getSubset(region=regS1).values[0].data[1]/AREA
v=-eps11/eps22
————————————-
Hi
Thank you for sharing the manual ”learn abaqus script in one hour”!
I wonder to ask about connecting Matlab to abaqus, I have download the link (files) that you provided here but unfortunately I still can not understand how to link my matlab file to abaqus! Would you advise me regarding this issue or would you suggest what book shall I look?
Many thanks in advance
Hi,
I have added a more basic example of the connection between Abaqus and Matlab.
You can download the files from this website.
I want to model a concrete slab with a void inside the concrete. It is a thermal analyse where I apply a heat flux to the bottom surface. Within the void heat is transferred by radiation and convection. For simulating heat convection within the void, I use the surface film condition function in interaction module. I have to define the film coefficient and sink temperature. I decided to use the average temperature of the void surface for sink temperature. I don’t know how to define the average surface temperature. I think I have to use Sink amplitude and user type amplitude. In user type amplitude, I have to take an average of temperature of each node around the void in each time increment and then assign this average to the sink temperature. But I don’t have any idea, how to use the user amplitude and how to calculate the average temperature in Abaqus. I would appreciate any ideas from anyone who has worked in a similar area in Abaqus.
cheers
—————-
|——/ \——- |
|—–/ \ ——|
|—-/void \—–|
|—-\ /——|
|—–\ /——-|
|——\ /— —-|
—————-
fire
Hi Johannes,
I guess my problem is quite basic, but I can’t figure it out. I am performing a frequency step in Abaqus, in order to have access to mode shapes of my structure. What I want is to compute the different components of the strain energy, per instance, with a Pythin script.
It has been very easy to code the tensor multiplication, i.e. 0.5 * S11 * E11 for the first component, then 0.5 * S22 * E22 for the second and so on … But now I need to multiply with the volume of the corresponding element. Because of the frequency step, Abaqus provides EVOL only (and not IVOL), which is an element based quantity, whereas S11 and E11 are integration point quantities. How could you possible compute either S11 and E11 for an element, or the volume of an element based on the integration point?
Thanks!
Nathalie
Hi Nathalie,
You could try to calculate the volume of the element from the position of the corner nodes. You then have to know the element type (i.e the number of nodes and the shape) and the vector multiplication to calculate the volume. This can be implemented in the script environment.
Another possibility is to multiply the volume of the element times the weight of the integration point. However, I do not know if Abaqus provides this weight. Let me know if you have more questions.
1) I am totally new to python and looking for a way to read abaqus ” .rpt” files directly to make plots ( for eg. Load Vs Disp).
2) Also How can i get same data from the .odb file directly? using python(Spyder).
If possible could you get me a spyder script directly?
3) Could you also suggest me a suitable guide to learn to using python to get necessary results from abaqus files(odb, rpt, rpy, etc.)
Thanks in Advance. :)
1) Change extension .rpt to .py and run script from Abaqus GUI.
2) An example of how to read and odb file using script
————————————-
odb = openOdb(path=’JOBNAME.odb’)
lastFrame = odb.steps['STEPNAME'].frames[1]
displacement=lastFrame.fieldOutputs['U']
regS1 = odb.rootAssembly.instances[INSTNAME1].nodeSets['NODESET1']
eps11 = displacement.getSubset(region=regS1).values[0].data[0]/AREA
eps22 = displacement.getSubset(region=regS1).values[0].data[1]/AREA
v=-eps11/eps22
————————————-
3) I have posted a tutorial on my website for learning how to use the Abaqus GUI to create python files and thus to read results from odb. This should get you started.
hi,
I had a quick question on abaqus scripting. i am very new to scripting. I have a history output (U2,RF2) at a specific node set which i am trying to extract from an odb (step1 and step2) and write it in to a text file. i want to write data in such a way that i get history outputs with reference to the step names.
for example,
step1 1 10
step1 2 10
step2 3 10
step4 4 10
any help would be great.
thanks
You could try:
————————————
text_file = open(“Output.txt”, “w”)
text_file.write(‘step1 %d %d\n’ % (1,10))
text_file.write(‘step1 %d %d\n’ % (2,10))
text_file.write(‘step1 %d %d\n’ % (3,10))
text_file.write(‘step1 %d %d\n’ % (4,10))
text_file.close()
Hi Overvelde,
I run “MainBrutePois.m” in Matlab 2009a, but I get an error :
Abaqus Error: Abaqus/Standard Analysis exited with an error – Please see the
message file for possible error messages if the file exists.
Abaqus/Analysis exited with errors
WindowsError: (32, ‘The process cannot access the file because it is being used by another process’, ‘abaqus.rpy’)
I run script All-Main.py, but it also get an error:
Job JOB2: Analysis Input File Processor completed successfully.
Error in job JOB2: Too many attempts made for this increment
Job JOB2: Abaqus/Standard aborted due to errors.
Error in job JOB2: Abaqus/Standard Analysis exited with an error – Please see the message file for possible error messages if the file exists.
Job JOB2 aborted due to errors.
Can you help me with that?
Thanks and Regards,
Haibin
Hi Haibin,
The error comes from Abaqus, not Matlab. Which version of Abaqus have you used? As far as I know you can delete abaqus.rpy. Perhaps you can then run it from matlab. Moreover, you can adapt the number of increments in the python files (perhaps I have also parameterized these in Matlab), this should solve the problem. For you information I have used version 6.8.2 of Abaqus.
Hi Johannes,
I am wondering whether you are aware of a method to assign an individual user defined value to each element? I am running an iterative process which assigns each element an apparent density value between 1 and 0.0001 and then uses this to calculate an interpolated Young’s Modulus for each element. Currently I assign a number of materials between these two extremes into an abaqus input file and then run the input file, but I feel like there must be a more elegant way to do this…
Thanks.
You can try to use script for this. The tutorial I have provided on this website should get you started.
You can then take the following steps:
1. Create model in GUI (without different densities)
2. Create script from automatically generated files
3. Insert python code into script to loop over each element and change density (and also to create multiple densities)
4. Run script file to perform simulation
Good luck!
I’m working on a Python script to extract data from an ODB for post processing in Matlab. The data is from a dynamic simulation with nodal field outputs for each time step saved in a separate frame (model is too large for history outputs of all desired nodal data). I can get the step time from the frame description string with a little manipulation, but it appears to be truncated/rounded. Is there a way to extract the simulation time vector from elsewhere in the ODB structure? Any help/advice you can offer would be greatly appreciated!
Never mind, I found it. The time is stored under the somewhat non-intuitive ‘frameValue’ descriptor. I assumed that since ‘frequency’ had its own listing, ‘time’ would as well… Thanks anyway!
Hi Johannes,
I have the following problem on Abaqus. I ve written a python script where I import a part consisting of different regions with different material behaviours and different orientations. I run it with no problems. Now I want to import in the second step the deformed part as input geometry; so I can model cracking. So what I do is simply import the model from odb. It seems that it takes all the necessary information: regions, materials.. But it doesnt take the deformed state and moreover I get the following error:
Warning: Part “SHELL” is empty. A new part “SHELL” will be created from the mesh data in part instance “SHELL”.
All the best,
Panos
I am working on a project to measure the residual stress in a sample. We cut the sample in half and use a profilometer to give us the contour of the cut surface (~ 15,000 x and y coordinates in a few inches). I want to translate these points into a surface in abaqus and then calculate the stress needed to cause this size of deformation. Can you give me a few pointers to get started? I’ve used abaqus some, but nothing this extensive.
Thanks!
Are these nodes positioned on the surface? If so, perhaps you could make nodes from these coordinates and add a surface mesh through these nodes.
I have used the spline function to create one dimensional lines from a set of nodes. However, you do have to know the order of the nodes. Perhaps you need to first do some post processing. You could also try to generate a mesh with Matlab.
Just some ideas. If you need more help, a picture of the problem would be nice!
Hi Mr. Overvelde.
I’ve got problems with Abaqus keeping variables, i have defined, in the memory.
Today i realized that i’ve got a ‘dead’ variable in my *.py-script and it had ben’t there for a long time. First when i restarted Abaqus there was an error message.
Can you help me with a command, i can put in my script, to clear all variables in the memory..?
I cant find it…
Best Regards
/Sylvester
Technical University of Denmark (DTU)
You should use a clear memory command from python for that. You could use for instance the del command:
del command
Good luck!
Dear you
I’m managing with Abaqus. I intend to create a matrix ( multi-dimensions) in abaqus script by python after that I want to put output-result in this matrix. You have some ideal about this i’m reading something like that in matlab – i worried about doing it in python
Hi, Can you please explain what this script means? or perhaps give a reference from where I can understand it line by line…I tried abaqus scripting manual…I am new to scripting…please help
job_path_name = jobName+’.odb’
b = session.Viewport(name=’spring analysis’, origin=(0,-50), width=200, height=150)
b.maximize()
myodb = visualization.openOdb(path=job_path_name)
b.setValues(displayedObject=myodb)
firststep = myodb.steps['Load Testing']
frame1 = firststep.frames[-1]
displacement1 = frame1.fieldOutputs['U']
stress1 = frame1.fieldOutputs['S']
b.odbDisplay.setDeformedVariable(displacement1)
b.odbDisplay.setPrimaryVariable(field=stress1,outputPosition=INTEGRATION_POINT,refinement=(INVARIANT, ‘Mises’))
b.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
job_path_name = jobName+’.odb’
### create string with path for odb file
b = session.Viewport(name=’spring analysis’, origin=(0,-50), width=200, height=150)
b.maximize()
### Create new viewport (is the window you see in the GUI postprocessing )
myodb = visualization.openOdb(path=job_path_name)
b.setValues(displayedObject=myodb)
###Show the results from the odb file in the viewport
firststep = myodb.steps['Load Testing']
frame1 = firststep.frames[-1]
###Create structure which creates all steps
displacement1 = frame1.fieldOutputs['U']
stress1 = frame1.fieldOutputs['S']
###Create structures which contain displacements and stress
b.odbDisplay.setDeformedVariable(displacement1)
###Show deformed shape in viewport
b.odbDisplay.setPrimaryVariable(field=stress1,outputPosition=INTEGRATION_POINT,refinement=(INVARIANT, ‘Mises’))
###Show Von Mises stress in viewport
b.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
###Show both Von Mises and deformed shape in viewport
Thanks soo much!
I have another question. When I run my script I get stress as my output. I would also like to get displacement as output. How can I edit my script for this. I can attach my script and output file if needed. Please let me know. Thanks a lot.
Can you attach the script, so I can adapt it.
Hi,
I am not sure where to attach the file. I couldn’t find any option in reply section. Would you like me to send an email, if so, your email ID please. Thank in advance.
Hi every one!
I am new in to the world of Abaqus and python script. I want to get the pressure a the element node. I really need to know how I can get this data from a odb file with a python script.
I really appreciate your help.
Thank in advance.
Regards.
Florian.
I think you should export data from abaqus to txt file afterward, you read txt file by python code
contact me: luonganh89@yahoo.com. I gonna doing final thesis about abaqus and python.
Hi Florian,
This is part of a script file which reads an odb file and retrieves the strains. You do the same for elements.
————————————-
odb = openOdb(path=’JOBNAME.odb’)
#calculate Poisson’s ratio
lastFrame = odb.steps['STEPNAME'].frames[1]
displacement=lastFrame.fieldOutputs['U']
regS1 = odb.rootAssembly.instances[INSTNAME1].nodeSets['NODESET1']
eps11 = displacement.getSubset(region=regS1).values[0].data[0]/AREA
eps22 = displacement.getSubset(region=regS1).values[0].data[1]/AREA
v=-eps11/eps22
————————————-
hi you !
I want to ask a question about export output data to txt. I don’t see abaqus record step : export data. Can you help me about code to export data to txt
thank you
Here is an example:
———————————–
text_file = open(“NAMETEXT.txt”, “w”)
text_file.write(‘%1.10f %1.10f %1.10f %1.10f %1.10f %1.10f\n’ % (a,b,c,d,e,f))
text_file.close()
thank a lot :D
I can import an inp file and export a txt database – that’s so great :)))
Hi I want to pause a Job after I resume this job again . Python in abaqus can do it ????
Hello,
I am trying to model a porous material in Abaqus. In a fire event, the material is expanded about 12 times of its initial thickness. Hence the geometry
of the pores varies with temperature. I was wondering if I can model a moving geometry with respect to temperature or time in Abaqus.
Thank you
There are probably possibilities for this. If I understand your question correctly, you do not want your temperature boundary conditions to move with your deformed boundary. I do not know if there are standard options for this in Abaqus. You could try to ask your question here: http://www.imechanica.org
In principle you can write an Abaqus script file and assign a temperature to each element depending on the position of the elements in each timestep. You could use script for this. However, Abaqus probably has some build in function for this.
Hi you
I try to use tabular in import load to my model in code python:
# Create a pressure load on the top face of the beam.
topSurface = ((topFace, SIDE1), )
myModel.Pressure(name=’Pressure’,createStepName=’beamLoad’,region=topSurface, magnitude=0.5 ,Amplitude=TabularAmplitude(name=’load1′, timeSpan=STEP,smooth=SOLVER_DEFAULT, data=((0,0),(0.1,0.167)(0.2,0.233))))
It occurs error – if you have experience about its , you can give me solution. Thank you very much !
Have you tried to create this pressure by using the GUI and then open the .jnl file Abaqus created?
It seems that you are also missing a ,
data=((0,0),(0.1,0.167)(0.2,0.233)) –> data=((0,0),(0.1,0.167),(0.2,0.233))
Good luck!
Hi Johannes,
I m struggling lately with the following problem.. From Abaqus I can output the results for shear strains for all the regions in my part. But is there a python command where I can output the results for a specific region? Let’s say: Region_22
The file looks like this:
Field Output reported at integration points for region: SHELL-1.Region_1
Element Int E.E12
Label Pt @Loc 1
————————————————-
2424 4 17.6945E-03
2419 2 14.9336E-03
2419 4 14.8857E-03
….
Field Output reported at integration points for region: SHELL-1.Region_2
Element Int E.E12
Label Pt @Loc 1
————————————————-
4425 2 13.6945E-03
….
Dear Panos,
Do you have the code for me that generates this output? That will clearify your question. I have added part of my code where I define my own node region to get the displacements and calculate Poisson’s ratio. Perhaps this will help.
————————————-
odb = openOdb(path=’JOBNAME.odb’)
#calculate Poisson’s ratio
lastFrame = odb.steps['STEPNAME'].frames[1]
displacement=lastFrame.fieldOutputs['U']
regS1 = odb.rootAssembly.instances[INSTNAME1].nodeSets['NODESET1']
eps11 = displacement.getSubset(region=regS1).values[0].data[0]/AREA
eps22 = displacement.getSubset(region=regS1).values[0].data[1]/AREA
v=-eps11/eps22
————————————-
Note that “values[0]” refers to the nodelabel in your set and “data[0]” refers to the displacement component.
Hi Johannes,
Finally it seems I reached correct website where I can get some help. I am a Abaqus user but completely new to Python. Now I have some requirement of extracting strain energy (ELSE) data from my Modal step for various modes and average it for all modes (frames) and replot in Abaqus. I picked Python language from few scripts on the net and came up with following code. Now I need your help in two areas:
1. Efficiently summing up of the data of various frames. Now I am doing using fieldValues and it takes 3-4 mins for just two frames. I have 250 frames !! I tried using summation on fields directly but failed!
2. I read in Scripting user manual that we have to create a separate field in (a) step and write these values there. Now however much I am trying I am failing in adding data to a created field. It seems we have to mention instance name in the ‘addData’ function. When I give my instance name it is saying ‘string passed as argument, odbInstance expected’. Then I try to create a instance – then for part argument it says same error. It seems unending chain of error. In the first place, I don’t want to create any instance! I have already one -’Casing-1′
Can you kindly have a look at the following code and suggest solution for above problems ?
odb=session.openOdb(name=odbPath,readOnly=TRUE)
casingSurf = odb.rootAssembly.elementSets['CASINGINSIDESURF']
frameRepository = odb.steps['Modal'].frames
a=[0]*3000 # Element subset has 3000 elements
no_frames = 2 # Only two frames selected out of 250 frames
for i in range(no_frames):
strainEner = frameRepository[i+1].fieldOutputs['ELSE']
field = strainEner.getSubset(region=casingSurf, elementType = ‘C3D20R’)
fieldValues = field.values
count=0
for v in fieldValues:
a[count] = a[count] + v.data
count = count+1
a=a/no_frames # Taking average of all frames’ data
frame251 = odb.steps['Modal'].Frame(incrementNumber=1, frameValue=251, description=”)
MSEField = frame251.FieldOutput(name=’MSE’,description=’ModalStrainEnergy’, type=VECTOR)
a=odb.rootAssembly
instance1 = a.Instance(name=’TestCase’, object=’Casing’) # Stopping here pointing error at object argument
count=0
for v in fieldValues:
MSEField.addData(position=NODAL, instance=instance1[0],labels=v.elementLabel, data=a[count])
count=count+1
Thank you very much in advance !!
Although I do not have any experience with optimizing speed of your code, I do see some parts that could cause the problem. First, when you are summing your v.data, you are actually summing an object. You should probably use v.data[0] to get the scalar value. Finally, should a be a scalar as well? Second, I had some troubles with capital letters and instances in the past. You could try to use ‘TESTCASE’ instead of ‘TestCase’. I have encountered this problem a few times and decided to only use capital letters in naming my parts, instances etc.
Good luck! If you have more questions let me know. Hopefully this helps.
hi
i have been struggling since 2 days to extract acoustic pressure at many nodal points froma odb file(AC2DR element has been used)
i know how to write script for extracting displacements from the odb file,(may be it will be useful for other users) it is given as follows
initial import statements and input file names from odb have to be coded and stored in variable ‘odb’
node_extract=[ 2
,365
,370
,375
,380
,385 ]
n=len(node_extract)
session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=((‘U’,NODAL, ((COMPONENT, ‘U1′), )), ), nodeSets=(‘PART-3-1.TOP-1′, ))
i=0
for i in range(n):
node = node_extract[i]
x0 = session.xyDataObjects['U:U1 PI: PART-3-1 N: ' + str(node)] # In results xydata name
session.writeXYReport(fileName = rdd + str(i) + ‘_U1.txt’, xyData=(x0, ), appendMode=OFF)
But to extract acoustic pressure none of the syntax given in abaqus help works
( In abaqus help file the syntax is listed in this item 51.1.5 xyDataListFromField )
session.xyDataListFromField(odb=odb, outputPosition=NODAL, variable=((‘POR’,NODAL,((INVARIANT, ‘POR’), )), ), nodeSets=(‘PART-5-1.BSCAN’, ))
(i get this standard error VisError: No xy data was extracted using the provided options)
do not know what to include in case of POR for extracting acoustic pressure
None of these work NO_REFINEMENT, INVARIANT or COMPONENT
can any one help me to know syntax for acoustic pressure extraction from odb file
thanks in advance
Jack
Dear Jack,
I am not familiar with xyDataObjects. Instead, I use a different method for extracting data. Although I do not know how to extract the acoustic pressure, perhaps these lines of code can give you a different direction to look.
Good luck!
————————————————————————
odb = openOdb(path=’NAMEODB.odb’)
nFrames=len(odb.steps['NAMESTEP'].frames)
for i in range(1,nFrames):
lastFrame = odb.steps['NAMESTEP'].frames[i]
displacement=lastFrame.fieldOutputs['U']
RForce=lastFrame.fieldOutputs['RF']
regS1 = odb.rootAssembly.instances['NAMEINSTANCE'].nodeSets['NAMENODESET']
eps11 = displacement.getSubset(region=regS1).values[0].data[0]
F22 = RForce.getSubset(region=regS1).values[0].data[1]
odb.close()
Dear sir
I have one question I am wondering if someone help me
the question is I have linked abaqus with modefrontier software and I need for every simulation to write the result in .rpt file I have did this job but the file still with the first simulation (I means in second simulation the file doesn’t change)
Best wishes
Did you close the file? Do you have the script file code for me, I can take a look at it to look for the problem.
Hi Johannes,
i have contacted you before.. And your help and advice was very important for learning Python in the right way… I want to ask you the following.. I have in Abaqus python a square geometry with random polygons; which I define as areas with different properties… I want to create within these polygons random circles.. But not in the polygon centers, not on the edges and they should not overlap each other… Do you have any ideas how to approach the problem, functions or scripts available…
Thanks in advance,
Panos
Hi Panos,
Can the circles overlap the boundaries of your poloygons.
You could create random points inside your square domain, and check for certain constraints. If the points is to close to a polygon boundary, in the center, or to close to other already created circles, then you should not create that points and start over.
Good luck!
Hi Johannes,
the circles should not overlap the edges of the polygons.
I have 2 questions:
I have assigned to each polygon a name, and are defined as regions. Are there any commands in python for taking random points within these regions?
Is there an overlap condition for objects in python? Or should it be like a script that checks the distance of every circle with the rest?
All the best,
Panos
You should probably write a script that checks the overlap. An overlap condition for objects in python would probably do the same, and I don’t know if that exists.
A discussion on generating points inside triangle is given here:
http://gis.stackexchange.com/questions/6412/generate-points-that-lie-inside-polygon
Good Afternoon mr. Overvelde
Recently, I’ve been running a few tests with contacts in abaqus. The last one (a beam-solid contact) failed. It is basically a polymer pipe with four wires of helicoidal tensile armor inside. The contact seems to be ignoring the polymer layer and the wires are passing through. When I checked the status file, I found the following warning:
“Some nodes involved in general contact have penetrated their
tracked faces by more than 50.000 percent of the typical element
dimension in the general contact domain, 4.5263. Please check the
node set “InfoNodeDeepPenetFirst” in Abaqus/Viewer for more
information. Please make sure that these nodes and their
contacting faces have sufficient mass to allow the code to
calculate realistic contact penalties for enforcing the contact
constraint.”
I basically used penalty-hard contact properties and the default general contact setup.
Thanks in advance
I can think of two possibilities:
-You are take timesteps that are to large.
-Although you are using hard contact, if youre mass is to low, youre contact forces are probably to low. Hard contact does not necessarily mean that the contact boundary does not have any thickness. When the two surfaces are in each others contact boundary, they will feel a force. If the force is to low, they will penetrate.
Dear sir,
i am trying to implement periodic boundary conditions from your codes,
but i am getting error ‘TypeError: ‘Repository’ object is not callable’ at this line
for i in a:
mdb.models[modelName].parts[partName].Set(name=’Node-’+str(rep), nodes=
mdb.models[modelName].parts[partName].nodes[(i[1]-1):(i[1])])
please can you help me in this error and can i know what this part will do in your coding (i mean already you got the nodes at left side)
thanks in advance
regards
kiran kumar A
In this part I give each organized nodes (organized on the position) a set name. When creating the Equation constraints for the periodic boundary conditions I can easily connect the nodes that are on opposite sides by looking at the set names.
tanks for reply. i am trying by giving
mdb.models['inplaneshear'].rootAssembly.sets(name=’kiran’+str(rep),nodes=mdb.models['inplaneshear'].parts['PART-3-1'].nodes[(i[1]-1):(i[1])])
i am getting error ‘TypeError: ‘float’ object is unsubscriptable’
please can you help in this error
The problem probably arises from the fact that you select nodes from your parts
nodes=mdb.models['inplaneshear'].parts['PART-3-1'].nodes[(i[1]-1):(i[1])]
and that you use these nodes to create set in rootassembly.
mdb.models['inplaneshear'].rootAssembly.sets(name=’kiran’+str(rep),nodes=…)
I am not certain this is the problem. Which node numbers are in your vector? are these node numbers from parts or assembly?
i am doing as per your code
y=mdb.models['inplaneshear'].rootAssembly.sets(‘WESTNODES’).node %assigning node sets to y
a=[] %define some array
for i in y:
a=a+[(i.coordinates[1]),i.label] %extraction of nodal y- coordinates and labels
rep=1
for i in a: mdb.models['inplaneshear'].rootAssembly.sets(name=’kiran’+str(rep),nodes=mdb.models['inplaneshear'].rootAssembly.nodes[(i[1]-1):(i[1])])
TypeError: ‘float’ object is unsubscriptable
whether i define by part or assembly i am getting same error
pls can u give any solution
Hi,
I have a very trivial doubt but not able to solve it. In the following script file, if I run using Basewire feature in line 26, I get a nice sinusoidal profile that I have given. But if I change it to Baseshell (instead of basewire), the profile becomes almost flat. could you help locate the problem? Thanks in advance!!
=======================================
# -*- coding: mbcs -*
from abaqus import *
from abaqusConstants import *
import regionToolset
session.viewports['Viewport: 1'].setValues(displayedObject=None)
#———————————-
# Create Model
mdb.models.changeKey(fromName=’Model-1′, toName=’Elastic Film Model’)
filmModel=mdb.models['Elastic Film Model']
#———————————-
# Create Part
import sketch
import part
# a) create sketch
filmSketch = filmModel.ConstrainedSketch(name=’2D Film Sketch’, sheetSize=4000.0)
filmSketch.Line(point1=(0,0), point2=(0,-500))
filmSketch.Line(point1=(0,-500), point2=(4000,-500))
filmSketch.Line(point1=(4000,-500), point2=(4000,-3.5261))
filmSketch.Spline(points=((0.0,0.0000),(25.0,5.0660),(50.0,5.4290),(75.0,0.7520),(100.0,-4.6231),(125.0,-5.7063),(150.0,-1.4922),(175.0,4.1073),(200.0,5.8937),(225.0,2.2088),(250.0,-3.5267),(275.0,-5.9882),(300.0,-2.8906),(325.0,2.8905),(350.0,5.9882),(375.0,3.5268),(400.0,-2.2087),(425.0,-5.8937),(450.0,-4.1073),(475.0,1.4920),(500.0,5.7063),(525.0,4.6231),(550.0,-0.7519),(575.0,-5.4289),(600.0,-5.0660),(625.0,-0.0001),(650.0,5.0659),(675.0,5.4290),(700.0,0.7521),(725.0,-4.6230),(750.0,-5.7064),(775.0,-1.4923),(800.0,4.1072),(825.0,5.8938),(850.0,2.2089),(875.0,-3.5266),(900.0,-5.9882),(925.0,-2.8907),(950.0,2.8904),(975.0,5.9881),(1000.0,3.5269),(1025.0,-2.2086),(1050.0,-5.8937),(1075.0,-4.1074),(1100.0,1.4919),(1125.0,5.7063),(1150.0,4.6232),(1175.0,-0.7518),(1200.0,-5.4289),(1225.0,-5.0661),(1250.0,-0.0003),(1275.0,5.0658),(1300.0,5.4291),(1325.0,0.7523),(1350.0,-4.6229),(1375.0,-5.7064),(1400.0,-1.4924),(1425.0,4.1071),(1450.0,5.8938),(1475.0,2.2090),(1500.0,-3.5265),(1525.0,-5.9882),(1550.0,-2.8908),(1575.0,2.8902),(1600.0,5.9881),(1625.0,3.5270),(1650.0,-2.2084),(1675.0,-5.8937),(1700.0,-4.1075),(1725.0,1.4918),(1750.0,5.7062),(1775.0,4.6233),(1800.0,-0.7516),(1825.0,-5.4288),(1850.0,-5.0662),(1875.0,-0.0004),(1900.0,5.0658),(1925.0,5.4291),(1950.0,0.7524),(1975.0,-4.6228),(2000.0,-5.7065),(2025.0,-1.4925),(2050.0,4.1070),(2075.0,5.8938),(2100.0,2.2091),(2125.0,-3.5264),(2150.0,-5.9882),(2175.0,-2.8909),(2200.0,2.8901),(2225.0,5.9881),(2250.0,3.5271),(2275.0,-2.2083),(2300.0,-5.8936),(2325.0,-4.1076),(2350.0,1.4917),(2375.0,5.7062),(2400.0,4.6234),(2425.0,-0.7515),(2450.0,-5.4287),(2475.0,-5.0662),(2500.0,-0.0005),(2525.0,5.0657),(2550.0,5.4292),(2575.0,0.7525),(2600.0,-4.6227),(2625.0,-5.7065),(2650.0,-1.4927),(2675.0,4.1069),(2700.0,5.8938),(2725.0,2.2093),(2750.0,-3.5263),(2775.0,-5.9882),(2800.0,-2.8910),(2825.0,2.8900),(2850.0,5.9881),(2875.0,3.5272),(2900.0,-2.2082),(2925.0,-5.8936),(2950.0,-4.1077),(2975.0,1.4916),(3000.0,5.7062),(3025.0,4.6235),(3050.0,-0.7514),(3075.0,-5.4287),(3100.0,-5.0663),(3125.0,-0.0006),(3150.0,5.0656),(3175.0,5.4292),(3200.0,0.7526),(3225.0,-4.6227),(3250.0,-5.7065),(3275.0,-1.4928),(3300.0,4.1068),(3325.0,5.8939),(3350.0,2.2094),(3375.0,-3.5262),(3400.0,-5.9882),(3425.0,-2.8911),(3450.0,2.8899),(3475.0,5.9881),(3500.0,3.5273),(3525.0,-2.2081),(3550.0,-5.8936),(3575.0,-4.1078),(3600.0,1.4914),(3625.0,5.7061),(3650.0,4.6236),(3675.0,-0.7513),(3700.0,-5.4286),(3725.0,-5.0664),(3750.0,-0.0008),(3775.0,5.0656),(3800.0,5.4293),(3825.0,0.7528),(3850.0,-4.6226),(3875.0,-5.7066),(3900.0,-1.4929),(3925.0,4.1067),(3950.0,5.8939),(3975.0,2.2095),(4000.0,-3.5261)))
# b) create 2D deformable part
filmPart=filmModel.Part(name=’Film’, dimensionality=TWO_D_PLANAR, type=DEFORMABLE_BODY)
filmPart.BaseWire(sketch=filmSketch)
#del mdb.models['Elastic Film Model'].sketches['2D Film Sketch']
#————————————
# Create material
import material
filmMaterial=filmModel.Material (name=’Linear Elastic’)
filmMaterial.Density(table=((7.8e-21, ), ))
filmMaterial.Elastic(table=((0.001342, 0.0), ))
#————————————
#Create Section
filmSection = filmModel.HomogeneousSolidSection(material=’Linear Elastic’,
name=’Film Section’, thickness=None)
Hi Hema,
Did you figure out how to deal with your problem?
I have the same issue and I could not find a way to solve it!
I am using a sketch generated using spline for partitioning a domain but when it partitions lots of features are missing!
Please keep me updated.
Regards
Hi Overvelde,
This website is very useful for the beginning like me who want to us script file on Abaqus and interacting of some works between Abaqus and Matlab. Thank you very much. I’m start learning downloaded files and hope you don’t mind answers my questions in the future.
Have a nice day,
Musiket.
Thanks! Just let me know when you have questions.
Hello Mr.Overvelde
You can see my previous message on message line
I am M.Sc. student in Istanbul Technical University and my research subject is comparision of several ductile damage models both computationaly and experimentally.
As i said before I am trying to compare ductile damage models such as Freudenthal,Cockroft,Ayada ,Brozzo etc. computationally using ABAQUS .
Now temporarily I gave up scripting and trying to make a successful
Tensile test simulation and realize necking and fracture.
I am to make modelling ABAQUS cae interface and trying to use ”ductile damage” in material property definition. Here, stress triaxiality, fracture strain, and strain rate is questioned.
I have real stress-strain curve of experimental material and ı know fracture strain.
What do you advise me for triaxiality and how can i make constant velocity/strain tensile test simulation in Abaqus.
I wonder this because after a successful simulation, using output file a will try to ductile damage critera such as Freudenthal,Cockroft,Ayada ,Brozzo , values by a matlab code.
Thanks in advance for your help.
Regards
Hakkı ISIK.
import os
file = openMdb(‘heep’).models.items()[0][1]
error:
IOError: heep.cae: No such file or directory
since i run in linux server, whether there might be some read/right permission ?
Is the mdb file you are trying to open in the working directory? Maybe you have to use heep.mdb. I am actually not sure.
Hi every one
I need help from someone have good experience in abaqus scripting language
I will pay for this service
Best regards
on behalf of chouarfia charef
I am liveliness to prepare my thesis in doctorate whose theme is the relation between the proprietée mechanics and microstructure and a confrontation between the affected results and the experimental of the Aluminium 7075 alloys (state : T-6 and T-73),has this effect ,I have needs if it is possible to send me the documentation on the creation of interface between matlab (version:R2011a) and abaqus (version: 6.5-1) the analysis and an automatic simulation of the abaqus by the mediator of matlab.
I thank you for your collaboration.
chouarfia-charef
tel: 05-53-54-32-96
email : chchmosta07@yahoo.fr
Dear Mr. Overvelde,
I want to create a code that does the following:
Input: x,y,z (a random location)
Output: the stress S33 at x,y,z.
I have created a small script, but I get an OdpError saying when I’m calling a variable: “The selected variable is unavailable.” I have no idea on how to solve this. I’ve posted my script below. The inputfile can be downloaded at (http://www.box.net/shared/dd61iog2oc0hcpn4jcbf)
Any help would be highly appreciated.
# Import all the necessary packages
import os
import visualization
import sys
from odbAccess import *
from abaqusConstants import *
# The point at a random location (x, y, z) where we want to extract S33
locx = 25
locy = 25
locz = 25
point= ( (locx,locy,locz), )
# The path object to map all the values to
myPath=session.Path(name=’track’, type=POINT_LIST, expression=point)
# These parameters are used in XYDataFromPath
var_s33=((‘S’, INTEGRATION_POINT, ((COMPONENT, ‘S33′ ), )),)
session.paths['track']
StepName = ‘Step-1′
# Setup the odb and viewport
myodb = openOdb(path = ‘Small_model.odb’)
viewport = session.viewports[session.viewports.keys()[-1]]
viewport.setValues(displayedObject=myodb)
viewport.odbDisplay.setPrimaryVariable(variableLabel = ‘S’,outputPosition = INTEGRATION_POINT, refinement=COMPONENT,’S33′))
viewport.odbDisplay.display.setValues(plotState=CONTOURS_ON_DEF,))
# Map S33 values to the path
stress33XYData=session.XYDataFromPath(name=’Stress in 33-direction’,
path=myPath,
includeIntersections=False,
shape=DEFORMED,
labelType=TRUE_DISTANCE,
step=-1,
frame=-1,
variable=var_s33)
# Extract the S33 value from the XYData
stress33Value = stress33XYData.data[0][1]
I do not know how to find the stress at a random location. I also don’t know why your script file doesn’t work, however you do seem to use variables that are not to obvious. How did you write this script file?
Below I added some script which looks for the closest node to your random location. This might help you in finding the stress at this point, or the stress in an element which contains this node. Hopefully this can be of some help. Good luck
——————————————————————-
# Import all the necessary packages
import os
import visualization
import sys
from odbAccess import *
from abaqusConstants import *
# The point at a random location (x, y, z) where we want to extract S33
locx = 25.1
locy = 25
locz = 25
point= ( (locx,locy,locz), )
StepName = ‘Step-1′
# Setup the odb and viewport
myodb = openOdb(path = ‘Small_model.odb’)
# Get frame and stress
lastFrame = myodb.steps[StepName].frames[-1]
Stress=lastFrame.fieldOutputs['S'] # I think these are the stresses at the intergration points
# Find the node closest to random location
mindistance2=10000
for nod in myodb.rootAssembly.instances['FEM_YSW-1'].nodes:
Coorx=nod.coordinates[0]
Coory=nod.coordinates[1]
Coorz=nod.coordinates[2]
distance2=(locx-Coorx)*(locx-Coorx)+(locy-Coory)*(locy-Coory)+(locz-Coorz)*(locz-Coorz)
if mindistance2>distance2:
mindistance2=distance2
minnod=myodb.rootAssembly.instances['FEM_YSW-1'].nodes[(nod.label-1):nod.label]
Dear Bas,
this script might help in case I can’t get mine to work. Thank you for that.
Can you explain which variables are not obvious in your opinion? Or do you just mean the following line?
var_s33=((‘S’, INTEGRATION_POINT, ((COMPONENT, ‘S33′ ), )),)
Hello Mr.Overvelde
I am M.Sc. sutdent in Istanbul Technical University and my research subject is comparision of several ductile damage models both computationaly and experimentally.
I am trying to compare ductile damage models such as Freudenthal,Cockroft,Ayada ,Brozzo etc. computationally using ABAQUS and seeking a way to implement these damage models in ABAQUS.
To obtain each models damage result individually should damage model be implemented in ABAQUS or can a regular tensile test results be used for calculation of damage values.
Could you please advise me for methodolgy to run a simulation to obtain ductile damage values according to models mentioned above.
Thanks in advance for your help.
Hakkı ISIK.
Dear Hakki,
I do not have a lot of experience with damage models in Abaqus. I do know you can use Abaqus for modeling of damage. I advice you to go to imechanica.org and ask the same question as above.
Good luck
Great tutorial. Thanks!
I am trying to run the script through the abaqus command line -> abaqus python main.py, but I get and error at each of the import.. lines.
Error description:
D:\myTempForAbaqus\SimpleBeamScript>abaqus python Main.py
Traceback (most recent call last):
File “Main.py”, line 3, in
from part import *
ImportError: No module named part
Do you recognize this error?
Thanks in advance
Regards Brian
I have never tried to run the model through the command line. I always run it from the Abaqus GUI. I think you should select main–>run script. Make sure your work directory is set to the folder in which the python files are situated. Does this help?
I was a bit quick on the trigger.
abaqus command line ->
abaqus cae noGUI=main.py
@Brian:
abaqus command line ->
abaqus cae noGUI=main.py
how to specify the number of cpus the script should use here ?
Dear Mr. Overvelde
Thank you for sharing this guide. The guide is easy to understand and you example files showing how to structure the scripts with a main file calling the other scripts is very nice. I wonder why things like this is not a part of the manual to begin with.
regards Brian
Great! Thanks, It might help me.
Hi ,
I am totally new to the world of Abaqus. I really need to know how I can define a 3D cubic or cylindrical (rock or concrete) material and then simulate a triaxial test on it. Could you please advise? Do I need to write a script for this purpose?
I really appreciate your guide. (a beginner’s example etc)
Cheers,
About the scripting: it is very useful if you want to run your simulation with different parameters. For instance changing mesh size, or model size is very easy in a script file. However, if you only need to do one particular simulation I advise you to just use the graphical user interface (GUI).
You can find tutorials for Abaqus at:
http://www.imechanica.org/node/365
I have not tried them, but they have got a lot of positive comments.
For rock or concrete you need to use an anisotropic material. However if you are only going to compress it, an elastic material might work. I’m not very experienced with these types of materials. You might find more information in the Abaqus 6.9 online manual:
http://abaqusdoc.ucalgary.ca/v6.9/
I hope this is of any help. If you get stuck on scripting or have more questions, please say so.
Hello,
Thanks for the tutorial on scripting. I had a particular question regarding using scripting to obtain odb results and history data and was hoping you could help me in that.
I am trying to extract contact interaction related field outputs and history output data but I am unable to do so using the python scripts.
I have a contact interaction in my model and I have requested the contact forces (CFN) and contact area (CAREA) as a history output. But, while writing the script, I am unable to find as to how to define a “historyRegion” or “historyPoint” for a contact interaction. Hence, I am unable to extract that data.
Can you help me with that?
Regards,
Tuhin Sinha
I normally use the GUI to generate my script files. This can also be done for post-processing on the odb file. Otherwise you can find more information in the abaqus script reference manual Chapter 31:
http://abaqusdoc.ucalgary.ca/v6.9/books/ker/default.htm
Good luck!
Hi Overvelde,
I have gone through the following thread in Imechanica (http://imechanica.org/node/9135) and tried to use the python script provided by you for applying periodic boundary conditions. When I copied the same and tried to run it abaqus it gives me some indentation errors. Request you to email me the working version of the script in a file to unsrohith@gmail.com.
Thanks and Regards,
Rohith
India.
In Python script indentation needs to be done consistently. Copying the code from htm probably will not work. An implementation on the periodic boundary conditions can be found in the files ‘connect Matlab with Abaqus’, which you can download above. I have also sent an email to you containing simplified versions of these files.
This is nice, reflection of a humble mind.
Good idea!