« Back

How to Visualize Your M-STAR Results in Tecplot 360


M-Star is a powerful CFD package that can be used for a wide variety of problems, such as bioreactors, agitated tanks, HVAC systems, and more. M-Star CFD produces output that can be read by Tecplot 360 2024 R1 and newer, using the recently introduced PVD file loader.

In this article, we’ll show you how to visualize and analyze M-Star results with Tecplot 360. The animation below was created using a number of capabilities provided by Tecplot 360 including:

  • Loading PVD and CSV data files
  • Utilizing PyTecplot to compute histograms
  • Synchronizing animation over time via Frame Linking
  • Novel uses of slices and contour color cut-off


Top-Left Frame:

  • Slice showing velocity magnitude
  • Pseudo Volume Rendering showing Scalar concentration (scalar injected at T=10s)
  • Particles
  • Geometry of the static and moving bodies

Top-Right Frame:

  • Histogram of the Scalar concentration, using log scale for the Y-axis

Bottom Frame:

  • Line plots of Power number and ‘gv’, from ‘Stats/MovingBody_Moving Body.txt’ and ‘Stats/GlobalVariables.txt’ respectively’

To complete these steps you’ll need to following files:

  • 0716-agitated tank.zip (9Gb)
  • Histogram_MStar.py
  • show_markergridline.mcr

These files can be downloaded here.

Visualizing Velocity Magnitude and Scalar Concentration

Velocity Magnitude and Scalar Concentration

  1. Load the ‘_StaticBody.pvd’ PVD files from ‘out/Output’ first. This is helpful as it places the non-transient data first in the dataset listing. Select the PVD Data Loader from the dropdown menu in the Load Data dialog first to make selecting the appropriate files easier.
  2. These data contain only 2D cell types, so Tecplot 360 will initially show these in a 2D plot. Change to 3D Plot Type using the Plot sidebar.
    3D Cartesian Plot
  3. The Static Body files will be treated as Transient data on first load.  Use Data > Edit Time Strands to change Strand to zero (0) to treat them as non-transient (a.k.a. static). 
    Edit Time Strands
  4. Load the remaining PVD files in ‘out/Output’ (omit the Boundary Conditions file), ensuring to select ‘Append data to active frame’ when prompted. This can take a while, as Tecplot 360’s PVD loader will scan through all timesteps to determine the set of data to load.
  5. Press ‘Add All’ when presented with the Variable Load and Combine dialog to ensure the additional variables included in these PVD files are loaded.
    Variable Load and Combine
  6. Activate Plot > Blanking > Value Blanking to view the interior of the vessel.  This will blank all data that meet these criteria. We want to only affect the StaticBody data, so we’ll adjust which data are affected by Value Blanking in the next step.
    Value Blanking
  7. On the Effects page of the Zone Style dialog, toggle on Use Value Blanking for only the Static Body data.  Also, toggle Show Zone to match the picture below.
    Zone Style
  8. You should now have a plot that looks like this:
    Zone Style Plot
  9. To show the particles, turn on the Scatter layer on the Plot Sidebar. Also ensure Show Scatter is toggled on for only the spset data in the Zone Style dialog. Adjust the scatter style settings as desired. Here, we’re using spheres colored by Contour Group 1, which we’ve assigned to Velocity Magnitude using the Contour Details dialog.
    Zone Style Velocity Magnitude
  10. For the Slice, we color the slice using the same Contour Group as the particles (spset). In this case we’re using Contour Group 1, assigned to Velocity Magnitude. Notice that we’ve chosen cmocean – thermal for the colormap and we’re using Color cutoff below 0. The color cutoff hides contour coloring below that value, resulting in a ‘round’ slice. Make sure to also deactivate the Shade layer for the Slice zone! Also note that Velocity Magnitude is zero at the first timestep – so make sure to advance a timestep or two. To easily adjust style settings of the slice – either double-click (to launch the Zone Style dialog) or right-click to access some quick style options.
    Contour & Multi-Coloring Details
  11. To visualize the Scalar concentration (which is injected at T=10s) we’re going to use a large number of highly transparent slices through the volume data to create something that looks like a plume. To achieve this effect, advance to a solution time >= 10. Then add 100 slices which are 99% translucent. We’ll also color the slices by Contour group 2, which we assign to Scalar scalar concentration (mol/L). Launch the Plot>Slices… dialog and match the pictured settings.
                                                                           Slice Details Left Slice Details Right
  12. From the Contour Details dialog we use Color cutoff again can help enhance the areas of high Scalar concentration. Notice that we use cmocean – algae for the colormap and the Color cutoff below value is set to 0.0001.
    Contour & Multi Coloring Details cmocean algae
  13. Display the solution time on the plot by adding a Text object with the string: ‘Time: &(SolutionTime%0.1f)’.
  14. Finally, adjust the contour legends, plot orientation, and lighting as desired.

Computing the Histogram 

