Simulink Demux Error & PID Controller Issue in Heat Exchanger Network Model with S-Functions

1 次查看(过去 30 天)
The file containing block diagram 'PID' is missing. A different file of the same name exists on the MATLAB path. This can cause unexpected behavior. For more information see "Avoiding Problems with Shadowed Files" in the Simulink documentation. The missing file is: C:\Users\User\Documents\MATLAB\Heat_Exchanger_Network_Apr2025\Scripts\PID.slx. The file on the MATLAB path is: C:\Users\User\Documents\MATLAB\Heat_Exchanger_Network_Apr2025\Scripts\PID_HEN_Model\PID.slx Component:Simulink | Category:Block diagram warning Invalid setting for input port dimensions of 'PID/Demux5'. The dimensions are being set to [1x1]. This is not valid because the total number of input and output elements are not the same Component:Simulink | Category:Model error Error in port widths or dimensions. 'Output Port 1' of 'PID/E1' is a [1x1] matrix. Component:Simulink | Category:Model error
This is my error in simulink. Check my uploaded folders and files (mfile and slxfile)
I am currently developing a Heat Exchanger Network (HEN) process control model in MATLAB/Simulink, incorporating PID controllers and Level-2 MATLAB S-Functions to regulate the outlet temperatures of multiple heat exchangers (E1, E2, E3) and a heating utility (H1).** The goal is to dynamically control the system by adjusting the hot and cold inlet flow rates (Fh, Fc) based on PID outputs. However, I am encountering the following critical errors in my Simulink model.
My grid diagram of HEN description:
The Heat Exchanger Network (HEN) consists of two hot streams (S1, S2) and two cold streams (S3, S4), where S2 is split into two branches, interacting through three process heat exchangers (E1, E2, E3) and one heating utility (H1) for heat recovery and energy efficiency. E1 transfers heat from S1 (368 K → 348 K) to S4 (335 K → 343 K) with a duty of 400 kW, while E2 heats S3 (303 K → 325.5 K) using the first split of S2 (353 K → 348 K) with a duty of 900 kW. E3 heats S4 (333 K → 335 K) using the second split of S2 (353 K → 348 K) at 100 kW. H1 provides additional heating to S3 (325.5 K → 363 K) with a duty of 1500 kW. The system is dynamically modeled in MATLAB/Simulink, utilizing S-Functions and PID controllers to regulate outlet temperatures for process stability, optimizing energy recovery while responding to variable disturbances in real-time.
PID model connection description:
📌 Step-by-Step Verification & Optimization of PID Model Connections
The PID model connections for the Heat Exchanger Network (HEN) are structured to regulate the outlet temperatures by dynamically adjusting mass flow rates through PID controllers. Each heat exchanger has two PID controllers: one for the hot outlet temperature (Thout) and another for the cold outlet temperature (Tcout). Setpoints are defined for each heat exchanger: E1 (Thout = 348 K, Tcout = 343 K), E2 (Thout = 348 K, Tcout = 325.5 K), E3 (Thout = 348 K, Tcout = 335 K), and H1 (Thout = 440 K, Tcout = 363 K). Sum blocks compute error signals by subtracting the actual outlet temperatures from the setpoints. These error signals are fed into the PID controllers, which adjust the hot and cold mass flow rates to maintain the desired temperature conditions. The S-Function blocks for E1, E2, E3, and H1 take nine inputs, including inlet temperatures (Th_in, Tc_in), manipulated mass flow rates (Fh, Fc), the overall heat transfer coefficient (U), heat exchanger area (A), and geometric parameters such as outer tube diameter (Dotl), inner tube diameter (d_in), and tube length (L). The output of each S-Function is a [2×1] vector containing the dynamically computed Thout and Tcout, which is then separated by Demux blocks into two distinct outputs for feedback control and monitoring. Scopes are used to observe the real-time behavior of outlet temperatures, ensuring process stability and effective heat recovery.
For E1, a constant block (348 K) sets the Thout setpoint, which connects to a sum block that calculates the error signal by subtracting the actual Thout from the setpoint. The sum block output is fed into a PID controller (PID_E1_Thout), which adjusts the hot stream flow rate (Fh) by connecting to the 3rd input of E1's S-Function. Similarly, the Tcout control loop follows the same process, with a constant block (343 K) connecting to the sum block (E1 Error Tcout), which then passes through PID_E1_Tcout, controlling the cold stream flow rate (Fc) at the 4th input of E1's S-Function. The first Demux block extracts Thout and Tcout from E1’s output, with Thout connected to the second Demux and routed to a Scope for monitoring. The second Demux output is fed into the negative input of the sum block (E1 Error Thout) to close the control loop. Similarly, the cold stream output (Tcout) is processed through another Demux and connected to the scope while also being fed into the sum block (E1 Error Tcout).
For E2, a constant block (348 K) connects to the sum block (E2 Error Thout), generating the error signal for PID_E2_Thout, which adjusts Fh (3rd input of E2's S-Function). The cold stream flow rate (Fc) is controlled similarly via PID_E2_Tcout, with a setpoint of 325.5 K. The first Demux extracts the Thout and Tcout values, where Thout is routed to the scope and the sum block (E2 Error Thout). The cold outlet temperature (Tcout) is routed to the 2nd input of H1's S-Function, ensuring the correct heat cascade within the network. For E3, a constant block (335 K) connects to the sum block (E3 Error Tcout), with PID_E3_Tcout controlling Fc (4th input of E3's S-Function). Thout is extracted from the first Demux, connected to E1’s Tc_in (2nd input), maintaining the structured energy transfer throughout the network. The output connections follow the same feedback control logic, ensuring all heat exchanger outputs are continuously monitored and adjusted to meet setpoints dynamically.
For H1 (heating utility), a constant block (440 K) is connected to the sum block (H1 Error Thout), feeding the error signal into PID_H1_Thout, which controls Fh (3rd input of H1's S-Function). The cold outlet temperature (Tcout) setpoint (363 K) is connected to the sum block (H1 Error Tcout), with PID_H1_Tcout controlling Fc (4th input of H1's S-Function). The 1st Demux extracts the Thout and Tcout values, where Thout is sent to the scope and the sum block (H1 Error Thout), while Tcout is sent to another scope and the sum block (H1 Error Tcout). The control structure effectively minimizes disturbances, maintaining the desired temperature levels across all heat exchangers, ensuring optimal heat recovery, energy efficiency, and process stability under dynamic conditions.
Before running the simulation, all Sum blocks should be verified to ensure correct positive and negative inputs for accurate error calculations. Additionally, Demux blocks must correctly split the [Th_out; Tc_out] vector into separate outputs for proper feedback control. PID controllers should be tuned appropriately to avoid excessive oscillations and ensure fast convergence to setpoints. Finally, Scopes should be checked to ensure they are correctly connected to monitor hot and cold outlet temperatures in real-time. Running the simulation (Ctrl + D) will provide insight into the system's response, PID tuning effectiveness, and overall heat exchanger network performance, ensuring optimized energy recovery and stable operation under varying process conditions.

回答(1 个)

Kautuk Raj
Kautuk Raj 2025-3-24
The error you are encountering in Simulink seems to be related to two main issues: file shadowing and port dimension mismatch. I will answer these issues in a point-wise manner:
(1) File Shadowing:
Simulink is warning about a potential shadowing issue where two files with the same name "PID.slx" exist in different directories. This can lead to unexpected behavior because Simulink might be loading a different file than intended.
The solution is to ensure that the correct "PID.slx" file is being used. You can do this by:
  • Removing the incorrect path from your MATLAB path using "rmpath".
  • Renaming one of the files if both are needed but serve different purposes.
  • Using the "which" command in MATLAB to verify which file is being accessed: "which PID.slx -all".
(2) Port Dimension Mismatch:
The error indicates that the dimensions of the input and output ports in your model do not match, specifically with the "Demux5" and "E1" blocks.
  • Check the configuration of the "Demux5" block to ensure it is set up to handle the dimensions of the incoming signal correctly.
  • Verify that the output dimensions of the "E1" block match the expected input dimensions of any downstream blocks.
  • Use the Model Explorer or the Signal Dimensions tool in Simulink to diagnose and correct dimension mismatches.
By addressing these issues, you should be able to resolve the errors and run your Simulink model successfully.

类别

Help CenterFile Exchange 中查找有关 Classical Control Design 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by