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.

image

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…

image

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:

image

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 updateWB2.py -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. 

image

The outline for the parameter manager looks like this:


image

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

   6:  

   7: # import system things needed below

   8: from System.IO import Directory, Path

   9: from System import DateTime

  10:  

  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)

  15:  

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

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

  18:  

  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)

  25:  

  26:  

  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

  34:  

  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

  41:  

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

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

  44:  

  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")

  50:  

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

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

  53:  

  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 + "]"

  60:  

  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..."

  73:  

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

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

  76: Update()

  77:  

  78: # If asked for, save the project

  79:  

  80: if saveit == "Yes": 

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

  82:     Save()

  83:  

  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

  86:  

  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

 102:  

 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

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.

Resources

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:

 www.ironpython.info

Specific info on the connection to Excel can be found at: http://www.ironpython.info/index.php/Interacting_with_Excel

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.

dust5crop

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:  http://en.wikipedia.org/wiki/Haboob.  In order to have a humongous dust storm, you’ve got to have wind. 

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

 

dust4

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.

image

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.

image

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

 

 

image

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.

image

 

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

image

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).

P1130671
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. 

pic1

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

pic3

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.
pic4

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’. 

pic5

                                                               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.

pic7
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.

pic11

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

pic12

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

image

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

image

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.

image

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.

image

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

image

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

image

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

image

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

image

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

image

15. ANSYS 13.0 Licensing Client Installation – Begin verification

image

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

image

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

image

Parallel Performance: ANSYS FLUENT R13 with Service Pack 2

Recently, PADT has conducted some parallel benchmarks with our Linux cluster.  The model used for the tests is an ANSYS FLUENT *.cas file with 26.5 million cells and 6.5 million nodes.  The physics in this model are fairly simple; it is modeling external, steady airflow over an object.  Simulations of 10 iterations were conducted using as many as 144 processors over three 48-core systems (the machine names are “cs0”, “cs1”, and “cube48”, and are summarized in Table 1).  The first two machines in Table 1 (cs0 and cs1) are connected together via Infiniband, so they effectively form a 96-core machine.  Furthremore, the cs0 and cs1 machines are connected to cube48 via GigE network ports.  Each of the machines has two GigE network ports each which connect to a Gigabit switch to allow for trunking.

Table 1 – Benchmark machine specifications

Machine

Processor Type

Processor Count

cs0

2.3 GHz AMD Opteron 6176SE

48

cs1

2.3 GHz AMD Opteron 6176SE

48

cube48

2.2 GHz AMD Opteron 6176SE

48
 
Two versions of FLUENT were tested; the original version 13 (R13), and the new Service Pack 2 for version 13 (R13 SP2).  The results were scaled according to the one-processor solve time to compute the “speedup” (defined as the solve time on 1 processor divided by the solve time on “N” processors), and are presented in Figure 1 with a comparison to “Linear” or ideal speedup (ideal speedup implies that the speedup value is equal to the number of processors for a given processor count).

image

Figure 1 – Speedup vs. Processors with 6.5 million node ANSYS FLUENT model

The first result in Figure 1 (blue curve) was obtained using as many as 48 processors on the cs0 machine before installing the Service Pack 2 for FLUENT version 13.  As illustrated in Figure 1, the speedup values of the blue result decrease as the number of processors increases.  The next result (green curve with triangles) was calculated using Service Pack 2 for ANSYS FLUENT version 13 on the cube48 machine using as many as 48 processors.  This result on cube48 presents perfect correspondence with Linear speedup, and even displays some values which are “super-linear”.  This behavior led us to suspect that the improvements in Service Pack 2 for ANSYS FLUENT version 13 were the primary cause of the increase in performance demonstrated by the cube48 speedup result.

However, further testing of the cs0 and cs1 machine with Service Pack 2 for ANSYS FLUENT seems to suggest otherwise.  These data are represented by the red squares in Figure 1.  Runs were conducted on as many as 144 processors, which involved a distributed run using 48 processors on cs0, 48 processors on cs1, and 48 processors on cube48.  The general trend of this result is the same as that recorded on cs0 before installing Service Pack 2 for ANSYS FLUENT version 13, suggesting that some other effect (likely machine-related) is present.   Our current hypothesis is that the socket 2 processor (which handles the Infiniband UIO card hardware) is causing the slowdown, primarily because the Infiniband switch is present only on the cs0 + cs1  machine, and not on the cube48 machine.  This was suggested by the manufacturer of Infiniband switch (SuperMicro).  Testing to asses this problem is on-going.

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):
        outres,all,all
        mxpand,,,,yes,,yes
  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:
       /post1
       set,3,1
       cmsel,s,react_area1
       esln
       fsum
       *get,my_fsumx,fsum,0,item,fx
       *get,my_fsumy,fsum,0,item,fy
       *get,my_fsumz,fsum,0,item,fz
       allsel

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