Making the histogram requires running a PyTecplot script. We started with the Histogram.py script available on the Tecplot GitHub (https://github.com/Tecplot/handyscripts/blob/master/python/Histogram.py) and adapted it to create one histogram per timestep. The modified script is ‘out/Output/Histogram_MStar.py’ Once the script is finished running we save the data to a new file. This process could be further automated by extending the script to run fully in batch mode. This would also improve execution time. A pre-requisite to this step is to install PyTecplot (https://tecplot.azureedge.net/products/pytecplot/docs/install.html)

To create the histogram:

  1. Load Volume.pvd (or just continue from the last step above)
  2. Turn on PyTecplot connections via Scripting>PyTecplot Connections
  3. For the following steps to work make sure that Contour Group 2 is assigned to Scalar Concentration with Contour Levels range from 0.0001 to 0.001. This will ensure we get the bins we want.
  4. Open a command prompt and run ‘Histogram_MStar.py’ as such:
    python -O Histogram_MStar.py --use_contour_group 2
    The use_contour_group option will use the contour level range and number of levels to define the bins. It will also compute the histogram for the variable assigned to the contour group.Enter Contour Levels
  5. When the script is complete, make a few style adjustments to the new (empty looking) Frame that was created:
    •  Switch the Plot Type to 2D Cartesian
    • Go to Plot > Axis and select the Y-Axis page. Change the axis Dependency to Independent and toggle on Use Log Axes.
    • Adjust the Y-Min to 1 and the Y-Max to 1e+6
    • On the X-axis page, adjust the X-Min to 0.0001 and the X-Max to 0.001
    • Enable the Mesh and Shade layers, changing the Shade color to Red.
  6. Advance to a solution time >= 10.
  7. Move the newly created Frame so you can see the histogram and the 3D plot simultaneously.
  8. Save the layout – this will prompt you to save a new data file which should be named something like ‘Histogram_of_ScalarConcentration.plt’.

Plotting line data (CSV)

To load the line data we’re going to use Tecplot 360’s ‘General Text Loader’. This data loader is intended to load text files and allow you to specify the format. In the case of the M-Star files, we have tab-delimited text files, which work well with this loader.

  1. Add another empty frame to the layout using the Add Frame tool
  2. Use File > Load Data and select out/Stats/GlobalVariables.txt
  3. Select General Text Loader
    Choose Loader
  4. Identify the variables to load by doing the following:
    • Click Variables…
    • Change Delimiter to Tab
    • Click Select Variables to Load…
    • Confirm the set of variables and click OK on the Variables to load dialog
    • Click OK on the Variable Import Instructions dialog
      Variables to Load
  5. Identify the data to load by doing the following:
    • Click the Data… button
    • Set Start Identification to First All Numeric Line
    • Set End Identification to End of File
    • Click OK on the Data Import Instructions dialog
      Data Import Instructions
  6. Finally, click OK on the General Text Loader dialog

This should result in a plot with Time on the X-axis and gv on the Y-axis.

Plot with Time on X-Axis

To add the Power Number data to the plot, we repeat the data loading steps with the MovingBody_Moving Body.txt file, ensuring to select Append data to all shared frames when prompted. And ensuring to Add All new variables via the Variable Load and Combine dialog.
Variable Load and Combine Add all

The new data are not automatically added to the plot, so we must create a new Line Map by pressing the Create Map… button on the Mapping Style dialog and using the following settings.  Note that both sets of data loaded are named ‘Zone 1’.  Ensure that you select the second one, which contains the Power Number data.
Create Mappings

Since gv and Power Number have very different magnitudes, we’ll move gv to use the Y2 axis via the Which Y-Axis column in the Mapping Style dialog.
Mapping Style

Finally perform a View>Data Fit (or use Ctrl+F) to fit the data to the plot.  You should now have a line plot that looks like this:
New Plot

Linking the Frames in Time

As a final step we want all of these frames to be synchronized as we animate through time.  Linking frames in time can be done via the Frame>Frame Linking… dialog.  Toggle on Solution time and then click Apply Settings to All Frames of this group, which will activate this for the other two frames.
Set Links for Active Frame

Now, when you animate time, all three frames will be synchronized in time.  The line plot has Time on the X-axis, so the data doesn’t move.  To see where we are in time with the line plot, we can activate a ‘timing marker’.  This is performed by executing a Tecplot macro script to turn on the timing marker.

Click on the line plot to ensure it’s active and go to Scripting > Play Macro/Script, and select the  ‘show_markergridline.mcr’ file.  You should now see a marker line on the line plot and by arranging the frames you will finally have a layout that looks like this:
Final Visual

Conclusion

This article has shown how to use a wide variety of capabilities available in Tecplot 360 such as:

  • Loading and appending data
  • Use of multiple frames and datasets
  • Linking frames to create dynamic animations
  • Data analysis using PyTecplot
  • Running Tecplot 360 macros

Knowing this spectrum of capabilities will set you of for success in using Tecplot 360 in the future.