Where are the other equations in my simscape block?
7 views (last 30 days)
Show older comments
Jan Kragbæk
on 29 Aug 2017
Commented: Jan Kragbæk
on 18 Sep 2017
I have created my own simple custom simscape block. It should increase fluid temperature by X degrees. The block is build without any issues, but when I use it in a model, I get an error.
"Error compiling Simscape network for model untitled.
Caused by:
Number of equations exceeds number of variables. Click on any Simscape blocks identified below for more detailed diagnostics.
untitled/Increaser of fluid temperature (°C) (TL)"
The matlab window says:
Simscape diagnostics for block untitled/Increaser of fluid temperature (°C) (TL):
In the Simscape component Comp2.TemperatureIncrease, the number of equations exceeds the
number of continuous variables. The component only defines 4 variables, but 5 equations.
Possible causes are given below:
Caused by:
Node TemperatureIncrease.B is possibly missing a branch statement for domain variable
name: Phi.
Node TemperatureIncrease.B is possibly missing a branch statement for domain variable
name: mdot.
Node TemperatureIncrease.A is possibly missing a branch statement for domain variable
name: Phi.
Node TemperatureIncrease.A is possibly missing a branch statement for domain variable
name: mdot.
The set of variables or outputs ( TemperatureIncrease.A.T, TemperatureIncrease.B.T ) is
overdetermined because they are used in the following equations:
In TemperatureIncrease (Line 21)
An additional 2 automatically generated conservation equations.
My block code is:
component TemperatureIncrease
% Increaser of fluid temperature (°C) (TL)
% This block increases the temperature of the fluid by a user determined
% value
nodes
A = foundation.thermal_liquid.thermal_liquid; % A:left
B = foundation.thermal_liquid.thermal_liquid; % B:right
end
parameters
dT = {10, 'K'}; % Temperature increase
end
% outputs
% % New temperature of port B
% T = {0, 'K'}; % T:right
% end
equations
B.T == A.T + dT
%T == A.T - B.T
end
end
What am I doing wrong?
0 Comments
Accepted Answer
Sebastian Castro
on 30 Aug 2017
As your error message states:
Node TemperatureIncrease.B is possibly missing a branch statement for domain variable
name: Phi.
Node TemperatureIncrease.B is possibly missing a branch statement for domain variable
name: mdot.
Node TemperatureIncrease.A is possibly missing a branch statement for domain variable
name: Phi.
Node TemperatureIncrease.A is possibly missing a branch statement for domain variable
name: mdot.
In other words, you are missing a branches section defining the sign convention of the heat flux and mass flow rate at each port. If you look at the source code of some existing components (e.g. foundation.thermal_liquid.two_port_steady), you will see this section is included in the .ssc file.
branches
mdot_A : A.mdot -> *;
mdot_B : B.mdot -> *;
Phi_A : A.Phi -> *;
Phi_B : B.Phi -> *;
end
However, you'll see that a lot more may be missing from your code. I'd recommend using the inheritance feature in the Simscape Language by declaring your components as follows:
component TemperatureIncrease < foundation.thermal_liquid.two_port_steady
This will make sure all the necessary nodes/equations/variables are already defined, and you just fill in the rest of this "template" -- in your case, just the parameters and equations.
- Sebastian
3 Comments
Sebastian Castro
on 31 Aug 2017
You're right that the documentation is a little skewed towards the "easier" domains. There is some more information about the Thermal Liquid domain (and others) in the guide at http://www.mathworks.com/help/pdf_doc/physmod/simscape/simscape_lang.pdf
Besides that, I find the best success looking at the source code of existing components. If you look at the Simscape Foundation Library block dialogs, they should all have a "Source Code" hyperlink.
If you inherit from the foundation.thermal_liquid.two_port_steady component, all you need to define are any additional inputs/outputs/parameters in the block, as well as equations that relate the "through" (heat flux/mass flow) and "across" (pressure/temperature) variables.
- Sebastian
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!