Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a valve model #59

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions OpenHPL/ElectroMech/BaseClasses/BaseValve.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
within OpenHPL.ElectroMech.BaseClasses;
partial model BaseValve "Simple hydraulic valve (base class)"
outer Data data "Using standard class with global parameters";
extends OpenHPL.Interfaces.ContactPort;

parameter Boolean ValveCapacity = true "If checked the valve capacity C_v should be specified,
otherwise specify the nominal values (net head and flow rate)"
annotation (Dialog(group = "Nominal values"), choices(checkBox = true));
parameter Real C_v = 1 "Guide vane 'valve capacity'"
annotation (Dialog(group = "Nominal values", enable = ValveCapacity));
parameter SI.Height H_n = 100 "Nominal net head"
annotation (Dialog(group = "Nominal values", enable = not ValveCapacity));
parameter SI.VolumeFlowRate Vdot_n = 3 "Nominal flow rate"
annotation (Dialog(group = "Nominal values", enable = not ValveCapacity));
parameter SI.PerUnit u_n = 0.95 "Nominal guide vane opening"
annotation (Dialog(group = "Nominal values", enable = not ValveCapacity));
parameter Boolean ConstEfficiency = true "If checked the constant efficiency eta_h is used,
otherwise specify lookup table for efficiency"
annotation (Dialog(group = "Efficiency data"), choices(checkBox = true));
parameter SI.Efficiency eta_h = 0.9 "Hydraulic efficiency"
annotation (Dialog(group = "Efficiency data", enable = ConstEfficiency));
parameter Real lookup_table[:, :] = [0, 0.4; 0.2, 0.7; 0.5, 0.9; 0.95, 0.95; 1.0, 0.93]
"Look-up table for the turbine efficiency, described by a table matrix,
where the first column is a pu value of the guide vane opening,
and the second column is a pu value of the turbine efficiency."
annotation (Dialog(group = "Efficiency data", enable = not ConstEfficiency));
parameter Boolean WaterCompress = false "If checked, the water is compressible"
annotation (Dialog(tab = "Advanced"), choices(checkBox = true));

SI.Pressure dp "Pressure drop";
SI.EnergyFlowRate Kdot_i_tr "Kinetic energy flow";
SI.VolumeFlowRate Vdot "Flow rate";
Real C_v_ "Valve capacity";

output SI.EnergyFlowRate Wdot_s "Valve power";
Modelica.Blocks.Tables.CombiTable1Dv look_up_table(table=lookup_table);
protected
Modelica.Blocks.Interfaces.RealInput u(min=0, max=1)
"=1: completely open, =0: completely closed"
annotation (Placement(transformation(
origin={0,70},
extent={{-10,-10},{10,10}},
rotation=270), iconTransformation(
extent={{-20,-20},{20,20}},
rotation=270,
origin={0,80})));
equation
Vdot = if WaterCompress then mdot / (data.rho * (1 + data.beta * (i.p - data.p_a))) else mdot / data.rho
"Checking for water compressibility";
look_up_table.u[1] = u "Link the valve opening";
C_v_ = if ValveCapacity then C_v else Vdot_n/sqrt(H_n*data.g*data.rho/data.p_a)/u_n
"Define 'valve capacity' base on the nominal values";
dp = Vdot ^ 2 * data.p_a / (C_v_ * max(1e-6, u)) ^ 2 "Valve equation for pressure drop";
dp = i.p - o.p "Link the pressure drop to the ports";
Kdot_i_tr = dp * Vdot "Energy balance";
if ConstEfficiency then
Wdot_s = eta_h * Kdot_i_tr;
else
Wdot_s = look_up_table.y[1] * Kdot_i_tr;
end if;

