Abaqus_Python

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Abaqus_Python

Abaqus Users mailing list
Hi every body,
 

 I am trying to extract some data using python development environment in abaqus. However, my model has almost, 350 frames and 7000 meshes and takes a lots of time, more than one day, to give me results. Does anyone know how to extract some variables from .odb file in python without opening abaqus. Seems to me it will be faster. thank you in advance for your help.
 

 Best regards,
 Mojtaba
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Abaqus_Python

Abaqus Users mailing list
Hi Mojtaba


If you invoke Abaqus as


abaqus cae -noGUI <script name>


eg abaqus cae -noGUI test_script.py


then the gui does not open and script executes in the background.


Does that help?


Miten

________________________________
From: [hidden email] <[hidden email]> on behalf of [hidden email] [Abaqus] <[hidden email]>
Sent: 04 August 2017 12:13:40
To: [hidden email]
Subject: [Abaqus] Abaqus_Python



Hi every body,


I am trying to extract some data using python development environment in abaqus. However, my model has almost, 350 frames and 7000 meshes and takes a lots of time, more than one day, to give me results. Does anyone know how to extract some variables from .odb file in python without opening abaqus. Seems to me it will be faster. thank you in advance for your help.


Best regards,

Mojtaba


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Abaqus_Python

Abaqus Users mailing list
In reply to this post by Abaqus Users mailing list
Hello Mojtaba,
 

 You can use Matlab for the extraction of results from an odb file without opening Abaqus at all. You can try the Abaqus2Matlab application with which you can extract a variety of results from an odb file. Go to www.abaqus2matlab.com and download the 2nd version of the app. This application is capable of postprocessing relatively large odb files, and it can create Python scripts configured according to your needs for postprocessing any odb file.
 

 I hope this will help you in your research.
 

 Best,
_______________________________________________
George Papazafeiropoulos
Captain, Infrastructure Engineer, Hellenic Air Force
Civil Engineer, M.Sc., Ph.D. candidate, NTUA
Email: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Abaqus_Python

Abaqus Users mailing list
In reply to this post by Abaqus Users mailing list
Hello Miten,

 Thanks a lot, it really helps.
 however, my abaqus command does not work and i created a .bat file which runs cmd in related folder and could run .py file.
 

 Best regards,
 Mojtaba.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Abaqus_Python

Abaqus Users mailing list
In reply to this post by Abaqus Users mailing list
Perhaps you should post some of your code.  There are a variety of things that could be making your code less efficient than it could be.

Regards,

Dave Lindeman
Lead Research Specialist
SEMS Research Laboratory
3M Center 235-3G-08
St. Paul, MN 55144
651-733-6383

From: [hidden email] [mailto:[hidden email]]
Sent: Friday, August 04, 2017 6:14 AM
To: [hidden email]
Subject: [EXTERNAL] [Abaqus] Abaqus_Python



Hi every body,



I am trying to extract some data using python development environment in abaqus. However, my model has almost, 350 frames and 7000 meshes and takes a lots of time, more than one day, to give me results. Does anyone know how to extract some variables from .odb file in python without opening abaqus. Seems to me it will be faster. thank you in advance for your help.



Best regards,

Mojtaba





3M security scanners have not detected any malicious content in this message.
Click here<https://spam.mmm.com:443/pem/pages/digestProcess/digestProcess.jsf?content=aedaaa864ecbae943d1b8fccea6cdae74edb895cc9d1e467ae71f68db7a9c6ecc6c4ff5fb22097b592aab29dac82584f30f60c161a797f8d8d8a621478a2f25250f75f3a4b570e12125b08ef0dd8e5d1dbc7a045714a146255659761471276b985c737a3334ed90b1ff78053eaa8c27c6dc37ee21f7f3ae2a65d7f79d67ffbd5ff53b47a8a233403> to report this email as spam





