Simple Case

Simple example that demonstrates how to use the Pre API. Outputs an msb file that you can open and run in M-Star.


import mstar

mstar.Initialize()

model = mstar.Load()

staticBody = model.AddComponent("Static")
tankGeo = staticBody.AddGeometry("Cylindrical Tank")
tankGeo.Get("Diameter").Value = 0.5
tankGeo.Get("Length").Value = 0.5
tankGeo.Get("End1").Value = "Flat"
tankGeo.Get("Baffle Width").Value = 0.05	

simParams = model.GetSimParams()
movingBody = model.AddComponent("Moving")
globalVar = model.AddComponent("GlobalVariable")
miscScalar = model.AddComponent("MiscibleScalar")

impellerGeo = movingBody.AddGeometry("Rushton")
miscScalarGeo = miscScalar.AddGeometry("Cylinder")

simParams.Get("Run Time").Value = 180.0
impellerGeo.Get("Diameter").Value = 0.15

miscScalar.SetName("dye")
miscScalar.Get("Injection Time Span").Value = "Impulse"
miscScalar.Get("Injection Impulse Time").Value = 10.0
miscScalar.Get("Child Geometry Value").Value = "1.0"

miscScalarGeo.Get("Diameter").Value = 0.01
miscScalarGeo.Get("Length").Value = 0.01
miscScalarGeo.SetLocation(0.15, 0.45, 0.0)

movingBody.Translate(0, 0.25, 0)
movingBody.Get("Rotation Speed UDF").Value = "70.0"

globalVar.SetName("blendTime")
globalVar.Get("Data Source").Value = "Fluid"
globalVar.Get("Reduction").Value = "RelStdDev"
globalVar.Get("Code").Value = "value=dye;"

model.Save("simplecase.msb")