How To Post Process ANSYS FEA Results in ANSYS CFD

The other day there was a thread on XANSYS about the best way to create animations in ANSYS Mechanical APDL (MAPDL).  If you are an MAPDL user you know that the animation tools found there were actually way ahead of their time… in 2001.  Now they are a bit limited and the AVI file it creates uses a codec that are a bit old.  You can write a macro that creates PNG files that you can then string together into an AVI, WMV, MOOV or animated gif file.  Check out the thread (go to XANSYS and search on animation) and you can see some of the options suggested.

As I was reading the thread I remembered that one of the CFD guys from ANSYS, Inc. once asked if we used CFX Post to post process our FEA results.  I of course pretended that I knew all about it and “just didn’t have time to play with it yet.”  The next time I had time at my desk I looked it up and there it was, under File->Load Results you can set the “Files of Type” drop down to read a whole slew of ANSYS Mechanical and MAPDL files:


I then promptly forgot about it till I was reading the thread.  So, I figure the best way to remember is to store it for posterity bouncing through the tubes of the interweb  as a blog posting.


CFX Post has been generalized and renamed as CFD Post. As a long time ANSYS MAPDL bigot I have to say, and this is a very difficult admission, CFD Post is a a very nice post processor.  Maybe I think like a Torontonian or something, but no matter how long it has been since I’ve used it, I can jump right in and figure out what needs to be done. 

It is a CFD post processor and you can use it to post CFX, FLUENT, FIDAP, TASKFLOW and the general CGNS files that most CFD tools create.  So the terminology is defiantly oriented towards CFD users.  But because CFX supports moving meshes and conjugate heat transfer, it has most things that you need to read and post process an FEA result.  It is also scriptable and can be run in batch for process automation.

If you are not familiar with the tool I recommend that you go into help and find the CFD-Post manual.  Inside you will find a great user guide, but more importantly there are a set of thorough tutorials. The Mixing Elbow example will teach you the basics you need to know to find your way around the interface.

Before we get into the details, it should be pointed out that you are not going to find some huge, awesome, fantastic feature in CFD Post that is not in ANSYS Mechanical.  It does pretty much the same things, just a little differently.  I find it a bit more intuitive and there are some key things it does better as well as some things that it only does.  What we recommend it for is fancy animations, higher quality graphics, batch post processing, and comparing multiple results in one run.

The Key Things to Know

Most things you want to do in CFD Post occur in the tree to the left of the view window.  It has multiple tabs but you will be using the Outline tab most of the time unless you are doing expressions and stuff (like *get’s in MAPDL, we will leave those as an exercise for the user).  Once you load a result you will see four top level folders:  Cases, User Locations and Plots, Report and Display Properties & Defaults:


The file you read in is shown in cases.  The external surface of your model is grouped as the Default Boundary.  You can pretty much ignore Report and Display Properties and Defaults unless you want to get fancy or for some reason you really hate the almost identical report generator in ANSYS Mechanical.

This leaves the User Locations and Plots. This is where you specify what you want to see and how you want to see it. 

The most common thing to do is RMB on User Locations and Plots and insert a Contour Plot.  When you do so you get “Details” dialog below your tree that has all the options. To see the details on an existing menu item double-click on it or RMG->Edit:


Most of the options you need are in the first tab, Geometry.  The key option is the Variable. This is the result value you want to display.  The list is limited compared to MAPDL but has all of the values that are explicitly stored in the *.RST file.  You will want to set Range to local (min and max from the domain you have selected).  You can also add or delete contours with # of Contours.  I set this to 256 to get a smooth contour.

At the bottom of the Detail there is an apply button, use this to update your plot as you play with the various options.

By default the contour plot shows color bands and lines between color bands, called Isopleths in most programs. CFD Post calls them Contour lines. If you want them off, go to the Render tab and uncheck Show Contour Lines.  If you just want the lines and no color bands, then check Show Contour Lines and uncheck Show Contour Bands.  Below are some plots with the options used to create them.  Any values not specified were at their default value:


  • Tree:
    • Default Boundary – Off
    • Contour 1 – On
    • Default Legend View 1 – On
    • Wireframe – On
  • Detail – Geometry:
    • Domains –  All Domains
    • Locations – Default Boundary
    • Variable – Total Mesh Displacement
    • Range – Local
    • # of Contours – 11
  • Detail – Render
    • Show Contour Bands – On
    • Show Contour Lines – On
    • Line Width – 1
    • Constant Coloring – Off


  • Tree:
    • Default Boundary – Off
    • Contour 1 – On
    • Default Legend View 1 – On
    • Wireframe – On
  • Detail – Geometry:
    • Domains –  All Domains
    • Locations – Default Boundary
    • Variable – Total Mesh Displacement
    • Range – Local
    • # of Contours – 256
  • Detail – Render
    • Show Contour Bands – On
    • Show Contour Lines – OFF


  • Tree:
    • Default Boundary – On
    • Contour 1 – On
    • Default Legend View 1 – On
    • Wireframe – On
  • Detail – Geometry:
    • Domains –  All Domains
    • Locations – Default Boundary
    • Variable – Total Mesh Displacement
    • Range – Local
    • # of Contours – 10
  • Detail – Render
    • Show Contour Bands – OFF
    • Show Contour Lines – On
    • Line Width – 5

Every once in a while you need a black and white contour plot with isopleths.  You can do that in CFD Post very easily with contour options and by going into the Cases part of the tree and editing the Default Boundary options.  On the render tab, set the color to 0.   Make sure that the Default Boundary is checked so it shows up.  Now go to the Contour and:

  • Adjust the number of contours to a reasonable number (10 is good)
  • Under the Labels tab check Show Numbers
  • Under the Render tab:
    • Uncheck Show Contour Bands
    • Check Show Contour Lines
    • Set line width to a larger number, 2 to 5 should work depending on your geometry
    • Check Constant Coloring
    • Make sure Color Mode is at Default


I could fill up another 20 screens with all the options available.  Just get in there and play with it.


Multiple Result Steps

If your result file has multiple result sets in it, maybe it is a transient run or has multiple load steps, you can access those results by clicking on the little Clock icon at the top of the CFD Post window:


You get a dialog that shows each of the steps in your *.RST along with times.  To look at a specific result, click on it and hit apply.


I have not found a way for this to work with modal results yet…  For now you need to use a macro to split your modes into separate RST files.


One of the key reasons to use CFD Post for an FEA model is to get keyframe animations.  Clinton wrote a great article on how to use this great feature a while back.   It doesn’t really do the type of 0 to result animation that we do in the FEA world (like say a mode shape animation)  What it is good at is transients.

It has lots of nice options to make a high quality file.  It also has the ability to animate the motion of the camera, which may be nice to have.  Also, if you are animating a contour plot you want to enable global ranges on your contour. To do this read the section on global variables in the “Things to Know” section below.

The defaults make an OK animation. To get a good animation you need to click on the Options button and then make sure that “White Background” is checked (or you will get JPEG’y distortion) and on the Advanced tab set Quality to High.  Last, check Don’t Encode Last MPEG frame so you can loop.

I’ve included a couple of animations I did with it here:

Basic plot:


Fancy with camera moving.  Note that when converting to GIF you loose colors (GIF is only 256 colors).  The AVI looks much nicer.



A Valve fly through. I put this one on YouTube:

Here is the animated gif:


Things to Know

There are some limitations.  Take a look at the help for CFD Post in section

Setting units is hidden a bit.  Go to Edit->Options->Units and set them to what you want.

If you want a deformed shape on your plot, you access that by RMB’ing on the graphics window, but not on your part.  Then choose Deformation and then the level you want. Auto usually works best.

Files for ANSYS Webinar on External Connections

Here are the files for the webinar on External Connection from 10/14/2011.

Example XML File: sampleconfig2.xml

Example Python Script:

Sample Input File: costcalc.inp

PDF Of PowerPoint: External_Connections_2011_10_14.pdf

You can find a recording of this webinar and all others at:

Importing and Exporting ANSYS Mechanical Loads as XML Files

I was futzing around with some loads the other day and noticed that, to my shock, that if you click on the value for a load and instead of typing a value in, click on the drop down menu and you will find that it has an Import and an Export on it.   I’m not sure when that became a capability, but I think it has been there for a while.  A quick check with the staff here at PADT and only a few knew about it.  Which makes it a great topic for The Focus.image

XML, Engineering Data, and Verbosity

The easiest way to check this out is to go into a model and insert a force into your model.  Go ahead and pick the geometry.  In the Details for the force, click on the magnitude cell and you will see a little drop-down menu triangle:


Click on that and you will see the menu:


Click on Export and give it a file name.  You will notice when you do this that it makes an XML file.  If you didn’t know it, ANSYS Mechanical uses a lot of XML.  In fact, they used to even store results in an XML file.  The good thing about XML files is that they kind of self-describe themselves and organize the data in them in a sort of object oriented way.  This makes them very easy to read and portable between programs. 

XML stands for eXtensible Markup Language and it is an expansion of HTML to handle data. Check out the Wikipedia article on the topic to learn more.  XML is hear to stay and if you don’t get it, you might struggle with some advanced stuff in a lot of areas, not just ANSYS.

The down side of XML is that it is very wordy – verbose.  It has lots of text in there that specifies relationships, names, ID’s, etc…  Tags out the wazoo.  For those of us that grew up feeding our simulation programs fixed format or comma delimited files where the first line specified all the constants and the rest was the data, this can be a bit annoying.  But it does make the data portable and “human readable”

Let’s take a look at the XML file from applying a load of 0.0 lbf to our model.  The best way to view an XML file is to doubleclick on it. Your browser will bring it up and show what is inside.   If you have Dreamweaver or some other HTML editor, that will work even better.

Here is our example:

   1: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
1.5: <

   2:     <MaterialData/>

   3:     <ConvectionData/>

   4:     <LoadVariationData>

   5:           <MatML_Doc>

   6:               <LoadVariation>

   7:                     <BulkDetails>

   8:                         <Name>Force 2</Name>

   9:                         <Form>

  10:                               <Description/>

  11:                     </Form>

  12:                         <PropertyData property="pr1">

  13:                               <Data format="float">0.,0.</Data>

  14:                               <Qualifier>Force</Qualifier>

15: <ParameterValue format="float" parameter="pa1">

  16:                     </PropertyData>

  17:                 </BulkDetails>

  18:                     <Metadata>

  19:                         <ParameterDetails id="pa1">

  20:                               <Name>Time</Name>

  21:                     </ParameterDetails>

  22:                         <PropertyDetails id="pr1">

  23:                               <Name>Force</Name>

  24:                     </PropertyDetails>

  25:                 </Metadata>

  26:             </LoadVariation>

  27:         </MatML_Doc>

  28:     </LoadVariationData>

  29:     <BeamSectionData/>

  30: </ANSYS_EnggData>

The first thing you will notice is that the second tag (right after the XML version info) is <ANSYS_EnggData>.  That is because ANSYS already had a nice well defined format for putting tabular data into Workbench applications: EngineeringData.  So they just used the same format for loads.

The next thing you will notice is a lot of text to specify two value at two time points.  A lot of the data is just blank. There in case you need it.  To understand this let’s step back and look at tags in HTML.

A tag goes around some piece of information and describes what that information is.  Usually you have a starting tag which is the string with a less-than sign at the start and a greater-than sign at the back:


You then put in your information.  It could be data, text, more tags, whatever you want.  then when you are done, you close out the tag with the same string, but this time start with less-than followed by a forward slash. You still end with greater than:


You can nest these guys, with tags inside tags. This is how you get your object parent-child relationships.

So let’s look at our first couple of lines again, repeated here with the meat taken out (<…>) so we don’t have to scroll back and forth:

   1: <?xml version="1.0" encoding="UTF-8" standalone="no" ?><ANSYS_EnggData>

   2:     <MaterialData/>

   3:     <ConvectionData/>

   4:     <LoadVariationData>

   5:           <MatML_Doc>

   6:               <LoadVariation>

   7:                     <BulkDetails>

   8:                         <...>

   9:                     </BulkDetails>

  10:                     <Metadata>

  11:                         <...>                       

  12:                     </Metadata>

  13:             </LoadVariation>

  14:         </MatML_Doc>

  15:     </LoadVariationData>

  16:     <BeamSectionData/>

  17: </ANSYS_EnggData>

You will notice that a lot of the tags in our example end with a forward slash:


This is an empty tag. It tells the program I got no data of this type. It does save some text compared to other market languages where you just have a blank start and end tag. 

So, our example starts and ends with <ANSYS_EnggData> and </ANSYS_EnggData>  Everything between in engineering data.  Then it says no material data and no convection data.  It does say it has load variation data.  We then find the LoadVariationData tag.  This is what we actually have in the file.  It then goes one step down and has a MatML_Doc tag.  This tells the program the format of the data being given is in the MatML schema.  more on that below.

Then we break the load into two parts: The BulkDetails where the actual data values are specified and the MetaData, which tells the program information it needs to know about the data.  Then everything has its end tag, you tell the program you don’t have BeamSectionData, and you finish up.

If you want to, you can not include all the empty tags.  the <tagString/> tags.  Mechanical reads the file just fine without them.   But you can’t get rid of anything else.

The MatML Language

MatML is “an extensible markup language (XML) developed especially for the interchange of materials information.”  You can read all about it at:  History, examples, news, etc…  It is all there.   Like most standards, you can waste a lot of time saying what is good or bad about it.  But in the end, what matters is that everyone uses the same standard. (Of course, MatWeb doesn’t support this standard because they want you to pay for native format… grumble, grumble…).

Looking at the Data and MetaData

