Error : Number of variables exceeds number of equations.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone,
I've created a custom Simscape component and I have the following error : Number of variables exceeds number of equations. Click on any Simscape blocks identified below for more detailed diagnostics.
My code for the component is the following :
component pelton_turbine
%Pelton turbine
%This component convert the hydraulic energy given by the pressurized water into mechanical energy (torque).
%It plays the role of a Pelton turbine
nodes
H = foundation.isothermal_liquid.isothermal_liquid; %H : left
R = foundation.mechanical.rotational.rotational; %R : right
end
outputs
T_out = {0, 'N*m'}
end
parameters
eta = {0.9, '1'};
rho = {1000, 'kg/m^3'};
r = {0.5, 'm'};
end
parameters (Access = private)
g = {9.81, 'm/s^2'};
end
variables
mdot = {0, 'kg/s'};
T = {0, 'N*m'};
H_head = {0, 'm'};
end
branches
mdot : H.mdot -> *;
end
equations
H_head == H.p/ (rho * g);
T == eta * mdot * r * sqrt(H_head * g/2);
T_out == T;
end
Please let me know if you have any idea on how to fix this and on which equation to add.
1 comentario
David Goodmanson
el 2 de Abr. de 2025
Hi NIls,
the result depends on dm/dt, and it looks like that has to be specified in some way, for example by knowing the diameter of the pipe and determing the rate of flow in some fashion.
Respuestas (1)
Adarsh
el 2 de Abr. de 2025
I understand that you are trying to create a custom Simscape component called “pelton_turbine” and facing the error: “Number of variables exceeds number of equations”.
Going through the code I have noticed that a branch statement should be added indicating that the internal Torque variable ‘T’ is directly associated with the torque at the node ‘R’.
The following code must be added in the branch section:
T: R.t->*;
After the addition of above line, the following error pops up which states that some of the equations might be missing for the given variables:

From the error message and the existing equations, a condition on ‘R.w’ which is the “Angular Velocity” parameter of the ‘R’ Node is missing.
To resolve the error, add a condition on the ‘R.w’ parameter by add a new variable ‘w’ and condition ‘R.w’ using the formula:
Torque == Inertia * Alpha
Alpha: Angular Acceleration (dw/dt)
Please refer to the final code after adding the constraint:
component pelton_turbine
%Pelton turbine
%This component convert's the hydraulic energy given by the pressurized water into mechanical energy (torque).
%It plays the role of a Pelton turbine
nodes
H = foundation.isothermal_liquid.isothermal_liquid; %H : left
R = foundation.mechanical.rotational.rotational; %R : right
end
outputs
T_out = {0, 'N*m'}
end
parameters
eta = {0.9, '1'};
rho = {1000, 'kg/m^3'};
r = {0.5, 'm'};
J = {1, 'kg*m^2'};
end
parameters (Access = private)
g = {9.81, 'm/s^2'};
end
variables
mdot = {0, 'kg/s'};
T = {10, 'N*m'};
H_head = {100, 'm'};
w = {100, 'rad/s'};
end
branches
mdot : H.mdot -> *;
T: R.t -> *;
end
equations
H_head == H.p/ (rho * g);
T == eta * mdot * r * sqrt(H_head * g/2);
T_out == T;
J * w.der == T;
R.w == w;
end
end
This ensures the model compiles correctly without any error. Also ensure the correctness of the underlying physical equations for accurate results.
For more information on creating custom Simscape components you can refer to the following documentation link:
I hope this resolves the issue.
0 comentarios
Ver también
Categorías
Más información sobre Troubleshooting en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!