×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

On the tutorial script example in the Doc

On the tutorial script example in the Doc

On the tutorial script example in the Doc

(OP)
I am trying to work with the existing example in scripts user Manual under section

8.10.1 Finding the maximum value of von Mises stress
in the user interface script manual on how to run a script and find Max Mises
They wrote the script
abaqus fetch job=odbMaxMises.py
which suppose to operate on the example:
abaqus fetch job=viewer_tutorial

I have fetched both and then open the viewer_tutorial.Odb file
before I went to run script I went through the script and changed "Odb.name" with "viewer_tutorial"
then I saved the script and went to Run script trying to run it but it said invalid syntex. I am usin the same script in the manual then why Iam getting this
--------------------------------------------
"""
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
"""

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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)
    





RE: On the tutorial script example in the Doc

You should not have changed "odbName" in the script. Undo any changes you made (or fetch it again). It is a very important variable name, check out the script itself and you'll see...

As the comments in the script describe, to run it on your odb (viewer_tutorial) you just need to type:
> abaqus python odbMaxMises.py -odb viewer_tutorial

RE: On the tutorial script example in the Doc

(OP)
I could get the answer after I typed in the abaqus command window C:\abaqus python odbMaxMises.py -odb viewer_tutorial
However,I do not know when It doesnot work the other way: open the OdB viewer_tutorial and then File- Run script.
Try if you donnot beleive

-In general when we want to operate a script on ODB seesion. How can we make them communicate .. should not we (manually) pass the ODB-associated info (OdB name, material name..) to the script, save, and then run the script, e.g you want the obove script to operate on another ODB (not on "viewer_tutorial").
Please let me know as this is very critical to my work.

RE: On the tutorial script example in the Doc

Well, I do believe it... The script was obviously written specifically to be used at the command line. ;)

It is very easy to write scripts (as many here contribute all the time) that use the current odb displayed as the reference for the script. If you ar enice to the group, contribute to the community and so on, then some nice person might even hack the current script to run as you desire...

Or you could just download this:
http://www.wikiupload.com/download_page.php?id=127846

clown

RE: On the tutorial script example in the Doc

(OP)
Brep do you work for wiki upload
have a good night.

RE: On the tutorial script example in the Doc

To your question: No I have nothing to do with wikiupload. (Why would an FE trained engineer be doing that??)

I take it you did not download and/or appreciate my script? I hope someone else is willing to help.

RE: On the tutorial script example in the Doc

(OP)
Brep.. I was just jocking..  anyway thank you for the helpful reply advice

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources