Discussion:
help in simscape
(too old to reply)
a black
2010-07-03 08:48:05 UTC
Permalink
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
Arnaud Miege
2010-07-13 15:37:14 UTC
Permalink
Post by a black
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
a black
2010-07-14 12:52:05 UTC
Permalink
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
a black
2010-07-14 13:00:22 UTC
Permalink
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
Arnaud Miege
2010-07-14 14:45:11 UTC
Permalink
Post by a black
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
a black
2010-07-17 17:43:06 UTC
Permalink
i did what u suggested and the model run!!!! thank you very much.I ve got one more question. can i add a new domain in an existing model of simulink for example the pump model is in the hydraulic domain can i add the thermal domain in the existing pump model and have 4 nodes 2 for hydraulic and another 2 for the thermal ? or should i create a new model? and if i cant can i inherit the properties of the pump model (cause i have seen in a tutorial tha i can inherit) i am just asking because they have the source code locked...

thanx for the valuable advices ...
Arnaud Miege
2010-07-20 10:42:03 UTC
Permalink
Post by a black
i did what u suggested and the model run!!!! thank you very much.I ve got one more question. can i add a new domain in an existing model of simulink for example the pump model is in the hydraulic domain can i add the thermal domain in the existing pump model and have 4 nodes 2 for hydraulic and another 2 for the thermal ? or should i create a new model? and if i cant can i inherit the properties of the pump model (cause i have seen in a tutorial tha i can inherit) i am just asking because they have the source code locked...
thanx for the valuable advices ...
Most of the Simscape foundation blocks ship with the Simscape source code, so you can create your own version of these. However, this isn't the case for the add-on products such as SimHydraulics, so if you want to create your own pump model, then you'd have to start from scratch (having said that the equations are provided in the documentation).

Either way, with regards to thermal effects, there are two scenarios:
* you create a *new* physical domain where each port has both thermal and hydraulic characteristics, with 2 through (mass flow rate and heat flow) and 2 across variables (pressure and temperature), in which case you need re-create a new library of all the blocks you need in that domain.
* you create a new block, with ports from different *existing* domains, e.g. 2 hydraulic and 2 thermal ports. This doesn't require the definition of a new domain, and you may be able to re-use some of the existing source code from the Simscape foundation library. You would have to couple the thermal and hydraulic variables somehow, but the hydraulic ports would only account for flow/pressure (and not thermal) characteristics and the thermal ports would only account for thermal (and not hydraulic flow) effects. Have a look at the rotational or translational electro-mechanical converter for examples of blocks which spans multiple domains.

These are two completely different things.

HTH,

Arnaud
a black
2010-07-23 08:52:06 UTC
Permalink
if i follow the first scenario should i create a new domain or i can just follow the pneumatic domain and programm what i ll need for the simulation of the cycle? because i will use pressure temperature and mass flow and heat flow and as far as i know pneumatic uses the same variables ?
Arnaud Miege
2010-08-09 15:41:04 UTC
Permalink
Post by a black
if i follow the first scenario should i create a new domain or i can just follow the pneumatic domain and programm what i ll need for the simulation of the cycle? because i will use pressure temperature and mass flow and heat flow and as far as i know pneumatic uses the same variables ?
I think you will need to create a new domain, because although the through and across variables are the same, the domain parameters (i.e. how you approximate the fluid properties), will be different between (ideal) gases and fluids.

HTH,

Arnaud
Jeff
2012-11-12 03:22:05 UTC
Permalink
Post by a black
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
Loading...