Simscape custom component - Spring based poppet valve - How to define if-based limit in the equation section?

8 visualizaciones (últimos 30 días)
Hello guys,
I'm modeling a poppet valve through a simscape custom component.
The poppet is subject to a spring force (with precharge) and it opens when the pressure on the left side rises enough.
There is a maximum compression for the spring, resulting in a maximum valve opening.
All areas are circular. The orifice area is function of the poppet position (spring contraction) and is a cylindric surface. To prevent the valve to close as soon as it opens, the poppet is made in a way such that after opening the left area rises, preventing the valve to enter in an open/close fast loop.
I'm interested in the poppet position, in the flow through and in the pressure across the valve.
I modeled the component as follows. But I receive several errors. I'm quite sure the problem is in how I define the equations/variables.
Error using SimValv (line 63) Error compiling Simscape network for model ProvaExp.
Caused by: Error using SimValv (line 63) Number of equations exceeds number of variables.
Moreover I'd like to set a limit to the poppet excursion such as:
if x > hmax x == hmax end %Maximum opening
Is anyone able to help me to figure out how to solve this issue?
component valvola
% Connections A and B are conserving hydraulic ports associated
% with the orifice inlet and outlet, respectively.
% The block positive direction is from port A to port B.
nodes
A = foundation.hydraulic.hydraulic; % A:left
B = foundation.hydraulic.hydraulic; % B:right
end
parameters
C_d = { 0.5, '1' }; % Flow discharge coefficient
Re_cr = { 10, '1' }; % Critical Reynolds number
k = {300, 'N/mm'}; % Spring coefficient
min_area = { 1e-12, 'm^2' }; % Minimum area
r0 = {2.2, 'mm'}; %inner radius
r1 = {5, 'mm'}; % middle radius
r2 = {10, 'mm'}; %large radius
r3 = {3.75, 'mm'}; %rod radius
hmax = {4, 'mm'}; %Maximum compression
x0 = {0.5, 'mm'}; %Precharge
m = {0.05, 'kg'}; % piston mass
end
parameters(Access=private)
A0= { 0, 'm^2' };
A1= { 0, 'm^2' };
A2= { 0, 'm^2' };
xdot0 ={0, 'mm/s'};
xdotdot0 ={0, 'mm/s^2'};
end
variables
q = { 1e-3 , 'm^3/s' }; % Flow rate
p = { 0 , 'Pa' }; % Pressure
end
branches
q : A.q -> B.q;
end
function setup
across(p, A.p, B.p);
through(q, A.q, B.q);
A0 = pi *(r1^2-r0^2); % Closed area
A1 = pi *(r2^2-r3^2); % Discharge side area
A2 = pi *(r2^2-r0^2); % Open Area
end
outputs
x = { 0 , 'mm' };
xdot = {0, 'mm/s'};
xdotdot = {0, 'mm/s^2'};
end
equations
p == A.p - B.p;
if (A.p*A0 - B.p*A1 <= k * x0)
% System closed
x == 0*x0;
xdot == x.der;
xdotdot == xdot.der;
let
area = 2*pi*r0*x;
D_h = (4.0*area/pi)^0.5;
in
q == C_d*area*sqrt(2.0/A.density) * p/(p^2)^(1/4);
end
else
% System open
x == 1/k*(A.p*A2 - B.p*A1 -k*x0 - m*xdotdot);
xdot == x.der;
xdotdot == xdot.der;
let
area = 2*pi*r0*x;
D_h = (4.0*area/pi)^0.5;
p_cr = A.density/2*(Re_cr*A.viscosity_kin/(C_d*D_h))^2;
in
q == C_d*area*sqrt(2.0/A.density) * p/(p^2+p_cr^2)^(1/4);
end
end
end
end

Respuestas (1)

Brandon Eidson
Brandon Eidson el 16 de Mzo. de 2017
This message indicates that the component is "overdefined" in the sense that there are so many equations that Simscape cannot uniquely determine the variables of the component.
A general rule of thumb is that the number of equations "E" shall equal: E = N + (V - TA) - 1
where "N" is the number of physicall connections (ports), "V" is the number of the component's variables and "TA" is the number of the components' through/across variables (thus, "V-TA" is the number of the component's internal variables). There exist numerous exceptions to this general rule and this equation shall not always hold. Nevertheless, this rule of thumb shall provide a good guideline, especially for complex components.
In all cases, once such error messages are received, the set of equations shall be reduced. Specifically, the first equations that shall be revised are those that overdefine a given variable.
For instance, try removing one or more of your x/xdot/xdotdot equations by combing them together. You very well may need to incorporate these into your p and q equations.
Also, you will almost certainly need to define x, xdot, and xdotdot as variables. Then create dummy outputs (x_out, xdot_out, xdotdot_out) that you assign to the variables in your equations.

Categorías

Más información sobre Discrete Events and Mode Charts en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by