 Simulate - MapleSim Help

Simulate Calling Sequence A := MapleSim:-LinkModel(); A:-Simulate(options) Parameters

 options - (optional) equation(s) of the form name = value Returns The type of output depends on the returntype option, which can be datapoint, plot, or simrec. See the description of the returntype option in the Output Options section. Options Parameter and Initialization Options

 • params : set or list of equations
 Specifies which, if any, new parameter values are to be used for the simulation. Default is {}.
 • ics : set or list of equations
 Specifies the initial conditions for system states, ix1 variables, and inputs. The default value is the linked model A subsystem's initial conditions.
 • nosubs : true or false
 Specifies whether the parameters are entered as the original model names or the substituted names. The default value is false. Simulation Options

 • tf : nonnegative
 The tf option specifies the simulation end time in seconds.
 • solver : one of the following: "RKF45", "CK45", "Rosenbrock", "Euler", "ImplicitEuler", "RK2", "RK3", "RK4"
 Specifies which solver dsolve/numeric uses for integration.
 • t0 : nonnegative
 The t0 option specifies the simulation start time in seconds.
 • baumgarte : list
 Specifies derivative (alpha) and proportional (beta) gains for Baumgarte constraint stabilization in the form baumgarte=[alpha,beta]. If this parameter is set to the empty list, the Baumgarte constraint stabilization is not carried out.
 • numericjacobian : true or false
 Specifies whether the system Jacobian is formulated numerically for implicit integration solver.  This option is only used with stiff solvers (Rosenbrock or ImplicitEuler).
 • coniter : nonnegative
 Indicates the maximum number of constraint projection iterations.  If coniter is set to 0, constraint projections are not carried out.
 • contol : nonnegative
 Indicates the error tolerance at which constraints are satisfied and projection iterations are terminated.
 • optimize : true or false
 If true, compiler optimizations are applied during code compilation.
 • evtiter: positive integer
 Specifies maximum number of event iterations.
 • scalemethod : one of the following: "none", "minimum", "maximum", "geometric"
 Method of variable scaling applied to the system. Fixed-step Solver Specific Options

 • stepsize : positive
 The uniform step size of the sampling periods if you are using a fixed-step solver to run the simulation. You can specify a value for this option only when a fixed-step solver is used.
 • evtproj : true or false
 If true, constraint projection occurs during event iterations.
 • evthyst : nonnegative
 Indicates the maximum number of event iterations. Variable-step Solver Specific Options

 • abserr : positive
 The limit on the absolute error tolerance for a successful integration step if you are using an adaptive solver to run the simulation.
 • relerr : positive
 The limit on the relative error tolerance for a successful integration step if you are using an adaptive solver to run the simulation.
 • minstep : nonnegative
 The lower limit on the step size used for the integration. If the solver is unable to achieve the requested error tolerance with this minimum then it will take the step anyway, so this option should be used with caution. The default value for this option is 0.
 • maxstep : nonnegative
 The upper limit on the step size used for the integration. This option is most useful for simpler models, as it limits the growth of the step size when the error is low. The default value for this option is 0 (disabled).
 • maxfun : nonnegative
 The upper limit on the number of rhs evaluations in for the underlying ode system. When exceeded the simulation will halt and return partial results. The default value for this option is 0 (disabled).
 • ix1relfac : positive
 Controls the relative error on algebraic variables compared to differential variables.
 • ix1errctl : true or false
 Turns on error control for all algebraic variables if true. By default this is false, and error control is only enabled for algebraic variables that directly influence probes or events, or are outputs of black box functions.
 • ratehyst : nonnegative
 Specifies the width of the event hysteresis for all event triggers at the start of the simulation.
 • reduceevents : true or false
 If true, heuristics are used to reduce the number of events encountered during the simulation.
 • plotevents : true or false
 If true, extra plot points are added at event points during the simulation. When used with the option ds below, if either plotevents = true or the GUI Simulation Settings Plot Events check box is selected, a warning will be issued. To turn this warning off, set plotevents = false explicitly.
 • compile : true or false
 Specifies whether to use the compiler in the simulation. Output Options

 • ds : nonnegative
 The ds option specifies the sampling time in seconds. For variable-step solvers, the default value is set to (tf-t0)/minpoints; for fixed-step solvers, the default is set to the stepsize. If the provided sampling time, ds, does not divide the simulation duration evenly, the last point of the simulation result will be lost. The ds option overrides event plotting specified either by the plotevents option above or the GUI Simulation Settings "Plot Events" checkbox.
 • outputs : list of any combination of system variables or algebraic expressions using system variables
 Depending on the value of the returntype option (see below), specifies the list of outputs to be plotted or stored in the returned Array. The default is a list of all the system's probes.
 • returnTimeData : true or false
 When used with returntype = datapoint (see below), the time data is added as the first column of the output Array. The default value is true.
 • returntype : one or a list of the following symbols: 'plot', 'datapoint', 'simrec'
 Specifies the output type. The value can be a single symbol or a list of symbols. If a list is specified, a list is returned with the corresponding symbols replaced with their values. The default value is plot.
 – plot: generate the simulation results in plots. The returned value for plot is NULL unless the environment variable _EnvMapleSimReturnPlots is set to true. If _EnvMapleSimReturnPlots is set to true, the corresponding value is either a sequence of plot structures, if returntype = plot, or a list of plot structures, if plot is an element of the list assigned to returntype.
 – datapoint: generate the simulation results as an Array of data values. There is one column of data values per probe specified in the outputs option. Additional time data in the first column of the returned data array can be generated by setting the returnTimeData option to true (see below).
 – simrec: generate a record of the simulation.  This record can be used by other MapleSim commands to generate plots and visualizations.
 • minpoints : positive integer
 The minimum number of samples to plot in the simulation graphs. If evenlyspaced is false, this value is the exact number of samples that appear in the graphs; otherwise, samples at the boundaries of subintervals are also included. The default value is 200.  This option is not meant to be used together with ds option above.
 • evenlyspaced : true or false
 Specifies whether the time samples are spaced evenly in the simulation graphs. If this option is set to false, the start and end times of each subinterval corresponding to a particular configuration are included in the graphs. The default value is false.
 • diagnosticinfo : true or false
 True adds four outputs which behave as probes: LogStepSize, EventIterations, ConstraintIterations, and ConstraintResidual. The EventIterations output will only have a nonzero value if the model has events, and the ConstraintIterations and ConstraintResidual outputs will only have nonzero values if the model has constraints. Note that if the model has constraints, but constraint projection is turned off, this option will add expense to the integration. The default is false.
 • saveresults or saveresult : string, or true or false
 A string saves the result to the MapleSim Result Manager, using the value. True is equivalent to saveresults = "Latest Results". False does not save the result. The default is false. The options saveresults and saveresult are synonyms. Description

 • A:-Simulate simulates linked model A.
 • The simulation engine uses the default settings stored in the model (as set under the Simulation Settings tab of the MapleSim GUI). The solver option can be used to change the solver type. For example, A:-Simulate(solver = "Euler") replaces the solver stored in the model with the fixed-step "Euler" solver. Use A:-GetSettings to see the default simulation settings stored in the model. This returns the settings for the solver specified under the Settings tab in the MapleSim GUI. The solver type must be changed using the MapleSim GUI in order to view its default settings using A:-GetSettings command.
 • The A := MapleSim:-LinkModel() statement needs to be run prior to successfully using any of the ModelObject A's export functions. Examples

 > $A≔\mathrm{MapleSim}:-\mathrm{LinkModel}\left('\mathrm{filename}'=\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/RLCcircuit.msim"\right)\right):$

Simulating the active system with default options:

 > $A:-\mathrm{Simulate}\left(\right)$ Simulating the active system with various options:

 > $\mathrm{simData}≔A:-\mathrm{Simulate}\left(\mathrm{returntype}=\mathrm{datapoint},\mathrm{tf}=2.0,\mathrm{abserr}=0.1\right)$
 ${\mathrm{simData}}{≔}\begin{array}{c}\left[\begin{array}{cc}{0.}& {-0.}\\ {0.0100502512562814}& {0.000319903949509881}\\ {0.0201005025125628}& {0.00127155613983562}\\ {0.0301507537688442}& {0.00284160813619416}\\ {0.0402010050251256}& {0.00501503290716617}\\ {0.0502512562814070}& {0.00777512482469598}\\ {0.0603015075376884}& {0.0111034996640917}\\ {0.0703517587939698}& {0.0149800946040251}\\ {0.0804020100502513}& {0.0193831682265317}\\ {0.0904522613065327}& {0.0242893005170107}\\ {⋮}& {⋮}\end{array}\right]\\ \hfill {\text{200 × 2 Matrix}}\end{array}$ (1)
 > $\mathrm{plot}\left(\mathrm{simData}\left[1..-1,1\right],\mathrm{simData}\left[1..-1,2\right]\right)$ 