Let’s look at the heart of our file, the actual data we want.  In MatML they call it BulkDetails:

   1: <BulkDetails>

   2:     <Name>Force 2</Name>

   3:     <PropertyData property="pr1">

   4:         <Data format="float">0.,0.</Data>

   5:         <Qualifier>Force</Qualifier>

   6:         <ParameterValue format="float" parameter="pa1">0.,1.</ParameterValue>

   7:     </PropertyData>

   8: </BulkDetails>

The first thing we find is the name.  This is not the name that will be used in the tree.  It is the name that will show up in the library if you combine a bunch of XML files and the name that will show up in your detail view for magnitude.  So if you make your own load, give it something descriptive here so you can pick it out of the library but not so long that you can’t read it in the detail. Calling it F1 will just tick you off in six months when you try to reuse a load.

Next is the PropertyData tag.  It will always have the name “prn” as far as I can tell, where n is an integer starting at 1 and increasing for each property in the file.  If you change it, everything gets messed up – so always use pr1. 

Now the data.  You give it a format, float in most cases, then a comma delimited list.  That is it.

Then you tell the program that it is a Force with the Qualifier.

Last, you need to specify the parameters that your load will vary over.  Usually this is time.  Use <ParameterValue> to do this.  Notice how you specify a format and what the parameter is called, and this is always “pa1”  (or pan actually, where n starts at 1 and increases for each property in the file).

Now we have to tell the program some additional information about our data, which is called Meta Data.  For loads, the only thing that is supported is the definition of the type of load being specified:

   1: <Metadata>

   2:     <ParameterDetails id="pa1">

   3:         <Name>Time</Name>

   4:     </ParameterDetails>

   5:     <PropertyDetails id="pr1">

   6:         <Name>Force</Name>

   7:     </PropertyDetails>

   8: </Metadata>

Don’t worry too much about this formating stuff.  The best thing for you to do is make a load like the one you want in Mechanical, export it to XML, then modify the values inside as you see fit.  Much easier than understanding the schema… or even what a schema is.


Please notice that there are no units anywhere.  Right now all of your values must be in SI units, and Mechanical will convert when it displays the values.  This is because Mechanical always stores values internally as SI.  So, if you make your own load files, make sure you convert to SI.

This is the single biggest potential for error… so mind your units!

Importing XML Load Files

The process of reading in the loads is a bit more complicated then simply pointing to a file.  This is because each file can hold more than one load. You should think of the XML file as a library.

To read the file go to your Magnitude, click on the drop-down menu icon and choose “Import…”  This brings up the “Import Load History Data” dialog:


Note that instead of picking a file you are given a Data Source area and a Load History Data to Import area.  the top Data Source is the file.  Click Add… and point to your XML file.  Once it reads that file in it will always remember the file and every time you open this dialog box, it will re-read it and update the Load History data to Import values.



You can see our sample file, tt4.xml, is the library Data Source and within it are two loads.  You use the radio button to choose the load you want to apply.  Click OK and you will notice that your Details for the load now lists that name as the Magnitude:


As you can imagine, you can put a ton of loads in one file, maybe all the loads for your project.  Then use the filter to find the load you want in a big file.  This is again a reminder of why it is important to specify a useful name when you create the load.


The examples above deal with tabular data.  You can also store formulas in the file.  This looks a little different in the <BulkDetails> in that you specify format=”function> in the <Data> tag.  Here is an example:

   1: <MatML_Doc>

   2:     <LoadVariation>

   3:           <BulkDetails>

   4:               <Name>Force 2</Name>

   5:               <Form>

   6:                     <Description/>

   7:           </Form>

   8:               <PropertyData property="pr1">

   9:                     <Data AngleInDegrees="1" AngularVelocityInRPM="1" 

  10:                         TemperatureUnit="3" UnitSystem="4" format="function">

  11:                         <Domain LowerLimit="0." UpperLimit="-999.">

  12:                             time

  13:                         </Domain>

  14:                         <Domain LowerLimit="0." UpperLimit="-999.">

  15:                             1.2*sin(time/6)

  16:                         </Domain>

  17:               </Data>

  18:                     <Qualifier>Force</Qualifier>

  19:                     <ParameterValue format="float" parameter="pa1">

  20:                            0.,.1,.2,.3,.4,.5,.6,.7,.8,.9,

  21:                            1.0,1.1,1.2,1.3,1.4,1.5,1.6,

  22:                            1.7,1.8,1.9,2.0

  23:                     </ParameterValue>

  24:           </PropertyData>

  25:       </BulkDetails>

  26:           <Metadata>

  27:               <ParameterDetails id="pa1">

  28:                     <Name>Time</Name>

  29:           </ParameterDetails>

  30:               <PropertyDetails id="pr1">

  31:                     <Name>Force</Name>

  32:           </PropertyDetails>

  33:       </Metadata>

  34:   </LoadVariation>

  35: MatML_Doc>

A lot more complicated. The best way to make one of these is to do it interactively and export.

Generating XML Load Files

At first blush, the file looks complicated but a simple VBA script in excel or a python macro can build the file very quickly because most of the text is static, you are really just changing the data and parameter value values.  I was going to do such an example, but ran out of time.  If any of you have one or write one, please let us know so we can share.

Making Animated GIF’s of ANSYS Graphics for Fun and Profit

In last weeks article I included some animations of some plots from the examples.  While doing that I remembered that we have received a couple of questions recently about how to get result animations in a PowerPoint or a Website.  In this article we will talk about the tool I use and give some tips on making the process better. And, it give me an excuse to write about some software other than ANSYS, Inc.

Animated Gif Humor (14)Animated GIFs and Why we Need Them

As you know, an animation is simply a series of still images shown one right after another.  When we create Video on a computer we generally make something with 30 still frames shown every second.  Although the various formats for video have gotten much better, that is still a lot of pixels to send around. That makes a big file that may not be best for your web page or PowerPoint.  However, with modern high-speed internet and fast computers, that is not the problem it used to be.  It is still a concern.

What we really have to deal with is making sure that whatever we are using to present our animation can play it.  Can the person’s web browser show it?  Can PowerPoint show it?  Although YouTube is a possibility more and more, you really want a portable format that you can imbed in your document or site and that everyone can see.  If you research…  the only format that fits that bill is an animated GIF.

The gif format is compact, and because the early Netscape Navigator browser supported it, it became a default format.  Even Microsoft decided to support it.  So, as in some ways, it is the least common denominator that works for everyone.  Another cool thing is that the programs treat it as an image, not as a video or animation.  You copy and paste it, insert it, place it, edit its size just like you would any JPEG, PNG, or TIFF image.

You can learn about the format on Wikipedia. But if the binary info that greats you on that page causes your eyes to glaze over, you only really need to know the following:

    1. It is a file format that supports multiple images all contained in one image file
    2. You can specify how long to play a given image (frame)
    3. It supports transparency
    4. It is a standard and all web browsers and PowerPoint will display it
    5. You can imbed it in a PowerPoint so you don’t have to worry about carrying your animation files around in a folder with your PowerPoint.
    6. It only supports 256 colors. This is the downside of GIF’s

Unfortunately non of the ANSYS products make an animated GIF file.  They generally make an AVI, which is the most common video file, but something that most people can’t display on their website or put in a PowerPoint.  So we need to convert the AVI to a GIF, or create a GIF from a series of images.

There is one option we should mention, and that is creating an Adobe Flash file. This is a more modern and capable format but it has problems.  First and foremost, iPhones and iPads don’t display flash.  Second, to show a flash animation in PowerPoint you have to make sure a special flash player is installed.  So again, lowly GIF wins out.

GIF Movie Gear

I use a program called GIF Movie Gear. If you Google “AVI to GIF” you will find other tools. I picked this one because it had the features I wanted, it was cheap, and it works so far just fine. Over time, I have found it to be very robust as well.  It is from a company called Gamani, and you can download a trial version or purchase it for $29.95.  They have a nice website that lists all the features and offers some tutorials at:

Once you have it installed check it out. If you have not tried similar tools in the past, go through the tutorial. It is worth the time.

For the ANSYS user, here are the important features:

    1. It will import an AVI and break it into individual images (frames)
    2. You can crop and resize
    3. You can set the speed of the animation
    4. It is easy to use (important, since if you are like me you only need it once in a while)
    5. You can easily make a ping-pong animation (copy frames then reverse them)
    6. You can make an animation by reading in a series of images (important for MAPDL users that want to make a high quality animation)

There are a ton more features, but these are the ones that matter to us ANSYS types.

Building Animations from Images

If you are using Mechanical APDL (MAPDL) you can use the ANIM command to build an animation of your model as an AVI. The problem with this is that the AVI file format that ANSYS uses compresses the images to save space, and to do so it really reduces the quality of the image.  So instead, you can write your own animation macro and save a PNG file for each frame, then use GIF Movie Gear to make an animation.

To learn about how to make the images for your own animation, check out an old Focus article in Issue 49 from 2006, on page 6.  It talks about the program we used to use to make an AVI instead of a GIF, but it works the same.  You basically make a plot and save it as a PNG then modify your image and make the next one.  We use that macro in the examples below and put it here for you to use.  Take a good long look at it

You probably also want to reread (because I know you read it when we put it out) the more recent article on making pretty images from March of this year.

A Simple Example

To get the gist of how this all works, let’s build a simple tower model, put a pressure on the side, then animate it’s displacement.  Download this macro and run it in MAPDL.  If you look at the macro the last thing it does is make a contour plot of the total deflection (PLNSOL, U, SUM).  This is what we want to animate.

So we simply type: “agif_anm1,10”  into the command line to run the animation macro and it will make 10 PNG file. Look in your working directory and you will see twrexmp000.png through twrexmp009.png.  These are the frames.  Now on to making our GIF.

Start GIF Movie Gear and you will get the little start wizard:


Click on Insert Frames.  This opens a file selection dialog box. Shift-select the 10 frames we just made and click open:


You will now see the upper right corner of the first frame… Don’t panic.  this is the size of your image and the window is small.  Click the little zoom in icon (magnifying glass with a minus sign) until you see a couple of frames.  If you click the play icon, you will see your animation play very fast.  Not what we want.

So the first thing we will do is change the animation speed by changing the duration of each frame. It is 0 by default.  Go to Animation->Timing and it will show your hyper animation again. At the bottom, change the 0 to a 20 and hit return:


That calmed things down a bit. Close that window.

At this point you can simply save your animation and be done: File->Save and give it a name.  And this is what you get:


The Blogging software resizes it. Click on the image to get the full size version.

Changing the Size

That may not be the shape, size, or content you want.  To resize the image, use Animation->Resize:


Make sure that “Maintain aspect ratio” is checked.  If you don’t, your image can get distorted.  Then set the width or height to what you want.   I’ll use a width of 400.  Make sure the Bicubic is picked for your resizing.  The other method is slower to run but makes bad images unless you have only a few colors.  If you save this image you get the following:


Now, we may want to crop. We do that the same way: Animation->Crop. Now this is the only feature I don’t like. It shows the image in a small window.


So click on the Zoom In icon till you can see your image and drag to where you want it and click OK. Save that and you get:



One of the coolest things about GIF files is that you can tell the display program to not show a certain color, to make your image transparent.  This is great for PowerPoints.  To do this you need to mark one of the colors in your animation as “transparent.”

Go to Animation->Properties then click on the Global Frame tab:


Click on Transparent and it will bring up your color Pallet.  Click on the black background or the black color in the table and that will be the transparent color.  Now you need to set the bottom menu to “Restore to Background before drawing next frame”.  If you don’t do this you will see ghosting.

Click OK. Save that and you get:


Not too exciting on this blog because the background is white.  But imagine we had some fancy background.  Copy and paste this into your corporate PowerPoint template and you will see:


Converting for AVI’s

What, you are not a gray-haired throwback to a past time.  You use CDF Post or ANSYS Mechanical?  You can skip a lot of the first steps and just go straight from an AVI to an Animated GIF.

Regardless of which tool you are using, you simply need to save an AVI to get started.  For ANSYS Mechanical you do that by using the animation viewer to get the animation you want then click on the “Export Video File” Icon.  Remember to make sure you have turned off the fancy Aero window stuff.

To make a CFD animation read Clinton’s Article

Now that you have the AVI file you can make a GIF. Start GIF Movie Gear and click on Open File this time.  Choose the AVI and you will see all the frames in the AVI (zoom out if you need to).  If you like what you see, just do a File->Save As and save as a GIF.


Just like the animations made from images, you can adjust the size of the image, crop, and set animations.

One thing you may notice is the banding on the background. This is in the AVI due to compression in the AVI.  So if you are making animation we recommend you create a solid background (set in the project schematic->Tools->Options->Appearance) :


And once you have done that, you can use transparency:


Other Things You Should Know

When setting transparencies above we talk about making sure it says: “Restore to Background before drawing next frame” If you don’t, this is what your animation will look like:


For debugging it is kind of a pain to place in PowerPoint then view as slide show.  A faster way to view an animated GIF is to RMB on it in the explorer and say Open With… and choose Internet Explorer.  You can also drag it into your browser.  Much faster.

The program has an Undo.  Use it.  Try stuff, save the file, look at it, then undo if you need to.

Another thing to be aware of is Ping-Pong.  If you remember our first animation of the deflected tower, it only goes to the max deflection then snaps back to the beginning. It would be much nicer if it went back.   You can do that by going to Animation->Rearrange Frames –>Ping-Pong Animation.


Now save and you have an “up and back” animation.  The original is on the left, the ping-pong is on the right.


This tool is also a great way to grab a single frame from an animation.  Say you have an animation and you need a picture, and you don’t want to go back into the program to make it.  Simply read the AVI into this program, find the frame you want, then do a File->Save As. Pick your format and set “Save as Style” to Individual Image(s).  Then select the “Only selected frames(s)”


