OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to run Abaqus Script in no-GUI mode with using display group APIs

  • Thread starter Thread starter Neha
  • Start date Start date
N

Neha

Guest
I am creating an Abaqus script to get image for max stress and strain of parts across each time increment. Script should open odb files in Abaqus Viewer in no-GUI mode and find out in which time increment each part has max stress and strain, and get an image output of the same. For getting the max values I am using Report-> Field output option API [session.writeFieldReport()]

My script is working fine in GUI mode but not in Non-GUI. May be beacause I have used displayGroupOdbToolset library. Can anyone please help me to modify the code so that it may work in non-GUI mode.

Following is my code to get max result values for each part. #############################################

Code:
from abaqus import *
import displayGroupOdbToolset as dgo
import odbAccess
from abaqusConstants import *
import odbSection
import visualization
import os
import platform
import shutil

# get results
def getResultsFromODB(odbPath, odbName):
    # open odb
    odbPath = os.path.join(odbDir, odbName)
    odb = odbAccess.openOdb(path=odbPath)
    session.viewports['Viewport: 1'].setValues(displayedObject=odb)
    allframe = odb.steps['Step-1'].frames
    leaf = dgo.Leaf(leafType=DEFAULT_MODEL)
    session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
    # filter parts which have "_3D" as suffix in their name
    allElemSets = odb.rootAssembly.instances['PART-1-1'].elementSets.keys()
    sets_3D = []
    p = 0
    while p < len(allElemSets):
        x = allElemSets[p]
        p += 1
        if x[-3:] == '_3D':
            name = 'PART-1-1.' + x
            name = str(name)
            sets_3D.append(name)
    # log('getting data from parts...')
    # displaying parts one by one to export *.rpt file to get max values of results in each increments
    session.fieldReportOptions.setValues(printXYData=OFF, printTotal=OFF)
    for name in sets_3D:
        # log(name)
        leaf = dgo.LeafFromElementSets(elementSets=(name, ))
        session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
        outFile = os.path.abspath(os.path.join(odbDir, name)) + '.rpt'
        session.writeFieldReport(fileName=outFile, append=ON, 
                sortItem='Node Label', odb=odb, step=(len(odb.steps)-1), frame=(len(allframe)-1), outputPosition=NODAL, 
                variable=(('LE', INTEGRATION_POINT, ((INVARIANT, 'Max. Principal'), )), (
                'S', INTEGRATION_POINT, ((INVARIANT, 'Mises'), (INVARIANT, 
                'Max. Principal'), )), ), stepFrame=ALL)
    # reading max values from *.rpt file and exporting into *.csv file
    result = []
    for name in sets_3D:
        lst_resultValues = readTextFile((os.path.join(odbDir, name)) + '.rpt')
        data = str(name) + ',' + str(lst_resultValues[0][0]) + ',' + str(lst_resultValues[0][1]) + ',' + str(lst_resultValues[0][2]) +\
        ',' + str(lst_resultValues[1][0]) + ',' + str(lst_resultValues[1][1]) + ',' + str(lst_resultValues[1][2]) +\
        ',' + str(lst_resultValues[2][0]) + ',' + str(lst_resultValues[2][1]) + ',' + str(lst_resultValues[2][2])
        result.append(data)
    # log('exporting results to CSV...')
    OutFileName = os.path.splitext(os.path.basename(odbName))[0]
    export_CSV( os.path.abspath(os.path.join(odbDir, OutFileName)) + '.csv' , result)
    # log('Done')
    session.odbs[odbPath].close()

getResultsFromODB(odbDir, odbName)
<p>I am creating an Abaqus script to get image for max stress and strain of parts across each time increment.
Script should open odb files in Abaqus Viewer in no-GUI mode and find out in which time increment each part has max stress and strain, and get an image output of the same. For getting the max values I am using Report-> Field output option API [session.writeFieldReport()]</p>
<p>My script is working fine in GUI mode but not in Non-GUI. May be beacause I have used displayGroupOdbToolset library.
Can anyone please help me to modify the code so that it may work in non-GUI mode.</p>
<p>Following is my code to get max result values for each part.
#############################################</p>
<pre><code>from abaqus import *
import displayGroupOdbToolset as dgo
import odbAccess
from abaqusConstants import *
import odbSection
import visualization
import os
import platform
import shutil

# get results
def getResultsFromODB(odbPath, odbName):
# open odb
odbPath = os.path.join(odbDir, odbName)
odb = odbAccess.openOdb(path=odbPath)
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
allframe = odb.steps['Step-1'].frames
leaf = dgo.Leaf(leafType=DEFAULT_MODEL)
session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
# filter parts which have "_3D" as suffix in their name
allElemSets = odb.rootAssembly.instances['PART-1-1'].elementSets.keys()
sets_3D = []
p = 0
while p < len(allElemSets):
x = allElemSets[p]
p += 1
if x[-3:] == '_3D':
name = 'PART-1-1.' + x
name = str(name)
sets_3D.append(name)
# log('getting data from parts...')
# displaying parts one by one to export *.rpt file to get max values of results in each increments
session.fieldReportOptions.setValues(printXYData=OFF, printTotal=OFF)
for name in sets_3D:
# log(name)
leaf = dgo.LeafFromElementSets(elementSets=(name, ))
session.viewports['Viewport: 1'].odbDisplay.displayGroup.replace(leaf=leaf)
outFile = os.path.abspath(os.path.join(odbDir, name)) + '.rpt'
session.writeFieldReport(fileName=outFile, append=ON,
sortItem='Node Label', odb=odb, step=(len(odb.steps)-1), frame=(len(allframe)-1), outputPosition=NODAL,
variable=(('LE', INTEGRATION_POINT, ((INVARIANT, 'Max. Principal'), )), (
'S', INTEGRATION_POINT, ((INVARIANT, 'Mises'), (INVARIANT,
'Max. Principal'), )), ), stepFrame=ALL)
# reading max values from *.rpt file and exporting into *.csv file
result = []
for name in sets_3D:
lst_resultValues = readTextFile((os.path.join(odbDir, name)) + '.rpt')
data = str(name) + ',' + str(lst_resultValues[0][0]) + ',' + str(lst_resultValues[0][1]) + ',' + str(lst_resultValues[0][2]) +\
',' + str(lst_resultValues[1][0]) + ',' + str(lst_resultValues[1][1]) + ',' + str(lst_resultValues[1][2]) +\
',' + str(lst_resultValues[2][0]) + ',' + str(lst_resultValues[2][1]) + ',' + str(lst_resultValues[2][2])
result.append(data)
# log('exporting results to CSV...')
OutFileName = os.path.splitext(os.path.basename(odbName))[0]
export_CSV( os.path.abspath(os.path.join(odbDir, OutFileName)) + '.csv' , result)
# log('Done')
session.odbs[odbPath].close()

getResultsFromODB(odbDir, odbName)
</code></pre>
 

Latest posts

J
Replies
0
Views
1
Jeff P Chacko
J
Top