The Cosimulation for Simulink Node
To add a Cosimulation for Simulink node, go to the Study tab, or right-click Global Definitions, and select Cosimulation for Simulink.
You can add more than one export node if you have different scenarios that you want to simulate. The exported cosimulation file only contains information about how Simulink should interface to the COMSOL model. The cosimulation file itself does not contain the model, which remains solely in the COMSOL MPH file.
In the Filename section, enter the name of the cosimulation file to export to. Enter the full name, including the path, if you want to save the file in a specific location; otherwise, the file is saved at the same location as the model MPH file.
A proper cosimulation file is set with at least one output expression and a supported study step.
Click Export to generate the cosimulation file in FMU-format.
The Inputs Section
In the Inputs section you specify the input variables and their order in the COMSOL Cosimulation block in Simulink. The input variables can be modified and updated in the model at every communication time. In the Parameter name column, the list contains all global parameters defined in the model. This list is automatically updated with respect to the block parameters settings, as a global parameter can either be set as input or block parameter.
In the Initial value cell enter the value to be set at initial time step.
To add a new input, click Add. To remove an input, select a row and click Delete.
In case you have several inputs, their order in the input list correspond to the order for the COMSOL Cosimulation block. To improve the visibility of the simulation diagram you may want to change the order of input. To proceed, select the row to move and click Move Up or Move Down.
Click Clear Table to clear all parameter from the input list.
If you want to save or import a list from an external file, click Save to File or Load from File, respectively.
The Block Parameters Section
In the Block Parameters section you specify the parameters you want to change in Simulink but which are only evaluated during the initialization of the cosimulation. In the Parameter name column choose one of the parameters from the list. This list is automatically updated with respect to the inputs settings, as a global parameter can either be set as input or block parameter. There is no restriction on which settings are defined by Block Parameters.
In the Initial value cell enter the default value in the COMSOL Cosimulation block.
To add a new block parameter, click Add. To remove a block parameter, select a row and click Delete.
Click Clear Table to clear all parameter from the input list.
If you want to save or import a list from an external file, click Save to File or Load from File, respectively.
The Outputs Section
In the Outputs section you specify the output expressions and their order in the COMSOL Cosimulation block in Simulink.
In the Expression column enter the global expression you want to be evaluated and sent to Simulink. The expression has to include the component scope where the variable is defined, even if the model contains only one component. It is of good practice to create a probe with the desired output expression, and click Add Expression to get the correct variable expression.
In the Unit column you can specify the unit for evaluation. The unit column is populated automatically with the base unit when adding a new output expression. Inconsistent unit prevents you to export the cosimulation file.
In the Name column you set the display string to be used in the COMSOL cosimulation block. The name column is populated automatically with the variable description, or variable name when a probe is set as output expression.
In the Unit column enter the unit in which the expression is evaluated and transferred to Simulink.
In case you have several output, their order in the output list correspond to the order for the COMSOL Cosimulation block. To improve the visibility of the simulation diagram you may want to change the order of output. To proceed, select the row to move and click Move Up or Move Down.
Click Clear Table to clear all parameter from the input list.
If you want to save or import a list from an external file, click Save to File or Load from File, respectively.
The Study Section
In the study section you specify the study to run in the cosimulation.
From the Study list, select the study to run in the cosimulation. This list is populated with studies that only contain a single study step, either a Stationary or a Time Dependent study step.
In addition, the list does not contain studies that include auxiliary sweep, time-dependent study steps with adaptive mesh refinement, nor stationary study steps including load cases or adaptation and error estimates.
The Dependencies Section
Specify any direct dependencies between input parameters and output expressions using the radio buttons. The information is included in the exported cosimulation file in order to notify Simulink about the direct feedthrough in the model.
The Image Section
To easily recognize the model when loaded into the COMSOL Cosimulation block in Simulink you can select an image. Browse to select the image file to import, or click Set from Graphics Window to use a screenshot of what is currently displayed in the Graphics window.
In case you did specify a filename, click Import, to embed the image in the COMSOL model.