That is about it.  I hope this will help you make better presentations and cool websites.

Do you have seizures yet?







HSFLD241/242: Modeling Enclosed Liquids

This is a second attempt at this posting.  The first attempt got 60% of the way done, then I rebooted my machine before I saved the posting… Doh.  So let’s try this again:


Every once in a while I feel the need to stop exploring all the new and cool stuff in the world of workbench and do a deep dive into something that involves names which are restricted to eight characters or less. Something that involves a script rather than a GUI click.  Something that requires you to look at a real equation, something with an integral sign in it:


I want to learn about something that uses comma delimited commands. 

So, up comes ANSYS Help, dive down into the release notes for Mechanical APDL and look for something obscure but useful.  New elements…  Aha!  HSFLD21 – now that is a name to make any I-only-use-the-GUI-and-manuals-with-equations-but-without-color-animations-make-me-nervous user cringe.  Hydrostatic.  I like that word.  It reads:

This 2-D hydrostatic fluid element models fluids that are fully enclosed by 2-D planar and axisymmetric solids. This element is well suited for modeling fluid-solid interaction with incompressible or compressible fluids under uniform pressure. It can be used in geometrically linear as well as nonlinear static and transient dynamic analyses.

Now I have something I can sink my teeth in.

The Basics on the HSFLD241 and HSFLD242

New at R13, these elements are used to model compressible or incompressible fluids that are surrounded by solids. The key assumption to be aware of is deserving of its own line:

The fluid volume has uniform pressure, temperature, and density without any gradients

So no sloshing, variation due to gravity, etc.. Take a look at FLUID80 if you want these things… maybe a future article topic.

HSFLD241 is the 2D and axisymetric version, and HSFLD242 is the 3D version.  If you look at the element pictures from the manual at the top of the posting you’ll see that they are a surface effect element with an extra node, called a pressure node.  You use ESURF to apply the element to the inside face of your enclosing volume, and you link all the faces that make up the volume by making them share a node (L or Q).  The fact that they all share the same node tells the solver that they make a volume. Besides sharing the node, they must share the same material and real number. 

When you use ESURF to make the elements, it automatically makes them a positive volume by the order it defines the face nodes with.  But sometimes you may want to create a negative volume inside your positive. Say you are modeling a tire (what this element was added for actually) and you will find that the pressure node is outside of the volume.  The calculated volume is not correct.  You need to subtract volume for the elements that are actually not in your volume. Here is a cross section to try and make more sense of it.


The purple parts are the fluid.  So this is not right. You need to go in and create negative elements on any faces that face away from the origin.  You do this in two steps:  Mesh using ESURF like you normally would, then grab the elements you want to turn into negative elements and issue the ESURF,pnode,REVERSE command.  This will turn those elements into negative volumes.  The key hear is to create your geometry in a way so that you can easily select faces that point away from the center of your volume. If you don’t, you will need to write a macro that loops through the elements, checks the vector from the face centroid to the center of you volume and if it facing out, swap the element normal. Not hard, just tedious.  In our example, the negative element will look like this (color changed for clarity):



The elements have displacement (UX,UY and UX,UY,UZ) Degrees of Freedom on the face part of the element, the part that sits on your structural elements.  The pressure node has a DOF of HDSP or hydrostatic pressure by default, and both PRES and HDSP if you set KEYOPT(1) = 1.  This is so you can hook the node to other elements that have PRES DOF’s like the FLUID116.

Real Constants

For real properties you have the ability to specify a thickness (defaults to 1) on the 2D element so the program can calculate volume correctly. Both versions have a real constant of PREF, the reference pressure. Simple enough.

Material Properties

If you opt for an incompressible fluid, just specify a density and coefficient of thermal expansion for your material.  But if you are modeling a compressible fluid, you use a new material property table to specify the material properties:  TB,FLUID.  Within the FLUID model you have three options:  a model for liquids, a model for gases, or you can provide pressure-volume data. It is recommended that you read the theory manual on these three to understand the difference and how to use them, as well as the standard command information for the TB.

For TB,FLUID,,,,LIQUID the model is basically a squishy solid.  You give a bulk modulus, coefficient of thermal expansion, and an initial density over up to 20 temperatures. 

For TB,FLUID,,,,GAS you simply give a Density. The program then simply uses the Ideal Gas Law… you remember that from freshman physics? Or was it chemistry.  I kind of remember it… sort of:


If you have a compressible fluid that does not follow the idea gas law, then you can supply your own pressure vs. volume table with TB,FLUID,,,,PVDATA.


KEYOPT(1) controls the DOF’s on the pressure node.  By default the uniform pressure for the solid is stored as HDSP.  If you set KEYOPT(1) to 1, then a PRES DOF is added and is set to be equal to HDSP.  This is so you can hook a FLUID116 up to it and flow out of your volume… more below.

KEYOPT(3) is used on the HSFLD241 element to say if it is Planer (0) or Axisymmetric (1)

Use KEYOPT(5) to turn on mass effects for the elements. Remember, this is a uniform mass. But if you have gravity or you are doing a modal analysis, you need this turned on.

Turn compressibility off by setting KEYOPT(1) to 1.

Other Basic Info

Give the manual page a read on the element.  There are a lot of output options besides the DOF solution. Stuff like Volume, Mass, and mass flow rate. 

Simple ExampleHSFLD_EXMP1

(Want to know how I made this animation… that will be next weeks article.
  I used a program called GIF Movie Gear, best $29.95 I’ve spent in a while…)

So, having waded through the boring bits, let’s build a model.  Our first example is simply a 2D hollow rectangle that we apply a pressure to. Here is the macro.  Take a look at the comments and follow the process.

   1: !Square Baloon Macro   - Example for HDSP241

   2: !

   3: ! Get in the begin level, clear the databse

   4: !   and go to the preprocessor

   5: finish

   6: /clear

   7: /prep7

   8: ! Define Dimensions as parameters

   9: wdth = 2

  10: hght = 4

  11: thk = .1

  12: ! Build two rectangles and subtract the inner one

  13: !  to make an enclosure

  14: blc4,(-1*wdth/2),0,wdth,hght

  15: blc4,(-1*wdth/2)+thk,thk,wdth-2*thk,hght-2*thk

  16: asba,1,2

  17: ! Make a component out of the inner lines - this is

  18: !  where we will put our HDSP elements

  19: lsel,s,,,5,8

  20: cm,l_insd,line


  22: ! Define a 182 for the solid and 241 for the fluid

  23: et,1,182

  24: et,2,241


  26: ! Sort of soft material for the enclosure wall

  27: mp,ex,1,10e5

  28: mp,nuxy,1,.3

  29: mp,dens,1,.001


  31: ! Some fluid properties

  32: tb,fluid,2,,,,liquid   ! Liquid Properties

  33: tbdata,1,300000        ! Bulk Modulous

  34: tbdata,2,6.4e-4        ! Coeficient of thermal exp.

  35: tbdata,3,.001          ! Density


  37: ! Mesh the enclosure wall

  38: type,1

  39: mat,1

  40: esize,thk/2

  41: amesh,all


  43: ! Grab the inside nodes from the compenent and create

  44: !   the fluid mesh using esurf

  45: cmsel,s,l_insd

  46: nsll,s,1

  47: type,2

  48: mat,2

  49: n,999,0,2

  50: esurf,999  ! Tell esurf to make the "extra" node 999

  51:            ! That all the elements share

  52: allsel,all


  54: ! Fix the bottom of the enclosure vertically

  55: !  And fix the bottom right corner tangentially

  56: !  to constrain the model

  57: nsel,s,loc,y,0

  58: d,all,uy

  59: nsel,r,loc,x,-1*wdth/2

  60: d,all,ux

  61: allsel


  63: ! Specify an load of 100 psi as the internal pressure

  64: !  The model will ramp up to that load over the specified

  65: !  substeps

  66: d,999,hdsp,100


  68: ! Set up Solve and Run

  69: /solu

  70: nlgeom,on

  71: nsubst,50,100,20

  72: outres,all,all   ! Don't forget to save substeps so you

  73:                  !   can animate them

  74: solve

  75: finish


  77: ! Animate the resulting displacement

  78: /post1

  79: set,last

  80: /dscale,1,1

  81: plnsol,u,sum

  82: andata,0.5,,0,0,0,1,0,1

One key thing to note in the code is the ESURF command.  Notice how you specify the common node as the first argument in the command. This is pretty useful and avoids making you go through and specify.  You can download the macro here.

HSFLD_Piston1A More Complex Example

The help on this element is pretty cool, and it even includes an example of how to build a piston. Unfortunately it does not include the part that solves it.  So I’ve added that imagemade some other changes, including an animation and a short trip into POST26 to get pressure and volume of the fluid over time. The code is below.  The most obvious thing when looking at this animation is the funny triangle thingy.  that is a negative element that deals with the fact that the volume is changing over time.  It is not 100% accurate but basically says any fluid above the piston needs to be subtracted.  In the image on the right, the solid geometry mesh, you can imagine that your fluid volume can be anywhere inside the piston, from the top of the yellow line to the whole length of the green.  The red dot shows the bottom corner of the piston.  If you make an element from the red dot to the top and bottom of the yellow line, no mater where the piston goes you will subtract the volume of any part of the total volume that is above the piston.  I found that kind of slick and clever of the ANSYS developers.  It doesn’t plot so cool, but it gets the job done.

Here is the code:

   1: finish

   2: /clear

   3: /prep7

   4: ! Define element types

   5: et,1,182    !plane182

   6: keyopt,1,3,1    !axisymmetric option

   7: et,2,241    !hsfld241 

   8: keyopt,2,3,1 ! axi option

   9: ! Material properties for Steel

  10: mp,ex,1,2.0e5    !Young's Modulus in N/mm^2

  11: mp,nuxy,1,0.3    !Poisson's ratio

  12: mp,dens,1,7.7e-9!Density in ton/mm^3


  14: ! Material properties for hydraulic fluid

  15: tb,fluid,2,,,,liquid

  16: tbdata,1,2000.0    !Bulk Modulus in N/mm^2

  17: tbdata,2,6.4e-4    !Coefficient of thermal expansion

  18: tbdata,3,8.42e-5!Density in ton/mm^3

  19: ! Nodes

  20: n,1,0.0,50.0    !pressure node

  21: ! Keypoints

  22: k, 1, 0.0,  0.0

  23: k, 2,25.0,  0.0

  24: k, 3,25.0,100.0

  25: k, 4,10.0,100.0

  26: k, 5,10.0, 95.0

  27: k, 6,20.0, 95.0

  28: k, 7,20.0,  5.0

  29: k, 8, 0.0,  5.0

  30: k, 9, 0.0, 80.0

  31: k,10,19.0, 80.0

  32: k,11,19.0, 85.0

  33: k,12, 3.5, 85.0

  34: k,13, 3.5,185.0

  35: k,14, 0.0,185.0

  36: ! Areas

  37: a,1,2,3,4,5,6,7,8

  38: a,9,10,11,12,13,14

  39: ! Planar elements

  40: type,1

  41: mat,1

  42: esize,2.5

  43: amesh,all

  44: ! Hydrostatic fluid elements--automatic generation

  45: type,2

  46: mat,2

  47: lsel,s,line,,6,9

  48: nsll,s,1

  49: esurf,1

  50: allsel,all

  51: ! Create the Negative volume element- needed to take into account

  52: ! the movement of the piston

  53: e,61,162,,1    !element with negative volume--nodes 61 and 162 swapped

  54: ! Symmetry boundary condition on pressure node   [REQUIRED]

  55: d,1,ux,0.0

  56: ! Symmetry boundary condition on planar mesh

  57: lsel,s,line,,8,14,6

  58: nsll,s,1

  59: d,all,ux,0.0

  60: allsel,all

  61: ! Fixed boundary condition on planar mesh

  62: lsel,s,line,,1

  63: nsll,s,1

  64: d,all,all,0.0

  65: allsel,all


  67: ! Grab the nodes on top and apply a downward displacement 

  68: nsel,s,,,179

  69: nsel,a,,,219

  70: cm,ptop,node

  71: d,ptop,uy,-35


  73: ! Run the model

  74: finish

  75: /solu

  76: nlgeom,on

  77: nsubst,200,500,10

  78: outres,all,all

  79: solve


  81: ! Go to post 26 and get pressure and volume over time

  82: /post26

  83: numvar,200

  84: ESOL,2,180,1 ,NMISC,2,NMISC2_2 

  85: nsol,3,1,HDSP

  86: /grtyp,2

  87: plvar,2 ,3


  89: !Animate the results

  90: /post1

  91: set,last

  92: /dscale,1,1

  93: /pnum,mat,1

  94: /number,1

  95: /edge,1,1

  96: !esel,u,,,eflp

  97: pldisp

  98: andata,0.1,,0,0,0,1,0,1


Here is the graph of the results.  Not very exciting.


Download the Macro here.

Other things to know

OK, this was a lot more involved than planned, and there is still more to learn.  But I’ve got HR paperwork to fill out so we will wrap it up.

You should go through the verification problem for this element: VM209

