SystemModelSimulate[model]
simulates model according to experiment settings.
SystemModelSimulate[model,tmax]
simulates from 0 to tmax.
SystemModelSimulate[model,{tmin,tmax}]
simulates from tmin to tmax.
SystemModelSimulate[model,vars,{tmin,tmax}]
stores only simulation data for the variables vars.
SystemModelSimulate
SystemModelSimulate[model]
simulates model according to experiment settings.
SystemModelSimulate[model,tmax]
simulates from 0 to tmax.
SystemModelSimulate[model,{tmin,tmax}]
simulates from tmin to tmax.
SystemModelSimulate[model,vars,{tmin,tmax}]
stores only simulation data for the variables vars.
Details and Options
- The model can have the following forms:
-
SystemModel[…] general system model StateSpaceModel[…] state-space model TransferFunctionModel[…] transfer function model AffineStateSpaceModel[…] affine state-space model NonlinearStateSpaceModel[…] nonlinear state-space model DiscreteInputOutputModel[…] discrete input-output model SystemModelSurrogate[…] surrogate model - SystemModelSimulate returns a SystemModelSimulationData object.
- The stored simulation variables vars can have the following values:
-
Automatic automatically choose what to store {v1,v2,…} store only variables vi All store all variables - SystemModelSimulate[…,spec] uses Association spec for initial values, parameters and inputs:
-
"ParameterValues" {p1val1,…} parameter pi has value vali "InitialValues" {v1val1,…} variable vi has initial value vali "Inputs" {in1fun1,…} input ini has value funi[t] at time t - Setting "ParameterValues" or "InitialValues" to {pi->{c1,c2,…},…} runs simulations in parallel, with pi taking values cj.
- "InitialValues" corresponds to the start property in the Modelica model.
- The following options can be given:
-
InterpolationOrder Automatic continuity degree of output between events Method Automatic what simulation method to use ProgressReporting $ProgressReporting control display of progress - The option Method is supported when model is a SystemModel.
- Method settings take the form Method->"method" or Method{"method","sub1"->val1,…}.
- The following adaptive step methods can be used:
-
"DASSL" DASSL DAE solver "CVODES" CVODES ODE solver - Suboptions for adaptive-step methods include:
-
"InterpolationPoints" Automatic number of interpolation points "Tolerance" 10-6 tolerance for adaptive step size - The following fixed-step methods can be used:
-
"Euler" explicit Euler's method of order 1 "Heun" Heun's method of order 2 "RungeKutta" explicit Runge–Kutta method of order 4 - Suboptions for fixed-step methods include:
-
"StepSize" 10-3 fixed step size - With Method->{"NDSolve",sub1->val1,…}, NDSolve is used as the solver. Method options subi are passed to NDSolve.
Examples
open all close allBasic Examples (3)
Simulate a model with the time interval of simulation settings from the model:
sim = SystemModelSimulate[[image]]SystemModelPlot[sim, {"y", "z"}]Do a parameter sweep over a voltage offset:
sim = SystemModelSimulate[[image], 1, <|"ParameterValues" -> {"sineVoltage1.offset" -> Range[5]}|>];Plot the voltage for all simulations:
SystemModelPlot[sim, {"sineVoltage1.v"}]Use the diagram representation of a model as input:
SystemModel["DocumentationExamples.Simulation.WeakAxis"]Copy and paste the output above:
SystemModelSimulate[\!\(\*GraphicsBox[«8»]\)]SystemModelSimulate["DocumentationExamples.Simulation.WeakAxis"]Scope (24)
Models (6)
Simulate one of the included example models from the thermal domain:
model = RandomChoice[SystemModelExamples["Models", "Modelica.Thermal.FluidHeatFlow.*"]]SystemModelSimulate[model]Simulate a NonlinearStateSpaceModel and plot simulation results:
sim = SystemModelSimulate[NonlinearStateSpaceModel[{{Cos[x] + 4*Sin[x/2]},
{x + Sin[x]}}, {x}, {}, {Automatic}, Automatic,
SamplingPeriod -> None]]SystemModelPlot[sim, All]Simulate a TransferFunctionModel with a UnitStep as input:
sim = SystemModelSimulate[TransferFunctionModel[{{{2*(1 - s)}}, 2*(1 + s/2 + s^2)},
s], <|"Inputs" -> {1 -> UnitStep}|>]SystemModelPlot[sim, All, PlotRange -> All]Do a parameter sweep in an AffineStateSpaceModel:
sims = SystemModelSimulate[AffineStateSpaceModel[{{Cos[x2], (-a)*x2 +
Cos[x1^2]}, {{0}, {1}}, {x2}, {{0}}},
{x1, x2}, Automatic, {Automatic}, Automatic, SamplingPeriod -> None], <|"ParameterValues" -> {a -> {0.1, 0.2}}|>]SystemModelPlot[sims, {x2}]Simulate a DiscreteInputOutputModel:
diom = DiscreteInputOutputModel[{u[0] + y[-1] + y[-2], u[1] + u[0] + u[-1]}, {{u, {-2, -1, 1}}}, {{y, {-1, -1, -1}}}]sim = SystemModelSimulate[diom, <|"Inputs" -> {1 -> Range[-20, 20]}|>]SystemModelPlot[sim, All]Simulate a SystemModelSurrogate:
surrogate = SystemModelSurrogateTrain[\!\(\*GraphicsBox[«8»]\), <|"Outputs" -> "Inertia2.w", "ParameterValues" -> {"Resistor1.R" -> CenteredInterval[0.5, 0.1]}|>]sim = SystemModelSimulate[surrogate, <|"ParameterValues" -> {"Resistor1.R" -> 0.45}|>]SystemModelPlot[sim, "Inertia2.w"]Simulation Time (4)
Simulate with settings from the model:
sim = SystemModelSimulate[[image]]sim["SimulationInterval"]sim = SystemModelSimulate[[image], 5]sim["SimulationInterval"]Simulate for an explicit time interval:
sim = SystemModelSimulate[[image], {2, 10}]sim["SimulationInterval"]Use a Quantity to specify the time interval:
sim = SystemModelSimulate[[image], {0, Quantity[2500, "Microseconds"]}]sim["SimulationInterval"]Variables, Parameters and Inputs (8)
Initial values for variables can be set using "InitialValues":
sim = SystemModelSimulate[[image], <|"InitialValues" -> {"y" -> 5}|>]sim[{"y"}, 0]Parameter values can be set using "ParameterValues":
sim = SystemModelSimulate[[image], <|"ParameterValues" -> {"a" -> 5}|>]sim[{"a"}]Simulate a model that adds two inputs together:
sim = SystemModelSimulate[[image], {0, 10}, <|"Inputs" -> {"u1" -> Sin, "u2" -> Cos}|>];Plot the inputs and the output:
SystemModelPlot[sim, {"u1", "u2", "y"}]Simulate for different initial values for the variable x:
sim = SystemModelSimulate[[image], <|"InitialValues" -> {"x" -> Range[5]}|>];Plot the variable x from all simulations:
SystemModelPlot[sim, {"x"}]Simulate a model with default parameters:
sim1 = SystemModelSimulate[[image], 1];Set a parameter in the simulation:
sim2 = SystemModelSimulate[[image], 1, <|"ParameterValues" -> {"sineVoltage1.offset" -> 5}|>];Compare the variable
between the simulations:
SystemModelPlot[{sim1, sim2}, {"capacitor1.v"'}]Do a parameter sweep over a voltage offset:
sim = SystemModelSimulate[[image], 1, <|"ParameterValues" -> {"sineVoltage1.offset" -> Range[5]}|>];Plot the voltage for all simulations:
SystemModelPlot[sim, {"sineVoltage1.v"}]Setting ranges for two parameters simulates once for each position in the ranges:
sims = SystemModelSimulate[[image], 1, <|"ParameterValues" -> {"a" -> {1, 2}, "f" -> {3, 4}}|>];Map[SystemModelPlot[#, {"y"}, PlotLabel -> {"a", "f"} -> #[{"a", "f"}]]&, sims]Simulate a model with a TimeSeries as input:
ts = TimeSeries[{2, 2, 1, 6, 5, 7, 4, 4}, {{0, 1, 2, 5, 7, 7.5, 9, 10}}];sim = SystemModelSimulate[[image], 10, <|"Inputs" -> {"u" -> ts}|>];Plot the input and the output:
SystemModelPlot[sim, {"u", "y"}]Simulation Results (6)
Simulate a model and plot the variables x1 and x2:
sim = SystemModelSimulate[[image]];SystemModelPlot[sim, {"x1", "x2"}]sim = SystemModelSimulate[[image], 10];Get simulation results for the variables x and x':
{xvar, xvarprime} = sim[{"x", "x"'}, t]Plot the variables using the Plot function:
Plot[{xvar, xvarprime}, {t, 0, 10}]Simulate a model and find the maximum of a variable:
sim = SystemModelSimulate[[image]];Get the value of the variable angle1v:
angle1v = sim[{"angle1v"}]//First;Find the maximum value of the angle:
NMaximize[angle1v[t], t]Run a simulation and plot in a single call:
SystemModelPlot[[image], {"x1", "x4"}]Specify arguments to SystemModelSimulate:
SystemModelPlot[[image], {"x1", "x4"}, 5]Store only selected variables:
sim = SystemModelSimulate[[image], {"x1", "x2", "x3"}]Only the given variables are saved:
sim["VariableNames"]Store only selected variables and simulate with a given simulation interval:
sim = SystemModelSimulate[[image], {"x1", "x2", "x3"}, {2, 5}]SystemModelPlot[sim, sim["VariableNames"]]Generalizations & Extensions (1)
Debug messages are collected in the message group "WSMDebug":
Hold["WSMDebug"] /. $MessageGroupsTurn on debug messages for initialization:
On[SystemModelSimulate::dinit]SystemModelSimulate[[image], {0, 1}]Turn off all debug messages for "WSMDebug":
Off["WSMDebug"]Options (10)
InterpolationOrder (1)
Simulate with interpolation orders 1 and 3, and 3 interpolation points:
{sim1, sim2} = Table[SystemModelSimulate[[image], 5, Method -> {Automatic, "InterpolationPoints" -> 3}, InterpolationOrder -> intOrder], {intOrder, {1, 3}}];SystemModelPlot[{sim1, sim2}, {"x"}]Method (8)
sim = SystemModelSimulate[[image], 20, Method -> {"Heun", "StepSize" -> 0.1}]SystemModelPlot[sim, {"capacitor1.p.v"}]sim = SystemModelSimulate[[image], 1220, Method -> {"DASSL", "InterpolationPoints" -> 3000}]Show the result in a ParametricPlot:
ParametricPlot[Evaluate[sim[{"x", "y"}, t]], {t, 0, 1220}, ColorFunction -> (ColorData[{"SunsetColors", "Reverse"}][#3]&), PlotPoints -> 400]For stiff problems, use an adaptive-step method:
{adaptive, fixed} = SystemModelSimulate[[image], 3, <|"ParameterValues" -> {"lambda" -> 45}|>, Method -> #]& /@ {{"DASSL"}, {"Euler", "StepSize" -> 0.01}};Plot[Evaluate[#[[1]][{"x", "y"}, t]], {t, 1.6, 1.8}, PlotRange -> {-10, 5}, PlotLabel -> #[[2]]]& /@ {{adaptive, "Adaptive step"}, {fixed, "Fixed step"}}Simulating with too few interpolation points can give inexact plots:
sim1 = SystemModelSimulate[[image], 5, Method -> {"DASSL", "InterpolationPoints" -> 3}];SystemModelPlot[sim1, {"x"}]Increasing the number of points gives a better result:
sim2 = SystemModelSimulate[[image], 5, Method -> {"DASSL", "InterpolationPoints" -> 100}];SystemModelPlot[sim2, {"x"}]The default step size for a fixed-step solver might be smaller than needed:
AbsoluteTiming[sim1 = SystemModelSimulate[[image], 50, Method -> "Heun"]]Use a larger step size to speed up computation:
AbsoluteTiming[sim2 = SystemModelSimulate[[image], 50, Method -> {"Heun", "StepSize" -> 0.01}]]SystemModelPlot[{sim1, sim2}, {"x"}]Let an adaptive solver choose the solver steps:
SystemModelSimulate[[image], {0, 2}, Method -> {"CVODES", "InterpolationPoints" -> "AllSolverSteps"}]Use NDSolve for simulating a model:
sim = SystemModelSimulate[[image], 2, Method -> "NDSolve"]The result is a SystemModelSimulationData object containing the simulation results:
sim[{"x", "x"'}]Pass options to NDSolve:
sim = SystemModelSimulate[[image], 4, Method -> {"NDSolve", MaxStepSize -> 3, StartingStepSize -> 3, AccuracyGoal -> 0.001, PrecisionGoal -> 0.001}]The accuracy is reduced because of the options:
SystemModelPlot[sim, {"x", "x"'}]ProgressReporting (1)
Control progress reporting with ProgressReporting:
SystemModelSimulate[[image], ProgressReporting -> False]Applications (11)
Calculate the overshoot of the height in a tank system:
sim = SystemModelSimulate[[image], 150]height = sim[{"tank.h"}][[1]];max = FindMaximum[{height[t], 0 < t < 150}, {t, 20}][[1]]Get the value of the step sent in to the tank:
step = sim[{"tank.qIn"}, 0][[1]];overshoot = (max - step) / stepPlot[Evaluate@height[t], {t, 0, 150}, GridLines -> {{}, {height[150]}}, PlotRange -> All, Mesh -> {{height[150]}}, MeshShading -> {Automatic, Red}, MeshFunctions -> {#2&}]Calculate the rise time for the height in a tank system:
sim = SystemModelSimulate[[image], 150];height = sim[{"tank.h"}][[1]];Get the required values at 10% and 90% by looking at the steady-state value for height:
{p10, p90} = height[150]{0.1, 0.9}Find the times at which the signal reaches these values:
{t10, t90} = FindMinimum[{t, height[t] > # && t > 0}, t][[1]]& /@ {p10, p90}t90 - t10Plot lines at the final value, and when the signal reaches 10% and 90% of the final value:
Plot[Evaluate@height[t], {t, 0, 100}, GridLines -> {{t10, t90}, {height[150]}}, PlotRange -> All, Mesh -> {{t10, t90}}, MeshShading -> {Automatic, Red, Automatic}]Calculate the settling time for the height in a tank system:
sim = SystemModelSimulate[[image], {0, 150}];height = sim[{"tank.h"}][[1]];Find 5% bounds on the final value:
{p95, p105} = height[150]{0.95, 1.05}Find the time at which the signal stays within these values:
ts = Max[First@FindMaximum[{t, height[t] > p105 && 0 ≤ t ≤ 150}, {t, Cases[Range[0, 150, 5], t_ /; height[t] > p105][[-1]]}],
First@FindMaximum[{t, height[t] < p95 && 0 ≤ t ≤ 150}, {t, Cases[Range[0, 150, 5], t_ /; height[t] < p95][[-1]]}]]Plot the bounds and the found settling time:
Plot[Evaluate@height[t], {t, 0, 150}, GridLines -> {{ts}, {p95, p105}}, PlotRange -> All, Mesh -> {{ts}}, MeshShading -> {Automatic, Red}]Change parameter values interactively:
simf[v_] := simf[v] = SystemModelSimulate[[image], 5, <|"ParameterValues" -> {"conduction.G" -> v}|>][{"Tsensor1.T", "Tsensor2.T"}, t];Manipulate[
Plot[Evaluate[simf[v]], {t, 0, 5}, PlotRange -> {0, 100}], {v, 6, 10}, SaveDefinitions -> True, SynchronousUpdating -> False]Simulate a rolling wheel for different starting inertias along the wheel axis:
sims = SystemModelSimulate[[image], 5, <|"ParameterValues" -> {"wheel1.I_axis" -> Range[0.05, 0.08, 0.004]}|>];Fetch the trajectories for the wheel:
vars = #[{"wheel1.x", "wheel1.y"}, t]& /@ sims;ParametricPlot[Evaluate@vars, {t, 0, 5}, Frame -> True, Axes -> False]Analyze resonance peaks when varying a spring constant:
sims = SystemModelSimulate[\!\(\*GraphicsBox[«8»]\), 200, <|"Inputs" -> {"u" -> Function[t, UnitStep[t] - UnitStep[t - 2]]}, "ParameterValues" -> {"spring1.c" -> Range[0.1, 1.5, 0.4]}|>];idata = Table[Abs@Fourier@Table[UnitStep[t] - UnitStep[t - 2], {t, 0, 200, 0.25}], {sim, sims}];
odata = Table[Abs@Fourier@Table[Evaluate[sim[{"inertia3.w"}, t][[1]]], {t, 0, 200, 0.25}], {sim, sims}];ListLogLinearPlot[odata[[All, 1 ;; 200]] / idata[[All, 1 ;; 200]], Joined -> True, DataRange -> {0, 2Pi}, PlotRange -> {{0.1, 5}, {0, 50}}]Calibrate parameters in a model by comparing to measurement data:
data = Import["ExampleData/inertiaTestData.dat"];Set up a criteria function for model fitting:
model = \!\(\*GraphicsBox[«8»]\);criteriaFun[pv : {Verbatim[Rule][_ ? StringQ, _ ? NumericQ]..}, var_ ? StringQ] :=
Module[{f, tmax = 40},
f = SystemModelSimulate[model, tmax, <|"ParameterValues" -> pv|>][{var}][[1]];
Norm[Table[data[[i, 2]] - f[data[[i, 1]]], {i, Length[data]}]]^2
]Fit parameters to the test data:
fittedpars = FindMinimum[criteriaFun[{"Resistor1.R" -> p, "SpringDamper1.d" -> q}, "Inertia2.w"], {{p, 0.1}, {q, 0.25}}, StepMonitor :> PrintTemporary[{p, q}]]Simulate with the fitted parameters:
sim = SystemModelSimulate[model, {0, 40}, <|"ParameterValues" -> ({"Resistor1.R" -> p, "SpringDamper1.d" -> q} /. fittedpars[[2]])|>];Show the test data and the calibrated model together:
Show[SystemModelPlot[sim, {"Inertia2.w"}, PlotStyle -> Orange], ListPlot[data]]Filter sampled data from a Tinker Forge Weather Station:
tslux = TemporalData[TimeSeries, {{{Quantity[104.7, "Lux"], Quantity[101.30000000000001, "Lux"],
Quantity[194.9, "Lux"], Quantity[200.8, "Lux"], Quantity[169., "Lux"], Quantity[158.3, "Lux"],
Quantity[174.3, "Lux"], Quantity[169.60000000000002, " ... 3.6042180438464176`17.309385928427066*^9, 3.6042180439474277`17.30938592843924*^9}}}, 1,
{"Discrete", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1,
MetaInformation -> {"Illuminance" -> TemporalData`Self["PathComponent", 1]}}}, True, 10.];Time shift and retrieve the magnitude of the data:
ts = TimeSeriesMap[QuantityMagnitude, TimeSeriesShift[tslux, {{0}}]];Run the time series through a lowpass filter:
filterParameters = {"C1" -> 0.03, "C2" -> 0.115};sim = SystemModelSimulate[[image], {0, ts["LastTime"]}, <|"Inputs" -> {"Vi" -> ts}, "ParameterValues" -> filterParameters|>];SystemModelPlot[sim, {"Vi", "Vo"}]Simulate a lowpass filter with sound as input:
audioIn = Function[t, (2 + Cos[40t])Sin[2000t]];Simulate with given input sound:
filterParameters = {"C1" -> 0.9, "C2" -> 0.01};
sim = SystemModelSimulate[[image], 2, <|"Inputs" -> {"Vi" -> audioIn}, "ParameterValues" -> filterParameters|>, Method -> {"DASSL", "InterpolationPoints" -> 2 * 44100}]Retrieve the audio for input and output:
AudioNormalize /@ sim["Audio", {"Vi", "Vo"}]sim = SystemModelSimulate[[image], 20];Fetch trajectories from the result:
traj = Table[sim[{"x" <> ToString[i], "y" <> ToString[i]}, ], {i, 5}];Animate[Graphics[Table[{Disk[traj[[i]], 0.5], Line[{{5 - i, 5}, traj[[i]]}]}, {i, 5}] /. -> t, PlotRange -> {{-5, 9}, {-1, 5}}], {t, 0, 20}, SaveDefinitions -> True, AnimationRunning -> False]Visualize simulated data with a WaveletScalogram:
sim = SystemModelSimulate[\!\(\*GraphicsBox[«8»]\), {0, 10}];Pick out the data you are interested in:
data = Table[Evaluate[sim[{"chainLink4.frame_b.r_0[1]"}][[1]][t]], {t, 0, 10, 0.01}];Compute the wavelet transform:
cwd = ContinuousWaveletTransform[data];Plot the wavelet vector coefficients:
WaveletScalogram[cwd]Properties & Relations (3)
The output from SystemModelSimulate is a SystemModelSimulationData object:
sim = SystemModelSimulate[[image], 10]Use properties to get variable trajectories:
{x, xp} = sim[{"x", "x"'}]Use SystemModelSimulateSensitivity to also get sensitivities to parameters:
sim = SystemModelSimulateSensitivity[[image], 10, {"sineVoltage1.f"}];Plot the capacitor's voltage sensitivity to the frequency of "sineVoltage1":
sim["SensitivityNames"]SystemModelPlot[sim, {{"capacitor1.v", "sineVoltage1.f"}}]Use SystemModelParametricSimulate for a function that can be evaluated for different values:
sols = SystemModelParametricSimulate[[image], "capacitor1.v", {"sineVoltage1.f"}]Compute solutions for different values of the frequency parameter:
fns = Table[sols[hz], {hz, 1, 5}]Table[Plot[fn[t], {t, 0, 10}], {fn, fns}]Neat Examples (1)
Simulate a Van der Pol model and show in a parametric plot:
sim = SystemModelSimulate[[image], {1.67, 10}, <|"ParameterValues" -> {"lambda" -> Range[0.1, 5, 0.1]}|>];Show@@(ParametricPlot[Evaluate[#[{"x", "y"}, t]], {t, 1.67, 10}, PlotRange -> All]& /@ sim)Tech Notes
Related Links
Text
Wolfram Research (2018), SystemModelSimulate, Wolfram Language function, https://reference.wolfram.com/language/ref/SystemModelSimulate.html (updated 2022).
CMS
Wolfram Language. 2018. "SystemModelSimulate." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/SystemModelSimulate.html.
APA
Wolfram Language. (2018). SystemModelSimulate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SystemModelSimulate.html
BibTeX
@misc{reference.wolfram_2026_systemmodelsimulate, author="Wolfram Research", title="{SystemModelSimulate}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/SystemModelSimulate.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_systemmodelsimulate, organization={Wolfram Research}, title={SystemModelSimulate}, year={2022}, url={https://reference.wolfram.com/language/ref/SystemModelSimulate.html}, note=[Accessed: 13-June-2026]}