From: a black on
hi, i am trying to simulate a rankine cycle in simulink for a paper i have. As far i have only seen pumps models so i decided to take it step by step, i tryied and created a very simple model of a water turbine where W = dp*q . My problem is that the model i created has p as a through variable and q as an across variable and i cant figure out how to connect it with the centrifigual pump. Can i connect them or should i create my own pump model and generally all the models i wll need ? turbine pump condenser and the boiler? I am very new to simulink and matlab so any advice will be valuable
From: Arnaud Miege on
"a black" <earedil88(a)gmail.com> wrote in message <i0mtg5$p33$1(a)fred.mathworks.com>...
> hi, i am trying to simulate a rankine cycle in simulink for a paper i have. As far i have only seen pumps models so i decided to take it step by step, i tryied and created a very simple model of a water turbine where W = dp*q . My problem is that the model i created has p as a through variable and q as an across variable and i cant figure out how to connect it with the centrifigual pump. Can i connect them or should i create my own pump model and generally all the models i wll need ? turbine pump condenser and the boiler? I am very new to simulink and matlab so any advice will be valuable

p (pressure) should the across variable, not the through variable, while q (flow rate) should be the through variable, not the across variable. This is because the algebraic sum of the through variables at a node is equal to zero, while two ports connected together have the same across variable (similar to Kirchoff's laws in electronics with voltage & current). Could you post the code of your Simscape file? Note that SimHydraulics (where the centrifugal pump comes from) does not include any thermal effects, the fluid properties (temperature, viscosity, etc...) are constant for the duration of the simulation and throughout the physical network.

HTH,

Arnaud
From: a black on
this is my code


component turb

nodes
k = foundation.hydraulic.hydraulic; % +:top
l = foundation.hydraulic.hydraulic; % -:bottom
end

parameters
density = { 1000 , 'kg/m^3' }; % Fluid density
q0 = {0 , 'm^3/s' }; % initial value for q
W = {0 , 'Pa*m^3/s'}; % power
end

variables
p = { 1000 , 'Pa' }; %pressure across
q = { 0.3 , 'm^3/s' }; %flow rate through
end

my problem is that when i make a simple example in simulink which includes a fixed displacement pump my model and 2 sensors one pressure sensor and one flow sensor the pressure sensor which counts the pressure before and after my model i get 0 pressure and i dont know why
function setup

across( p, k.p, l.p ); % across variable p from node k to node l
through( q, k.q, l.q ); % through variable q from k to l

end

equations
p == W/q; %equation
end

end

my problem
From: a black on
sorry for the previous message this is my code


component turb

nodes
k = foundation.hydraulic.hydraulic; % +:top
l = foundation.hydraulic.hydraulic; % -:bottom
end

parameters
density = { 1000 , 'kg/m^3' }; % Fluid density
q0 = {0 , 'm^3/s' }; % initial value for q
W = {0 , 'Pa*m^3/s'}; % power
end

variables
p = { 1000 , 'Pa' }; %pressure across
q = { 0.3 , 'm^3/s' }; %flow rate through
end


function setup

across( p, k.p, l.p ); % across variable p from node k to node l
through( q, k.q, l.q ); % through variable q from k to l

end

equations
p == W/q; %equation
end

end

my problem is that when i make a simple example in simulink which includes a fixed displacement pump my model and 2 sensors one pressure sensor and one flow sensor the pressure sensor which counts the pressure before and after my model i get 0 pressure and i dont know why
From: Arnaud Miege on
"a black" <earedil88(a)gmail.com> wrote in message <i1kcd6$k3r$1(a)fred.mathworks.com>...
> sorry for the previous message this is my code
>
>
> component turb
>
> nodes
> k = foundation.hydraulic.hydraulic; % +:top
> l = foundation.hydraulic.hydraulic; % -:bottom
> end
>
> parameters
> density = { 1000 , 'kg/m^3' }; % Fluid density
> q0 = {0 , 'm^3/s' }; % initial value for q
> W = {0 , 'Pa*m^3/s'}; % power
> end
>
> variables
> p = { 1000 , 'Pa' }; %pressure across
> q = { 0.3 , 'm^3/s' }; %flow rate through
> end
>
>
> function setup
>
> across( p, k.p, l.p ); % across variable p from node k to node l
> through( q, k.q, l.q ); % through variable q from k to l
>
> end
>
> equations
> p == W/q; %equation
> end
>
> end
>
> my problem is that when i make a simple example in simulink which includes a fixed displacement pump my model and 2 sensors one pressure sensor and one flow sensor the pressure sensor which counts the pressure before and after my model i get 0 pressure and i dont know why

The code looks OK. In fact it is very similar to the linear hydraulic resistance block from the Simscape foundation library. I suspect it's the rest of the model that is not correct, either you have not connected the sensors correctly or the model is put together such as there is no path for the flow to go. A pressure sensor needs to be connected in parallel (because pressure is an across variable) whereas a flow rate sensor needs to be connected in series (because flow rate is a through variable).

With regards to the Simscape code, I will make the following suggestions for improvement:
1) with the code as is, you are going to have numerical problems around zero flow (divide by zero). I would do something a liner interpolation around zero flow, for example:
if abs(q)<q_thresh
p == (W/q_thresh^2)*q;
else
p == W/q;
end
where q_thresh is a parameter:
q_thresh = { 1e-3, 'm^3/s'}; % Flow rate threshold

2) You can only initialise q with q0 (in the setup function) if q is a differential variable, i.e. if q.der appears somewhere in the equations, otherwise it doesn't make sense.

3) Density is a domain-wide parameter, you can inherit it from the node properties.
Define it as a private parameter:
parameters (Access = private)
density = { 1000 , 'kg/m^3'};
end
and then in the setup function, overwrite the value with the value of the domainw-die parameter:
density = k.density;

4) You probably want to do some parameter checking in the setup function, for example checking that W>0 and q_thresh>0, otherwise they can cause numerical problems.

HTH,

Arnaud