User login

Navigation

You are here

Boundary Conditions in ABAQUS using a script file

Dear All,

I am new
both in IMechanica and python. I need help with a python script. I am writing a
script file that the deformations from a result file for a set (nodes) will be
read. And then these deformations will be insert a new model, totally same detail
but the deformations will be now define as boundary conditions. The script file I wrote can
read and write the deformations in a list. The sets in odb.file is exactly the
same in the new model (mdb) but I could not figure out how to insert them as
boundary conditions. If I understand correctly I need to create a region. This became a problem for me.
How to create a region using a node label in a set and match it with the node
label in odb list? Can someone help me with that, please?

Thank you in advance

/Aygul 

Johannes T.B. Overvelde's picture

Dear Aygul,

I have sort of done this in my own script. You can find more information on Abaqus script on my website. Below is the part I have used for applying an imperfection after doing a linear buckling analysis

---------------------------------------------------------------------------------------------

#apply imperfection
odb = openOdb(path=tDr+'/'+jobName1+'.odb')
Frame1 = odb.steps[stepName1].frames[1]
displacement=Frame1.fieldOutputs['U']
fieldValues=displacement.values
Coor=zeros((len(mdb.models[modelName2].parts[partName1].nodes),3),Float)
rep=0
for i in mdb.models[modelName2].parts[partName1].nodes:
    Coor[i.label-1][0]=i.coordinates[0]+imperf*fieldValues[i.label-1].data[0]
    Coor[i.label-1][1]=i.coordinates[1]+imperf*fieldValues[i.label-1].data[1]
    Coor[i.label-1][2]=0.0
    rep=rep+1
mdb.models[modelName2].parts[partName1].editNode(
    nodes=mdb.models[modelName2].parts[partName1].nodes,
    coordinates=Coor)
odb.close()

 ---------------------------------------------------------------------------------------------

However this is not done on a region. In another part of my script I make my own output file for displacement of a certain nodes from a set. The python script is shown below. It is only the part how to read from a region in an odb file

 ---------------------------------------------------------------------------------------------

     lastFrame = odb.steps[stepName2].frames[i]
    displacement=lastFrame.fieldOutputs['U']
    RForce=lastFrame.fieldOutputs['RF']
    regTop = odb.rootAssembly.instances[instName1].nodeSets['TOP']
    regBottom = odb.rootAssembly.instances[instName1].nodeSets['BOTTOM']
    RFYTop=0; RFYBottom=0
    for Num in range(0,len(RForce.getSubset(region=regTop).values)):
        RFYTop=RFYTop+RForce.getSubset(region=regTop).values[Num].data[1]
    for Num in range(0,len(RForce.getSubset(region=regBottom).values)):
        RFYBottom=RFYBottom+RForce.getSubset(region=regBottom).values[Num].data[1]

 --------------------------------------------------------------------------------------------- 

I hope this is readable and of any help.

Best,

Bas

Dear bas,

It was a long time ago I asked this question and I could not thank you for your help!

any way I will like to thank you for your help.

 all the best

 /aygul

Dear Bas,

          I d like to ask you how it is possible to create the following geometry in python. I have a anisotropic square material: (0,0)-->(1,1). Inside this rectangle I have some polygons and for each of them I want to use the same material but different orientations. For these polygons I have the vertices as follows:

xyCoords=((0.5723 ,-0.0000),(0.5195 ,0.0647),(0.6879 ,0.1685),(0.7590 ,0.1384))
 xyCoords=((0.7624 ,-0.0000),(0.7590 ,0.1384),(0.8669 ,0.2088),(0.9035 ,0.2021),(1.0000 ,0.1266))
 xyCoords=((0.2201 ,0.2383),(0.1493 ,0.1824),(-0.0000 ,0.2071),(0.0000 ,0.4047),(0.1666 ,0.3813))

...

All the polygons together create the square. What I want is different solid section for each polygon and different orientation.

 

The input file looks like that:

*Solid Section, elset=_I1, orientation=Ori-16, material=Copper
,
*Orientation, name=Ori-12
          1.,           0.,           0.,           0.,           1.,           0.
3, 78.

...

Hope you could give me a glance how I could achieve that.

All the best,

           Panos

Johannes T.B. Overvelde's picture

Dear Panos,

I haven't got experience with anistropic material in Abaqus. However I do see you have an input file, which means it is possible. In that case I suggest you make the model in the graphical user interface from Abaqus. You can save the model and you will also get a .jnl file. This file contains the script of the actions you performed in the GUI of abaqus. You can change the .jnl file to a .py file and run it. Or change it to your needs. When I explore new things in Abaqus script I always take this route. I wrote an introduction tutorial for Abaqus script that clearly shows how this can be done. You can find it on my website

I should mention that defining orientation in script is not very simple. I have done this when looking for a surface. If the method above does not help you, I can provide you with an example script of finding a surface with correct orientation.

Good luck! 

Hi,

   thank's a lot for your answer. It was really really helpful! I managed after some time to find the solution. Till I encountered another problem. I am using a UMAT for my material. So when I need to run it. I modify the input file and import a user material card with some material parameters (state dependent variables, young modulus, hardening...). There is a specific format in order to couple it with the UMAT.

