Scripted Pre-processing


This capability is currently under development as of July 2021. Supported in M-Star versions 3.2.14+


M-Star supports pre-processing via a python interface. The current supported actions are summarized as follows –

  • Change property values

  • Export solver case files

  • Load/save *.msb files


M-Star python is compatible with Miniconda3 with Python 3.9, installer version 4.9.2.

Follow the Miniconda installation instructions –

Start a new command prompt with the conda environment. For more information on how to get started, see the conda documentation –


The below example is comprised of a python script and a bash script that sets up the environment and executes the script. To run the example, copy this code into new files and create an example msb file called “simulation.msb” using the built-in agitated test example case.

import sys
import os
import mstar


# checkout license

# load msb file into the variable 'm'
m = mstar.load(r"simulation.msb")

# Get the fluid model
fm = m.get("Single Phase Model")

# Show the density
print("Density = ", fm.get("Density"))

# change the density
print("-- Setting density")
fm.set("Density", 1200.0)
print("Density = ", fm.get("Density"))

# Save the msb document as a new file
caseDir = r"python-test"

if not os.path.isdir(caseDir):

fn2 = os.path.join(caseDir, r"saved_by_python.msb")
print ("-- Saving document;", fn2)

# Export the solver case files
print ("-- Exporting case: ", caseDir)

# Source the M-Star environment
source ~/3.2.14/

# Setup the M-Star license
export mstar_LICENSE=mymstar.lic

# Add the lib directory to your python module search path
export PYTHONPATH=~/3.2.14/lib

# run the script