image image

  • You can connect different volumes with FLUID116 elements.  This allows some pretty fancy system modeling.  Add in some control elements and electromagnetics and you can really capture some complex systems.
  • Be very aware of the negative volume issues when modeling tires and such. 
  • After I started on this article I found out that we are in the middle of a project for a customer who is modeling an optical device that has a fluid core.  It is working very well for them. I wish I could show the model, but I would be shot by the customer.  I can say that we are getting much better results than when we modeled the volume with solids.
  • The FLUID80 is a solid fluid volume element that does take into account non-uniform pressure, mass, etc… Take a look at it if these guys don’t do what you need.
  • Can you do this in Workbench?  Sort of.  You should be able to write a macro that uses a component to create your hydrostatic elements and define the material properties.  You won’t be able to post process the results but you can at least set it up and bring back plots. (check out this presentation, slide 41)
  • Workbench Scripting: Using Forms in your Script

    Last week we had a very well attended Webinar on using Scripting with Workbench. We talked about how you can control projects, parameters, and material properties with python.  We also talked about how you can use python to drive data compliant applications by sending commands and/or parameters to it.  You can watch the webinar on YouTube here.

    Click on PADT ANSYS Webinar Series and then find the recording from August 11, 2011.

    Several attendees asked if we had an example of using python to bring up a GUI on top of workbench. We did not. This is how The Focus articles are born.

    The Basics

    In case you missed the webinar or didn’t follow some of it, here are the important points:

    • Workbench has IronPython built into it from the ground up
    • You can record whatever you do in the GUI to create scripts
    • You can read those scripts in to control Workbench
    • ANSYS uses IronPython because it talks to Windows programs
    • Get detailed info at,, and

    Most of the examples below are derived from information I got at:

    We will be making a GUI for the famous Tower of Test application.  We will need a place to enter in the size of the tower, a pressure load. Then a simple table showing the results when we get them. And of course, buttons to cancel and execute.

    If you are already an experienced Windows programmer, this will be a slam dunk. If you are not, then you will need to make sure you learn your way around the MSDN .Net Class Library Reference:

    That is where you find properties and methods for the GUI.  We will be spending most of our time in System.Windows.Form.

    Why .NET?

    Right now, some of you might be asking “Why .NET?”  Python supports probably over a dozen different GUI’s.  I am using .NET for a few reasons:

    1. It is built into IronPython. No need to download a library and install it right
    2. It will have a consistent look and feel to Workbench
    3. More people know .NET than the other GUI libraries.

    If you are anit-microsoft, you can poke around and find a library that fits your needs.  The process will be the same.

    Crawl: Always Start with Hello World

    Anytime I try and learn a new language, I usually find a “Hello World” Example.  And, thanks to the internet I found one that only needed slight modification:

       1: import clr

       2: clr.AddReference('System.Windows.Forms')


       4: from System.Windows.Forms import Application, Form, Label


       6: form = Form(Text="Hello World Form")

       7: label = Label(Text="Hello World!")


       9: form.Controls.Add(label)


      11: Form.ShowDialog(form)

    So first, we access the huge number of Windows tools by importing clr.  Then, get a reference to Windows Forms.  Once that is done we need to import more from Windows Forms. This is a big tool box so it has lots of levels you have to dig through.  For this guy we need to be able to do the form itself (the window) and a label (text in the window).

    Now that we have our objects, we create a form with the title “Hello World Form” and a label with the text “Hello World!”  We then use the Add method to add the label control to the form. Last, we use the Show Dialog method to show the form.  TADA.

    To give it a try, copy and paste this into your own text editor and then go into Workbench and choose:

    File->Scripting->Open Command Window…

    Then paste in the script.  Or you can save it to a file and read it in. I like to paste so I can see my error messages as it goes.


    Now you are a Workbench GUI programmer.  Put it on your resume!

    Walk: Add Some Controls to the Window

    Next we want to do a bit more than saying hello.

    The important thing I learned that I just didn’t’ get before is that you have to make a class out of your form and any functions that get called when the user clicks on a button or interacts in any way with the form.  You do this because Windows will then pass information about the form back to the event function.

    In the example below is like “Hello World” to start, then we make 4 text boxes with labels for the user to enter data into.  We then add an OK and a Cancel button.  The code is commented with an explanation of what is going on.  If something does not make sense, look it up in a python reference or ask someone who is a python programmer.

       1: # --  Bring in the .NET stuff, and reference Forms and drawing

       2: import clr

       3: clr.AddReference('System.Windows.Forms')

       4: clr.AddReference('System.Drawing')


       6: #   get the objects you need from forms and drawing

       7: from System.Windows.Forms import Form, Label, Button, TextBox

       8: from System.Drawing import Point, ContentAlignment


      10: #-- The way python works with events, you have to make a class out of your form.  

      11: #   Then the objects 

      12: #    you add are available in event functions.

      13: class TowerForm(Form):

      14:     def __init__(self):

      15: #-- First, make the form (self)

      16:         self.text="Tower Simulation Tool"

      17:         self.Height=500

      18:         self.Width=250


      20: #-- Create a Simple Text Label describing the tool

      21: #   it is not self.label because we are not going to access it in event functions

      22:         lbl1 = Label()

      23:         lbl1.Text = "This is the Tower of Test Tool. \n\

      24:             Please Enter values and click OK to run the \

      25:             model and get new results\n"

      26:         lbl1.Height = 50

      27:         lbl1.Width = 200


      29: #-- Create the Text Labels and text boxes to get Dimensions and Pressure

      30: #   We need to get to the textboxes so we will make them part of the class

      31: #

      32: #   some constants to make the positioning easier

      33:         x1 = 10

      34:         y1 = 80

      35:         w1 = 70

      36:         w2 = 80

      37:         x2 = x1 + w1 + 10

      38: #   Make the labels for the text boxes.  This is done in the Labe() call with 

      39: #   Name = Value arguments 

      40: #   instead of = value to save space.  All in one line instead of 

      41: #   four lines.

      42: #     The alighment is done so that the labels are all right justified to line 

      43: #     up with the boxes. Set ContentAlignment.MiddleRight to mr to save space

      44:         mr = ContentAlignment.MiddleRight

      45:         lb_Length=Label(Text="Length", Width=w1,TextAlign=mr)

      46:         lb_Width  = Label(Text="Width",   Width = w1, TextAlign=mr)

      47:         lb_Height = Label(Text="Height",  Width = w1, TextAlign=mr)

      48:         lb_Press  = Label(Text="Pressure",Width = w1, TextAlign=mr)


      50: #   Make the text boxes. Note that these are put in the self. class. 

      51: #   We do this so that when the OK 

      52: #   button is pushed, we have access to the text boxes and therefore the values 

      53: #   typed within


      55:         self.tb_Length = TextBox(Width = w2)

      56:         self.tb_Width  = TextBox(Width = w2)

      57:         self.tb_Height = TextBox(Width = w2)

      58:         self.tb_Press  = TextBox(Width = w2)


      60: #   Specify the location for the label and the text boxes.  Move down by 

      61: #   30 after each line

      62:         lb_Length.Location = Point(x1,y1)

      63:         self.tb_Length.Location = Point(x2,y1)

      64:         y1 = y1 + 30

      65:         lb_Width.Location = Point(x1,y1)

      66:         self.tb_Width.Location = Point(x2,y1)

      67:         y1 = y1 + 30

      68:         lb_Height.Location = Point(x1,y1)

      69:         self.tb_Height.Location = Point(x2,y1)

      70:         y1 = y1 + 30

      71:         lb_Press.Location = Point(x1,y1)

      72:         self.tb_Press.Location = Point(x2,y1)


      74: #   Make an OK and a Cancel Button

      75:         okBut = Button(Text="OK", Width=50)

      76:         okBut.Location = Point(30,430)

      77: #       This is where you specify the funtion to be called when the button is clicked

      78: #       note that you call the function self.functionname.

      79:         okBut.Click += self.okButPressed


      81:         cancelBut = Button(Text="Cancel", Width=50)

      82:         cancelBut.Location = Point(110,430)

      83:         cancelBut.Click += self.cancelButPressed


      85: #   Put everything on the form (some sort of list and loop would make this easier)

      86:         self.Controls.Add(lbl1)

      87:         self.Controls.Add(lb_Length)

      88:         self.Controls.Add(self.tb_Length)

      89:         self.Controls.Add(lb_Width)

      90:         self.Controls.Add(self.tb_Width)

      91:         self.Controls.Add(lb_Height)

      92:         self.Controls.Add(self.tb_Height)

      93:         self.Controls.Add(lb_Press)

      94:         self.Controls.Add(self.tb_Press)

      95:         self.Controls.Add(okBut)

      96:         self.Controls.Add(cancelBut)


      98: #-- Now define the button event functions as part of the class

      99: #

     100: # Cancel simply closes the form down.  Nothing fancy

     101:     def cancelButPressed(self, sender, args ):

     102:         print 'Closing the Window... Bye...\n'

     103:         self.Close()


     105: # OK prints the values of the text boxes to the console

     106: #   This will be replaced with calls to workbench for the next step

     107:     def okButPressed(self, sender, args ):

     108:         print 'Values Entered:\n'

     109:         print '  Length: %s\n' %self.tb_Length.Text

     110:         print '   Width: %s\n' %self.tb_Width.Text

     111:         print '  Height: %s\n' %self.tb_Height.Text

     112:         print 'Pressure: %s\n' %self.tb_Press.Text

     113:         self.Close()

     114: #---------End of class definition



     117: # Instantiate the form and make the form visible

     118: print '=======================================\n'

     119: print 'Opening the Windows...\n'

     120: myForm = TowerForm()

     121: Form.ShowDialog(myForm)


    If you have not programmed a go dialog box in a while by hand, instead of using a WYSIWIG GUI builder, you can see why.  Lots of lines… lots of lines…
    Here is the file without the numbers in it so you can run it in Workbench:

    imageRun:  Send Values to Workbench, Update Model, Get Results

    If you remember the previous article on Driving Workbench from Excel this will all look familiar.  If you don’t review the article, especially the part about getting parameters in and out of Workbench with Python.  To finish our example we will use the same basic code to:

    • Get the current values from Workbench and set our dialog to show those values
    • When the user hits OK:
      • Set the Workbench parameters to the current dialog box parameters
      • Update the model
      • Get the resulting deflection and display it.

    The code is shown below, with the bits added for the Workbench interaction highlighted.  Note that we also introduced the specification of font properties on a label.  Making it even more fancy.

       1: # --  Bring in the .NET stuff, and reference Forms and drawing

       2: import clr

       3: clr.AddReference('System.Windows.Forms')

       4: clr.AddReference('System.Drawing')


       6: #   get the objects you need from forms and drawing

       7: from System.Windows.Forms import Form, Label, Button, TextBox

       8: from System.Drawing import Point, ContentAlignment,

    Font, FontStyle, GraphicsUnit


      10: #-- The way python works with events, you have to make a class out of your form.  

      11: #   Then the objects 

      12: #    you add are available in event functions.

      13: class TowerForm(Form):

      14:     def __init__(self):

      15: #-- First, make the form (self)

      16:         self.text="Tower Simulation Tool"

      17:         self.Height=500

      18:         self.Width=250


      20: #-- Create a Simple Text Label describing the tool

      21: #   it is not self.label because we are not going to access it in event functions

      22:         lbl1 = Label()

      23:         lbl1.Text = "This is the Tower of Test Tool. \n\

      24:             Please Enter values and click OK to run the \

      25:             model and get new results\n"

      26:         lbl1.Height = 50

      27:         lbl1.Width = 200


      29: #-- Create the Text Labels and text boxes to get Dimensions and Pressure

      30: #   We need to get to the textboxes so we will make them part of the class

      31: #

      32: #   some constants to make the positioning easier

      33:         x1 = 10

      34:         y1 = 80

      35:         w1 = 70

      36:         w2 = 80

      37:         x2 = x1 + w1 + 10

      38: #   Make the labels for the text boxes.  This is done in the Labe() call with 

      39: #   Name = Value arguments 

      40: #   instead of = value to save space.  All in one line instead of 

      41: #   four lines.

      42: #     The alighment is done so that the labels are all right justified to line 

      43: #     up with the boxes. Set ContentAlignment.MiddleRight to mr to save space

      44:         mr = ContentAlignment.MiddleRight

      45:         lb_Length=Label(Text="Length", Width=w1,TextAlign=mr)

      46:         lb_Width  = Label(Text="Width",   Width = w1, TextAlign=mr)

      47:         lb_Height = Label(Text="Height",  Width = w1, TextAlign=mr)

      48:         lb_Press  = Label(Text="Pressure",Width = w1, TextAlign=mr)


      50: #   Make a label to give status of the update in:


    self.updlbl = Label(Text=” “,Width=200, Height=100,\




    self.updlbl.Location = Point(0,200)


    self.updlbl.Font = \


    Font(‘Verdana’,10, FontStyle.Bold, GraphicsUnit.Point,0)


      57: #   Make the text boxes. Note that these are put in the self. class. 

      58: #   We do this so that when the OK 

      59: #   button is pushed, we have access to the text boxes and therefore the values 

      60: #   typed within


      62:         self.tb_Length = TextBox(Width = w2)

      63:         self.tb_Width  = TextBox(Width = w2)

      64:         self.tb_Height = TextBox(Width = w2)

      65:         self.tb_Press  = TextBox(Width = w2)


      67: #   Specify the location for the label and the text boxes.  Move down by 

      68: #   30 after each line

      69:         lb_Length.Location = Point(x1,y1)

      70:         self.tb_Length.Location = Point(x2,y1)

      71:         y1 = y1 + 30

      72:         lb_Width.Location = Point(x1,y1)

      73:         self.tb_Width.Location = Point(x2,y1)

      74:         y1 = y1 + 30

      75:         lb_Height.Location = Point(x1,y1)

      76:         self.tb_Height.Location = Point(x2,y1)

      77:         y1 = y1 + 30

      78:         lb_Press.Location = Point(x1,y1)

      79:         self.tb_Press.Location = Point(x2,y1)


      81:         self.tb_Length.Text = Parameters.GetParameter(Name="P1").Expression

      82:         self.tb_Width.Text = Parameters.GetParameter(Name="P2").Expression

      83:         self.tb_Height.Text = Parameters.GetParameter(Name="P3").Expression

      84:         self.tb_Press.Text = Parameters.GetParameter(Name="P5").Expression


      86: #   Make an OK and a Cancel Button

      87:         okBut = Button(Text="OK", Width=50)

      88:         okBut.Location = Point(30,430)

      89: #       This is where you specify the funtion to be called when the button is clicked

      90: #       note that you call the function self.functionname.

      91:         okBut.Click += self.okButPressed


      93:         cancelBut = Button(Text="Cancel", Width=50)

      94:         cancelBut.Location = Point(110,430)

      95:         cancelBut.Click += self.cancelButPressed


      97: #   Put everything on the form (some sort of list and loop would make this easier)

      98:         self.Controls.Add(lbl1)

      99:         self.Controls.Add(lb_Length)

     100:         self.Controls.Add(self.tb_Length)

     101:         self.Controls.Add(lb_Width)

     102:         self.Controls.Add(self.tb_Width)

     103:         self.Controls.Add(lb_Height)

     104:         self.Controls.Add(self.tb_Height)

     105:         self.Controls.Add(lb_Press)

     106:         self.Controls.Add(self.tb_Press)



     108:         self.Controls.Add(okBut)

     109:         self.Controls.Add(cancelBut)


     111: #-- Now define the button event functions as part of the class

     112: #

     113: # Cancel simply closes the form down.  Nothing fancy

     114:     def cancelButPressed(self, sender, args ):

     115:         print 'Closing the Window... Bye...\n'

     116:         self.Close()


     118: # OK prints the values of the text boxes to the console

     119: #   This will be replaced with calls to workbench for the next step

     120:     def okButPressed(self, sender, args ):


     122: # In Workbench: Get objects for all the parameters you need access to

     123: #   Remember, it goes by parameter name, not the name you give them.


    lenParam = Parameters.GetParameter(Name=“P1”)


    widParam = Parameters.GetParameter(Name=“P2”)


    hgtParam = Parameters.GetParameter(Name=“P3”)


    prsParam = Parameters.GetParameter(Name=“P5”)

     128: # don't forget the resulting deflection output parameter:


    defParam = Parameters.GetParameter(Name=“P4”)


     131: # Now set the workbench values to the values from the dialog


    lenParam.Expression = self.tb_Length.Text


    widParam.Expression = self.tb_Width.Text


    hgtParam.Expression = self.tb_Height.Text


    prsParam.Expression = self.tb_Press.Text


    self.updlbl.Text = “Updating”





    dflValue = defParam.Value.Value


    self.updlbl.Text = “Deflection is %s in\n” %dflValue



     143: #---------End of class definition



     146: # Instantiate the form and make the form visible

     147: print '=======================================\n'

     148: print 'Opening the Windows...\n'

     149: myForm = TowerForm()

     150: Form.ShowDialog(myForm)



    Next Steps and Suggestions

    And that in a nutshell is the basics of putting a GUI on Workbench.  By using the calls to Workbench, .NET or any other complaint application, you can script away and do what you want.

    Much more can be done.  You could have the solver you are running in update and create some plots, and then use python to find those plots (say search for any *.jpg files in the project director created after the OK button was pushed) and insert them into PowerPoint with text that you also gather.

    There really are no limitations.

    To learn more, try stuff.  Get to know the MSDN documentation to know what you can do to make a more professional GUI.  The Windows Forms part of is a great resource for this and points to MSDN as needed.

    There is a lot more you can do with ANSYS  Workbench and the various solvers.  And with each release, workbench will add and document more.

    If you write a cool application you can share, make sure you put it on XANSYS or send it to Sheldon at

    Using the ‘Identifier’ for Mechanical Post-Processing

    Wow, how time flies.  I wrote an article ~5 weeks ago where I discussed User Defined Results in ANSYS Mechanical.  One of the comments on that blog concerned being able to operate on results from multiple load steps, “e.g. stress in step 2 minus stress in step 1”.  I responded that yes you could, and then like an idiot stated I would have another article written in “a week or so” detailing how to do this.  My apologies Kjetil, I’m just now getting to this.  Please don’t cancel your membership in the “Doug Oatis B-Movie + ANSYS Trick Fan Club” (I’d hate to be the only member left, plus your dues are non-refundable).


    Do you know how exhausting it is to party like Motley Crue…by yourself?!?

    Anyways…back on topic.  The ‘identifier’ is a line available in the Details Window for any result item.


    You can type in any kind of name in the cell to the right.  Note that you need to enter the name in before you evaluate the result item, or else you will see that the right cell is gray (meaning you cannot edit it).  If this happens, simply RMB on the result item in the tree and select ‘Clear Generated Data’.  That will empty the ‘bucket’ of that result item and let you edit the details of it (it WILL NOT clear out your result file…unless you RMB on ‘Solution’).


    pic2 pic3

    Identifier cell after result has been evaluated

    To fix, RMB and select ‘Clear Generated Data’

    The benefit to using the identifier is that you can then create a user-defined result and type in an expression using these identifiers.  Here’s the documentation section that discusses the available functions:
    Lots of words…but pretty intuitive function definitions
    The thing to note up there is the order you define the function depends on if you’re operating off of scalars or vectors (I’ll explain below).  Let’s start out by first defining our UX and UY identifiers in our post-processing section:
    pic5 pic6
    X-Direction, Identifier = d_ux Y-Direction, Identifier = d_uy
    After I’ve defined both of these identifiers, I insert a User Defined Result.  Next, I just type in the expression I want it to evaluate:
    pic7 pic8
    Going back to the issue of scalars vs arrays, let’s say I wanted to add some type of constant to one of my user defined results.  In this case let’s assume I know that there’s an additional .5-in of rigid body motion that I want to plot.  To do this, I need to understand that the identifier d_ux represents an array of information (node vs displacement).  If I want to add a scalar (.5), I need to enter the expression d_ux+.5 (NOT .5+d_ux). 
    If I had multiple load-steps, I could scope a stress result to a specific time-point and then perform a similar operation.  That would give me the stress increase due to the load change in between load-steps.
    pic9 pic10 pic11
    The thing to watch out here is to make sure that you stay consistent in what you’re operating on.  Sure you can add stress and displacement together, but that’s not really going to get you anywhere.
    pic12 nobel-medal
    d_ux*10000+d_seqv…everyone knows that [in]+[psi]=[Oatis] For outstanding achievement in the field of flat-plate-with-hole-in-it analysis
    Also make sure that other details of identifiers you’re combining are consistent (e.g. coordinate system, integration option, etc).
    For all those MAPDL users, think of this as exposing most of the *voper command within the Mechanical interface.  The main difference is that you don’t have to worry about defining your array size, and it’s incredibly easy to get the data out (RMB > Export…rather than fighting your way through fortran or C formatters).

    CAE Market Fully Analyzed… Is that Cannibalism?

    Just saw a news article that a consulting company called 01 Consulting just did a study of the CAE market.  Unfortunately the report is $2,850 so, no matter how interested I am in the results I’m not going to buy one.

    However they did release an Executive Summary:

    And in there they have a cool graph that shows relative size (by revenue):

    The size of MathWorks was shocking to me how big they are.  At their price point that is a lot of seats.  ANSYS dominates, with between 20% and 25% of the market. 

    The other thing they mention is continued double digit growth in the CAE segment.  Even in these times, people are getting the message that simulation pays back big. 

    Workbench and Excel, Part 2: Driving Workbench From Excel with Python

    imageFor a couple of releases now you have been able to use the very common scripting language python to script applications that are considered Workbench native: the project page, Engineering Data, DesignXplorer, and the Parameter Manager.  This is pretty cool and something that we will cover in a future The Focus article.  But one thing that most people don’t know is that python also works well with Microsoft Excel.  So if it works with Excel and Workbench, you should be able to use it to connect the two.

    Now before you get too excited, realize that ANSYS Mechanical, CFX, FLUENT, CFX Post and most other solvers and post processors that launch from Workbench are not workbench native applications, so they don’t speak python. So no, this is not a replacement for PADL or CCL.  They are called “data integrated” applications in that they share data through the Workbench interface, but they have their own software structure that is unique, and their own scripting language.

    So to take advantage of this python commonality you have to connect to one of the native applications, and the parameter manager makes the most sense.  And fortunately the kind technical people at ANSYS, Inc. have provided a great example in the help system to do just that. And in doing so they have cut the length of this article in half.

    ANSYS Documentation Example

    You can find the example under: Workbench //  Scripting Guide // Using Scripting in ANSYS Workbench // Usage Examples // Updating a Workbench Project and Parameters from Excel.  It is a very simple example, a cantilever beam, but it shows the basics and is a great place to start.


    Read the manual page completely, especially the notes at the bottom.  They point out the key things you need to know.  The files you need are in the documentation, but you need to dig up the excel/workbench files and copy the python script and get rid of the line numbers.  I’ve put them all together in a zip file to make things easier:

    There are a few things worth discussing on this example before we move on to something more complicated.

    How to Run It

    One thing the example leaves out is the details on how to run it.  To start, you need to copy all the files to one directory: the python script, the workbench database, the workbench files, the excel file.  Then (it does point this out) you need to set the working directory variable in the script to the directory with all the files.  Now it is time to run. To do this open up Workbench with a new project (or File->New if you already have Workbench open).  Now run the script with File->Scripting->Run Script File…


    This will launch Excel and Workbench and add the command to execute the update script when you push the button.  So, what next?  Change the value for Bar Length or Load and press the button.  This should cause Workbench to update and the Maximum Deformation value to change to Updating… and then the new value when the run is done.  And that, in a nutshell, is the basics of making the two tools talk.

    How it Works

    The documentation does a pretty good job of explaining the details. The important take away is that you have to do a couple of key steps in any program that is going to do this sort of thing:

    1. Tell python to load the Excel stuff
    2. Set up the working directory, the routines all need absolute paths to work
    3. Grab cell’s from excel, grab params from Workbench, and set one to the other as needed
    4. Do an update
    5. Provide a mechanism to start the process (the button in this case)

    If you have these steps, you can make Excel and ANSYS talk.

    Where Things Run

    An important thing to get your head around is where the script is running, or more accurately, what process is reading and executing the script. The python interpreter is actually in the Workbench environment.  When you run the python script you are not running it in Excel or in the operating system.  It is running through a interpreter inside Workbench.

    This is important because it controls what information is automatically available to the script as well as how you launch it.  In this example, you launch from Workbench and it starts up Excel, does stuff in Excel, and then assigns a python routine to the button. When the button is clicked, you are still running a python script in Workbench – it is just talking to Excel.

    Limitations in the Example

    There are two big limitations with this example when it comes to using it on a real problem. First, it is not general enough because you have to hard code in file names, directory locations, cell locations and strings. This is not a huge deal because if you are going to use an excel based simulation tool over and over, you only have to set it up once and go.

    The other problem is that the action to update the spreadsheet and model is assigned as an OLEObject to the button. Unfortunately this is only active when the script is running. Once it is done the click action is removed, and the button becomes useless… allowing for only one use of the button.  This is a significant issue.

    A More General and Complex (Sort Of) Example

    A common potential usage for this sort of tool would be to provide a user with an Excel based tool that they would use to design a part and see the results.  For this example we are going to use a very complicated tool for designing towers with a rectangular cross section.  The input variables are the length, width, and height of the tower as well as a pressure applied to one face.  The output variables are the deflection from the pressure and the first 10 natural frequencies.

    Of course a real example would have more complex input and output values, and the spreadsheet would probably do a lot more calculations, perhaps even optimization.

    This example avoids the button problem by actually running Workbench from Excel by launching it from the command console and supplying the project file AND the python script as startup parameters to Workbench.  Workbench loads the project, runs the script, then exits.

    The Spreadsheet

    The spreadsheet is called TowerTool1 and it is a macro (xlsm) spreadsheet. You can download it here:


    The sheet is not that different from the ANSYS provided example. It has cells for input and output parameters.  It also has a button to update the system.  The first thing that is different is that it uses named ranges for the input and output cells.  To see the names go to Formulas->Defined Names->Name Manager.  I used “Create from Selection” to automatically assign the text in Column B to the values in Column C an D for each row.

    Also note the units. Because Workbench parameters (with the exception of Design Modeler parameters) are unit sensitive, you can specify the units in those columns and use them to do unit conversion as needed. In this example only the units on the Pressure are implemented to show how this is done.

    There is also a little Drop Down Yes/No choice for the user to decide if they want to save the project file or not when they are done running.

    The button is also different from the ANSYS example.  Instead of being assigned an action by the python script, it executes a very simple Visual Basic routine:

    Private Sub CommandButton1_Click()
    retval = Shell(“C:\Program Files\Ansys Inc\V130\Framework\bin\win64\runwb2 \
    -X -R -F ExcelTower1.wbpj”, vbNormalFocus)
    End Sub

    The line uses the Shell function to execute a system level command in Windows.  The command it runs is the command line way to start Workbench.

    The –X says run interactive and exit when any given command line options are completed.

    The –R gives a python script to be run, and this is our python script that is presented in detail below.

    The –F specifies that project file to be executed.  As an aside, you could make this program more general by having a cell in the spreadsheet hold that file name and then substituting that value in the execution string.

    The ANSYS Model

    This extremely complex model can be found in the following archived project file:

    The model contains a DesignModeler solid, a static structural solution, and a modal analysis. The key aspect of the model are the parameters.


    The outline for the parameter manager looks like this:



    The various parameters were set up in each system in the normal way, by clicking on the parameter box next to them for each value you want to supply or return.  The key thing to note here are the Names (P1-P15) for the parameters, because this is what our python script will use to change or retrieve values before and after the model update.

    The Script

    The actual script we are using is shown below.  Comments have been added to describe important steps.  You can download it, without the line numbers, here:

    Please don’t laugh too hard. I ran out of time to convert the code into something more concise using do loops and variables.  The whole thing could be made much more general if you know python better than I do.

       1: # IronPython imports to enable Excel interop,

       2: import clr

       3: clr.AddReference("Microsoft.Office.Interop.Excel")

       4: import Microsoft.Office.Interop.Excel as Excel

       5: from System.Runtime.InteropServices import Marshal


       7: # import system things needed below

       8: from System.IO import Directory, Path

       9: from System import DateTime


      11: # use the ANSYS function GetProjectDirectory to figure out what directory you are in

      12: # and set that to the current directory

      13: projDir = GetProjectDirectory()

      14: Directory.SetCurrentDirectory(projDir)


      16: # Open up a log file to put useful information in

      17: logFile = open("TowerTool.log","w")


      19: # Put a header in the log file

      20: logFile.write("================================================\n")

      21: logFile.write("Tower Tool Run Log File\n")

      22: logFile.write("================================================\n")

      23: logFile.write("Start time: " + DateTime.Now.ToString('yyyy-mm-dd hh:mm:ss') + "\n")

      24: logFile.write("Proj Dir: %s\n\n" % projDir)



      27: # Use the Excel GetActiveObject funtion to get the object for the excel session

      28: ex = Marshal.GetActiveObject("Excel.Application")

      29: # Make Excel visible

      30: ex.Visible = True

      31: # Define the active workbook and worksheet

      32: wb = ex.ActiveWorkbook

      33: ws = wb.ActiveSheet


      35: # In Excel: Grab values for the cells that we want data from (input cells)

      36: length = ws.Range["Length"](1,1).Value2

      37: width = ws.Range["Width"](1,1).Value2

      38: height = ws.Range["Height"](1,1).Value2

      39: press = ws.Range["Pressure"](1,1).Value2

      40: upress =  ws.Range["Pressure"](1,2).Value2


      42: # In Excel: See if the user wants to save the project after the update

      43: saveit = ws.Range["Save_Project"](1,1).Value2


      45: # In Workbench: Grab the parameter objects for the input values

      46: lenParam = Parameters.GetParameter(Name="P1")

      47: widParam = Parameters.GetParameter(Name="P2")

      48: hgtParam = Parameters.GetParameter(Name="P3")

      49: prsParam = Parameters.GetParameter(Name="P5")


      51: # In Workbench: Get the object for the deflection parameter vlue

      52: defParam = Parameters.GetParameter(Name="P4")


      54: #In Workbench: Set the value of the input parameters in Workbench using the values 

      55: #   we got from Excel

      56: lenParam.Expression = length.ToString()

      57: widParam.Expression = width.ToString()

      58: hgtParam.Expression = height.ToString()

      59: prsParam.Expression = press.ToString() + " [" + upress + "]"


      61: # Set the output values to "Calculating..." since they no longer match the input values

      62: ws.Range["Max_Bending_Distance"](1,1).Value2 = "Calculating..."

      63: ws.Range["Mode_1"](1,1).Value2 = "Calculating..."

      64: ws.Range["Mode_2"](1,1).Value2 = "Calculating..."

      65: ws.Range["Mode_3"](1,1).Value2 = "Calculating..."

      66: ws.Range["Mode_4"](1,1).Value2 = "Calculating..."

      67: ws.Range["Mode_5"](1,1).Value2 = "Calculating..."

      68: ws.Range["Mode_6"](1,1).Value2 = "Calculating..."

      69: ws.Range["Mode_7"](1,1).Value2 = "Calculating..."

      70: ws.Range["Mode_8"](1,1).Value2 = "Calculating..."

      71: ws.Range["Mode_9"](1,1).Value2 = "Calculating..."

      72: ws.Range["Mode_10"](1,1).Value2 = "Calculating..."


      74: # Now let Workbench go to town and update the systems using the new parameter values

      75: logFile.write("Updating Project\n")

      76: Update()


      78: # If asked for, save the project


      80: if saveit == "Yes":

      81:     logFile.write("Saving Project\n")

      82:     Save()


      84: # Assign the value of the Excel deflection cell output deflection from Workbench 

      85: ws.Range["Max_Bending_Distance"](1,1).Value2 = defParam.Value.Value


      87: # Now go through the value of each natural frequency in Workbench and 

      88: #   set the corresponding cell in Excel

      89: #    This could be made more general or at least more concise by using a do loop

      90: #    Also note that instead of getting the objects, then the values the two steps are 

      91: #    combined for these values

      92: ws.Range["Mode_1"](1,1).Value2 = Parameters.GetParameter(Name="P6").Value.Value

      93: ws.Range["Mode_2"](1,1).Value2 = Parameters.GetParameter(Name="P7").Value.Value

      94: ws.Range["Mode_3"](1,1).Value2 = Parameters.GetParameter(Name="P8").Value.Value

      95: ws.Range["Mode_4"](1,1).Value2 = Parameters.GetParameter(Name="P9").Value.Value

      96: ws.Range["Mode_5"](1,1).Value2 = Parameters.GetParameter(Name="P10").Value.Value

      97: ws.Range["Mode_6"](1,1).Value2 = Parameters.GetParameter(Name="P11").Value.Value

      98: ws.Range["Mode_7"](1,1).Value2 = Parameters.GetParameter(Name="P12").Value.Value

      99: ws.Range["Mode_8"](1,1).Value2 = Parameters.GetParameter(Name="P13").Value.Value

     100: ws.Range["Mode_9"](1,1).Value2 = Parameters.GetParameter(Name="P14").Value.Value

     101: ws.Range["Mode_10"](1,1).Value2 = Parameters.GetParameter(Name="P15").Value.Value


     103: # Done!  Close the log file and move on 

     104: logFile.write("End time: " + DateTime.Now.ToString('yyyy-mm-dd hh:mm:ss') + "\n")

     105: logFile.close()


    Execution is pretty simple.  When the user pushes  the Update system button the program goes off and launches Workbench with the script as input.  The script changes the parameters, updates the model, saves if asked for, updates the values in the spreadsheet, then Workbench exits.

    One key thing to know is the issue with working directories.  The Excel file needs to be in the same directory as the script and the project.  Sometimes Excel changes the working directory (say you opened a different spreadsheet).  If you get an error on execution that Workbench can’t find the project file, you just need to go back to Excel and do a Save As in of your file on top of itself.  That fixes the problem. More advanced users can use VBA to control directories.


    The first resource for doing this type of work is the ANSYS Workbench->Scripting Guide in the online help.

    ANSYS uses a flavor of python called IronPython. They have a great web site at:

    Specific info on the connection to Excel can be found at:

    Thoughts and Suggestions

    Both examples presented are pretty simple, but they have the core of what you need to drive Workbench from Excel. It really is not that hard to do and can provide a nice interface for users who don’t know Workbench.

    Some areas for improvement and suggestions for a real application are:

    • Use jScript in Workbench to add a button that runs a script that attaches to an open Excel file and update based on the current values in that Excel file. So instead of running Workbench in batch from Excel, pressing the button would update everything.  That seems to be a more effective way to do it. (maybe a quick article in the future if Matt help me figure out how to add a button quickly…)
    • Do more with VBA or Python in the Excel file to make you Excel based tool more sophisticated.
    • There is no error checking in this example… very bad.  For a real world tool a lot more code should be added to check things and to capture errors from various functions.
    • As one can imagine, this can be extended to other programs.  A good example would be an optimization tool or another “calculating” tool like MathCAD or Matlab.

    Dust In the Wind: Stress and Strain Results in Workbench Mechanical vs. Mechanical APDL

    Twice in the last week we’ve taken tech support calls in which the users questioned why their stress or strain results were being reported differently in Workbench Mechanical vs. the results from the same results file in /POST1 with ANSYS Mechanical APDL.  After answering those questions it was pretty obvious that a Focus blog entry was in order.  All we needed was a good, relevant example to demonstrate the issues and the explanation.


    First glimpse of approaching dust storm.   All photos by the author.

    In case you missed it, the big story here in the Phoenix area this week was our monster haboob, or dust storm.  If you’re not familiar with the term haboob, Wikipedia explains it here:  In order to have a humongous dust storm, you’ve got to have wind. 

    Stopped in a parking lot to take these pictures – the only camera I had was my phone.



    About 3 minutes after this picture was taken the dust storm arrived.

    Wind tends to cause damage, but although our recent dust storm is estimated to have been 100 miles wide and up to 10,000 ft. high, we fortunately did not sustain much significant wind damage.  Things that do tend to get mangled, however, are deployed patio umbrellas and portable expanding sunshades.  These sunshades typically retract into a compact size and fit in a zip up carrying case.  Many of us have collections of damaged sun shades that still work via creative application of duct tape, wire, etc.  These inexpensive shades work great for keeping the sun off of us during birthday parties or other outdoor gatherings, but high winds tend to cause the metal members to bend and break, causing the shades to need some field engineering repair if not just a one way trip to the dumpster.

    Here is a solid geometry representation of a typical portion of the frame of a representative shade.  It consists of two rectangular hollow members, pinned to each other at the center, with pins at each end that in the full structure would be attached to additional components.


    For simplicity, we fixed the pins on the right side to ground, while those on the left side have an upward bearing load applied to the upper pin and a downward bearing load applied to the lower pin.  These loads tend to cause the members to bend at the central pin.  The bearing loads in our example represent the effect of a strong gust of wind hitting the fabric canopy above the frame, with the load eventually reacting through the frame to stakes that attach the frame to the ground at the bottom.   The main thing to note here is that the applied load is large enough to cause significant plastic deformation, not unlike what one might experience in the real world when one of these structures is subjected to a very strong wind.


    Workbench Mechanical, Coarse Mesh, Peak von Mises Stress is 79,219 psi




    Same Results File in Mechanical APDL /POST1, Peak von Mises Stress is 83,873 psi

    The issue here is that for our initial run with a very coarse mesh, when we view the von Mises stress results in the Mechanical editor and then compare them with the von Mises stress results obtained from the same results file in /POST1 in Mechanical APDL, we notice there is a difference (79.2 ksi vs. 83.9 ksi).  Why is that?  It has to do with how stresses are calculated.  First let’s consider Mechanical APDL and /POST1.  The original graphics display system is known as Full graphics.  Fifteen or twenty years ago ANSYS, Inc. developed a newer graphics display system for MAPDL known as Powergraphics.  There are several differences between these two display systems which affect results quantities. 

    ANSYS Mechanical APDL uses PowerGraphics by default, which among other things only looks at results on the exterior surfaces of the model.  Full Graphics, on the other hand, includes interior elements in addition to the exterior surfaces when displaying results plots.  Another difference is that with Powergraphics we can vary the number of element facets displayed per element edge with the /efacet command.  The default is one facet per edge but for midside-noded elements we can increase that to two or four.  With Full Graphics we are stuck with one facet per element edge.  Workbench Mechanical uses an algorithm whose results tend to compare more favorably with full graphics, although it apparently displays with 2 facets per element edge.   Another option in MAPDL is to plot nodal (averaged) vs. element (unaveraged) stresses. 

    So, which of all these methods is the correct one?  I would consider them all to be correct, just different.  However, we can use the difference in results as guideline for our mesh density (as well as the presence of singularities). If there is a significant difference between PowerGraphics and Full Graphics results in MAPDL, this usually indicates the mesh is too coarse, at least in our region of interest.  As the mesh is refined, the difference between the two calculations should decrease.  In Workbench Mechanical 13.0, we can plot averaged and unaveraged stress and strain result plots.  The choice is made in the details view for a given plot.  A significant difference between these two quantities also indicates that mesh refinement is needed.  In our shade frame model, we can see that as the mesh is refined, the difference in von Mises stress results decreases, as shown in the table below.



    A similar effect is seen with the von Mises plastic strain results:


    Regarding the mesh densities used, the coarse mesh had an element size of at least 0.05 in. on the member hole at the high stress/strain location,  while the fine mesh had an element size of 0.025 on the same hole.  Another way to look at the mesh refinement is that the coarse model had 20 elements on the hole of interest while the fine mesh had 104 elements on the same hole.  Clearly the coarse mesh in this example was way too coarse for engineering purposes, but this was selected for this article to ensure the effect of different results calculation methods was significant and observable.

    So, the bottom line here is that if you see unacceptable differences in stress or strain results using different results calculation methods, it likely means that your mesh, at least in the area of interest, is too coarse.  Try adding mesh refinement and check the results again.  In Mechanical, you can try adding a Convergence item to a scoped result plot to at least partially automate this process.  Just be careful that you don’t include any singularities in your desired convergence region.

    If you were expecting a reference to the Kansas song, “Dust in the Wind,” well, I guess this is it.  Fortunately we don’t seem to have many lingering affects of the big dust storm.  The parking lot here at PADT has a thin layer of dirt that’s gradually disappearing.  Once we get a good rain it will all get washed away.

    Using User Defined Results in ANSYS Mechanical

    I first started contemplating this article several weeks ago, and I was planning on somehow working in a Jersey Shore reference.  But now that I’ve relocated to Colorado and am recovering from a climbing trip that was a bit above my ability, my creative juices are a little low (they were used up trying to improvise my way up an overhanging roof pitch).

    Hmm…I’m noticing there aren’t a lot of foot-holds to get me over there, prussik to the rescue!

    Anyways, User Defined results were first introduced in R12 to grant the user access to element table items. 


    When you insert a user-defined result, you are required to fill in the ‘expression’ line in the details window. 


    Just like Johnny 5, ANSYS needs input

    You can look up everything that’s available through the documentation, but we all know that no one reads the instructions.

    Reading is boring…I’ll wait until the movie comes out, I hear it stars the guy who voiced Johnny 5

    There’s a much easier way to auto-populate the ‘expression’ line…the Worksheet view!  To access this, first click on the ‘Solution’ branch and then select ‘Worksheet’ (tab in R12, button in R12.1 and newer).  This will show you a list of all the user defined result expressions.  Find one you like, right-mouse-click on it and select ‘Create User Defined Result’. 


                                                                   That’s more like it

    This will insert a ‘User Defined Result’, the only work you need to do is scope it to a body (if necessary).  The only ‘tricky’ part of this process is that you need to solve the model first before using the Worksheet view.  This is because before the model has been solved, Mechanical doesn’t know what is in the result file.  So if the worksheet view is blank or grayed out, it’s because you haven’t solved the model.

    So what’s the benefit of using the User Defined Results?  Say you wanted to look at total strain, kinetic energy, or reaction force contour plots…just to name a few.  In order to view any of those, you would either have to open the .rst file in MAPDL or use the User Defined Result.

    Left = FX, Right = Total Strain
    Here’s a quick description of the ‘headers’ available on the Worksheet tab. 
    U Displacement
    S Stress
    EPTO Total Strain
    EPEL Elastic Strain
    EPPL Plastic Strain
    EPTT Thermal Strain
    ENFO Element Nodal Reaction Forces
    NDIR Nodal Orientation Values
    There are more headers that are listed in the documentation (I know, we all agreed that was boring).  However if you’re looking for items stored in the NMISC or SMISC (for ‘regular’ or contact elements), those are accessible provided you properly format the expression line.
    So now let’s go through an example where we actually use this functionality.  A customer called in asking how to calculate the volume of a part above a specified stress level.  Interesting question…
    First we create a user defined result and use the ‘VOLUME’ expression.  So we’re half-way there.  Next, we need to understand about how the results are stored for a result item in the ‘Solution’ branch.  Each contour plot is actually a vector in the form of element/node vs result.  You can see this for yourself by right-mouse-clicking on the item in the tree and selecting ‘export’.  So right now we have a vector defined of element vs volume.  Now we just need another listing of element vs stress. 
    When you create a stress result in Mechanical, the default behavior is to show the nodal-stress, which represent the average of the adjacent elements.  That’s not what we want.  If we look into the ‘Integration Point Results’ we see there are more options.  Element mean seems like it might work for us, but when we export it, we see that it’s still reporting stresses at the node, only now it’s using a different integration scheme.
    pic9 pic10
    Averaged Elemental Mean

    In order to access the average stress value of the element (not node), we need to use the User Defined Results.  We’ll ask to evaluate the expression seqv (von Mises) and set the integration option of using the elemental mean.


    Now when we export that result item we get what we want…element vs stress:


    Now we just need to export both vectors (volume and stress), then copy/paste/sort/sum and you’re done.  Don’t forget the most important step…billing for 4 hours of post-processing work.

    Long story short, all you MAPDL users who have been complaining about not being able to access element tables should take a look at the User Defined functions. 

    How To update ANSYS Release 13.0 to ANSYS Release 13.0 SP2 for 64-bit Linux

    Pre-Install Tasks

    · ANSYS Release 13.0 must already be installed on your machine

    · Time needed to complete update: 15-30 minutes

    Begin ANSYS 13.0 SP2 update procedure

    1. Login and download the appropriate Linux version update from the ANSYS Customer Portal.

    2. Save ANSYS130SP2_LINX54.tar to your install Desktop

    3. Extract the files root Desktop

    4. Open a Terminal window session and change directory to your Desktop then to the extracted folder on the desktop. In my example the folder is Save ANSYS130SP2_LINX54.tar_FILES

    5. After you have verified that you are in this folder type. ./INSTALL


    7. Review the ANSYS Software License agreement and click I AGREE to continue.


    8. Verify your installation directory and click Next.

    You must install into the ANSYS RELASE 13.0 SP2 into the same location as your original ANSYS RELEASE 13.0 location.


    9. Select the components you would like to install. The installation GUI will by default have checked installed selected.

    You can choose to install fewer products to update but you would not be able to select products to add with the update package. You would need to install from the main ANSYS RELASE 13.0 media and then install the SP2 on top of that installation.


    Please note the amount of disk space required for the update. Approximately 7.2 GB. You will need to make sure that your Linux machine has at least 7.3GB free and available.

    10. Verification screens – Dates


    11. Installation screens – Various screens will scroll through as the installation manager extracts the package files. Screen shot of Extraction: Package 4 of 16


    12. Installation screens – Various screens will scroll through as the installation manager extracts the package files. Screen shot of Extraction: Package 5 of 16


    13. Installation screens – Various screens will scroll through as the installation manager extracts the package files. Screen shot of Extraction: Package 14 of 16


    14. Completed update – Click Next to begin the ANSYS 13.0 Licensing Client Installation update


    15. ANSYS 13.0 Licensing Client Installation – Begin verification


    16. ANSYS 13.0 Licensing Client Installation – Configuration log and successful completion of ANSYS 13.0 Licensing Client update.


    17. Click Finsh to end update installation script routine.

    As indicated in the note on the IMPORTANT note below. Please run the update for the ANSYS, Inc. License Manager SP2 update after completing this procedure. This download is also available through the ANSYS Customer Portal


    Retrieving Accurate PSD Reaction Forces in ANSYS Mechanical

    We just finished up a tech support call for a customer that wanted a way to get accurate reaction loads from a PSD run in ANSYS Mechanical. Alex Grishin took the call and provided a nice example to the customer, so we thought we would leverage that and share it with all of you.  Even if you are not in need of this particular function, it is a great example of using snippets.  If you are not familiar with this, check out our recent webinar on the subject.

    The reason why you have to do this is because doing an accurate PSD force calculation is not a simple thing.  The math is a bit complicated, because PSD responses are probabilities of results that loose sign.  And it is right now only available in Mechanical APDL (MAPDL).  This is not a problem because we can use an APDL command object to get the results from MAPDL and bring them back to ANSYS Mechanical.

    Three Simple Steps

    There are three very simple steps needed to get this done:

    1. Identify the geometry you want the reaction loads calculated on
      Do this by selecting a face, edge, or corner and create a named component.  You will use that named component to grab the nodes that sit on the piece of geometry and do an FSUM in MAPDL. In our example, we call the named selection react_area1.
    2. Tell the solver to store the required modal information
      Since ANSYS Mechanical doesn’t do reaction force calculations they save disk space by not storing the info needed for such calculations, but we need them.  So add a command object in your modal analysis environment that says save all my results (outres) and expand all my modes (mxpand):
    3. Calculate the reaction force
      Now we simply need to add a command object to the post processing branch that:
      • gets the PSD deflection results (set,3)
      • selects the named selection (cmsel),which is a nodal component in MAPDL,
      • gets the nodes attached (esln)
      • calculates the reaction load (fsum)
      • stores the results in parameters that we return to ANSYS Mechanical. (*get,my_).  Remember that anytime you create a MAPDL parameter in the post processor that starts with my_ it gets returned to ANSYS Mechanical. (well, that is the default, you can change the prefix)
      • select everything so that MAPDL can keep post processing like normal

      For our example, it looks like this:

    The following figure shows the model tree for our example, and the returned parameters:


    Nothing fancy, simple in fact: Make a component, store the required info in the result files, do an FSUM and bring back the results.

    You can download the example here.


    That was a short article!  And no exciting pictures.  So… if you want to you could check out the travels of The PADT Hat around the world. 

    How to Get a Cool Grip on Your Data Center Cooling in Three Easy Steps!

    Over the years I have learned to do more with less. When it comes to information systems world, you all know the equation is often much more with much less. One of my to-do’s over the years, umm that continued to get bumped down on the priorities list. It is the juggling act of making sure that the data center has enough cooling vs. power vs. yes again in AZ cooling. If you are an IT professional or even an Engineer you really don’t have time to attempt to try to convince someone, anyone that we need to speed more money. Even if you use the effective philosophy of Time, Money and Quality. After dealing recently “wish ware software vendors this past year” I added a fourth dimension to the above philosophy. It’s called Functionality; here is what Merriam Webster had to say about Functionality. The quality or state of being functional; especially: the set of functions or capabilities associated with computer software or hardware or an electronic device.

    1. Time – Try searching the internet for terms such as data center cooling calculator, data center cooling costs or how can I save money with our data center cooling? You will suddenly have millions of search queries at your beckon. From video blogs on data center cooling, white papers on optimizing IT strategy on data center cooling. It is endless 3 million plus hits on just one search term data center cooling calculator. Wow, Start researching my young padawon learner, fill out those lead generating white papers. Keep it simple…
    2. Money – I would prefer that we used or dollars on buying a server with a couple INTEL XEON ET-8870 processor. Or how about a QUAD based AMD FX-8130P processor server! I do not have any budget for a I am sure fabulous data center cost benefit crisis analysis.
    3. Quality – Can I even understand what the end-result document white paper will read. Will I look like even more of an idiot? This needs to be accurate information. I will have to do it myself or use a third party data center analysis.
    4. Functionality – Will our current air conditioners hold up this year? What about when we hit 120 degrees? Oh my do I need to add more cooling power?

    Wikipedia on British Thermal Unit (BTU) –

    So why I care about a BTU? Because approximately one “ton of cooling”, which is a typical way people talk about cooling devices in the USA, is 12,000 BTU/h. This is the amount of power needed to melt one short ton of ice in 24 hours. Locked away in a climate controlled vault is one of my data centers. “Said such vault may or may not contain the following items on any given day.” After all this is a mobile compute server world these days.

    • 13 Servers
    • 174 Cores (Mix of Windows/Linux servers)
    • 2 – Network Routers
    • 3 – Network Switches
    • Phone System
    • Voice Mail System
    • 1 LCD 20” monitor/KVM

    Go Green in the Data Center! First, let’s get a “Cool Grip” on your data center…16,484.058 BTU/h

    A couple years ago one of the our ANSYS Mechanical Simulation Engineers named Jason Krantz told me about a watt meter device. A handy little watt meter monitoring device designed by P3 International KILL A WATT™. Over the years that little watt meter devices has become one of closest friends and ally in IT. Today, I was able to quickly asses (realistically about four hours of time) just how many Watts of power each one of our servers, network devices, etc. used. I tried to be as accurate as I could without having to take out a second mortgage. So I made sure and verified that one of our PHD FE Analyst or CFD Analysts had our servers at our near 100% CPU use.

    YOUTUBE VIDEO :: Check out this real-world example of a AMD Opteron 6174, 287 hour electrical cost usage test. The data shown in this video is of a server that has four AMD Opteron 6174 processors installed.

    AMD Opteron 6174 Electrical Cost Usage

    So, what is your magical number? Ours is 4,831 Watts

    Do you know how many watts of power your server room is using? could you even logically guess what that number is? Our magical number for server room #1 turned out to be 4,831 Watts. I do need to state that I was unable to take some of the devices offline. When that was the case I used data pulled from the actual technical documents of the device’s manufacture website.

    So what is your BTU/h number? Ours is 16,484.058 BTU/h? Oh and I don’t even like math? I know, I know, math was solved and perfected centuries ago. But how do I convert Watts into BTU?

    I used a 99 cent app that I bought off of the iTunes App store called “Convert Units”.

    • Step 1 – Convert Watts into BTU/m
    • Step 2 – Then multiplied by 60 to get that value into BTU/h.
    • Step 3 – Speak to your Operations Department, send an email, shout from the rooftops!! We need at least a two ton Air Conditioning unit for Server Room #1

    Now with the precious BTU/h value in hand. I was able to speak the same language as that of our Director of Operations & Facilities manager.

    I wish you all could have been there when I walked up to Scott and told him the news. The dialogue went something like this:

    “Scott I wanted to talk to you about server room #1’s cooling situation…(pause for dramatic expression). Almost immediately you could see Scott’s blood pressure rising. Scott’s brain quickly churning through mountains of Air Conditioning cooling information and data. I quickly calmed his anxiety and said these exact words. “Server Room #1’s BTU/h ratio is approximately 16,484.058 BTU/h.” It took Scott just a moment for this bit of information to register. I do believe that I actually heard the hallelujah chorus in the heavens. I could also see the peace that passes all understanding come across Scott’s face. It was if I could read his mind and he was thinking how is this non-operation/facilities type humanoid speaking my language? For Scott knew immediately that he had enough cooling power at this moment into to cool that data center down all summer long.

    DATA CENTER #1 – 274.7343 BTU/m*60 = 16,484.058 BTU/h

    How the heck are you making money today? Step out of the Box, Step Into a Cube Computers for CFD and FEA Simulation.

    Workbench and Excel, Part 1: Using the Excel Component System

    It is a fact.  Microsoft Excel is the most used engineer tool in the world.  If you are like me, you do everything you can’t do in ANSYS in Excel.  And a lot of the time you wish you could talk directly from Excel to ANSYS – and in the day many of us wrote kludgey VB Macros that would write APDL scripts run ANSYS MAPDL in the background.  In the past couple of releases our friendly neighborhood ANSYS developers have added a lot of different ways to work with Excel: saving tables to a file, Python scripting to talk to Excel, and an Excel System.  I remember reading about these things as they came out, even wrote about how cool they were, but I never had the opportunity to use them.

    Then, last week, I noticed an Excel icon just sitting there in the toolbox, mocking me, taunting me to use it.


    So I dragged it out on my project page and tried to use it… and got no where.  My assumptions were not valid, it  didn’t work the way I expected because, it turned out, I was not thinking about how it fit into the project correctly.  So I backed up, actually read the help (gasp!) and after a experimenting got it to work, I thought.  Then I talked to some folks at ANSYS, Inc. and they reminded me of what this is: an Excel Solver System.  It is  not a tool that lets you “drive” your project from Excel. It lets you use Excel to calculate values.

    This posting is a summary of what I learned. And as I was working through it I thought it would be good to also cover the python interface to Excel and how to save tabular information to Excel. These will be covered in future articles (hence this being Part 1).

    What You Need to Know

    As I said above, my problem was that I was thinking about how Excel fit into my project all wrong.  The first thing you should do is read the help on the Excel System.  The best way to find it is type excel into search.  The item with the most hits will take you to the article for component systems, then click on Microsoft Office Excel. (I wish I could just put a link in… grumble… grumble… ).

    To use the Excel system you do the following:

    1. Add the System to your project
    2. Make a spreadsheet and use range names to identify parameters
    3. Attach an Excel spreadsheet
    4. Edit the system and tell the program which parameters are input and which are output
    5. Go into the parameter manager and hook up any derived parameters you want to pass to Excel and use any of the Excel parameters with other parameters as needed
    6. Tell ANSYS to run a VB macro (if you want)
    7. Update your project or Design Points

    We will go through the process in detail but first, a few things you should know:

    • The system kind of looks and feels like the parameter manager in Workbench, but it is not.  You have to think of Excel as a “solver” that feeds parameters from and to the parameter manager.
      • I struggled with this because I thought of output parameters as values calculated by Workbench and input parameters as ones that come from Excel, but the opposite is true.
      • Excel Input Parameter: A value calculated in Workbench parameter manager
      • Excel Output Parameter: A value calculated in Excel
      • You need to get your head around this or you will get stuck like I did.  The example should help.
    • Parameters that come from DesignModeler are dimensionless in the parameter manager.
    • This one really held me up for a while.  If you assign a parameter from Excel that has a unit to drive your geometry in design modeler, you get an error.
    • The solution is to make sure that you DO NOT use units on Excel parameters that you get or pass to DesingModeler
    • When you attach the Excel file to your Excel system on the project page Workbench copies the Excel file to your project and buries it in dpall\XLS.
    • You will get burned by this if you go to your original excel file, edit it, then try and update your project.  Your changes will not show up.  That is because it is not linked to the original file, it is linked to a copy stored in that XLS directory.
    • Once you have linked a file you should exit Excel then open the file by RMB on the Excel system and choose  “Open File in Excel” (see below for more on this whole process)
    • I recommend that you start buy making your Excel file, save it with the name you want in the C:\Temp directory, attach that file, close Excel, then open from Workbench.
    • Now you have a file to add your stuff to and you don’t have to worry about having an earlier version lurking around.
    • An important side effect of this is if you delete your system, it deletes your Excel file!  So make sure you make a copy or do a save as before you remove the Excel system
    • To get changes in Excel to show up in your project, you need to save the file AND refresh/reload.
    • Making a change to he Excel file will put the system out of date.  A refresh on the project page or a reload on the “Edit Configuration” page will update things.
    • The parameter names in Excel are case sensitive.  So whatever your prefix is in the system properties (WB_ by default) you need to have the same in your Excel spreadsheet for range names.
    • To get a full update, including running any macros and doing any calculation, you have to update the system.   This is kind of obvious, but I kept forgetting to do it.
    • Your Excel file will not update if you use RSM.  Make sure your default for updating your project is to run local and, that if you are using design points, you set that update to run in the foreground.
    • The easiest way to check and change this is to click on the parameter bar and view its properties.  Under Design Point Update Process set Update Option to Run in Foreground.
    • If you want to have your Excel file define both input and output parameters for the same ANSYS simulation, workbench sees that as  a “cyclic dependency and will not let you do it.
    • Although annoying at first glance, it kind of makes sense.  If you feed a value to Excel and then Excel calculates a new value that effects your ANSYS model, you need to update the ANSYS model, which will change the value that gets passed into Excel, which will change the value that gets passed out which changes your ANSYS model, which… and so it goes in a loop. This is considered a bad thing.
    • This goes back to the fact that Excel should be used as a solver, not as  ‘”driver” of you simulation.
    • If you do want to drive your analysis from Excel, you’ll need to do some scripting. We’ll cover that in a future article.

    The Process

    I started this article with a really cool valve demo model. Then found that it was just too slow and a pain to work with for showing how the Excel system works.  So I went back to my second favorite type of model, a simple “tower of test.”  (my favorite is a FPWHII – flat plate with a  hole in it).  You can download the project here.

    Add the System to Your Project

    Like every other system in Workbench, you simply drag from the toolbox to the Project Schematic.  Notice how the green “drop zones” are all empty spaces.  You can’t drop it on an existing cell in a system because there is no dependency between other systems and an Excel system.  The Excel system is connected through parameters, which we will see in a bit.


    Once you have dropped it onto the schematic, click on the Top cell (C1 in this case) and check out the properties (RMB Properties if the window is not already open).  From the properties you can see the system ID (XLS) and you can specify an Analysis Type.  You can leave it blank or type in something like “Home Grown Optimization.”

    Then click on the Analysis cell (C2 in this case) and look at the properties.  They are shown here:


    One key thing to note is that the directory where the Excel file will be copied is shown.  I did this once already on this project so it made a XLS-1 directory. If I did it again, I’d see XLS-2, etc…   In fact, by the time I got done with this article and trying all sorts of things, it ended up in XLS-8.

    The most important option under Setup is the “Parameter Key”   Any Excel named range that begins with this string will get read into the parameter manager.  If you make it blank, all the named ranges will come in.

    Make a Spreadsheet and Use Range Names to Identify Parameters

    Now you need to create your spreadsheet.  You need to plan ahead here a bit.  Figure out what parameters you need Excel to get from your models and what parameters you want to send back.  Come up with good names because that is what gets passed to Workbench.

    What happens when you attach a file is that Workbench goes to the Excel sheet and steps through all the named ranges in the file.  If it finds one with a name that starts with the filter value, it grabs the first value in the range as the parameter value and then grabs the second as the units.  If your range is bigger, it just ignores the rest.

    So this tells us that we need to create a range that has at least one cell, or two if units are important. For our simple example we will be calculating costs  and outputting that using the input Volume, Length and Width. There is a formula in the cost cell that multiples those values times pre-set costs per unit volume, length and width and sums them up to get a cost.

    So the laziest thing you can do is select a cell and name it.

    But it will help you and others if you actually make a table that has a descriptive name, the parameter name (WB_ should be your default), the value for that parameter, and the units, if any.  Note that for an input parameter you can just set the value to zero to get started.  Here is what the tables look like for our example:


    To create a range you select the value and units for a given parameter, hold down the Right-Mouse-Button (RMB), and Select “Define Range”


    A cool thing that Excel does is to use the value just to the left of the range as the default name of the range.  So by creating the table you save yourself some typing.  Or, if you don’t use a table, just type in the name you want .


    Now just click OK and you have a named range.  You can repeat this for each range, or you can get fancy and use the fact that your data is in a table, with the parameter name to the left, to quickly generate all the ranges at once.

    To do this, select the WB Param, value and unit columns. Then go to –>Formulas –> Defined Names –> Create from Selection.  When the dialog box pops up make sure only “Left column” is checked.  Click OK.


    In one fell swoop you created all your named ranges.  To see, edit, and delete ranges, regardless of how they were created, go to Formulas –> Defined Names –> Name Manager.


    Take some time to look at this and understand it. When you are debugging and fixing stuff, you will use this window.

    Now you have an Excel file that Workbench will like!  Time to attach  it. Save it (I recommend to save to temp so you don’t get it confused with the copy that Workbench will make).

    Attach an Excel Spreadsheet

    This is the easiest step. Simply RMB on the Analysis cell in the system and browse for the file.

    imageNow your Analysis cell has a lightning bolt, update to have it read the file and find parameters.  If you have your parameters set up wrong, such that you don’t have any named ranges with the specified prefix, it will generate an error but will still attach the file.

    NOTE:  If you get some weird errors  “Unexpected error…” and “Exception from HRESULT:…” when updating your Excel system, check your Excel file.  Odds are you have an open dialog box or the file is somehow locked. The error generates because Workbench can’t get Excel to talk to it.

    Edit the System and Tell the Program Which Parameters are Input and Which are Output

    Although you have a green check mark, you will notice that your system is still not connected to your parameters, and therefor it is not connected to the rest of your model.  The way to fix this is to RMB->Edit Configuration. Double-clicking on Analysis also does the same thing.


    This puts you in Outline Mode.  You should be familiar with this mode from the Parameter Manager or Engineering Data.


    Take some time to explore this outline.  Notice the setup cell, where you have access to the system properties.  Then it’s child, the Excel file.  Click on it to the properties for the file connection.  Under that is the important stuff, the parameters.

    If you did everything correctly, you will see all of your parameters in alphabetical order.  If you click on one, you will see the properties.  Here they are for the cost value:


    It shows the range, the value and units (C column) and the Quantity name.  Workbench guesses by units.  So PSI comes in as pressure by default.  If it is a stress, you need to change it here.

    But your main task right now is to tell Workbench which of these parameters you want passed to the parameter manager, and what type of parameter, input or output, they are.  Here is where I get screwed up.  Because an input parameter in the parameter manager is an output parameter here.  Remember, the Excel system is a solver that takes in parameters from the parameter manager and send back values to drive your models.  So in our example, all the dimensions and the volume are passed from the parameter manager TO excel, so they are input.  The cost is passed from Excel to the Parameter manager so it is output.


    Now you have hooked up your Excel system. Click on the “Return to Project” at the top of the window and you will go back to the project schematic and see that a Parameters cell has been added to the system and it has been attached to the parameter bar.


    Go Into the Parameter Manager and Hook Things Up

    Although the Geometry and Mechanical systems are connected through the parameters to the Excel system, no relationships exist.  We need to assign some values to our Excel parameters.

    This is what our test model looks like before we do this:


    Our goal is to have the parameters in the first column below to drive those in the second:

    Driving Parameter Driven Parameter
    P7: Len P10: WB_L
    P5: W1 P12: WB_W
    P8: Solid Volume P11: WB_V

    I tried to just click on the value in value column (C) and change the value from the number it is to the parameter name it should be but that does not work.  Because the parameter is set as a constant.  So, you need to click anywhere on the row for the parameter you want to set, then go down to the Properties window and change the Expression to the Parameter ID you want to change.  This changes the Expression to be an equation and the Expression Type to be Derived:


    That is it. You now have Excel in your project as a solver. Update your project and the cost will be calculated and presented as a parameter for optimization, DOE studies or whatever you want.

    Tell ANSYS to run a VB macro (if you want)

    One really cool feature is that you can tell the program to run a VB macro on an update. What you do is go to your system, click on Analysis then RMB-> Edit Configuration.  Then click on the file cell (A3).  The property area now shows info on your file, and has a Use Macro row at the bottom. Click on the checkbox and a Macro Name row will popup.  Enter the name of a macro in your spreadsheet and you are off.

    Here is a silly example where I use a macro to calculate a value.  For the example I put in the well known equation for deriving the Kafizle of a system:

    1. Create a new row in my table for the Kafizle value to go in
    2. Create a name WB_KF for the value
    3. Write my macro (don’t laugh):
      Sub CalcKafizle()
      Range(“E7”) = Rnd(1) + Cos(Range(“E5”).Value)
      End Sub
    4. Save my sheet and KABOOM. I now need to save it as an xlsm, not xlsx!  I didn’t think about that!
      • This means my Excel connection wont’ work.  So you have to delete your system and start again with your macro file.  So plan ahead! I’m glad I did this silly example rather than running in to it on a real problem.
    5. Once everything is right again, go into the outline for the excel system and make that new parameter (WB_KF)  an output parameter.
    6. Then click on the File (A3) and go to the properties window and click on the Use Macro checkbox
    7. Put the macro name into the  Macro Name field


    Now you can run you project, and every time you do, the program will calculate a new cost and Kafizle value.  This of course begs the question, what are the proper units of Kafizle?  Here is the Design Point table:


    Thoughts and Conclusions

    I started this effort thinking I would drive my model from Excel, basically replacing the Parameter Manager with Excel.  But that does not work because Excel doesn’t know enough about your project to handle the dependencies that can really cause problems if you don’t solve in the correct order.  So once I figured that out I found some pretty good uses.  Here are some other ideas for how to use the Excel System:

    • Do additional post processing on result values
    • Use formulas or lookup tables to calculate loads.
    • Just make sure that the values you take from your ANSYS model into Excel (inputs) are also input parameters in the parameter manager.
    • Use tables and lookups to calculate input values for an analysis
    • A good example would be a “family of parts” application where you put in a part number and Excel does a vlookup() on a table that has all the input parameters listed by part number.
    • To include results from an ANSYS analysis in a system model you have in Excel.
    • You still have to force the update on the ANSYS side, which is not the ideal way to run a system model, but it may be easier than writing scripts and hooking it up that way.

    This is a new feature at R13 and it can be a bit “touchy.”  Especially if you are rooting around in it like a Javalina rooting around in your flower bed (Arizona reference).  If you do something really crazy it can loose its way and start generated errors. I found the best solution at that point was to save a copy of my Excel file, delete the system, and start over.

    This took a lot longer than I thought to write, but the Excel System does a lot more than I thought.  I think as we all start thinking about how to use this tool, people will come up with some pretty cool applications.