SystemModelSimulateSensitivity[model,{p1,p2,…}]
simulates model and sensitivities to parameters pi following experiment settings.
SystemModelSimulateSensitivity[model,tmax,{p1,p2,…}]
simulates from 0 to tmax.
SystemModelSimulateSensitivity[model,{tmin,tmax},{p1,p2,…}]
simulates from tmin to tmax.
SystemModelSimulateSensitivity[model,vars,{tmin,tmax},{p1,p2,…}]
stores only simulation data for the variables vars.
SystemModelSimulateSensitivity
SystemModelSimulateSensitivity[model,{p1,p2,…}]
simulates model and sensitivities to parameters pi following experiment settings.
SystemModelSimulateSensitivity[model,tmax,{p1,p2,…}]
simulates from 0 to tmax.
SystemModelSimulateSensitivity[model,{tmin,tmax},{p1,p2,…}]
simulates from tmin to tmax.
SystemModelSimulateSensitivity[model,vars,{tmin,tmax},{p1,p2,…}]
stores only simulation data for the variables vars.
Details and Options
- SystemModelSimulateSensitivity is used to estimate the variations in simulation results when changing parameter values in system models.
- 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 - SystemModelSimulateSensitivity returns a SystemModelSimulationData object.
- SystemModelSimulateSensitivity generates solutions
for all real-valued variables
, as well as derivatives
,
, …, for
. - Sensitivities can be listed in a SystemModelSimulationData object sd with sd["SensitivityNames"].
- 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 - SystemModelSimulateSensitivity[…,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 setting Automatic normally means that the setting is taken from model or its experiment setting.
- With Method{"Sensitivity""WSM"} sensitivities are computed for state variables using the CVODES solver for a SystemModel model.
- Other Method simulation suboptions are as indicated in SystemModelSimulate.
Examples
open all close allBasic Examples (3)
Study sensitivity of a parameter over the time interval in model experiment settings:
sim = SystemModelSimulateSensitivity[[image], {"a"}]Extract sensitivity names and plot them:
sim["SensitivityNames"]SystemModelPlot[sim, {{"y", "a"}, {"z", "a"}}]Show the sensitivity of a signal to relative changes in a parameter:
sim = SystemModelSimulateSensitivity[[image], {"y", "z"}, 5, {"a"}]Plot bounds for y and z when varying a by 10%:
SystemModelPlot[sim, {{"y", "a", 0.1}, {"z", "a", 0.1}}]Use the diagram representation of a model as input:
SystemModel["IntroductoryExamples.ComponentBased.ElectricCircuit"]Copy and paste the output above:
sim = SystemModelSimulateSensitivity[[image], {"capacitor1.v"}, 5, {"sineVoltage1.f"}]Scope (17)
Models (3)
Compute variables and sensitivities when simulating a NonlinearStateSpaceModel:
sim = SystemModelSimulateSensitivity[NonlinearStateSpaceModel[{{Cos[x] + 4*a*Sin[x/2]},
{x + Sin[x]}}, {x}, {}, {Automatic}, Automatic,
SamplingPeriod -> None], 10, {a}, <|"ParameterValues" -> {a -> 1}|>]Extract sensitivity names and plot them:
sim["SensitivityNames"]SystemModelPlot[sim, {{x, a}, {Subscript[, 1], a}}, PlotRange -> All]Plot bounds for a state when varying a by 40%:
SystemModelPlot[sim, {{x, a, 0.4}}, PlotRange -> All]Compute sensitivities in a parameter sweep for an AffineStateSpaceModel:
sims = SystemModelSimulateSensitivity[AffineStateSpaceModel[{{Cos[x2], (-1 - a)*x2 +
Cos[x1^2]}, {{0}, {1}}, {x2}, {{0}}},
{x1, x2}, Automatic, {Automatic}, Automatic, SamplingPeriod -> None], 5, {a}, <|"ParameterValues" -> {a -> {1, 10}}|>]Plot bounds for a state when varying a by 50%:
SystemModelPlot[sims, {{x2, a, 0.5}}]Compute sensitivities for a DiscreteInputOutputModel:
diom = DiscreteInputOutputModel[{u[0] + y[-1] + a y[-2], u[1] + u[0] + u[-1]}, {{u, {-2, -1, 1}}}, {{y, {-1, -1, -1}}}]sim = SystemModelSimulateSensitivity[diom, {a}, <|"Inputs" -> {1 -> Range[-20, 20]}, "ParameterValues" -> {a -> 1}|>]Plot bounds for the output when varying a by 5%:
SystemModelPlot[sim, {{y, a, 0.05}}]Simulation Time (3)
Simulate with settings from the model:
sim = SystemModelSimulateSensitivity[[image], {"a"}]sim["SimulationInterval"]sim = SystemModelSimulateSensitivity[[image], 5, {"a"}]sim["SimulationInterval"]Simulate for an explicit time interval:
sim = SystemModelSimulateSensitivity[[image], {2, 10}, {"a"}]sim["SimulationInterval"]Sensitivity Results (6)
Study the sensitivity of one parameter:
sim = SystemModelSimulateSensitivity[[image], 50, {"a"}]sim["SensitivityNames"]SystemModelPlot[sim, {{"y", "a"}}]Simulate with sensitivity to parameter a:
sim = SystemModelSimulateSensitivity[[image], 5, {"a"}];sim["SensitivityNames"]Get the sensitivity y has to changes in a:
{ySensA} = sim[{{"y", "a"}}]Study the sensitivities from one parameter:
sim = SystemModelSimulateSensitivity[[image], 5, {"sineVoltage1.f"}];sim["SensitivityNames"]//ShortPlot one of the sensitivities:
SystemModelPlot[sim, {{"capacitor1.v", "sineVoltage1.f"}}]Show the sensitivity of a signal to a parameter a:
sim = SystemModelSimulateSensitivity[[image], 50, {"a"}]sim["SensitivityNames"]Get the sensitivity y has to changes in a, as well as the nominal trajectory for y:
{ySensA, y} = sim[{{"y", "a"}, "y"}, t]Plot y with original parameter a, and with parameter a increased by 0.05:
Plot[{Tooltip[y, "Nominal"], Tooltip[y + 0.05 ySensA, "Perturbed"]}, {t, 0, 50}]Show the sensitivity of a signal to relative changes in a parameter:
sim = SystemModelSimulateSensitivity[[image], 5, {"a"}];sim["SensitivityNames"]Get the sensitivity y and z have to changes in a, as well as nominal trajectories and value:
{ySensA, zSensA, y, z, a0} = sim[{{"y", "a"}, {"z", "a"}, "y", "z", "a"}, t];Plot bounds for y and z when varying a by 10% of the sensitivity:
{dY, dZ} = {a0 0.1ySensA, a0 0.1zSensA};Plot[{Tooltip[y, "y"], y + dY, y - dY, Tooltip[z, "z"], z + dZ, z - dZ}, {t, 0, 5}, Filling -> {2 -> {3}, 5 -> {6}}]Show the sensitivity of a signal to absolute changes in a parameter a:
sim = SystemModelSimulateSensitivity[[image], 50, {"a"}]Get the sensitivity y has to changes in a, as well as the trajectory for y:
{ySensA, y} = sim[{{"y", "a"}, "y"}, t];Compute the change in y when parameter a changes with absolute value 0.1:
dY = 0.1 ySensA;Plot the variation of y when parameter a varies by ±0.1:
Plot[{Tooltip[y, "y"], y + dY, y - dY}, {t, 0, 50}, Filling -> {2 -> {3}}]Variables, Parameters and Inputs (3)
Change the initial values of a simulation:
Subscript[sim, 1] = SystemModelSimulateSensitivity[[image], 50, {"a"}];Subscript[sim, 2] = SystemModelSimulateSensitivity[[image], 50, {"a"}, <|"InitialValues" -> {"y" -> 2.85}|>];Compare the changes in a plot:
SystemModelPlot[{Subscript[sim, 1], Subscript[sim, 2]}, {{"y", "a"}}]Change the parameter values of a simulation:
Subscript[sim, 1] = SystemModelSimulateSensitivity[[image], 50, {"a"}];Subscript[sim, 2] = SystemModelSimulateSensitivity[[image], 50, {"a"}, <|"ParameterValues" -> {"a" -> 2.95}|>];SystemModelPlot[{Subscript[sim, 1], Subscript[sim, 2]}, {{"y", "a"}}]Give an input function for a variable and study the sensitivity of the output to a gain parameter:
sim = SystemModelSimulateSensitivity[[image], 10, {"gain.k"}, <|"Inputs" -> {"u" -> Sin}|>]Plot the sensitivity of the output to the gain parameter:
SystemModelPlot[sim, {{"integrator.y", "gain.k", 0.1}}]Result Storage (2)
Store only selected variables:
sim = SystemModelSimulateSensitivity[[image], {"y", "a"}, {"a"}]Only the given variables and parameters are saved:
{sim["VariableNames"], sim["ParameterNames"]}Store only selected variables and simulate with a given simulation interval:
sim = SystemModelSimulateSensitivity[[image], {"TR", "lambda"}, {0, 50}, {"lambda"}]Plot bounds for TR when varying lambda by 20%:
SystemModelPlot[sim, {{"TR", "lambda", 0.2}}]Generalizations & Extensions (1)
Debug messages are collected in the message group "WSMDebug":
Hold["WSMDebug"] /. $MessageGroupsTurn on debug messages for initialization:
On[SystemModelSimulateSensitivity::dinit]SystemModelSimulateSensitivity["DocumentationExamples.Basic.OneParameter", {0, 1}, {"a"}, Method -> {"Sensitivity" -> "WSM"}]Turn off all debug messages for "WSMDebug":
Off["WSMDebug"]Options (4)
InterpolationOrder (1)
Simulate with interpolation orders 1 and 3, and 3 interpolation points:
{Subscript[sim, 1], Subscript[sim, 2]} = Table[SystemModelSimulateSensitivity[[image], 7, {"a"}, Method -> {Automatic, "InterpolationPoints" -> 3}, InterpolationOrder -> intOrder], {intOrder, {1, 3}}];Show the sensitivity variable:
SystemModelPlot[{Subscript[sim, 1], Subscript[sim, 2]}, {{"y", "a"}}]Method (2)
With Method{"Sensitivity""WSM"}, sensitivities are computed for state variables using the CVODES solver for a SystemModel:
simWSM = SystemModelSimulateSensitivity[[image], 5, {"a"}, Method -> {"Sensitivity" -> "WSM"}]simWSM["SensitivityNames"]Compute sensitivities for all real-valued variables with the default method:
sim = SystemModelSimulateSensitivity[[image], 5, {"a"}]sim["SensitivityNames"]Simulate a SystemModel and compute sensitivities with the number of interpolation points set by the model:
sim = SystemModelSimulateSensitivity[[image], 5, {"a"}];
SystemModelPlot[sim, {{"y", "a"}, {"z", "a"}, {Derivative[1]["z"], "a"}}]Simulate and compute sensitivities with a custom number of interpolation points:
sim = SystemModelSimulateSensitivity[[image], 5, {"a"}, Method -> {"InterpolationPoints" -> 5}];
SystemModelPlot[sim, {{"y", "a"}, {"z", "a"}, {Derivative[1]["z"], "a"}}]Simulate and compute sensitivities for state variables with a custom number of interpolation points:
simWSM = SystemModelSimulateSensitivity[[image], 5, {"a"}, Method -> {"Sensitivity" -> "WSM", "InterpolationPoints" -> 5}];
SystemModelPlot[simWSM, {{"y", "a"}, {"z", "a"}}]ProgressReporting (1)
Control progress reporting with ProgressReporting:
SystemModelSimulateSensitivity[[image], {"a"}, ProgressReporting -> False]Applications (5)
Study the sensitivity of a model:
sim = SystemModelSimulateSensitivity[[image], {"y"}, 40, {"a"}];{y, ysensa} = sim[{"y", {"y", "a"}}, t];Get the value of the parameter:
a0 = First[sim[{"a"}]]Find the peak deviation when varying the parameter:
{peakVal, {peakTime}} = NMaximize[{0.05 a0 ysensa, 0 < t < 40}, {t}]Show a 5% sensitivity bound and the peak deviation time:
Plot[Evaluate[{y, y + 0.05 a0 ysensa, y - 0.05 a0 ysensa}], {t, 0, 40}, Filling -> {2 -> {3}}, GridLines -> {{peakTime[[2]]}, None}]Find out which variable is most sensitive to a frequency parameter:
sim = SystemModelSimulateSensitivity[[image], {"integrator1.y", "integrator2.y", "integrator3.y"}, 1, {"sine.f"}];A 10% sensitivity bound shows that "integrator3.y" is most sensitive to the parameter:
SystemModelPlot[sim, Table[{v, "sine.f", 0.1}, {v, {"integrator1.y", "integrator2.y", "integrator3.y"}}]]sim = SystemModelSimulateSensitivity[[image], {"wheel1.x", "wheel1.y"}, 10, {"wheel1.radius", "wheel1.m"}]Select the position of the wheel and its sensitivities to different parameters:
{x, y, xsensrad, ysensrad, xsensmass, ysensmass} = sim[{"wheel1.x", "wheel1.y", {"wheel1.x", "wheel1.radius"}, {"wheel1.y", "wheel1.radius"}, {"wheel1.x", "wheel1.m"}, {"wheel1.y", "wheel1.m"}}, t];{r0, m0} = sim[{"wheel1.radius", "wheel1.m"}]Show the path of the wheel with 4% variation of the wheel radius and mass, respectively:
d = 0.04;
ParametricPlot[{{x, y}, {x + v d #[[1]], y + v d #[[2]]}}, {v, -1, 1}, {t, 0, 10}, PlotPoints -> 40, Mesh -> None, Axes -> None, PlotLabel -> #[[3]], FrameTicks -> {{Automatic, None}, {None, None}}]& /@ {{xsensrad r0, ysensrad r0, "Wheel radius"}, {xsensmass m0, ysensmass m0, "Wheel mass"}}Calibrate parameters in a model by comparing to measurement data:
model = \!\(\*GraphicsBox[«8»]\);data = Import["ExampleData/inertiaTestData.dat"];{p1, p2, var} = {"Resistor1.R", "SpringDamper1.d", "Inertia2.w"};Set up caching for simulation and use SystemModelSimulateSensitivity to get gradients:
g[p_ ? NumericQ, q_ ? NumericQ] := g[p, q] = Quiet[AssociationThread[{var, {var, p1}, {var, p2}}, SystemModelSimulateSensitivity[model, {var}, 40, {p1, p2}, <|"ParameterValues" -> {p1 -> p, p2 -> q}|>, ProgressReporting -> False][{var, {var, p1}, {var, p2}}]], {SystemModelSimulateSensitivity::gen}]Plot the result of the simulation for specific parameter values:
Plot[g[0.1, 0.25][var][t], {t, 0, 40}]Fit parameters to the measurement data without using gradients:
AbsoluteTiming[FindFit[data, g[p, q][var][t], {{p, 0.1}, {q, 0.25}}, t, Gradient -> "FiniteDifference"]]Fit using sensitivity information:
AbsoluteTiming[pars = FindFit[data, g[p, q][var][t], {{p, 0.1}, {q, 0.25}}, t, Gradient :> Comap[Lookup[g[p, q], {{var, p1}, {var, p2}}], t]]]Simulate with the fitted parameters:
sim = SystemModelSimulate[model, {0, 40}, <|"ParameterValues" -> ({p1 -> p, p2 -> q} /. pars)|>];Show the test data and the calibrated model together:
Show[SystemModelPlot[sim, {var}, PlotStyle -> Orange], ListPlot[data]]Plot a solution with its sensitivity bounds:
sim = SystemModelSimulateSensitivity[[image], 30, {"a"}]sim["SensitivityNames"]{y, ysensa} = sim[{"y", {"y", "a"} }, t];Get the nominal value of the parameter:
a0 = First[sim[{"a"}]]dY = 0.05 * a0 ysensa;Plot[Evaluate[{y, y + dY, y - dY}], {t, 0, 30}, Filling -> {2 -> {3}}]Simulate with a maximal variation of 5%:
simv = SystemModelSimulate[[image], 30, <|"ParameterValues" -> {"a" -> a0 Range[0.95, 1.05, 0.02]}|>];yV = Table[sd[{"y"}, t][[1]], {sd, simv}];Show that the trajectories are mostly contained in the approximated sensitivity bounds:
Plot[Evaluate[{y, y + dY, y - dY, yV}], {t, 0, 30}, Filling -> {2 -> {3}}]Properties & Relations (4)
Compare a sensitivity simulation with the sensitivity of the corresponding differential equation:
sim = SystemModelSimulateSensitivity[[image], 50, {"a"}];SystemModelPlot[sim, {"y", {"y", "a"}}]y = DSolve[{f'[t] + Sin[a]f[t] == 0, f[0] == b}, f[t], t][[1, 1, 2]];ySensA = D[y, a]Plot[Evaluate[{y, ySensA} /. {a -> 3, b -> 1}], {t, 0, 50}, PlotRange -> All]Plot bounds for a relative parameter change:
sim = SystemModelSimulateSensitivity[[image], 5, {"a"}];Get the sensitivity y has to changes in a, as well as y and the value for a:
{ySensA, y, a0} = sim[{{"y", "a"}, "y", "a"}, t];Plot bounds for y when varying a by 10% of the sensitivity:
dY = a0 0.1ySensA;Plot[{Tooltip[y, "y"], y + dY, y - dY}, {t, 0, 5}, Filling -> {2 -> {3}}, AxesLabel -> {"t", None}]Use SystemModelPlot instead:
SystemModelPlot[sim, {{"y", "a", 0.1}}]Sensitivities are valid for small changes in the parameter:
{par, var} = {"sineVoltage1.f", "capacitor1.v"};Get sensitivities to a parameter:
sim = SystemModelSimulateSensitivity[[image], {var}, 5, {par}];Simulate with
variation of the parameter:
{p0} = sim[{par}];sim2 = SystemModelSimulate[[image], {var}, 5, <|"ParameterValues" -> {par -> {0.9p0, 1.1p0}}|>];Comparing in a plot, a 10% variation gives trajectories outside computed bounds:
Show[SystemModelPlot[sim, {{var, par, 0.1}}, {2.5, 3.5}], SystemModelPlot[sim2, {var}]]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)
Show sensitivity bounds for the
and
axes in the Rabinovich–Fabrikant equations:
sim = SystemModelSimulateSensitivity[[image], {"x", "y", "z"}, 100, {"a", "g"}, <|"ParameterValues" -> {"a" -> 0.01, "g" -> 0.05}|>];{x, y, z, dx, dy, dz} = sim[{"x", "y", "z", {"x", "a"}, {"y", "a"}, {"z", "a"}}, t];d = 0.04;
ParametricPlot[{x + v d dx, y + v d dy}, {v, 0, 1}, {t, 0, 19}, PlotPoints -> 40, Axes -> None, ColorFunction -> ColorData["HypsometricTints"], Mesh -> False]Show the sensitivity bounds in 3D:
Graphics3D[Tube@@Transpose@Table[{{x, y, z}, 0.0005Norm[{dx, dy, dz}]}, {t, 10, 55, 0.05}], Axes -> True]Related Guides
Related Links
History
Text
Wolfram Research (2018), SystemModelSimulateSensitivity, Wolfram Language function, https://reference.wolfram.com/language/ref/SystemModelSimulateSensitivity.html.
CMS
Wolfram Language. 2018. "SystemModelSimulateSensitivity." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SystemModelSimulateSensitivity.html.
APA
Wolfram Language. (2018). SystemModelSimulateSensitivity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SystemModelSimulateSensitivity.html
BibTeX
@misc{reference.wolfram_2026_systemmodelsimulatesensitivity, author="Wolfram Research", title="{SystemModelSimulateSensitivity}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/SystemModelSimulateSensitivity.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_systemmodelsimulatesensitivity, organization={Wolfram Research}, title={SystemModelSimulateSensitivity}, year={2018}, url={https://reference.wolfram.com/language/ref/SystemModelSimulateSensitivity.html}, note=[Accessed: 13-June-2026]}