Programmatically Create Models

Systems Models

Create a SystemModeler model from Mathematica systems models:

WSMCreateModel["TfSISO",(TransferFunctionModel[((1+2 s)/(1+s)), ])]

WSMCreateModel["SsmPar2",(StateSpaceModel[a, 0, 1, 0, 0, b, 0, 1, 1, 1, 0, 0, ])]

Equations

Create a SystemModeler model from equations in Mathematica:

WSMCreateModel["BouncingBall",{a[t]==-9.82,v'[t]==a[t],h'[t]==v[t],WhenEvent[h[t]≤0,v[t]->-0.95v[t]],h[0]==1},t]

sim=WSMSimulate["BouncingBall",10];

WSMPlot[sim,"h"]

Connecting Components

Connect existing SystemModeler components to create a model:

comp={"a"∈"Abs","sine"∈"Sine"};

conn={"sine.y"->"a.u"};

mmodel=WSMConnectComponents["AbsSine",comp,conn]

sim=WSMSimulate[mmodel,2];

WSMPlot[sim,{"a.y"}]