annotation (
Documentation(info="<html><p>
This is a simple model of hydraulic valve.
The model can use a constant efficiency or varying
efficiency from a lookup-table.
</p>
<p>
This model is based on the energy balance of a valve.
The valve capacity can either be specified
directly by the user by specifying <code>C_v</code> or it will be calculated from
the nominal head <code>H_n</code> and nominal flow rate <code>Vdot_n</code>.
</p>
<p>
The valve efficiency is in per-unit values from 0 to 1, where 1 means that there are no losses in the valve.
The valve power is defined as the product of the valve power and valve efficiency.
</p>
<p>
Besides hydraulic input and output,
there is an input <code>u</code> for controlling the valve opening.
</p>
</html>"));
end BaseValve;
1 change: 1 addition & 0 deletions OpenHPL/ElectroMech/BaseClasses/package.order
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Power2Torque
BaseValve
64 changes: 9 additions & 55 deletions OpenHPL/ElectroMech/Turbines/Turbine.mo
Original file line number Diff line number Diff line change
@@ -1,67 +1,21 @@
within OpenHPL.ElectroMech.Turbines;
model Turbine "Simple turbine model with mechanical connectors"
outer Data data "Using standard class with global parameters";
extends Icons.Turbine;

parameter Boolean ValveCapacity = true "If checked the guide vane capacity C_v should be specified,
otherwise specify the nominal turbine parameters (net head and flow rate)"
annotation (Dialog(group = "Nominal turbine parameters"), choices(checkBox = true));
parameter Real C_v = 3.7 "Guide vane 'valve capacity'"
annotation (Dialog(group = "Nominal turbine parameters", enable = ValveCapacity));
parameter SI.Height H_n = 460 "Nominal net head"
annotation (Dialog(group = "Nominal turbine parameters", enable = not ValveCapacity));
parameter SI.VolumeFlowRate Vdot_n = 23.4 "Nominal flow rate"
annotation (Dialog(group = "Nominal turbine parameters", enable = not ValveCapacity));
parameter SI.PerUnit u_n = 0.95 "Nominal guide vane opening"
annotation (Dialog(group = "Nominal turbine parameters", enable = not ValveCapacity));
parameter Boolean ConstEfficiency = true "If checked the constant efficiency eta_h is used,
otherwise specify lookup table for efficiency"
annotation (Dialog(group = "Efficiency data"), choices(checkBox = true));
parameter SI.Efficiency eta_h = 0.9 "Turbine hydraulic efficiency"
annotation (Dialog(group = "Efficiency data", enable = ConstEfficiency));
parameter Real lookup_table[:, :] = [0, 0.4; 0.2, 0.7; 0.5, 0.9; 0.95, 0.95; 1.0, 0.93]
"Look-up table for the turbine efficiency, described by a table matrix,
where the first column is a pu value of the guide vane opening,
and the second column is a pu value of the turbine efficiency."
annotation (Dialog(group = "Efficiency data", enable = not ConstEfficiency));
parameter Boolean WaterCompress = false "If checked the water is compressible in the penstock"
annotation (Dialog(tab = "Advanced"), choices(checkBox = true));

extends BaseClasses.BaseValve;
extends BaseClasses.Power2Torque(power(y=Wdot_s));
extends OpenHPL.Interfaces.TurbineContacts;

SI.Pressure dp "Turbine pressure drop";
SI.EnergyFlowRate Kdot_i_tr "Kinetic energy flow";
SI.VolumeFlowRate Vdot "Flow rate";
Real C_v_ "Guide vane 'valve capacity'";
extends Interfaces.TurbineContacts;
extends Icons.Turbine;

output SI.EnergyFlowRate Wdot_s "Shaft power";
Modelica.Blocks.Tables.CombiTable1Dv look_up_table(table=lookup_table);
Modelica.Blocks.Math.Feedback lossCorrection annotation (Placement(transformation(extent={{-10,70},{10,90}})));
Modelica.Blocks.Math.Feedback lossCorrection annotation (Placement(transformation(extent={{-50,70},{-30,90}})));
equation
Vdot = if WaterCompress then mdot / (data.rho * (1 + data.beta * (i.p - data.p_a))) else mdot / data.rho
"Checking for water compressibility";
look_up_table.u[1] = u_t "Link the guide vane opening";
C_v_ = if ValveCapacity then C_v else Vdot_n/sqrt(H_n*data.g*data.rho/data.p_a)/u_n
"Define guide vane 'valve capacity' base on the Nominal turbine parameters";
dp = Vdot ^ 2 * data.p_a / (C_v_ * max(1e-6, u_t)) ^ 2 "Turbine valve equation for pressure drop";
dp = i.p - o.p "Link the pressure drop to the ports";
Kdot_i_tr = dp * Vdot "Turbine energy balance";
if ConstEfficiency then
Wdot_s = eta_h * Kdot_i_tr;
else
Wdot_s = look_up_table.y[1] * Kdot_i_tr;
end if;

/* // for temperature variation, not finished...
i.T = o.T; */

connect(P_out, lossCorrection.y) annotation (Line(
points={{40,110},{40,80},{9,80}},
points={{40,110},{40,80},{-31,80}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(lossCorrection.u1, power.y) annotation (Line(points={{-8,80},{-88,80},{-88,30},{-81,30}}, color={0,0,127}));
connect(frictionLoss.power, lossCorrection.u2) annotation (Line(points={{-1,12},{0,12},{0,72}}, color={0,0,127}));
connect(lossCorrection.u1, power.y) annotation (Line(points={{-48,80},{-88,80},{-88,30},{-81,30}},color={0,0,127}));
connect(frictionLoss.power, lossCorrection.u2) annotation (Line(points={{-1,12},{-40,12},{-40,72}},
color={0,0,127}));
connect(u_t, u) annotation (Line(points={{-80,120},{-80,90},{0,90},{0,70}}, color={0,0,127}));
annotation (
Documentation(info="<html><p>
This is a simple model of the turbine that give possibilities for simplified
Expand Down
5 changes: 0 additions & 5 deletions OpenHPL/Examples/Detailed.mo

This file was deleted.

6 changes: 6 additions & 0 deletions OpenHPL/Examples/DetailedTurbine.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
within OpenHPL.Examples;
model DetailedTurbine "Hydropower system using KP scheme based penstock"
extends SimpleTurbine(
redeclare Waterway.PenstockKP penstock);
annotation (experiment(StopTime=1000));
end DetailedTurbine;
3 changes: 2 additions & 1 deletion OpenHPL/Examples/SimpleGen.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
within OpenHPL.Examples;
model SimpleGen "Model of a hydropower system with a simple turbine turbine and generator"
extends Simple(turbine(
extends SimpleTurbine(
turbine(
enable_nomSpeed=false,
enable_P_out=true));
ElectroMech.Generators.SimpleGen simpleGen annotation (Placement(transformation(extent={{20,50},{40,70}})));
Expand Down
24 changes: 14 additions & 10 deletions OpenHPL/Examples/Simple.mo → OpenHPL/Examples/SimpleTurbine.mo
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
within OpenHPL.Examples;
model Simple "Model of a hydropower system with a simple turbine turbine"
model SimpleTurbine "Model of a hydropower system with a simple turbine turbine"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(
OpenHPL.Waterway.Reservoir reservoir(h_0=10) annotation (Placement(transformation(
origin={-90,30},
extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Ramp control(
duration=30, height = -0.04615, offset = 0.7493,
duration=30,
height=-0.9,
offset=1,
startTime=500) annotation (
Placement(transformation(origin={-10,70}, extent = {{-10, -10}, {10, 10}})));
OpenHPL.Waterway.Pipe intake(H=23, Vdot(fixed = true)) annotation (Placement(transformation(extent={{-70,20},{-50,40}})));
OpenHPL.Waterway.Pipe intake(H=10, Vdot(fixed = true)) annotation (Placement(transformation(extent={{-70,20},{-50,40}})));
OpenHPL.Waterway.Pipe discharge(H=0.5, L=600) annotation (Placement(transformation(extent={{50,-10},{70,10}})));
OpenHPL.Waterway.Reservoir tail(h_0=5) annotation (Placement(transformation(
origin={90,0},
Expand All @@ -17,18 +19,20 @@ model Simple "Model of a hydropower system with a simple turbine turbine"
replaceable OpenHPL.Waterway.Pipe penstock(
D_i=3,
D_o=3,
H=428.5,
L=600,
H=80,
L=200,
vertical=true) constrainedby Interfaces.TwoContact annotation (Placement(transformation(origin={0,30}, extent={{-10,-10},{10,10}})));
OpenHPL.Waterway.SurgeTank surgeTank(h_0=69.9) annotation (Placement(transformation(
OpenHPL.Waterway.SurgeTank surgeTank(h_0=20) annotation (Placement(transformation(
origin={-30,30},
extent={{-10,-10},{10,10}})));
ElectroMech.Turbines.Turbine turbine(C_v=3.7, ConstEfficiency=false, enable_nomSpeed=true,
ElectroMech.Turbines.Turbine turbine(
ValveCapacity=false, ConstEfficiency=false, enable_nomSpeed=true,
enable_f=false)
annotation (Placement(transformation(
origin={30,10},
extent={{-10,-10},{10,10}})));
inner OpenHPL.Data data annotation (Placement(transformation(
inner OpenHPL.Data data(Vdot_0=3)
annotation (Placement(transformation(
origin={-90,90},
extent={{-10,-10},{10,10}})));
equation
Expand All @@ -43,4 +47,4 @@ equation
connect(surgeTank.o, penstock.i) annotation (Line(points={{-20,30},{-10,30}}, color={28,108,200}));
connect(discharge.o, tail.o) annotation (Line(points={{70,0},{80,0}}, color={28,108,200}));
annotation (experiment(StopTime=1000));
end Simple;
end SimpleTurbine;
57 changes: 57 additions & 0 deletions OpenHPL/Examples/SimpleValve.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
within OpenHPL.Examples;
model SimpleValve "Model of a hydropower system with a simple turbine turbine"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=10) annotation (Placement(transformation(
origin={-90,30},
extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Ramp control(
duration=30,
height=-0.9,
offset=1,
startTime=500) annotation (
Placement(transformation(origin={-10,70}, extent = {{-10, -10}, {10, 10}})));
OpenHPL.Waterway.Pipe intake(H=10, Vdot(fixed = true)) annotation (Placement(transformation(extent={{-70,20},{-50,40}})));
OpenHPL.Waterway.Pipe discharge(H=0.5, L=600) annotation (Placement(transformation(extent={{50,20},{70,40}})));
OpenHPL.Waterway.Reservoir tail(h_0=5) annotation (Placement(transformation(
origin={90,30},
extent={{-10,10},{10,-10}},
rotation=180)));
replaceable OpenHPL.Waterway.Pipe penstock(
D_i=3,
D_o=3,
H=80,
L=200,
vertical=true) constrainedby Interfaces.TwoContact annotation (Placement(transformation(origin={0,30}, extent={{-10,-10},{10,10}})));
OpenHPL.Waterway.SurgeTank surgeTank(
H=30,
L=30,
h_0=20) annotation (Placement(transformation(
origin={-30,30},
extent={{-10,-10},{10,10}})));
inner OpenHPL.Data data(Vdot_0=3)
annotation (Placement(transformation(
origin={-90,90},
extent={{-10,-10},{10,10}})));
Waterway.Valve valve(
ValveCapacity=false,
C_v=1,
ConstEfficiency=false,
WaterCompress=false) annotation (Placement(transformation(extent={{20,20},{40,40}})));
equation
connect(reservoir.o, intake.i) annotation (
Line(points={{-80,30},{-70,30}}, color = {28, 108, 200}));
connect(intake.o, surgeTank.i) annotation (
Line(points={{-50,30},{-40,30}}, color = {28, 108, 200}));
connect(surgeTank.o, penstock.i) annotation (Line(points={{-20,30},{-10,30}}, color={28,108,200}));
connect(discharge.o, tail.o) annotation (Line(points={{70,30},{80,30}},
color={28,108,200}));
connect(penstock.o, valve.i) annotation (Line(points={{10,30},{20,30}}, color={0,128,255}));
connect(valve.o, discharge.i) annotation (Line(points={{40,30},{50,30}}, color={0,128,255}));
connect(control.y, valve.opening) annotation (Line(points={{1,70},{30,70},{30,38}}, color={0,0,127}));
annotation (experiment(StopTime=1000), Documentation(info="<html>
<p>
Simple model of a water way with only a valve component.
This can be used to investigate the effect of different opening and closing times in the waterway.
</p>
</html>"));
end SimpleValve;
5 changes: 3 additions & 2 deletions OpenHPL/Examples/package.order
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
BranchingPipes
Simple
SimpleValve
SimpleTurbine
SimpleGen
SimpleGenFrancis
Detailed
DetailedTurbine
DetailedGen
DetailedGenFrancis
PowerSystemSimple
Expand Down
35 changes: 35 additions & 0 deletions OpenHPL/Icons/Valve.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
within OpenHPL.Icons;
partial class Valve "Valve icon"
annotation (
Icon(graphics={
Text(
lineColor={28,108,200},
extent={{-100,-60},{100,-100}},
textString="%name",
textStyle={TextStyle.Bold},
visible=vertical),
Polygon(
points={{-90,40},{0,10},{90,40},{90,30},{0,0},{-90,30},{-90,40}},
lineColor={0,0,0},
fillColor={175,175,175},
fillPattern=FillPattern.Solid),
Polygon(
points={{-90,-30},{0,0},{90,-30},{90,-40},{0,-10},{-90,-40},{-90,-30}},
lineColor={0,0,0},
fillColor={175,175,175},
fillPattern=FillPattern.Solid),
Polygon(
points={{-90,-30},{-90,30},{0,0},{-90,-30}},
lineColor={0,128,255},
fillColor={0,128,255},
fillPattern=FillPattern.Solid),
Polygon(
points={{90,-30},{90,30},{0,0},{90,-30}},
lineColor={0,128,255},
fillColor={0,128,255},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-20,60},{20,50}},
fillPattern=FillPattern.Solid),
Line(points={{0,50},{0,0}})}));
end Valve;
1 change: 1 addition & 0 deletions OpenHPL/Icons/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ BendPipe
Surge
Fitting
DraftTube
Valve
OpenChannel
ElectroMech
Turbine
Expand Down
4 changes: 2 additions & 2 deletions OpenHPL/Interfaces/TurbineContacts.mo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
within OpenHPL.Interfaces;
partial model TurbineContacts "Model of turbine connectors"
extends Interfaces.ContactPort;
parameter Boolean enable_P_out = false "If checked, get a connector for the output power"
annotation (choices(checkBox = true), Dialog(group="Outputs",tab="I/O"));
input Modelica.Blocks.Interfaces.RealInput u_t "[Guide vane|nozzle] opening of the turbine" annotation (Placement(transformation(
input Modelica.Blocks.Interfaces.RealInput u_t "[Guide vane|nozzle] opening of the turbine(=1: completely open, =0: completely closed)"
annotation (Placement(transformation(
extent={{-20,-20},{20,20}},
rotation=-90,
origin={-80,120}), iconTransformation(
Expand Down
Loading