主要内容

parsim

并行或串行多次模拟动态系统

描述

example

SIMOut= parsim()SIMulates a model using the inputs specified in the仿真input对象,in。parsim命令使用一个数组仿真input对象运行多个模拟。

SIMOut= parsim(,“显示模仿者”,'on')SIMulates a model in parallel using the inputs specified in the仿真input对象并打开模拟管理器UI。有关更多信息,请参阅模拟管理器.

SIMOut= parsim(,名称,价值)SIMulates a model in parallel using the inputs specified in the仿真inputobject and the options specified as the名称,价值pair.

Theparsim命令使用并行计算工具箱™许可并行运行模拟。parsim如果无法创建并行计算工具箱,则在串行中运行模拟。

例子

全部收缩

Simulate the model,VDP,以快速加速器模式。

加载模型。

model ='vdp';LOAD_SYSTEM(型号)

This step builds the Rapid Accelerator target

万博1manbetxsimulink.blockdiagram.buildrapidacceleratortarget(模型);

Create a仿真input对象和使用setModelParameter设置的方法RapidAcceleratorUpToDateCheckto'离开'.

in = 万博1manbetxsimulink.simulationInput(模型);in = in.setModelParameter(“SimulationMode”,'rapid-accelerator');in = in.setModelParameter(“ RapidAcceleratoruptoptatecheck”,'离开');

Simulate the model.

out = parsim(in)

Simulate the model, CSTR, in parallel by sweeping over a variable. An array of SimulationInput objects is used to perform the sweep.

指定扫描值。

FeedTempSweep = 250:10:300;

Create an array of SimulationInput objects.

fori = length(FeedTempSweep):-1:1 in(i) = Simulink.SimulationInput('cstr');在(i)= in(i).setVariable('feedTemp0',feedTempsweep(i));结尾

并联模拟模型。

out = parsim(in,'ShowProgress','on')
[11-Dec-2020 09:14:55] Checking for availability of parallel pool... Starting parallel pool (parpool) using the 'local' profile ... Connected to the parallel pool (number of workers: 6). [11-Dec-2020 09:15:43] Starting Simulink on parallel workers... [11-Dec-2020 09:16:17] Configuring simulation cache folder on parallel workers... [11-Dec-2020 09:16:17] Loading model on parallel workers... [11-Dec-2020 09:16:25] Running simulations... [11-Dec-2020 09:16:58] Completed 1 of 6 simulation runs [11-Dec-2020 09:16:58] Completed 2 of 6 simulation runs [11-Dec-2020 09:16:58] Completed 3 of 6 simulation runs [11-Dec-2020 09:17:00] Completed 4 of 6 simulation runs [11-Dec-2020 09:17:01] Completed 5 of 6 simulation runs [11-Dec-2020 09:17:01] Completed 6 of 6 simulation runs [11-Dec-2020 09:17:02] Cleaning up parallel workers... out = 1x6 Simulink.SimulationOutput array

输入参数

全部收缩

A万博1manbetxSimulink.SimulationInput对象或一个数组万博1manbetxSimulink.SimulationInput用于指定模型更改的对象。

例子:in = 万博1manbetxsimulink.simulationInput('vdp')

Name-Value Arguments

例子:'ShowProgress','on'

Note

All parameters passed toparsim命令与与SIMcommand. To pass to theparsim命令,使用以下输入参数的列表

指定可选的逗号分隔对名称,价值参数。Name是参数名称和价值是相应的值。Name价值必须出现在单引号中(' ')。您可以按任何顺序指定几个名称和值对参数NAME1,Value1,...,Namen,Valuen.

指定为附加文件的单元格数组,以连接到并行池。

Set to'on', to see the progress of the simulations in the command window. The progress is hidden when set to'离开'.

Note

什么时候the progress is shown, a message“清理平行工人..”may be displayed before the completion of the last few simulations. This message does not depend on the completion of the simulations. Simulations complete when the outputs are fetched from the未来. For more information, see万博1manbetxsimulink.simulation.future.

Set to'on'to run simulations asynchronously, keeping the MATLAB®command prompt available for use.

指定function handleto'setupfcn'to run once per worker before the start of the simulations.

例子:'setupfcn',@()currentProject('modelex/model_example.prj')

Note

什么时候buildrapidacceleratortarget在设置中使用,该模型已指定了外部输入,要么设置“ loadexternalInput”to'离开'或确保在工人上可用指定的外部输入以防止编译错误。

指定function handleto'CleanupFcn'模拟完成后,每个工人一次运行一次。

什么时候托管依赖性被设定为,如果需要,模型依赖项会自动发送到并行工人。如果托管依赖性被设定为离开,明确将模型依赖性附加到并行池。

什么时候UseFastRestart被设定为,使用快速重新启动在工人上进行模拟。

什么时候performing a parameter sweep varying properties of a Simscape™ component (e.g. mass and inertia of a Solid block in Simscape Multibody), specify the Simscape block parameter as run-time configurable. For more information, seeAbout Simscape Run-Time Parameters(SIMSCAPE).

Note

使用时parsim, use theUseFastRestart选项,而不是FastRestartoption. SeeGet Started with Fast Restart了解更多信息。

什么时候TransferBaseWorkspaceVariables被设定为, variables used in the model and everything defined in the base workspace are transferred to the parallel workers.

什么时候“显示模仿者”被设定为'on',您可以使用Simulation Manager应用程序监视仿真。

环境'StopOnError'to'on'如果遇到错误,请停止执行模拟。

Output Arguments

全部收缩

数组Simulink.SimulationOutputobjects that contains all of the logged simulation results. The size of the array is equal to the size of the array of万博1manbetxSimulink.SimulationInput对象。

All simulation outputs (logged time, states, and signals) are returned in a singleSimulink.SimulationOutput目的。您定义使用该模型时间,状态和输出数据导入/导出模型配置参数对话框的窗格。您可以使用块(例如到工作区范围blocks. The信号和示波器经理可以直接记录信号。

Extended Capabilities

Version History

Introduced in R2017a