Simulate - MapleSim Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MapleSim : MapleSim Application Programming Interface : API Commands : MapleSim/LinkModel/Simulate

Simulate

simulate the linked MapleSim model

 

Calling Sequence

Parameters

Returns

Options

Description

Examples

Calling Sequence

A := MapleSim:-LinkModel();

A:-Simulate(options)

Parameters

options

-

(optional) equation(s) of the form name = value

Returns

• 

If returntype = datapoint or returntype = [datapoint,plot] then

– 

Array or list : the simulation results as an Array of data values or a list consisting of the simulation results as an Array and a list of plot structures.

• 

If returntype = plot then

– 

none

  

Note: Plots of the simulation results are displayed, but the actual return of the A:-Simulate command is NULL.

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

The default values for the simulation options below are retrieved from the linked MapleSim model. If the linking is done using a Modelica file, the defaults are as specified by MapleSim[LinkModel][GetSettings].

• 

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. This option cannot be used simultaneously with ds option below.

• 

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.

• 

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 : either, or both (in a list) of the following keywords: "plot","datapoint"

  

Specifies the output type. The value can be either one of the following symbols or a list of those 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).

• 

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

Linking to a MapleSim model (located in .msim file):

AMapleSim:-LinkModel'filename'=catkernelopts'toolboxdir'=MapleSim,/data/examples/RLCcircuit.msim:

Simulating the active system with default options:

A:-Simulate

Simulating the active system with various options:

simDataA:-Simulatereturntype=datapoint,tf=2.0,abserr=0.1

simData:= 200 x 2 MatrixData Type: float8Storage: rectangularOrder: Fortran_order

(1)

plotsimData1..1,1,simData1..1,2

See Also

MapleSim

MapleSim[LinkModel]

MapleSim[LinkModel][GetCompiledProc]

MapleSim[LinkModel][GetSettings]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam