how to solve the orror: Number of equations exceeds number of variables.

8 views (last 30 days)
hello,I am trying to write a Simscape component that can define a fluid with variable density.The code is as follows:
component rho_fluid
inputs
density = { 1000, 'kg/m^3' }; % Fluid density, now an input parameter
end
% Define parameters
parameters
viscosity_kin = { 18e-6, 'm^2/s' }; % Kinematic viscosity
bulk = { 0.8e9, 'Pa' }; % Bulk modulus at atm. pressure and no gas
alpha = { 0.005, '1' }; % Relative amount of trapped air
range_error = { 2, '1' }; % Absolute pressure below absolute zero in blocks with fluid compressibility
end
nodes
G = foundation.hydraulic.hydraulic; % :right
end
equations
assert(density > 0, 'Density must be positive');
% Assign input and parameter values to the node
G.density == density;
G.viscosity_kin == viscosity_kin;
G.bulk == bulk;
G.alpha == alpha;
G.range_error == range_error;
assert(viscosity_kin > 0, 'Kinematic viscosity must be positive');
assert(bulk > 0, 'Bulk modulus must be positive');
assert(alpha >= 0, 'Alpha must be non-negative');
assert(alpha < 1, 'Alpha must be less than 1');
end
end
I can succeesfully using 'ssc_build' to build the component,but when i run the model,the error occured:
Number of equations exceeds number of variables. Click on any Simscape blocks identified below for more detailed diagnostics.
the picture is the simplified test model
Can anyone help me?matlab r2022b
  3 Comments
Umar
Umar on 22 Oct 2024
Hi @Yifeng Tang,
I did not know OP had a similar question posted in another post. Glad you caught it.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 20 Oct 2024
Moved: Star Strider on 20 Oct 2024
I do not have Simscape, so I looked at your Question simply out of interest.
Using Deploy a Component File in Block Diagram as a reference (there are others linked to it as well), it appears that you have not actually defined any variables in your posted code.

Categories

Find more on Foundation and Custom Domains in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!