Is it possible to couple the UMAT to the required material input file without determining the parameters in the python code? Because if I define them in python then the coupling is not obtained with UMAT.for. Another way might be to have the parameters in python but with no definition names and specific order though.

All the best,

             Panos

Johannes T.B. Overvelde's picture

I am not sure I get your question. I have implemented a UMAT or VMAT before with python. To do so I had to change variables in a text file that contained the fortran code to add certain parameters. Then I saved the text file as the correct file type. If you are interested I can look up the script file I applied this in. Just let me know. Did I answer your question?

 

Hi,

  I will tell you what I have so far:

in abaqus window I can run the command abaqus job= file.inp user=umat.

where file.inp has a material module that looks like the following

*USER MATERIAL,CONSTANTS=160,UNSYMM
**
**
    168400., 121400., 75400. ,
**    c11  ,   c12  ,   c44  , (elastic constants of copper crystal)
**    MPa  ,   MPa  ,   MPa  ,
**
      0.   ,
** constants only used for an elastic orthotropic or anisotropic material
**    MPa  ,
...

So each sentence has specific number of parameters, etc...So when I run it, umat recognizes it's variable...

So I was wondering whether I could use a similar approach with python: couple a umat.for file to a txt file with the above descriptions and format of material parameters?

Do u think it is possible? Or do I have to determine all my parameters in python? Actually could you send me yours as well. To see how it  wokrs. Maybe the solution to my problem is already there...

 

All the best,

                Panos

Johannes T.B. Overvelde's picture

I think I have not worked with UMAT before. However, the simplest solution to this problem is to write your input file, and then add the UMAT part you have given above in the input file. You then have to first recognise at what line it should be placed and then add the lines. Save the input file and run it. Below I added part of my code where I edit my input file. It is for a different task (changing the MPC constraint in the input file), but it should give you a good example.

........................................

#write input
mdb.jobs['OldInput'].writeInput()

#change input for MPC
text_file = open("NewInput.inp", "w")
ne=0
for line in open('OldInput.inp'):
    if ne==1:
    if line[0]=='0':
        text_file.write(line[0:-1]+', '+instRefName1+'.VIRTUAL1, '+instRefName2+'.VIRTUAL2' +'\n')
    else:
        text_file.write(line[0:-1]+', MPCr2-'+line[-6:-1]+'\n')
    ne=0
    else:
        text_file.write(line)
    if line[0:4]=='*MPC':
        ne=1
text_file.close()

while os.path.exists(jobName2+'.lck')==True:
    time.sleep(1)
    rep=rep+1
    if rep>30:
        break

os.remove('notFinal.inp')

Thank's a lot!

Hi again,
another problem I am dealing is with the BCs. For the BCs, I select the faces by clicking on them, which reproduces a getSequenceByMask command in the journal. I tried to make a command based on the geometry. So I wont need to select every time the BCs. What I want is: I have a unit square, and I apply a grip on one side and displacement on the other side. The commands are listed below. But I get an error message saying that: 'Abaqus Method' object is unsubscriptable. The error is for the 'edges=a.Instance...' line of the below sequence:

a=mdb.models['Polycrystal'].rootAssembly
a.DatumCsysByDefault(CARTESIAN)
a.Instance(dependent=ON, name='Shell-1',
part=mdb.models['Polycrystal'].parts['Shell'])
mdb.models['Polycrystal'].StaticStep(initialInc=0.1, maxInc=0.1, maxNumInc=
10000, name='Step-displacement', previous='Initial')
#
edges = a.Instance['Shell-1'].edges.getClosest(coordinates=((0.0, 0.0,
0.0),(0.0, 1.0, 0.0),))
myAssembly.Set(edges=edges,name='edgeleft')
region=myAssembly.sets['edgeleft']
mdb.models['Polycrystal'].DisplacementBC(amplitude=UNSET, createStepName=
'Step-displacement', distributionType=UNIFORM, fieldName='', fixed=OFF,
localCsys=None, name='BC-left-roller', region=region, u1=0.0, u2=UNSET,
ur3=UNSET)

why do I get such an error? What I m trying to do is I have the two points, so I
want to get the edge and apply the BC.

All the best,
Panos

Johannes T.B. Overvelde's picture

You should use the command findAt for selecting an edge at a coordinate lying on the edge. When selecting the edges in the GUI you get indeed a command GetSequenceFromMask. You can change this by insterting I line of code in the lower box of Abaqus. The specific line is given in my tutorial, which can be found at my website. Using this line of code will change the GetSequenceFromMaks to the FindAt command, which is much more helpfull.

Good luck

Hi Johannes
I'm facing problem while writing a script for a parametric study.
After changing the each parameter the model changes and and the loaction
of the interested element changes based on those parameters.
Also the element number changes.
Is there any command in python script to choose the elements based on the location ? 

Thank you in advance

Rajesh Kumar

Subscribe to Comments for "Boundary Conditions in ABAQUS using a script file"

Recent comments

More comments

Syndicate

Subscribe to Syndicate