Engineering Software

Simulink and COMSOL Co-Simulation

Simulink and COMSOL Co-Simulation

Demand background

Matlab/Simulink is used for control system simulation, and COMSOL is used for model finite element simulation. If the finite element model is part of the control system, the two need to be combined to achieve collaborative simulation of Simulink and COMSOL.

Before COMSOL 3.5 (including the previous FEMLAB), a standard interface for exporting COMSOL models to Simulink was provided, but for nonlinear models, the directly exported models could not be used directly. In subsequent versions, COMSOL cancelled the function of directly exporting to Simulink, and the connection method with Simulink also changed.

Conceptually, Simulink’s S-function supports users to customize any subsystem. COMSOL models can be directly saved as Matlab’s “.m” files, and their modifications can be directly imported into the control system as part of the S-function. The Simulink model calls the S-function during the simulation process, and uses the S-function to modify COMSOL’s boundary conditions or physical parameters. COMSOL then executes a simulation step, obtains the result of COMSOL’s execution of the simulation step, and passes it to Simulink as the basis for Simulink to set parameters for the next step.

Demo: Simulating a temperature control system

As shown in the figure below, a simple temperature control system, the output power of the PID control system, S-Function calls COMSOL to perform heat transfer analysis on the model of the specified power, and the calculated temperature result is compared with the reference temperature (300K). If the temperature is low, the output power of the control system is increased, and if the temperature is high, the output power of the control system is reduced. After multiple iterations, the system output temperature is stabilized near the reference temperature.

Simulink and COMSOL Co-Simulation

The temperature change curve monitored in real time during the calculation process is as follows: The initial temperature is 293.15K, the initial heating power is 0W/m 3 , the PID controller automatically increases the output power, and finally the monitoring point temperature calculated by COMSOL gradually approaches the reference temperature of 300K.

Simulink and COMSOL Co-Simulation

When the temperature of the monitoring point (center point) reaches the reference temperature, the COMSOL heat transfer calculation results are as follows. At this time, the power output of the PID controller is 155.5893W/m 3 .

Simulink and COMSOL Co-Simulation

Related Articles

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker