« Back to Video Tutorials

FEA Series Part 3: Extracting Maximum Stress Using Macros


Description

This is the third video in the Finite Element Analysis (FEA) series. Earlier in this series, we calculated the von Mises Stress from stress vectors in the connecting rod data set. In this video, we will be extracting maximum stress using macros to calculate the von Mises stress over time.

To do this we will be using Tecplot Macro Variables which can access the minimums and maximums of the variable assigned to contour groups.

Maximum von Mises Stress at Each Time Step

For the initial setup, ensure von Mises Stress is calculated and in the variable list of the Data Set Info dialog. Then, turn on Contours by selecting the toggle on the plot sidebar. Finally, open the Contour & Multi-Coloring Details dialog to change the contour variable in Group 1 to von Mises Stress.

Once von Mises Stress contours the plot, select Scripting -> Play Macro/Script from the menu and the Open Macro dialog will appear. Navigate to the connecting rod folder and select the PlotMaxContourOverTime.mcr file.

After selecting Open, the macro will automatically run and an XY plot will appear of the maximum von Mises stress at each time step. The macro will also automatically link the solution time of the two frames. When the play button is pressed, a marker line follows over the XY plot to track the solution time.

PlotMaxContourOverTime Macro File

Let us breakdown the PlotMaxContourOverTime macro file.

  1. First, the macro gets the variable name of the current Contour variable in Group 1 using the Extended Macro Commands: Query.VarNumByAssignment and Query.VarNameByNum. The name of the Contour variable is then stored in the ContourVarName macro variable. The macro then creates a new one-dimensional zone based on the number of time steps and renames it based on the Contour variable.
  2. Next, the macro file loops through each time step and sets the first variable as Solution Time. The loop also sets the second variable to the intrinsic macro variable, MAXC.
    To prepare for the new frame, the macro turns on Frame Linking and makes sure the active frame is on top. Then it creates a new frame with an XY Line plot. The new frame then becomes our active frame by default. Now commands will only affect the new frame.
  3. A new line map is created with our variable 1 and 2 as the X and Y axes, respectively. Then, the titles change to custom titles: Solution Time and Max ContourVariable. To make the plot more interactive, frame linking is turned on in the new frame. This allows us to use a marker line to track the current Solution Time.
  4. Returning to the workspace, you can see the completed product functioning as the animation plays. Macros and Python scripts are useful for controlling Tecplot 360 through automation and can even extend the capabilities of Tecplot 360 beyond the user interface. For more information on macro commands, check out our Scripting Guide located in the installation directory.

Download the Tecplot 360 Scripting Guide (PDF)

See Also

FEA Series Part 1: Identifying Regions of Maximum Stress.
FEA Series Part 2: Data Alter Using IF Conditions