[Geoqus] ABAQUS tutorial example (Section 8.10.1) in script user Manual

bsaad at po-box.mcgill.ca bsaad at po-box.mcgill.ca
Mon Apr 16 06:26:19 CEST 2007


I am just going through the example below in the script User Manual

8.10 Example scripts that access data from an output database
Quote:
" The following illustrates how you can run the example script from the 
system prompt. The script will search the element set ALL ELEMENTS in 
the viewer tutorial output database for the maximum value of von Mises 
stress:

abaqus python odbMaxMises.py -odb viewer_tutorial.odb    -elset ? ALL 
ELEMENTS?
Note:  If a command line argument is a String that contains spaces, 
some systems will interpret the String correctly only if it is enclosed 
in double quotation marks. For example, ? ALL ELEMENTS?.

You can also run the example with only the -help parameter for a 
summary of the usage.


"""
odbMaxMises.py
Code to determine the location and value of the maximum
von-mises stress in an output database.
Usage: abaqus python odbMaxMises.py -odb odbName
       -elset(optional) elsetName
Requirements:
1. -odb   : Name of the output database.
2. -elset : Name of the assembly level element set.
            Search will be done only for element belonging
            to this set. If this parameter is not provided,
            search will be performed over the entire model.
3. -help  : Print usage
"""
# So according to the above I only  changed the argumeny odb.name 
#toviewer_tutorial in the script below, but why it doesnot run . I am 
#getting crazy. Please try the example yourselves

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from odbAccess import *
from sys import argv,exit
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def rightTrim(input,suffix):
    if (input.find(suffix) == -1):
        input = input + suffix
    return input
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def getMaxMises(viewer_tutorial,elsetName):
    """ Print max mises location and value given odbName
        and elset(optional)
    """
    elset = elemset = None
    region = "over the entire model"
    """ Open the output database """
    odb = openOdb(viewer_tutorial)
    assembly = odb.rootAssembly

    """ Check to see if the element set exists
        in the assembly
    """
    if elsetName:
        try:
            elemset = assembly.elementSets[elsetName]
            region = " in the element set : " + elsetName;
        except KeyError:
            print 'An assembly level elset named %s does' \
                   'not exist in the output database %s' \
                   % (elsetName, viewer_tutorial)
            odb.close()
            exit(0)
               """ Initialize maximum values """
    maxMises = -0.1
    maxElem = 0
    maxStep = "_None_"
    maxFrame = -1
    Stress = 'S'
    isStressPresent = 0
    for step in odb.steps.values():
        print 'Processing Step:', step.name
        for frame in step.frames:
            allFields = frame.fieldOutputs
            if (allFields.has_key(Stress)):
                isStressPresent = 1
                stressSet = allFields[Stress]
                if elemset:
                    stressSet = stressSet.getSubset(
                        region=elemset)                     for 
stressValue in stressSet.values:                                   if 
(stressValue.mises > maxMises):
                        maxMises = stressValue.mises
                        maxElem = stressValue.elementLabel
                        maxStep = step.name
                        maxFrame = frame.frameId
    if(isStressPresent):
        print 'Maximum von Mises stress %s is %f in element %d'%(
            region, maxMises, maxElem)
        print 'Location: frame # %d  step:  %s '%(maxFrame,maxStep)
    else:
        print 'Stress output is not available in' \
              'the output database : %s\n' %(odb.name)
       """ Close the output database before exiting the program """
    odb.close()

#==================================================================
# S T A R T
#    if __name__ == '__main__':
       odbName = viewer_tutorial
    elsetName = None
    argList = argv
    argc = len(argList)
    i=0
    while (i < argc):
        if (argList[i][:2] == "-o"):
            i += 1
            name = argList[i]
            odbName = rightTrim(name,".odb")
        elif (argList[i][:2] == "-e"):
            i += 1
            elsetName = argList[i]
        elif (argList[i][:2] == "-h"):                       print __doc__
            exit(0)
        i += 1
    if not (odbName):
        print ' **ERROR** output database name is not provided'
        print __doc__
        exit(1)
    getMaxMises(viewer_tutorial,elsetName)







More information about the Geoqus mailing list