Rsim Unlock

0 views
Skip to first unread message

Tamsyn

unread,
Jul 24, 2024, 11:50:14 PM7/24/24
to dragsimischtrod

Rpath is an implementation of the ecosystem model Ecopath with Ecosim (EwE; Christensen and Pauly 19921, Walters et al. 19972). This vignette describes some of the basic functionality of the package using a fictional ecosystem, R Ecosystem. Any resemblance to an actual ecosystem is purely coincidental. To see the underlying mathematics please refer to Lucey et al. (in prep3).

rsim unlock


Downloadhttps://bltlly.com/2zMvNN



Running rsim, is a three part process. First, the function rsim.scenario is run to convert rpath parameters to rates. Within rsim.scenario are 5 functions that initialize the basic and stanza parameters, creates perturbation matrices for fishing and other forcing functions, and a list of initial states. Arguments passed to the rsim.scenario function are the Rpath object, the rpath parameter object, and a vector of years corresponding to the length of the simulation.

The second part of rsim is to add forcing functions or change the fishing behavior. This is accomplished by changing the appropriate list within the Rsim.scenario object created in the first step. There are a series of adjust functions that will do this without having to know the specific group numbers. For example, we can double the effort of the trawler fleet after 25 years using the adjust.fishing function.

The final part is to apply the modified Rsim.scenario function to the rsim.run function. The only arguments to the rsim.run function are the Rsim.scenario object, the method for numerical integration, and the length of the simulation. Rpath allows for both Adams-Bashforth and Runge-Kutta 4 numerical integration. Older versions of EwE use the Adams-Bashforth method while the latest version (6+) uses Runge-Kutta (The default method for Rpath).

Using the RSim target, you can build a model once and run multiple simulations to study effects of varying parameter settings and input signals. You can run a simulation directly from your operating system command line, redirect the command from the MATLAB command line by using the bang (!) character, or execute commands from a script.

If a model experiences frequent zero crossings and the model's minor step size is small, consider setting a time limit for a rapid simulation. To set a time limit, specify the -L option with a positive integer value. The simulation aborts after running for the specified amount of clock time (not simulation time). For example,

By default, a rapid simulation runs until the simulation time reaches the time specified the Configuration Parameters dialog box, on the Solver pane. You can override the model simulation stop time by using the -tf option. For example, the following simulation runs until the time reaches 6.0 seconds.

If the model includes a From File block, the end of the simulation is regulated by the stop time setting specified in the Configuration Parameters dialog box, on the Solver pane, or with the RSim target option -tf. The values in the block time vector are ignored. However, if the simulation time exceeds the endpoints of the time and signal matrix (if the final time is greater than the final time value of the data matrix), the signal data is extrapolated to the final time value.

To read the model parameter vector into a rapid simulation, you must first create a MAT-file that includes the parameter structure as described in Create a MAT-File That Includes a Model Parameter Structure. You can then specify the MAT-file in the command line with the -p option.

If your model input data source is a From File block, you can feed the block with input data during simulation from a single MAT-file or you can change the MAT-file from one simulation to the next. Each MAT-file must adhere to the format described in Create a MAT-File for a From File Block.

From File blocks require input data of type double. If you need to import signal data of a data type other than double, use an Inport block (see Create a MAT-File for an Inport Block) or a From Workspace block with the data specified as a structure.

If your mode input data source is an Inport block, you can feed the block with input data during simulation from a single MAT-file or you can change the MAT-file from one simulation to the next. Each MAT-file must adhere to one of the three formats described in Create a MAT-File for an Inport Block.

Check the Inport block parameter settings. These Inport block data parameter settings and specifications, which you specify for the workspace variables, must match settings in the MAT-file, as indicated in Configure Inports to Provide Simulation Source Data:

Prepare the MAT-file by using one of the three available file formats described in Create a MAT-File for an Inport Block. This example defines a signal-and-time structure in the workspace and names it var_single_struct.

As described in Create a MAT-File That Includes a Model Parameter Structure, after you alter one or more parameters in a Simulink block diagram, you can extract the parameter vector, model_P, for the entire model. You can then save the parameter vector, along with a model checksum, to a MAT-file. This MAT-file can be read directly by the standalone RSim executable, allowing you to replace the entire parameter vector or individual parameter values, for running studies of variations of parameter values representing coefficients, new data for input signals, and so on.

For example, assume that you changed one or more parameters in your model, generated the new model_P vector, and saved model_P to a new MAT-file called mymatfile.mat. To run the same model and use these new parameter values, use the -p option, as shown in is example:

If you have converted the parameter structure to a cell array for running simulations on varying data sets, as described in Convert the Parameter Structure for Running Simulations on Varying Data Sets, you must add an @n suffix to the MAT-file specification. n is the element of the cell array that contains the specific input that you want to use for the simulation.

This example converts param_struct to a cell array, changes parameter values, saves the changes to MAT-file mymatfile.mat, and then runs the executable using the parameter values in the second element of the cell array as input.

In much the same way as you can specify a new system output file name, you can also provide new output file names for data saved from one or more To File blocks. To do this, specify the original file name at the time of code generation with a new name, as shown in this example:

In this case, assume that the original model wrote data to the output file rapidsim.mat. Specifying a new file name forces RSim to write to the file mynewrsimdata.mat. With this technique, you can avoid overwriting an existing simulation run.

4a15465005
Reply all
Reply to author
Forward
0 new messages