Skip to content
Merged
3 changes: 3 additions & 0 deletions OpenHPL/Data.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
within OpenHPL;
record Data "Provides a data set of most common used settings"
extends Modelica.Icons.Record;
parameter Boolean showElevation=true "Display elevation of connectors"
annotation(Dialog(group = "Icon"),
choices(checkBox = true));
parameter SI.Acceleration g = Modelica.Constants.g_n "Gravity constant"
annotation (Dialog(enable=false, group = "Constants"));
parameter Real gamma_air = 1.4 "Ratio of heat capacities at constant pressure (C_p) to constant volume (C_v) for air at STP"
Expand Down
1 change: 1 addition & 0 deletions OpenHPL/ElectroMech/BaseClasses/BaseValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ equation
Vdot = mdot/data.rho;
dp*(C_v_*max(epsilon, u^alpha))^2 = Vdot*abs(Vdot) "Valve equation for pressure drop";
dp = i.p - o.p "Link the pressure drop to the ports";
o.elevation.z = i.elevation.z "Elevation propagation: no height change across valve";
annotation (preferredView="info", Documentation(info="<html>
<p>
This is a partial, simple model of hydraulic valve. &nbsp;</p><p>This model is based on the energy balance of a valve.
Expand Down
2 changes: 2 additions & 0 deletions OpenHPL/ElectroMech/Turbines/Francis.mo
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ model Francis "Model of the Francis turbine"
Real W_t2_n "Euler second term, nominal", W_t1_n "Euler first term, nominal", Wdot_t_n "Total power, nominal", cot_a1_n "Cotant nominal alpha", Vdot_n_ = Vdot_n / 0.99 "Flow rate for fully open guide vane", d_n(start = 0.67) "Nominal servo term", theta_n "Servo angle for fully open guide vane";
SI.Angle alpha1_n "Nominal inlet guide vane angle";
// connectors
extends OpenHPL.Interfaces.TwoContacts;
extends OpenHPL.Interfaces.TurbineContacts(enable_P_out=true);
Modelica.Blocks.Interfaces.RealInput w_in "Input angular velocity from the generator" annotation (
Placement(transformation(origin={-120,-80}, extent={{-20,-20},
Expand Down Expand Up @@ -210,6 +211,7 @@ equation
p_tr2 = o.p;
i.mdot+o.mdot=0;
mdot=i.mdot;
o.elevation.z = i.elevation.z "Elevation propagation: no height change across turbine";

connect(p_out, P_out) annotation (Line(points={{40,90},{40,110}}, color={0,0,127}));
annotation (preferredView="info",
Expand Down
2 changes: 2 additions & 0 deletions OpenHPL/ElectroMech/Turbines/Pelton.mo
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ model Pelton "Model of the Pelton turbine"
SI.AngularVelocity w=w_in "Angular velocity";
Real cos_b = Modelica.Math.cos(Modelica.Units.Conversions.from_deg(beta));
// connectors
extends OpenHPL.Interfaces.TwoContacts;
extends OpenHPL.Interfaces.TurbineContacts(enable_P_out=true);
Modelica.Blocks.Interfaces.RealInput w_in "Input angular velocity from the generator" annotation (
Placement(transformation(origin={-120,-80}, extent={{-20,-20},
Expand Down Expand Up @@ -54,6 +55,7 @@ equation
// Flow rate connectors
i.mdot+o.mdot=0;
mdot=i.mdot;
o.elevation.z = i.elevation.z "Elevation propagation: no height change across turbine";

connect(p_out, P_out) annotation (Line(points={{40,90},{40,110}}, color={0,0,127}));
annotation (preferredView="info",
Expand Down
18 changes: 9 additions & 9 deletions OpenHPL/Examples/BranchingPipes.mo
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
within OpenHPL.Examples;
model BranchingPipes "Model of branching pipes"
extends Modelica.Icons.Example;
Waterway.Reservoir reservoir annotation (
Waterway.Reservoir reservoir(fixElevation = true, z_0 = 3) annotation (
Placement(transformation(extent = {{-80, -10}, {-60, 10}})));
Waterway.Pipe mainPipe(D_i = 6, H = 1, L = 100) annotation (
Placement(transformation(extent = {{-52, -10}, {-32, 10}})));
Waterway.Reservoir reservoir1 annotation (
Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {70, 0})));
Waterway.Pipe branch1(D_i = 3, H = 1, L = 100, Vdot_0 = data.Vdot_0/2) annotation (
Placement(transformation(extent = {{-10, 10}, {10, 30}})));
Waterway.Pipe branch2(D_i = 3, H = 1, L = 100, Vdot_0 = data.Vdot_0/2) annotation (
Waterway.Pipe branch2(D_i = 3, H = 1, L = 100, Vdot_0 = data.Vdot_0/2) annotation(
Placement(transformation(extent = {{-10, -30}, {10, -10}})));
Waterway.Pipe mainPipeOut(D_i = 5, H = 1, L = 100) annotation (
Placement(transformation(extent = {{30, -10}, {50, 10}})));
inner Data data(SteadyState = true, Vdot_0 = 75) annotation (
Placement(transformation(extent = {{-100, 80}, {-80, 100}})));
equation
connect(reservoir.o, mainPipe.i) annotation (
connect(reservoir.o, mainPipe.i) annotation(
Line(points = {{-60, 0}, {-52, 0}}, color = {28, 108, 200}));
connect(branch1.i, mainPipe.o) annotation (
connect(branch1.i, mainPipe.o) annotation(
Line(points = {{-10, 20}, {-20, 20}, {-20, 0}, {-32, 0}}, color = {28, 108, 200}));
connect(mainPipe.o, branch2.i) annotation (
connect(mainPipe.o, branch2.i) annotation(
Line(points = {{-32, 0}, {-20, 0}, {-20, -20}, {-10, -20}}, color = {28, 108, 200}));
connect(branch2.o, mainPipeOut.i) annotation (
connect(branch2.o, mainPipeOut.i) annotation(
Line(points = {{10, -20}, {20, -20}, {20, 0}, {30, 0}}, color = {28, 108, 200}));
connect(branch1.o, mainPipeOut.i) annotation (
connect(branch1.o, mainPipeOut.i) annotation(
Line(points = {{10, 20}, {20, 20}, {20, 0}, {30, 0}}, color = {28, 108, 200}));
connect(mainPipeOut.o, reservoir1.o) annotation (
connect(mainPipeOut.o, reservoir1.o) annotation(
Line(points = {{50, 0}, {60, 0}}, color = {0, 128, 255}));
annotation (
experiment(StopTime = 2000, StartTime = 0, Tolerance = 0.0001, Interval = 0.4));
end BranchingPipes;
end BranchingPipes;
4 changes: 2 additions & 2 deletions OpenHPL/Examples/DetailedTurbine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ within OpenHPL.Examples;
model DetailedTurbine "Hydropower system using KP scheme based penstock"
extends SimpleTurbine(
redeclare Waterway.PenstockKP penstock);
annotation (experiment(StopTime=1000));
end DetailedTurbine;
annotation (experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2));
end DetailedTurbine;
10 changes: 5 additions & 5 deletions OpenHPL/Examples/Gate.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
within OpenHPL.Examples;
model Gate "Usage of the tainter gate"
extends Modelica.Icons.Example;
inner Data data(SteadyState = true, Vdot_0 = 75) annotation (
inner Data data(SteadyState = true, Vdot_0 = 75, showElevation = false) annotation (
Placement(transformation(extent = {{-100, 80}, {-80, 100}})));
Modelica.Blocks.Sources.Ramp gateOpening(
height=0,
Expand All @@ -12,7 +12,7 @@ model Gate "Usage of the tainter gate"
constantLevel=false,
useLevel=true,
L=10,
W=10) annotation (Placement(transformation(extent={{-40,40},{-20,60}})));
W=10, fixElevation = true) annotation (Placement(transformation(extent={{-40,40},{-20,60}})));
Waterway.Reservoir downstream(
h_0=4,
constantLevel=false,
Expand All @@ -32,7 +32,7 @@ model Gate "Usage of the tainter gate"
constantLevel=false,
useLevel=true,
L=10,
W=10) annotation (Placement(transformation(extent={{-40,-10},{-20,10}})));
W=10, fixElevation = true) annotation (Placement(transformation(extent={{-40,-10},{-20,10}})));
Waterway.Reservoir downstream1(
h_0=4,
constantLevel=false,
Expand All @@ -51,7 +51,7 @@ model Gate "Usage of the tainter gate"
constantLevel=false,
useLevel=true,
L=10,
W=10) annotation (Placement(transformation(extent={{-40,-60},{-20,-40}})));
W=10, fixElevation = true) annotation (Placement(transformation(extent={{-40,-60},{-20,-40}})));
Waterway.Reservoir downstream2(
h_0=4,
constantLevel=false,
Expand Down Expand Up @@ -91,4 +91,4 @@ equation
connect(upstream2.level, up_level.y) annotation (Line(points={{-42,-44},{-52,-44},{-52,0},{-59,0}}, color={0,0,127}));
annotation (
experiment(StopTime=2000, Interval=0.4));
end Gate;
end Gate;
12 changes: 6 additions & 6 deletions OpenHPL/Examples/Pipes.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ model Pipes "Example of contracting, contstant and expanding pipe diameters"
inner OpenHPL.Data data annotation (
Placement(transformation(origin={-90,90}, extent={{-10,-10},{10,10}})));
parameter SI.Diameter Dn=0.3568 "Nominal Diameter";
Waterway.Reservoir Upstream(h_0 = 100.0, constantLevel=true)
Waterway.Reservoir Upstream(h_0 = 100.0, constantLevel=true, fixElevation = true, z_0 = 10)
annotation (
Placement(transformation(origin={-50,0}, extent={{-10,-10},{10,10}})));
Waterway.Reservoir Downstream(h_0 = 0.0, constantLevel=true)
Waterway.Reservoir Downstream(h_0 = 0.0, constantLevel=true, fixElevation = false)
annotation (
Placement(transformation(origin={50,0}, extent={{10,-10},{-10,10}}, rotation = -0)));
OpenHPL.Waterway.Pipe pipeExpanding(
D_i=0.8*Dn,
D_o=1.2*Dn,
H=0,
H= 10,
L=1000) annotation (Placement(transformation(origin={0,20}, extent={{-10,-10},{10,10}})));
OpenHPL.Waterway.Pipe pipeConstant(
D_i=Dn,
D_o=Dn,
H=0,
H= 10,
L=1000) annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
OpenHPL.Waterway.Pipe pipeContracting(
D_i=1.2*Dn,
D_o=0.8*Dn,
H=0,
H= 10,
L=1000) annotation (Placement(transformation(origin={0,-20}, extent={{-10,-10},{10,10}})));

equation
Expand All @@ -36,4 +36,4 @@ equation
connect(pipeContracting.o, Downstream.o) annotation (Line(points={{10,-20},{30,-20},{30,0},{40,0}}, color={0,128,255}));
annotation (
experiment(StartTime = 0, StopTime = 100, Tolerance = 1e-06, Interval = 0.02));
end Pipes;
end Pipes;
8 changes: 3 additions & 5 deletions OpenHPL/Examples/SimpleGen.mo
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
within OpenHPL.Examples;
model SimpleGen "Model of a hydropower system with a simple turbine turbine and generator"
extends SimpleTurbine(
turbine(
enable_nomSpeed=false,
enable_P_out=true));
turbine(enable_nomSpeed = false, enable_P_out = true), reservoir(fixElevation = true, z_0 = 100));
ElectroMech.Generators.SimpleGen simpleGen annotation (Placement(transformation(extent={{20,50},{40,70}})));
Modelica.Blocks.Math.Gain loadLevel(k=1) annotation (Placement(transformation(extent={{72,70},{52,90}})));
equation
Expand All @@ -12,5 +10,5 @@ equation
connect(simpleGen.flange, turbine.flange) annotation (Line(
points={{30,60},{30,10}},
color={0,0,0}));
annotation (experiment(StopTime=1000));
end SimpleGen;
annotation (experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2));
end SimpleGen;
8 changes: 4 additions & 4 deletions OpenHPL/Examples/SimpleGenFrancis.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
within OpenHPL.Examples;
model SimpleGenFrancis "Model of a hydropower system with Francis turbine model"
extends Modelica.Icons.Example;
Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(
Waterway.Reservoir reservoir(h_0 = 48, fixElevation = true) annotation (Placement(transformation(
origin={-90,50},
extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Ramp control(
Expand Down Expand Up @@ -57,7 +57,7 @@ model SimpleGenFrancis "Model of a hydropower system with Francis turbine model"
annotation (Placement(transformation(
origin={30,0},
extent={{-10,-10},{10,10}})));
inner OpenHPL.Data data(Vdot_0=4.54) annotation (Placement(transformation(
inner OpenHPL.Data data(SteadyState = false) annotation (Placement(transformation(
origin={-90,90},
extent={{-10,-10},{10,10}})));
Waterway.Fitting fitting(
Expand Down Expand Up @@ -86,5 +86,5 @@ equation
Line(points={{80,6.66134e-16},{80,0},{70,0}}, color = {28, 108, 200}));
connect(penstock.o, fitting.i) annotation (
Line(points={{-20,0},{-12,0}}, color = {28, 108, 200}));
annotation (experiment(StopTime=1000));
end SimpleGenFrancis;
annotation (experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2));
end SimpleGenFrancis;
6 changes: 3 additions & 3 deletions OpenHPL/Examples/SimpleTurbine.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
within OpenHPL.Examples;
model SimpleTurbine "Model of a hydropower system with a simple turbine turbine"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=10) annotation (Placement(transformation(
OpenHPL.Waterway.Reservoir reservoir(h_0 = 10, fixElevation = true, z_0 = 100) annotation (Placement(transformation(
origin={-90,30},
extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Ramp control(
Expand Down Expand Up @@ -45,5 +45,5 @@ equation
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,0},{80,0}}, color={28,108,200}));
annotation (experiment(StopTime=1000));
end SimpleTurbine;
annotation (experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2));
end SimpleTurbine;
6 changes: 3 additions & 3 deletions OpenHPL/Examples/SimpleValve.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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(
OpenHPL.Waterway.Reservoir reservoir(h_0 = 10, fixElevation = true, z_0 = 100) annotation (Placement(transformation(
origin={-90,30},
extent={{-10,-10},{10,10}})));
Modelica.Blocks.Sources.Ramp control(
Expand Down Expand Up @@ -46,10 +46,10 @@ equation
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>
annotation (experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2), 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;
end SimpleValve;
8 changes: 4 additions & 4 deletions OpenHPL/Examples/SimpleValveWithCreek.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ within OpenHPL.Examples;
model SimpleValveWithCreek
"Model of a hydropower system with a simple turbine turbine"
extends Modelica.Icons.Example;
Waterway.Reservoir reservoir(h_0 = 10, constantLevel = false) annotation(
Waterway.Reservoir reservoir(h_0 = 10, constantLevel = false, fixElevation = true, z_0 = 110) annotation(
Placement(transformation(origin = {-90, 30}, extent = {{-10, -10}, {10, 10}})));
Modelica.Blocks.Sources.Ramp control(duration = 30, height = 0.5, offset = 0, startTime = 500e6) annotation(
Placement(transformation(origin={-10,0}, extent = {{-10, -10}, {10, 10}})));
Expand All @@ -15,7 +15,7 @@ model SimpleValveWithCreek
replaceable Waterway.Pipe penstock(D_i = 3, D_o = 3, H = 80, L = 200, vertical = true)
constrainedby Interfaces.TwoContacts annotation(
Placement(transformation(origin={60,30}, extent = {{-10, -10}, {10, 10}})));
Waterway.SurgeTank creekIntake(H = 25, L = 30, h_0 = 20, useCreekIntake = true) annotation(
Waterway.SurgeTank creekIntake(H = 25, L = 30, h_0 = 20) annotation(
Placement(transformation(origin = {-30, 30}, extent = {{-10, -10}, {10, 10}})));
inner Data data(Vdot_0 = 0) annotation(
Placement(transformation(origin = {-90, 90}, extent = {{-10, -10}, {10, 10}})));
Expand Down Expand Up @@ -49,11 +49,11 @@ equation
connect(penstock.o, valve.i) annotation (Line(points={{70,30},{80,30},{80,10},
{8,10},{8,-20},{20,-20}}, color={0,128,255}));
annotation(
experiment(StopTime = 1000),
experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2),
Documentation(info = "<html>
<p>
Simple model of a water way with one creek intake.
This can be used to investigate the effects of a creek intake.
</p>
</html>"));
end SimpleValveWithCreek;
end SimpleValveWithCreek;
Loading
Loading