Simscape Language Chamber with Orifice

1 visualización (últimos 30 días)
Cedric Götze
Cedric Götze el 16 de Jul. de 2015
Respondida: Cedric Götze el 21 de Jul. de 2015
Unfortunately it is not possible to create Subsystem automated inside a Simscape Library. So I have to find an other way to solve the following problem.
I have a chamber which is similar to the constant volume chamber of the pneumatic library. I want to connect it to an orifice and an atmospheric reference in just one block.
My idea was the following code
component chamber2
% Constant Volume Pneumatic Chamber with opening
nodes
A = test.test; % A:top
end
parameters
Volume = { 1e-3, 'm^3' }; % Chamber volume
Area = { 1e-5, 'm^2' }; % Opening area
p2 = { 1e5, 'Pa' }; % Pressure at opening
end
parameters(Access = private)
Bcr = { 0.5283 , '1' }; % Critical pressure ratio (for choked flow)
% Collected constant terms for flow equation
c_1 = { 0, 'kg*K/J' };
c_2 = { 0, '1' };
c_3 = { 0, '(kg*K/J)^0.5' };
c_4 = { 0, '(kg*K/J)^0.5' };
c_5 = { 0, '1' };
end
variables
G = { 0, 'kg/s' }; % Mass flow rate
Q = { 0, 'J/s' }; % Heat flow into port A
p1 = { 1e5, 'Pa' }; % Pressure at port A
end
variables(Conversion=absolute)
T1 = { 300 , 'K' }; % Temperature at port A
end
function setup
% Calculate critical pressure ratio
Bcr = (2/(A.kappa+1))^(A.kappa/(A.kappa-1));
% Calculate collected constant terms for flow equation
c_1 = 2*A.kappa/(A.R*(A.kappa-1));
c_2 = (A.kappa+1)/A.kappa;
c_3 = sqrt( (A.kappa/A.R)*Bcr^((A.kappa+1)/A.kappa) );
c_5 = 2/A.kappa;
end
branches
G : A.G -> *;
Q : A.Q -> *;
end
equations
p1 == A.p;
T1 == A.T;
if p2/p1 > Bcr % Subsonic flow
G == Volume/A.R/T1^2 * (p1.der*T1 - p1*T1.der)+Area*p1*sqrt(c_1 /T1 * ( (p2/p1)^c_5 - (p2/p1)^c_2) );
else % Choked flow
G == Volume/A.R/T1^2 * (p1.der*T1 - p1*T1.der)+Area*p1*T1^-0.5*c_3;
end
Q == A.c_v * Volume / A.R * p1.der+G*A.c_p*T1;
end
end
p2 is the atmospheric pressure.
the domain is kind of similar to the pneumatic one.
Because of some reasons nothing happen to pressure and temperature at A at all. it stays constant at its value.
If this code isn't working at all that's fine for me. But i need some kind of solution to perform this problem with just one block. Has anybody an idea? Thanks in advanced

Respuesta aceptada

Cedric Götze
Cedric Götze el 21 de Jul. de 2015
It works by combining the different components in a Composite Component!

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by