[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Abaqus_Python

Abaqus Users mailing list
Hello David,

 Thank you for your answer. It is my code, please take a look at it.
 

 

 

 from odbAccess import *
 from abaqusConstants import *
 from odbMaterial import *
 from odbSection import *
 import sys
 import os
 

 

 myOdb  = openOdb(path='micro.odb')
 f=open('inputf.txt' , 'w')
 fu=open('inputu.txt' , 'w')
 fSig=open('inputSigma.txt' , 'w')
 fst=open('inputStrain.txt' , 'w')
 

 myAssembly = myOdb.rootAssembly
 

 mystepout = myOdb.steps
 rangestep = len(mystepout)
 Stress = 'S'
 Volume = 'EVOL'
 LogStrain = 'LE'
 Force = 'RF'
 Displacement = 'U'
 

 myInstance = myOdb.rootAssembly.instances['COMPOSITE-1']
 numNodes = len(myInstance.nodes)
 numElements = len(myInstance.elements)
 StressXX = []
 StrainXX = []
 StressYY = []
 StrainYY = []
 FXX =[]
 FYY =[]
 UXX =[]
 UYY =[]
 

 


 for i in range(rangestep):
 
   for j in range(0,LenghtofFrames,10):

        #print j
        TotalstressX = 0
        TotalstrainX = 0
        TotalstressY = 0
        TotalstrainY = 0
        Totalvalume = 0
       
        for el in range(0,numElements):
            #print el
            StressFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[Stress].getSubset(region=myInstance.elements[el],
            position=CENTROID, elementType='CPS4').values
           
            StrainFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[LogStrain].getSubset(region=myInstance.elements[el],
            position=CENTROID, elementType='CPS4').values                                                                                        
                                                                                                     
            AreaFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[Volume].getSubset(region=myInstance.elements[el],
            elementType='CPS4').values
                                                                                                   
       
            Sxx = StressFields[0].data[0]
            Syy = StressFields[0].data[1]
            Szz = StressFields[0].data[2]
            Sxy = StressFields[0].data[3]
            AreaofEl = AreaFields[0].data
            Exx = StrainFields[0].data[0]
            Eyy = StrainFields[0].data[1]
            Ezz = StrainFields[0].data[2]
            Exy = StrainFields[0].data[3]
            AreaofEl = AreaFields[0].data
            TotalstressX +=  Sxx*AreaofEl
            TotalstressY +=  Syy*AreaofEl
            TotalstrainX +=  Exx*AreaofEl
            TotalstrainY +=  Eyy*AreaofEl                                                                                    
            Totalvalume +=  AreaofEl
 

        calcstressXX = TotalstressX/Totalvalume
        StressXX.append(calcstressXX)
        calcstressYY = TotalstressY/Totalvalume
        StressYY.append(calcstressYY)
       
        fSig.write("%s\n" % (calcstressXX))
 

       
       
        calcstrainXX = TotalstrainX/Totalvalume
        StrainXX.append(calcstrainXX)
        calcstrainYY = TotalstrainY/Totalvalume
        StrainYY.append(calcstrainYY)
       
        fst.write("%s\n" % (calcstrainXX))
 

 

 fSig.close()
 fst.close()
 


 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Abaqus_Python

Abaqus Users mailing list
The following is entirely UNTESTED, but should at least give you some guidance.  The most important thing to learn is that when you are working with ‘for’ loops (especially nested loops), you want to work with the lowest level object possible (in this case, the ‘frame’ object).  Repeatedly accessing data from the top level object (e.g., ‘myOdb.steps[mystepout.keys()[i]]…’) is EXTREMELY  inefficient.  Also, as you can see, NumPy provides a variety of tools that can simplify various operations.


from abaqusConstants import *
import visualization
import numpy
import os

myOdb  = openOdb(path='micro.odb')

fStress = open('inputStress.txt' , 'w')
fStrain = open('inputStrain.txt' , 'w')

myAssembly = myOdb.rootAssembly
myInstance = myOdb.rootAssembly.instances['COMPOSITE-1']

for key in odb.steps.keys():
  step = odb.steps[key]
  for frame in step.frames:
    stressField = frame.fieldOutputs['S'].getSubset(region=myInstance, position=CENTROID)
    sxx = numpy.array([x.data[0] for x in stressField.values])
    syy = numpy.array([x.data[1] for x in stressField.values])
    szz = numpy.array([x.data[2] for x in stressField.values])
    sxy = numpy.array([x.data[3] for x in stressField.values])
    strainField = frame.fieldOutputs['LE'].getSubset(region=myInstance, position=CENTROID)
    exx = numpy.array([x.data[0] for x in strainsField.values])
    eyy = numpy.array([x.data[1] for x in strainField.values])
    ezz = numpy.array([x.data[2] for x in strainField.values])
    exy = numpy.array([x.data[3] for x in strainField.values])
    volumeField = frame.fieldOutputs['VOLU'].getSubset(region=myInstance, position=CENTROID)
    vol = numpy.array([x.data for x in volumeField.values])
    totalVol = sum(vol)
    sxxAve = sum(numpy.multiply(sxx, vol))/totalVol
    syyAve = sum(numpy.multiply(syy, vol))/totalVol
    szzAve = sum(numpy.multiply(szz, vol))/totalVol
    sxyAve = sum(numpy.multiply(sxy, vol))/totalVol
    fStress.write('%12.5e,%12.5e,%12.5e,%12.5e\n' % (sxxAve,syyAve,szzAve,sxyAve))
    exxAve = sum(numpy.multiply(exx, vol))/totalVol
    eyyAve = sum(numpy.multiply(eyy, vol))/totalVol
    ezzAve = sum(numpy.multiply(ezz, vol))/totalVol
    exyAve = sum(numpy.multiply(exy, vol))/totalVol
    fStrain.write('%12.5e,%12.5e,%12.5e,%12.5e\n' % (exxAve,eyyAve,ezzAve,exyAve))

fStress.close()
fStrain.close()


Regards,

Dave Lindeman
Lead Research Specialist
SEMS Research Laboratory
3M Center 235-3G-08
St. Paul, MN 55144
651-733-6383

From: [hidden email] [mailto:[hidden email]]
Sent: Wednesday, August 09, 2017 7:50 AM
To: [hidden email]
Subject: [EXTERNAL] [Abaqus] Re: Abaqus_Python



Hello David,

Thank you for your answer. It is my code, please take a look at it.



from odbAccess import *
from abaqusConstants import *
from odbMaterial import *
from odbSection import *
import sys
import os


myOdb  = openOdb(path='micro.odb')
f=open('inputf.txt' , 'w')
fu=open('inputu.txt' , 'w')
fSig=open('inputSigma.txt' , 'w')
fst=open('inputStrain.txt' , 'w')

myAssembly = myOdb.rootAssembly

mystepout = myOdb.steps
rangestep = len(mystepout)
Stress = 'S'
Volume = 'EVOL'
LogStrain = 'LE'
Force = 'RF'
Displacement = 'U'


myInstance = myOdb.rootAssembly.instances['COMPOSITE-1']
numNodes = len(myInstance.nodes)
numElements = len(myInstance.elements)
StressXX = []
StrainXX = []
StressYY = []
StrainYY = []
FXX =[]
FYY =[]
UXX =[]
UYY =[]


for i in range(rangestep):

  for j in range(0,LenghtofFrames,10):
       #print j
       TotalstressX = 0
       TotalstrainX = 0
       TotalstressY = 0
       TotalstrainY = 0
       Totalvalume = 0

       for el in range(0,numElements):
      &n! bsp;    #print el
      &nb! sp;    StressFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[Stress].getSubset(region=myInstance.elements[el],
           position=CENTROID, elementType='CPS4').values

           StrainFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[LogStrain].getSubset(region=myInstance.elements[el],
           position=CENTROID, elementType='CPS4').values
                         ! ;
           AreaFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[Volume].getSubset(region=myInstance.elements[el],
           elementType='CPS4').values


           Sxx = StressField! s[0].data[0]
           Syy = S! tressFields[0].data[1]
           Szz = StressFields[0].data[2]
           Sxy = StressFields[0].data[3]
           AreaofEl = AreaFields[0].data
           Exx = StrainFields[0].data[0]
           Eyy = StrainFields[0].data[1]
           Ezz = StrainFields[0].data[2]
           Exy = StrainFields[0].data[3]
           AreaofEl = AreaFields[0].data
           TotalstressX +=  Sxx*AreaofEl
           TotalstressY +=  Syy*AreaofEl
           TotalstrainX +=  Exx*AreaofEl
           Totalstr! ainY +=  Eyy*AreaofEl
           Totalvalume +=  AreaofEl

       calcstressXX = TotalstressX/Totalvalume
       StressXX.append(calcstressXX)
       calcstressYY = TotalstressY/Totalvalume
       StressYY.append(calcstressYY)

       fSig.write("%s\n" % (calcstressXX))



       calcstrainXX = Totalstra! inX/Totalvalume
       StrainXX.append(ca! lcstrainXX)
       calcstrainYY = TotalstrainY/Totalvalume
       StrainYY.append(calcstrainYY)

       fst.write("%s\n" % (calcstrainXX))


fSig.close()
fst.close()







3M security scanners have not detected any malicious content in this message.
Click here<https://spam.mmm.com:443/pem/pages/digestProcess/digestProcess.jsf?content=aedaaa864ecbae94ffbe65211036e682f11f2929a1c76f813a29b3ff4b8a56b2c6c4ff5fb22097b592aab29dac82584f30f60c161a797f8d8d8a621478a2f25250f75f3a4b570e12125b08ef0dd8e5d1dbc7a045714a146255659761471276b985c737a3334ed90b06d6f1c624cbecd4c32c6149d7e465ae6769d8be563e445d1f2bbf8de7d08ded> to report this email as spam





[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Abaqus_Python

Abaqus Users mailing list
That's superb Dave. Compressed my code substantially!


If I wanted to time average a stress or strain value extracted below over a number of consecutive (time) frames, then would the could I utilise the below logic with similar minimal extension or is that quite complex?


Thanks,


Miten



________________________________
From: [hidden email] <[hidden email]> on behalf of David Lindeman [hidden email] [Abaqus] <[hidden email]>
Sent: 10 August 2017 15:46:54
To: [hidden email]
Subject: RE: [Abaqus] Re: Abaqus_Python



The following is entirely UNTESTED, but should at least give you some guidance. The most important thing to learn is that when you are working with ‘for’ loops (especially nested loops), you want to work with the lowest level object possible (in this case, the ‘frame’ object). Repeatedly accessing data from the top level object (e.g., ‘myOdb.steps[mystepout.keys()[i]]…’) is EXTREMELY inefficient. Also, as you can see, NumPy provides a variety of tools that can simplify various operations.

from abaqusConstants import *
import visualization
import numpy
import os

myOdb = openOdb(path='micro.odb')

fStress = open('inputStress.txt' , 'w')
fStrain = open('inputStrain.txt' , 'w')

myAssembly = myOdb.rootAssembly
myInstance = myOdb.rootAssembly.instances['COMPOSITE-1']

for key in odb.steps.keys():
step = odb.steps[key]
for frame in step.frames:
stressField = frame.fieldOutputs['S'].getSubset(region=myInstance, position=CENTROID)
sxx = numpy.array([x.data[0] for x in stressField.values])
syy = numpy.array([x.data[1] for x in stressField.values])
szz = numpy.array([x.data[2] for x in stressField.values])
sxy = numpy.array([x.data[3] for x in stressField.values])
strainField = frame.fieldOutputs['LE'].getSubset(region=myInstance, position=CENTROID)
exx = numpy.array([x.data[0] for x in strainsField.values])
eyy = numpy.array([x.data[1] for x in strainField.values])
ezz = numpy.array([x.data[2] for x in strainField.values])
exy = numpy.array([x.data[3] for x in strainField.values])
volumeField = frame.fieldOutputs['VOLU'].getSubset(region=myInstance, position=CENTROID)
vol = numpy.array([x.data for x in volumeField.values])
totalVol = sum(vol)
sxxAve = sum(numpy.multiply(sxx, vol))/totalVol
syyAve = sum(numpy.multiply(syy, vol))/totalVol
szzAve = sum(numpy.multiply(szz, vol))/totalVol
sxyAve = sum(numpy.multiply(sxy, vol))/totalVol
fStress.write('%12.5e,%12.5e,%12.5e,%12.5e\n' % (sxxAve,syyAve,szzAve,sxyAve))
exxAve = sum(numpy.multiply(exx, vol))/totalVol
eyyAve = sum(numpy.multiply(eyy, vol))/totalVol
ezzAve = sum(numpy.multiply(ezz, vol))/totalVol
exyAve = sum(numpy.multiply(exy, vol))/totalVol
fStrain.write('%12.5e,%12.5e,%12.5e,%12.5e\n' % (exxAve,eyyAve,ezzAve,exyAve))

fStress.close()
fStrain.close()

Regards,

Dave Lindeman
Lead Research Specialist
SEMS Research Laboratory
3M Center 235-3G-08
St. Paul, MN 55144
651-733-6383

From: [hidden email] [mailto:[hidden email]]
Sent: Wednesday, August 09, 2017 7:50 AM
To: [hidden email]
Subject: [EXTERNAL] [Abaqus] Re: Abaqus_Python

Hello David,

Thank you for your answer. It is my code, please take a look at it.

from odbAccess import *
from abaqusConstants import *
from odbMaterial import *
from odbSection import *
import sys
import os

myOdb = openOdb(path='micro.odb')
f=open('inputf.txt' , 'w')
fu=open('inputu.txt' , 'w')
fSig=open('inputSigma.txt' , 'w')
fst=open('inputStrain.txt' , 'w')

myAssembly = myOdb.rootAssembly

mystepout = myOdb.steps
rangestep = len(mystepout)
Stress = 'S'
Volume = 'EVOL'
LogStrain = 'LE'
Force = 'RF'
Displacement = 'U'

myInstance = myOdb.rootAssembly.instances['COMPOSITE-1']
numNodes = len(myInstance.nodes)
numElements = len(myInstance.elements)
StressXX = []
StrainXX = []
StressYY = []
StrainYY = []
FXX =[]
FYY =[]
UXX =[]
UYY =[]

for i in range(rangestep):

for j in range(0,LenghtofFrames,10):
#print j
TotalstressX = 0
TotalstrainX = 0
TotalstressY = 0
TotalstrainY = 0
Totalvalume = 0

for el in range(0,numElements):
&n! bsp; #print el
&nb! sp; StressFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[Stress].getSubset(region=myInstance.elements[el],
position=CENTROID, elementType='CPS4').values

StrainFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[LogStrain].getSubset(region=myInstance.elements[el],
position=CENTROID, elementType='CPS4').values
! ;
AreaFields = myOdb.steps[mystepout.keys()[i]].frames[j].fieldOutputs[Volume].getSubset(region=myInstance.elements[el],
elementType='CPS4').values

Sxx = StressField! s[0].data[0]
Syy = S! tressFields[0].data[1]
Szz = StressFields[0].data[2]
Sxy = StressFields[0].data[3]
AreaofEl = AreaFields[0].data
Exx = StrainFields[0].data[0]
Eyy = StrainFields[0].data[1]
Ezz = StrainFields[0].data[2]
Exy = StrainFields[0].data[3]
AreaofEl = AreaFields[0].data
TotalstressX += Sxx*AreaofEl
TotalstressY += Syy*AreaofEl
TotalstrainX += Exx*AreaofEl
Totalstr! ainY += Eyy*AreaofEl
Totalvalume += AreaofEl

calcstressXX = TotalstressX/Totalvalume
StressXX.append(calcstressXX)
calcstressYY = TotalstressY/Totalvalume
StressYY.append(calcstressYY)

fSig.write("%s\n" % (calcstressXX))

calcstrainXX = Totalstra! inX/Totalvalume
StrainXX.append(ca! lcstrainXX)
calcstrainYY = TotalstrainY/Totalvalume
StrainYY.append(calcstrainYY)

fst.write("%s\n" % (calcstrainXX))

fSig.close()
fst.close()

3M security scanners have not detected any malicious content in this message.
Click here<https://spam.mmm.com:443/pem/pages/digestProcess/digestProcess.jsf?content=aedaaa864ecbae94ffbe65211036e682f11f2929a1c76f813a29b3ff4b8a56b2c6c4ff5fb22097b592aab29dac82584f30f60c161a797f8d8d8a621478a2f25250f75f3a4b570e12125b08ef0dd8e5d1dbc7a045714a146255659761471276b985c737a3334ed90b06d6f1c624cbecd4c32c6149d7e465ae6769d8be563e445d1f2bbf8de7d08ded> to report this email as spam

[Non-text portions of this message have been removed]



Loading...