image

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.


hat_beach1hat3imageimage

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!

CUBE 96 Mini-ClusterOver 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. http://www.merriam-webster.com/dictionary/functionality?show=0&t=1307146105

  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) – http://en.wikipedia.org/wiki/British_thermal_unit

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. http://www.cube-hvpc.com/

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. 

image

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… Instead, I leave the link to buy MS Office 2013 for those who does not have it).

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.

    image

    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:

    image

    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:

    image

    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”

    image 

    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 . 

    image

    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.

    image

    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. 

    image

    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.

    image

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

    image

    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:

    image

    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. 

    image

    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.

    image

    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:

    image

    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:

    image

    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

    image

    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:

    image

    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.

    How To run ANSYS Release 13.0 Workbench on 64-bit Linux

    Getting ANSYS Workbench up and running on Linux at R13 is pretty simple.  You just have to make sure that a few things are in place and some packages are loaded.  Then it works great.  Here is a quick HOW-TO on getting things going:

    Pre-Install Tasks

    • Install CentOS 5.3 or greater or RHEL5
      • Download and install the latest graphics card drivers for your video card. Restart
        image
    • Next, Gnome Desktop Environment is required for optimum use.

    • Next, Using the Linux Package Manager. Select the Development main group and then select the additional libraries all needed. (see images below)

    image

    image

    • Select Optional packages and then select the additional MESA libraries (see below).

    image

    • Next, select the Base System main group, then X Window system, and Legacy Software Support. With Legacy software support still selected. Click Optional Packages and select the additional package – openmotif22 and click close.

    image

    image

    • Restart the system

    Post ANSYS Install Setup Tasks

    • Within your Terminal session. Type ProductConfig.sh

    image

      • Click Configure Products, then select the products to configure or reconfigure
    • Pro/E Configuration GUI

    image

    • Unigraphics NX install Configuration GUI

    image

    • Click Continue and the product configuration script will run.

    image

    • Click Finish

    How to launching ANSYS Release 13.0 Workbench

    • Open a Linux terminal session:
    • Change your path to include /ansys_inc/v130/Framework/bin/Linux64

    image

    • Next, launch the program by typing ./runwb2 and press enter

    image

    • Basic opening up of a Design Modeler project
    • image

    Here it is: ANSYS 13 Workbench on CentOS 5.5 64-bit Linux

    image

    Done!

    Dad, What Do You Do at Work?

    I’m sure the question comes up for a lot of us from time to time, whether from one of our own offspring, another relative, or an acquaintance.  “Just what is it that you do, anyway?”  Typical answers might be something short and sweet, such as, “I’m an engineer.”  A more detailed response might be, “I use a technique called finite element simulation which is a computer tool we use to simulate the behavior of parts or systems in their real world environment.”

    You’ll probably find that people’s eyes glaze over and they start looking for someone else to talk to by the time you get to the end of that second quote above.  In fact, I find that my extended family is much more interested in my brother-in-law’s surgery stories from the operating room than they are in my own triumphs and challenges in the engineering simulation world.  Maybe you’ve had that same sort of reaction.  You have probably noticed that there are a whole lot more medical dramas on TV at any one time than there are engineering dramas.  They’ve got many characters from Marcus Welby on up to Dr. Ross on ER, Jack on Lost, to Dr. Grey on Grey’s Anatomy, with more than I can count in between.

    We’ve got, well, Scotty.  And even then I think Dr. McCoy got more air time.

    So when my kids ask me what I do at work, I recall a scene from that late 1980’s to early 1990’s TV show The Wonder Years.  In the episode “My Father’s Office,” Kevin asks his dad what he does for a living.  His father responds in an angry tone, “You know what I do!  I work at NORCOM.”  As if that were a sufficient explanation.  I suppose it was his way of saying, “It’s complicated.  It can be high pressure.  You might find it boring.  It puts food on the table and a roof over our heads, though.”

    Rather than reply that way, I’ve tried to come up with what is hopefully a better response.  In fact, this concept constitutes the first portion of our Engineering with FEA training class, written by Keith DiRienz of FEA Technologies with contributions by yours truly.

    I can’t guarantee that your audience’s eyes won’t glaze over by the end, nor that you’ll become the hit of the party, but this is free and you get what you pay for.  This explanation can obviously be adjusted based on the audience, but it goes something like this:

    Simple explanation:

    –We have equations to solve for stresses and deflections in simply-shaped parts such as cantilevered beams.

    –No such equations exist for complex shaped objects subject to arbitrary loads.

    –So, using finite elements, we break up a complex part into solvable chunks, leading to a finite set of equations with finite unknowns.

    -We solve the equations for the chunks, and that ends up giving us the results for the whole part.

    If we want more details, we can use this:  As an example, here is a simple beam, fixed at one end with a tip load P at the other end.  We have an equation to calculate the tip deflection u for simple cases:

    image

    In the above equation E is the Young’s Modulus, a property of the material being used and I is the moment of inertia, a property of the shape of the beam cross section.

    For more complex shapes and loading conditions, we don’t have simple equations like that, but we can use the concept by dividing up our complex shape into a bunch of simpler shapes.  Those shapes are called elements.

    image

    A useful equation for us is the linear spring equation, F=Kx, where F is the force exerted on the spring, K is the stiffness of the spring, and x is the deflection of one end of the spring relative to the other.  If we extend that concept into 3D, we can have a spring representation in 3D space, meaning the X, Y, and Z directions.  In fact, the tip deflection equation shown above for the beam fixed at one end can be considered a special case of our linear spring equation, solved for deflection with a known applied force.

    By assembling our complex structure out of these 3D springs, or elements, we can model the full set of geometry for complex shapes.  The process of making the elements is called meshing, because a picture or plot of the elements looks like a mesh.

    Using linear algebra and some calculus (stay in school kids!) we can setup a big  series of equations that takes into account all the little springs in the structure as well as any fixed (unable to move) locations and any loads on the structure.  The equations are too big to solve by hand by normal people so computers are used to do this.

    When the computer is done solving we end up with deflection results in each direction for the corner points (called nodes) in each element.  Some elements have extra nodes too.

    From those deflection results, the computer can calculate other quantities of interest, such as stresses and strains.  Further, other types of analyses can be solved in similar fashion, such as temperature calculations and fluid flow.

    Here is an example using a familiar object that practically everyone can relate to.  This plot shows the mesh:

    image

    This is fixed in the blue region at the bottom and has an upward force on the left end.  The idea here is that someone is holding it tightly on the blue surface and is pulling up on the red surface.

    image

    After solving the simulation, we get deflection results like this:

    image

    The picture above shows that the left end of the paper clip has deflected upward, which is what we would expect based on common experience with bending paper clips.  Using our finite element method, we can predict the permanent deflection resulting from bending the paper clip beyond it’s ‘yield’ point, resulting in what we call plastic deformation.

    Clearly there is a lot more to it than these few sentences describe, but hopefully this is enough to get the point across.

    In sum, not as exciting as my brother in law’s medical stories involving nail guns or other gruesome injuries, but hopefully this makes the world of engineering simulation a little more accessible to our friends and family.

    In the Wonder Years episode, Kevin ends up going to work with his father to see for himself what he does.  I won’t spoil the episode, but hopefully you’ll get the chance to show your family and friends what it is that you do from time to time.

    Knowing the ID of Coordinate Systems Created in ANSYS Mechanical – or perhaps – You didn’t know that, everyone knows that…

    During this weeks webinar on Using APDL Snippets in ANSYS Mechanical a question came up about coordinate systems. I actually don’t remember the original question, but in answering it the question came into my mind: how do you get access to the ID of coordinate systems that you create in ANSYS Mechanical?

    For a lot of items you can add to the ANSYS Mechanical model tree, you can attach a Command Object (snippet) and ANSYS Mechanical passes a parameter with the ID of the thing you want access to (material, contact pair, spring, joint, etc…).  But there is no way to add a Command Object to a coordinate system.

    So I dug into it and found something I didn’t know.  The problem with discovering something like this and sharing it is that you either just uncovered something that can help a lot of users or you are going to embarrass yourself over something that everyone already knows.  The idea of a blog is to be casual and informal, so let’s see which I did.

    If you click on a user created coordinate system in ANSYS Mechanical The Detail View list two things in the first grouping “Definition”.  They are Type and Coordinate System ID.  The default for the ID is “Program Controlled”  I’ve never clicked on it to see what the other options are. It turns out you can change it to “Manual”

    image

    Once you do that it gives you a second “Coordinate System ID” line and you can put in whatever number you want there.

    image

    Problem solved.  Just give your coordinate system whatever number you want and use that number in your macro.  Couldn’t be easier.

    Hopefully, this was helpful. If so, rate this posting at a 5.

    If you already knew this little factoid, rate it as a 1.

    – Eric

    Files and Info from “Using APDL Snippets in ANSYS Mechanical”

    We just finished the webinar “Using APDL Snippets in ANSYS Mechanical” and wanted to share the files weimage used and some additional information. 

    The presentation can be found here.

    The sample script for plotting mode shapes is here.

    You can view a recording of the presentation here on our WebEx site.

    PADT’s ANSYS Webinar Series is now off on Summer Break. We will be back in August!

    You can always view past recordings by going to http://padtincevents.webex.com and Click on PADT ANSYS Webinar Series to see a listing.

    A Further Assessment of Design Assessment

    Last weeks PADT ANSYS Webinar Series webinar was on a little used feature in ANSYS Mechanical called Design Assessment, or DA.  If you missed it, you can view a recording at:

    imagehttp://tinyurl.com/PADT-DA-Webinar

    And a PDF of the presentation can be found here:

    As promised, this weeks The Focus posting will be a follow up on that webinar with an in-depth look at the scripts that were used in the example.  But first, let us review what DA is for those that don’t remember, fell asleep, or don’t want to sit through 60+ minutes of me mumbling into the telephone.

    Review of DA

    Design Assessment is a tool in ANSYS Workbench that works with ANSYS Mechanical to take results from multiple time or load steps, perform post processing on those results, and bring the calculated values back into ANSYS Mechanical for viewing as contour plots.  It was developed to allow the ANSYS, Inc. developers to add some special post processing tools needed in the off shore industry, but as they were working on it they saw the value of exposing the Application Programmers Interface (API) to the user community so anyone can write their own post processing tools.

    image

    You use it by adding a Design Assessment system to you project.  In its most basic form, the default configuration, it is set up to do load case combinations.  That in itself is worth knowing how to use it.  But if you want to do more, you can point it to a custom post processing set of files and do your own calculations.

    A custom DA is defined by two things.  First is an XML file that tells ANSYS Mechanical what user input you want to capture, how you want to get results out of mechanical, what you want to do with the results, and how you want them displayed in your model tree.  Second is one or more Python scripts that actually do the work of capturing what the user input, getting results, doing the calculation, and sticking the resulting values back in the model.  Both are well documented and, once you get your head around the whole thing, pretty simple.

    Right now DA works with Static and Transient Structural models.  It also only allows access to element stress values.  Lots of good enhancements are coming in R14, but R13 is mature enough to use now.

    If that review was too quick, review the recording or the PowerPoint presentation.

    A Deep Dive Into an Example

    For the webinar we had a pretty simple, and a bit silly, example – the custom post processing tool took the results from a static stress model and truncates the stress values if they are above or below a user specified value.  Not a lot of calculating but a good example of how the tool works. 

    Note, this posting is going to be long because there is a lot of code pasted in.  For each section of code I’ll also include a link to the original file so you can download that yourself to use.

    Here is the XML file for the example (Original File):

       1:  <?xml version="1.0" encoding="utf-8"?>
    The first lesson learned was that you have to get all the tags and headers just right. 
    It is case sensitive and all the version and other stuff has to be there
    Cutting and pasting from something that work is the best way to go
       2:  <!-- 
       3:  www.PADTINC.com 
       4:            XML file for ANSYS DA R13
       5:            Demonstration of how to use DA at R13
       6:            Goes through results and sets stresses below floor value to floor
       7:              value and above ceiling value to ceiling value.     
       8:              
       9:          User adds DA Result to specify Floor and Ceiling
      10:          Attribute group can be used to specify a comment
      11:          
      12:          Calls da_trunc_solve.py and da_trunc_eval.py in c:\temp
      13:          
      14:          Eric Miller
      15:          5/18/2011
      16:  -->
      17:   
    Everything is in a DARoot tag.
      18:  <DARoot ObjId ="1" Type="CAERep" Ver="2">
    Attributes tags define items you want to ask the user about.  
      19:    <Attributes ObjId="2" Type="CAERepBase" Ver="2">
    This first attribute is a drop down for the user to decide which stress value they want 
    You use <AttributeType> to make it a dropdown then put the values in <Validation>
      20:      <DAAttribute ObjId="101" Type="DAAttribute" Ver="2">
      21:        <AttributeName PropType="string">Stress Value</AttributeName>
      22:        <AttributeType PropType="string">DropDown</AttributeType>
      23:        <Application PropType="string">All</Application>
      24:        <Validation PropType="vector&amp;lt;string>">
      25:               SX,SY,SZ,SXY,SYZ,SXZ,S1,S2,S3,SEQV
      26:        </Validation>
      27:      </DAAttribute>
    Next is the prompt for the stress floor value
      28:      <DAAttribute ObjId="102" Type="DAAttribute" Ver="2">
      29:        <AttributeName PropType="string">Stress Floor</AttributeName>
      30:        <AttributeType PropType="string">Double</AttributeType>
      31:        <Application PropType="string">All</Application>
      32:        <Validation PropType="vector&amp;lt;string>">-1000000,10000000</Validation>
      33:      </DAAttribute>
    Then the Ceiling Value
      34:       <DAAttribute ObjId="103" Type="DAAttribute" Ver="2">
      35:        <AttributeName PropType="string">Stress Ceiling</AttributeName>
      36:        <AttributeType PropType="string">Double</AttributeType>
      37:        <Application PropType="string">All</Application>
      38:        <Validation PropType="vector&amp;lt;string>">-1000000,10000000</Validation>
      39:      </DAAttribute>
    Finally a user comment, just to show how to do a string.
      40:      <DAAttribute ObjId="201" Type="DAAttribute" Ver="2">
      41:        <AttributeName PropType="string">User Comments</AttributeName>
      42:        <AttributeType PropType="string">Text</AttributeType>
      43:        <Application PropType="string">All</Application>
      44:      </DAAttribute>
      45:    </Attributes>
    To expose an attribute, you can put it in an AttributeGroup to get info shared by
    all DA result objects.  This one just does the Comment
      46:    <AttributeGroups ObjId ="3" Type="CAERepBase" Ver="2">
      47:      <DAAttributeGroup ObjId="100002" Type="DAAttributeGroup" Ver="2">
      48:        <GroupType PropType="string">User Comments</GroupType>
      49:        <GroupSubtype PropType="string">Failure Criteria</GroupSubtype>
      50:        <AttributeIDs PropType="vector&amp;lt;unsigned int>">201</AttributeIDs>
      51:      </DAAttributeGroup>
      52:    </AttributeGroups>
    <DAScripts> is the most important part of the file.  It defines the scripts to run for a 
    solve and for a evaluate.  At R13 you do need to specify the whole path to your python files
      53:    <DAScripts ObjId="4" Type="DAScripts" Ver="2">
      54:      <Solve PropType="string">c:\temp\da_trunc_solve.py</Solve>
      55:      <Evaluate PropType="string">c:\temp\da_trunc_eval.py</Evaluate>
      56:      <DAData PropType="int">1</DAData>
      57:      <CombResults PropType="int">1</CombResults>
      58:      <SelectionExtra PropType="vector&amp;lt;string>">DeltaMin, DeltaMax</SelectionExtra>
      59:    </DAScripts>
    The other way to get user input is to put attributes into a <Results> object.  
    Here we are putting the choice of stresses (101),and the floor and ceiling (102,103)
    into an object
      60:    <Results ObjId="5" Type="CAERepBase" Ver="2">
      61:      <DAResult ObjId ="110000"  Type="DAResult" Ver="2">
      62:        <GroupType PropType="string">Ceiling and Floor Values</GroupType>
      63:        <AttributeIDs PropType="vector&amp;lt;unsigned int>">101,102,103</AttributeIDs>
      64:        <DisplayType PropType="string">ElemCont</DisplayType>
      65:      </DAResult>
      66:    </Results>
      67:  </DARoot>

    I always have to go over XML files a few times to figure them out. There is a lot of information, but only a small amount that you need to pay attention to.  After a while you figure out which is which.

    Now on to the fun part, the Python scripts.  The first one gets executed when they user chooses solve. 

    da_trunc_solve.py is shown below and you can get the original here.   The comments inside pretty much explain it all.  It basically does two things:  creates an ANSYS MAPDL macro that extracts all the element stresses and puts them in a text file, then it runs MAPDL with that macro.

       1:  import subprocess
       2:  import os
       3:  import shutil
       4:   
       5:  #======================================================================
       6:  #
       7:  #   ------------------------------------------------------------  PADT
       8:  #    www.PADTINC.com
       9:  #
      10:  #    da_trunc_solve.py
      11:  #         Demonstration python script for Design Assessment in 
      12:  #            ANSYS R13
      13:  #         Called on solve from ANSYS Mechanical
      14:  #         Bulk of code copied and modified from TsaiWu example
      15:  #            provided by ANSYS, Inc.
      16:  #
      17:  #       E. Miller
      18:  #       5/18/2011
      19:  #======================================================================
      20:  def trunc_solve(DesignAssessment) :
      21:   
      22:      # Get number of elements in model
      23:   
      24:   
      25:      # Change directory to current workspace for DA
      26:      originaldir = os.getcwd()
      27:      os.chdir(DesignAssessment.getHelper().getResultPath())
      28:   
      29:      #Get the path to the results file name and the location of the temp directory
      30:      rstFname = DesignAssessment.Selection(0).Solution(0).getResult().ResultFilePath()
      31:      rstFname = rstFname.rstrip('.rst')
      32:      apath = DesignAssessment.getHelper().getResultPath()
      33:      
      34:      print "Result File:", rstFname
      35:      print "Apath:", apath
      36:   
      37:      # Write an ANSYS APDL macro to start ANSYS, resume the result file, grab the stress
      38:      #   results and write them to a file
      39:   
      40:      macfile = open(DesignAssessment.getHelper().getResultPath()+"\\runda1.inp", "w")
      41:   
      42:      macfile.write("/batch\n")
      43:      macfile.write("/post1\n")
      44:      macfile.write("file,"+rstFname+"\n")
      45:      macfile.write("set,last\n")
      46:      macfile.write("*get,emx,elem,,num,max\n")
      47:      macfile.write("*dim,evls,,emx,10\n")
      48:      macfile.write("etable,esx,s,x\n")
      49:      macfile.write("etable,esy,s,y\n")
      50:      macfile.write("etable,esz,s,z\n")
      51:      macfile.write("etable,esxy,s,xy\n")
      52:      macfile.write("etable,esyz,s,yz\n")
      53:      macfile.write("etable,esxz,s,xz\n")
      54:      macfile.write("etable,es1,s,1\n")
      55:      macfile.write("etable,es2,s,2\n")
      56:      macfile.write("etable,es3,s,3\n")
      57:      macfile.write("etable,eseqv,s,eqv\n")
      58:      macfile.write("*vget,evls(1, 1),elem,1,etab,  esx\n")
      59:      macfile.write("*vget,evls(1, 2),elem,1,etab,  esy\n")
      60:      macfile.write("*vget,evls(1, 3),elem,1,etab,  esz\n")
      61:      macfile.write("*vget,evls(1, 4),elem,1,etab, esxy\n")
      62:      macfile.write("*vget,evls(1, 5),elem,1,etab, esyz\n")
      63:      macfile.write("*vget,evls(1, 6),elem,1,etab, esxz\n")
      64:      macfile.write("*vget,evls(1, 7),elem,1,etab,  es1\n")
      65:      macfile.write("*vget,evls(1, 8),elem,1,etab,  es2\n")
      66:      macfile.write("*vget,evls(1, 9),elem,1,etab,  es3\n")
      67:      macfile.write("*vget,evls(1,10),elem,1,etab,eseqv\n")
      68:   
      69:      macfile.write("*cfopen,darsts,txt\n")
      70:      macfile.write("*vwrite,evls(1,1),evls(1,2),evls(1,3),evls(1,4),
    evls(1,5),evls(1,6),evls(1,7),evls(1,8),evls(1,9),evls(1,10)\n")
      71:      macfile.write("(G16.9, X, G16.9, X, G16.9, X, G16.9, X, G16.9, X, 
    G16.9, X, G16.9, X, G16.9, X, G16.9, X, G16.9)\n")
      72:      macfile.write("*cfclose\n")
      73:      macfile.write("finish\n")
      74:      macfile.write("/exit,nosave\n")
      75:   
      76:      macfile.close()
      77:   
      78:      # Set up execution of ANSYS MAPDL. 
      79:      #   Note: Right now you need to grab a different license than what Workbench is using
      80:      exelocation = "C:\\Program Files\\ANSYS Inc\\v130\\ansys\\bin\\winx64\\ansys130.exe"
      81:      commandlinestring = " -p ansys -b nolist -i runda1.inp -o runda1.out /minimise"
      82:   
      83:      #Execute MAPDL and wait for it to finish
      84:      proc = subprocess.Popen(commandlinestring,shell=True,executable=exelocation)
      85:      rc = proc.wait()
      86:   
      87:      # Read the output fromt the run and echo it to the DA log file
      88:      File = open("runda1.out","r")
      89:      DesignAssessment.getHelper().WriteToLog(File.read())
      90:      File.close()
      91:   
      92:      # Go back to the original directory
      93:      os.chdir(originaldir)
      94:   
      95:  trunc_solve(DesignAssessment

    Some key things you should note about this script:

    • You have to use MAPDL to get your stress values. Right now there is no method in the API to get the values directly.
    • You need a second MAPDL license in order to run this script.  It does not share the license you are using for ANSYS Mechanical at R13.  This should be addressed in R14.
      • One work around right now is to use an APDL code snippet in the ANSYS mechanical run that makes the text file when the original problem is solved.  The SOLVE script is then no longer needed and you can just have an evaluate script.  Not a great solution but it will work if you only have once seat of ANSYS available.
    • Note the directory changes and getting of result file paths.  This is important. Mechanical does stuff all over the place and not in just one directory.
    • Make sure the MAPDL execution stuff is correct for your installation.

    Once the solve is done and our text file, darsts.txt, is written, we can start truncating with the evaluate script (Original File).  This script is a little more sophisticated. First it simply reads the darsts.txt file into a python array.  It then has to go through a list of DA Results objects that the user added to their model and extract the stress value wanted as well as the floor and ceiling to truncate to. For each result object requested, it then loops through all the elements truncating as needed.  Then it stores the truncated values.

       
       1:  import subprocess
       2:  import os
       3:  import shutil
       4:  import sys
       5:   
       6:  #======================================================================
       7:  #
       8:  #   ------------------------------------------------------------  PADT
       9:  #    www.PADTINC.com
      10:  #
      11:  #    da_trunc_eval.py
      12:  #         Demonstration python script for Design Assessment in 
      13:  #            ANSYS R13
      14:  #         Called on eval from ANSYS Mechanical
      15:  #         Bulk of code copied and modified from TsaiWu example
      16:  #            provided by ANSYS, Inc.
      17:  #
      18:  # NOTE: Right now it just does SX.  XML and script need to be modified to allow user
      19:  #       to specify component to use (X, Y, or Z)
      20:  #
      21:  #       E. Miller
      22:  #       5/18/2011
      23:  #======================================================================
      24:  def trunc_eval(DesignAssessment) :
      25:   
      26:      # Change directory to current workspace for DA
      27:      originaldir = os.getcwd()
      28:      os.chdir(DesignAssessment.getHelper().getResultPath())
      29:   
      30:      # Find number of elements in DA
      31:      Mesh = DesignAssessment.GeometryMeshData()
      32:      Elements = Mesh.Elements()
      33:      Ecount = len(Elements)
      34:      print "DA number of elements is ",Ecount
      35:      print "Number of Result Groups:",DesignAssessment.NoOfResultGroups()
      36:   
      37:      # get User comment from Atribute Group
      38:      # Note: Assuems one.  Need to use a loop for multiple
      39:      attg = DesignAssessment.AttributeGroups()
      40:      atts = attg[0].Attributes()
      41:      usercomment = atts[0].Value().GetAsString()
      42:      print "User Comment = ", usercomment
      43:   
      44:          # create arrays for SX/Y/Z values
      45:      sx = []
      46:      sy =  []
      47:      sz = []
      48:      sxy = []
      49:      syz =  []
      50:      sxz = []
      51:      s1 = []
      52:      s2 = []
      53:      s3 = []
      54:      seqv = []
      55:      # read file written during solve phase
      56:      #   append stress values to SX/Y/Z arrays
      57:      File = open("darsts.txt","r")
      58:      for line in File:
      59:          words = line.split()
      60:          sx.append(float(words[0]))
      61:          sy.append(float(words[1]))
      62:          sz.append(float(words[2]))
      63:          sxy.append(float(words[3]))
      64:          syz.append(float(words[4]))
      65:          sxz.append(float(words[5]))
      66:          s1.append(float(words[6]))
      67:          s2.append(float(words[7]))
      68:          s3.append(float(words[8]))
      69:          seqv.append(float(words[9]))
      70:      File.close()
      71:   
      72:      # Loop over DA Results created by user
      73:      for ResultGroupIter in range(DesignAssessment.NoOfResultGroups()):
      74:          # Get the Result Group
      75:          ResultGroup = DesignAssessment.ResultGroup(ResultGroupIter)
      76:          # Extract Cieling and Floor for the Group
      77:          strscmp  = ResultGroup.Attribute(0).Value().GetAsString()
      78:          strFloor = float(ResultGroup.Attribute(1).Value().GetAsString())
      79:          strCeil  = float(ResultGroup.Attribute(2).Value().GetAsString())
      80:          print "DA Result", ResultGroupIter+1, ":", strFloor, strCeil
      81:   
      82:          #Add a set of results to store values in
      83:          ResultStructure = ResultGroup.AddStepResult()
      84:   
      85:          print "strscmp", strscmp
      86:   
      87:          # Loop on elements 
      88:          for ElementIter in range(Ecount):
      89:              #Add a place to put the results for this element
      90:              ResultValue = ResultStructure.AddElementResultValue()
      91:              # Get the element number and then grab SX values that
      92:              #   was read from file
      93:              Element = Mesh.Element(ElementIter).ID()
      94:   
      95:              if strscmp == "SX":
      96:                  sss = sx[Element-1]
      97:              elif strscmp == "SY":
      98:                  sss = sy[Element-1]
      99:              elif strscmp == "SZ":
     100:                  sss = sz[Element-1]
     101:              elif strscmp == "SXY":
     102:                  sss = sxy[Element-1]
     103:              elif strscmp == "SYZ":
     104:                  sss = syz[Element-1]
     105:              elif strscmp == "SXZ":
     106:                  sss = sxz[Element-1]
     107:              elif strscmp == "S1":
     108:                  sss = s1[Element-1]
     109:              elif strscmp == "S2":
     110:                  sss = s2[Element-1]
     111:              elif strscmp == "S3":
     112:                  sss = s3[Element-1]
     113:              elif strscmp == "SEQV":
     114:                  sss = seqv[Element-1]
     115:   
     116:              # Compare to Ceiling and Floor and truncate if needed
     117:              if sss > strCeil:
     118:                  sss = strCeil
     119:              if sss < strFloor:
     120:                  sss = strFloor
     121:              # Store the stress value
     122:              ResultValue.setValue(sss)
     123:      # Go back to the original directory
     124:      os.chdir(originaldir)
     125:   
     126:  trunc_eval(DesignAssessment)
     127:   

    Some things to note about this script are:

    • The same directory issues hold here.  Make sure you follow them
    • Always loop on ResultGroups.  You can assume the number of attributes is constant but you never know how many results the user has asked for.
    • In this example it is assumed that the stress label is the first attribute and that the floor and ceiling are the second and third.  This is probably lazy on my part and it should be more general.
      • The way to make it more general is to loop on the attributes in a group and grab their label, then use the label to determine which value it represents.
    • Before you can store values, you have to create the result object and then each result value in that structure:
      • ResultStructure = ResultGroup.AddStepResult() for each result object the user adds to the tree
      • ResultValue = ResultStructure.AddElementResultValue() for each element
      • ResultValue.setValue(sss) to set the actual value

    And that is our example.  It should work with any model, just make sure you get the paths right for where the files are.

    Be a Good Citizen and Share!

    If you have the gumption to go and try this tool out, we do ask that you share what you come up with.  A good place is www.ANSYS.NET.  That is the repository for most things ANSYS.  If you have questions or need help, try xansys.org or your ANSYS support provider.

    Happy Assessing!

    Files for Design Assessment in R13

    During the Webinar on 5/18/2011 we discussed a simple example we created to show how to use Design Assessment.  Click here to download the Zip file.

    You can get a PDF of the PowerPoint here.

    You can watch a recording of the webinar at: http://tinyurl.com/PADT-DA-Webinar

    image

    I Have the Touch: Check Contact in Workbench Prior to Solving with the Contact Tool

    Song quotes Peter Gabriel, “I Have the Touch”

    The time I like is the rush hour, cos I like the rush
    The pushing of the people – I like it all so much
    Such a mass of motion – do not know where it goes
    I move with the movement and … I have the touch

    Looking back I can see a defining moment in my life when about a month after high school graduation two good friends and I drove four hours from home to see Peter Gabriel in concert.  It’s not that the concert was great, which it was, but it was the trip itself.  It was a first foray after high school, a sort of toe dipping into the freedom of adulthood while in a strange pause between graduating in a small town in the same school system with the same kids and starting engineering school in a big city in the Fall.

    Wanting contact
    I’m wanting contact
    I’m wanting contact with you
    Shake those hands, shake those hands

    What does all that have to do with ANSYS, you ask?  Primarily, it’s hard to get Peter Gabriel’s “I Have the Touch” out of my head whenever I’m working with contact elements.  Someone once said that we are a product of the music of our youth.  While as I’ve gotten older and hopefully wiser I would hope that we are made up of much more than the product of listening to some songs, I do find it true that certain songs from years ago tend to stick in my head.  So, while Mr. Gabriel plays in my head, let’s discuss checking our contact status in Workbench Mechanical.

    For those of us familiar with Mechanical APDL, the CNCHECK command has been a good friend for a lot of years now.  This command can be used to interrogate our contact pairs prior to solving to report back which pairs are closed, what the gap distance is for pairs that are near touching, etc.  More recently, this type of capability has become available in Workbench Mechanical by inserting a Contact Tool under the Connections branch.

    Let’s take a look at that in version 13.0.  Here we have inserted a Contact Tool under the Connections branch.  It automatically includes the Initial Information sub-branch, with a yellow lightening bolt meaning no initial information has yet been calculated.

    image

    By right clicking on the Initial Information sub-branch, we can select Generate Initial Contact Results.  The resulting worksheet view provides significant information on all of the defined contact regions.  By default the information displayed for each contact region includes the name, contact/target side, type (fictionless, no separation, etc.), status, number of elements contacting, initial penetration, initial gap, geometric penetration, geometric gap, pinball radius, and real constant set number.  That last value is useful when reviewing the solver output, as it lists contact info per real constant set number of each contact pair (contact region).

    image

    Further, by right clicking on that table we have the option to display some additional data, or remove fields of data.  The additional fields that can be added are contact depth, normal stiffness, and tangential stiffness.  We can also sort the table by clicking on any of the headings. 

    The colors in the table display four possible status values:

    Red = open status for bonded and no separation types

    Yellow = open for non bonded/no separation types

    Orange = closed by with a large amount of gap or penetration

    Gray = inactive due to MPC or Normal Lagrange or auto asymmetric contact

    image

    If we left click on one or more of the contact regions in the table, we can then right click and “Go to Selected Items in Tree.”  This is a convenient way to view a particular set of contact regions in the graphics view.

    Any social occasion, it’s hello, how do you do
    All those introductions, I never miss my cue
    So before a question, so before a doubt
    My hand moves out and … I have the touch

    So, what do we do with this information?  Ideally it will prevent us from launching a solution that goes off and cranks for a few hours only to fail due to an improper contact setup.  For example, by viewing the initial status for each pair we can hopefully verify that regions that should be initially touching are in fact touching as far as ANSYS is concerned.  If there is an initial gap or penetration, correcting action can be taken by adjusting the contact settings or even the geometry if needed prior to initiating the solution.

    Wanting contact
    I’m wanting contact
    I’m wanting contact with you
    Shake those hands, shake those hands

    The Contact Tool > Initial Information is another tool we can use to help us obtain accurate solutions in a timely manner.  If you haven’t had the opportunity to use it, please try it out.  I can’t guarantee that it will trigger fond memories, but maybe you’ll have an enjoyable song playing in your head.