diff --git a/OpenHPL/Data.mo b/OpenHPL/Data.mo index f3b30a4..84a3f62 100644 --- a/OpenHPL/Data.mo +++ b/OpenHPL/Data.mo @@ -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" diff --git a/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo b/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo index 1d71383..404caca 100644 --- a/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo +++ b/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo @@ -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="
This is a partial, simple model of hydraulic valve.
This model is based on the energy balance of a valve. diff --git a/OpenHPL/ElectroMech/Turbines/Francis.mo b/OpenHPL/ElectroMech/Turbines/Francis.mo index dbffb45..a2cc290 100644 --- a/OpenHPL/ElectroMech/Turbines/Francis.mo +++ b/OpenHPL/ElectroMech/Turbines/Francis.mo @@ -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}, @@ -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", diff --git a/OpenHPL/ElectroMech/Turbines/Pelton.mo b/OpenHPL/ElectroMech/Turbines/Pelton.mo index 0b01956..a27546b 100644 --- a/OpenHPL/ElectroMech/Turbines/Pelton.mo +++ b/OpenHPL/ElectroMech/Turbines/Pelton.mo @@ -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}, @@ -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", diff --git a/OpenHPL/Examples/BranchingPipes.mo b/OpenHPL/Examples/BranchingPipes.mo index 5fbbe8a..e2672e0 100644 --- a/OpenHPL/Examples/BranchingPipes.mo +++ b/OpenHPL/Examples/BranchingPipes.mo @@ -1,7 +1,7 @@ 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}}))); @@ -9,25 +9,25 @@ model BranchingPipes "Model of branching pipes" 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; \ No newline at end of file diff --git a/OpenHPL/Examples/DetailedTurbine.mo b/OpenHPL/Examples/DetailedTurbine.mo index 1c66a01..101dce9 100644 --- a/OpenHPL/Examples/DetailedTurbine.mo +++ b/OpenHPL/Examples/DetailedTurbine.mo @@ -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; \ No newline at end of file diff --git a/OpenHPL/Examples/Gate.mo b/OpenHPL/Examples/Gate.mo index 1f8e556..0ff45bb 100644 --- a/OpenHPL/Examples/Gate.mo +++ b/OpenHPL/Examples/Gate.mo @@ -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, @@ -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, @@ -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, @@ -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, @@ -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; \ No newline at end of file diff --git a/OpenHPL/Examples/Pipes.mo b/OpenHPL/Examples/Pipes.mo index a9fedfa..4d35ef0 100644 --- a/OpenHPL/Examples/Pipes.mo +++ b/OpenHPL/Examples/Pipes.mo @@ -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 @@ -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; \ No newline at end of file diff --git a/OpenHPL/Examples/SimpleGen.mo b/OpenHPL/Examples/SimpleGen.mo index 3dc85ac..69a33d9 100644 --- a/OpenHPL/Examples/SimpleGen.mo +++ b/OpenHPL/Examples/SimpleGen.mo @@ -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 @@ -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; \ No newline at end of file diff --git a/OpenHPL/Examples/SimpleGenFrancis.mo b/OpenHPL/Examples/SimpleGenFrancis.mo index e5559ba..f118736 100644 --- a/OpenHPL/Examples/SimpleGenFrancis.mo +++ b/OpenHPL/Examples/SimpleGenFrancis.mo @@ -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( @@ -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( @@ -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; \ No newline at end of file diff --git a/OpenHPL/Examples/SimpleTurbine.mo b/OpenHPL/Examples/SimpleTurbine.mo index 2a6deec..4f95c4d 100644 --- a/OpenHPL/Examples/SimpleTurbine.mo +++ b/OpenHPL/Examples/SimpleTurbine.mo @@ -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( @@ -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; \ No newline at end of file diff --git a/OpenHPL/Examples/SimpleValve.mo b/OpenHPL/Examples/SimpleValve.mo index 432fe21..06f1552 100644 --- a/OpenHPL/Examples/SimpleValve.mo +++ b/OpenHPL/Examples/SimpleValve.mo @@ -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( @@ -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=" + annotation (experiment(StopTime = 1000, StartTime = 0, Tolerance = 1e-06, Interval = 2), Documentation(info="
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.
")); -end SimpleValve; +end SimpleValve; \ No newline at end of file diff --git a/OpenHPL/Examples/SimpleValveWithCreek.mo b/OpenHPL/Examples/SimpleValveWithCreek.mo index 0d88426..864a0a1 100644 --- a/OpenHPL/Examples/SimpleValveWithCreek.mo +++ b/OpenHPL/Examples/SimpleValveWithCreek.mo @@ -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}}))); @@ -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}}))); @@ -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 = "Simple model of a water way with one creek intake. This can be used to investigate the effects of a creek intake.
")); -end SimpleValveWithCreek; +end SimpleValveWithCreek; \ No newline at end of file diff --git a/OpenHPL/Examples/VolumeFlowSource.mo b/OpenHPL/Examples/VolumeFlowSource.mo index 17ea649..a490171 100644 --- a/OpenHPL/Examples/VolumeFlowSource.mo +++ b/OpenHPL/Examples/VolumeFlowSource.mo @@ -2,21 +2,21 @@ within OpenHPL.Examples; model VolumeFlowSource "Example demonstrating the use of VolumeFlowSource" extends Modelica.Icons.Example; OpenHPL.Waterway.Reservoir tail1 annotation (Placement(transformation(extent={{60,30},{40,50}}))); - inner OpenHPL.Data data annotation (Placement(transformation(extent={{-100,80},{-80,100}}))); - OpenHPL.Waterway.VolumeFlowSource volumeFlowConstant annotation (Placement(transformation(extent={{-50,30},{-30,50}}))); + inner OpenHPL.Data data(SteadyState = false, Vdot_0 = 1, showElevation = true) annotation (Placement(transformation(extent={{-100,80},{-80,100}}))); + OpenHPL.Waterway.VolumeFlowSource volumeFlowConstant(fixElevation = true) annotation (Placement(transformation(extent={{-50,30},{-30,50}}))); Waterway.Pipe pipe1(H=0) annotation (Placement(transformation(extent={{-10,30},{10,50}}))); Waterway.Pipe pipe2(H=0) annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); OpenHPL.Waterway.Reservoir tail2 annotation (Placement(transformation(extent={{60,-10},{40,10}}))); - OpenHPL.Waterway.VolumeFlowSource volumeFlowInput(useInput=true, useFilter=false) annotation (Placement(transformation(extent={{-48,-10},{-28,10}}))); - Modelica.Blocks.Sources.Sine sine(f=0.01) annotation (Placement(transformation(extent={{-80,-10},{-60,10}}))); - Modelica.Blocks.Sources.CombiTimeTable logdata(table=[1,0.256342739; 2,0.245221436; 3,0.266113698; 4,0.249561667; 5,0.525063097; 6,0.479064316; 7,0.494991362; 8,0.489708632; 9,0.50391084; 10,0.492354929; 11,0.509279788; 12,0.495274216; 13,0.493877858; 14,0.520679474; 15,0.499932915; 16,0.494227827; 17,0.472558141; 18,0.441845328; 19,0.398698032; 20,0.369865984; 21,0.341512531; 22,0.317958236; 23,0.300121665; 24,0.283421665; 25,0.271103382; 26,0.29000932; 27,0.276437521; 28,0.279719085; 29,0.273819894; + OpenHPL.Waterway.VolumeFlowSource volumeFlowInput(useInput=true, useFilter= false, fixElevation = true) annotation (Placement(transformation(extent={{-48,-10},{-28,10}}))); + Modelica.Blocks.Sources.Sine sine(f = 0.01, offset = 1) annotation (Placement(transformation(extent={{-80,-10},{-60,10}}))); + Modelica.Blocks.Sources.CombiTimeTable logdata(table=[1, 1; 2,0.245221436; 3,0.266113698; 4,0.249561667; 5,0.525063097; 6,0.479064316; 7,0.494991362; 8,0.489708632; 9,0.50391084; 10,0.492354929; 11,0.509279788; 12,0.495274216; 13,0.493877858; 14,0.520679474; 15,0.499932915; 16,0.494227827; 17,0.472558141; 18,0.441845328; 19,0.398698032; 20,0.369865984; 21,0.341512531; 22,0.317958236; 23,0.300121665; 24,0.283421665; 25,0.271103382; 26,0.29000932; 27,0.276437521; 28,0.279719085; 29,0.273819894; 30,0.530646265; 31,0.494690746; 32,0.668753743; 33,0.748319328; 34,1.156479597; 35,1.622769237; 36,1.455329537; 37,1.440503478; 38,1.388660312; 39,1.321571827; 40,1.428969026; 41,1.335716724; 42,1.240077496; 43,1.147016048; 44,1.046641827; 45,0.957466781; 46,0.877434254; 47,0.760209978; 48,0.685476542; 49,0.611937046; 50,0.5434497; 51,0.486470848; 52,0.437200874; 53,0.387043357; 54,0.346913666; 55,0.321531206; 56,0.3025949; 57,0.289946347; 58,0.76049149; 59,1.301532745; 60,1.66047287; 61, 1.468578339; 62,1.445258141; 63,1.381029367; 64,1.308333635; 65,1.429936647; 66,1.324193954; 67,1.215524554; 68,1.132795691; 69,1.039966226; 70,0.957139969; 71,0.881121516; 72,0.764806509; 73,0.679720461; 74,1.153712869; 75,1.617045045; 76,1.342065096; 77,1.21108222; 78,1.097126365; 79,0.956687152; 80,0.846820831; 81,0.726776063; 82,0.637088716; 83,0.566960931; 84,0; 85,0.081746899; 86,0.287258357; 87,0.440648884; 88,0.623197138; 89,0.745818675; 90,0.877141893; 91,1.14376235; 92,1.091307402; 93,1.166081309; 94,1.204966307; 95,1.155335188; 96,1.090149403; 97,1.023901701; 98,0.955312788; 99,0.895717919; 100,0.781589091; 101,0.711237729; 102,0.642216742; 103,0.592425168; 104,0.53075856; 105,0.470919639; 106,0.424907953; 107,0.379154414; 108,0.341206133; 109,0.313439339; 110,0.291419089; 111,0.282484144], extrapolation=Modelica.Blocks.Types.Extrapolation.HoldLastPoint) annotation (Placement(transformation(extent={{-80,-50},{-60,-30}}))); Waterway.Pipe pipe3(H=0) annotation (Placement(transformation(extent={{-10,-50},{10,-30}}))); Waterway.Reservoir tail3 annotation (Placement(transformation(extent={{60,-50},{40,-30}}))); - Waterway.VolumeFlowSource volumeFlowFiltered(useInput=true, useFilter=true) annotation (Placement(transformation(extent={{-48,-50},{-28,-30}}))); + Waterway.VolumeFlowSource volumeFlowFiltered(useInput=true, useFilter=true, fixElevation = true) annotation (Placement(transformation(extent={{-48,-50},{-28,-30}}))); equation connect(pipe1.o, tail1.o) annotation (Line(points={{10,40},{40,40}}, color={0,128,255})); connect(volumeFlowConstant.o, pipe1.i) annotation (Line(points={{-30,40},{-10,40}}, color={0,128,255})); @@ -27,5 +27,5 @@ equation connect(pipe3.o,tail3. o) annotation (Line(points={{10,-40},{40,-40}}, color={0,128,255})); connect(volumeFlowFiltered.outFlow, logdata.y[1]) annotation (Line(points={{-50,-40},{-59,-40}}, color={0,0,127})); - annotation (experiment(StopTime=120)); -end VolumeFlowSource; + annotation (experiment(StopTime = 120, StartTime = 0, Tolerance = 1e-06, Interval = 0.24)); +end VolumeFlowSource; \ No newline at end of file diff --git a/OpenHPL/Examples/package.order b/OpenHPL/Examples/package.order index 3b872e5..ce646a0 100644 --- a/OpenHPL/Examples/package.order +++ b/OpenHPL/Examples/package.order @@ -2,9 +2,9 @@ BranchingPipes SimpleValve SimpleValveWithCreek SimpleTurbine +DetailedTurbine SimpleGen SimpleGenFrancis -DetailedTurbine DetailedGen DetailedGenFrancis PowerSystemSimple diff --git a/OpenHPL/Interfaces/Contact.mo b/OpenHPL/Interfaces/Contact.mo index e15a0cb..9e273c3 100644 --- a/OpenHPL/Interfaces/Contact.mo +++ b/OpenHPL/Interfaces/Contact.mo @@ -1,10 +1,31 @@ within OpenHPL.Interfaces; connector Contact "Water flow connector" + parameter Boolean showElevation = true "Show elevation z"; SI.Pressure p "Contact pressure"; //SI.Temperature T "Contact temperature"; flow SI.MassFlowRate mdot "Mass flow rate through the contact"; + Elevation elevation "Overconstrained elevation at connection point"; + annotation ( Documentation(info = " -Contact is a basic water flow connector, which consists of water pressure and mass flow rate through the connector (positive if water is flowing into connector and negative if flowing out).
-")); -end Contact; +Contact is a basic water flow connector, which consists of water pressure, mass flow rate, +and elevation at the connector (positive if water is flowing into connector and negative if flowing out).
+ +p – Pressure (potential variable, equated across connections)mdot – Mass flow rate (flow variable, summed to zero across connections)elevation.z – Elevation (overconstrained variable, propagated via spanning tree).
+Each component provides an equation relating its connector elevations,
+enabling automatic propagation of absolute elevation through the system.
+Source components (e.g., Reservoir) set the absolute reference elevation.
+Uses the overconstrained connector mechanism (Modelica Spec 9.4) to support
+arbitrary topologies including parallel pipes and loops.TwoContact is a partial model, which consists of two Contacts iand o. diff --git a/OpenHPL/Interfaces/package.order b/OpenHPL/Interfaces/package.order index b30ebfb..16a6182 100644 --- a/OpenHPL/Interfaces/package.order +++ b/OpenHPL/Interfaces/package.order @@ -1,5 +1,6 @@ Contact Contact_i Contact_o +Elevation TurbineContacts TwoContacts diff --git a/OpenHPL/Waterway/BendPipe.mo b/OpenHPL/Waterway/BendPipe.mo index 1ca6a35..ea3ce82 100644 --- a/OpenHPL/Waterway/BendPipe.mo +++ b/OpenHPL/Waterway/BendPipe.mo @@ -23,6 +23,7 @@ equation o.p = i.p - dp "Pressure of the output connector"; i.mdot + o.mdot = 0 "Mass balance"; mdot = i.mdot "Flow direction"; + o.elevation.z = i.elevation.z "Elevation propagation: no height change across bend"; annotation (preferredView="info", Documentation(info="
Usually minor head losses in pipes are considered to be due to fittings, diffusers, nozzles, bend in pipes, etc. We are more interested in head loss due to bend pipes for this model.
diff --git a/OpenHPL/Waterway/DraftTube.mo b/OpenHPL/Waterway/DraftTube.mo index d4baad0..71ecde7 100644 --- a/OpenHPL/Waterway/DraftTube.mo +++ b/OpenHPL/Waterway/DraftTube.mo @@ -153,6 +153,7 @@ equation p_o = o.p; i.mdot+o.mdot=0; mdot = i.mdot; + o.elevation.z = i.elevation.z - H "Elevation propagation: outlet is H below inlet"; annotation (preferredView="info", Documentation(info="Two of the draft tubes are modeled using Momentum balance. They are:
diff --git a/OpenHPL/Waterway/Fitting.mo b/OpenHPL/Waterway/Fitting.mo index 2f12439..b256690 100644 --- a/OpenHPL/Waterway/Fitting.mo +++ b/OpenHPL/Waterway/Fitting.mo @@ -53,6 +53,7 @@ equation o.p = i.p - dp "Pressure of the output connector"; i.mdot+o.mdot = 0 "Mass balance"; mdot = i.mdot "Flow direction"; + o.elevation.z = i.elevation.z "Elevation propagation: no height change across fitting"; annotation (preferredView="info", Documentation(info="Various possibilities of the fittings for the pipes with different diameters diff --git a/OpenHPL/Waterway/Gate.mo b/OpenHPL/Waterway/Gate.mo index df125d4..2a1401d 100644 --- a/OpenHPL/Waterway/Gate.mo +++ b/OpenHPL/Waterway/Gate.mo @@ -51,6 +51,7 @@ equation mdot = Vdot * data.rho "Mass flow rate through the gate"; i.p = h_0 * data.g * data.rho + data.p_a "Inlet water pressure"; o.p = h_2 * data.g * data.rho + data.p_a "Outlet water pressure"; + o.elevation.z = i.elevation.z "Elevation propagation: gate at same elevation"; annotation ( preferredView="info", Documentation(info=" diff --git a/OpenHPL/Waterway/Gate_HR.mo b/OpenHPL/Waterway/Gate_HR.mo index b0bf4f5..cbdab03 100644 --- a/OpenHPL/Waterway/Gate_HR.mo +++ b/OpenHPL/Waterway/Gate_HR.mo @@ -50,6 +50,7 @@ equation mdot = Vdot * data.rho "Mass flow rate through the gate"; i.p = h_i * data.g * data.rho + data.p_a "Inlet water pressure"; o.p = h_o * data.g * data.rho + data.p_a "Outlet water pressure"; + o.elevation.z = i.elevation.z "Elevation propagation: gate at same elevation"; annotation ( preferredView="info", Documentation(info=" diff --git a/OpenHPL/Waterway/OpenChannel.mo b/OpenHPL/Waterway/OpenChannel.mo index f797f52..53d476e 100644 --- a/OpenHPL/Waterway/OpenChannel.mo +++ b/OpenHPL/Waterway/OpenChannel.mo @@ -39,6 +39,7 @@ equation // presurre boundaries i.p = h[1] * data.g * data.rho + data.p_a; o.p = h[N] * data.g * data.rho + data.p_a; + o.elevation.z = i.elevation.z - (H[1] - H[2]) "Elevation propagation: channel bed drops from H[1] to H[2]"; annotation (preferredView="info", Documentation(info="
Note: Currently under investigation for plausibility.
diff --git a/OpenHPL/Waterway/Penstock.mo b/OpenHPL/Waterway/Penstock.mo index 9102b54..7ca74ea 100644 --- a/OpenHPL/Waterway/Penstock.mo +++ b/OpenHPL/Waterway/Penstock.mo @@ -83,6 +83,7 @@ equation // volumetric flow rates for all cells V_p_out = mdot ./ rho_m; V_p_out_end = mdot_V / (data.rho * (1 + data.beta * (p_o - data.p_a))); + o.elevation.z = i.elevation.z - H "Outlet elevation is H below inlet"; annotation (preferredView="info", Documentation(info="This is a more detaied model of the pipe that can be use for proper modeling of penstock. (This model does not work well. Instead PenstockKP model can be used.)
The model for the penstock with the elastic walls and compressible water with simple discretization method (Staggered grid). The geometry of the penstock is described due to figure:
When useCreekIntake = true, an additional inlet connector creek becomes active.
-This connector can be attached to a VolumeFlowSource to model lateral inflow
-(e.g., a creek or groundwater seepage) entering the surge tank. The parameter H_creek
-specifies the height of the intake above the surge tank base (default H = at the top of the surge tank,
-not relavant if a volume flow source is connected).
-The connector pressure is set hydrostatically from the water surface down to the intake elevation,
+
The surge tank has a creek inlet connector that can be attached to a
+VolumeFlowSource to model lateral inflow (e.g., a creek or groundwater seepage)
+entering the surge tank. The connector is always present; when left unconnected,
+the flow is zero by Modelica's default flow-variable semantics and has no effect on
+the model. The parameter H_creek specifies the height of the intake above
+the surge tank base (default: equal to H). The boolean useCreekIntake controls
+the visibility of H_creek in the parameter dialog.
The connector pressure is set hydrostatically from the water surface down to the intake elevation,
so it correctly follows the actual water level h in the tank:
$$ p_\\mathrm{creek} = p_\\mathrm{t} + \\rho g (h - H_\\mathrm{creek}) $$
+The creek connector participates in the overconstrained elevation graph via
+Connections.branch(creek.elevation, o.elevation), ensuring that its elevation
+is consistent with the rest of the waterway:
+$$ z_\\mathrm{creek} = z_\\mathrm{o} + H_\\mathrm{creek} $$
The creek inflow is included in the mass balance:
$$ \\frac{\\mathrm{d}m}{\\mathrm{d}t} = \\rho \\dot{V} + \\dot{m}_\\mathrm{creek} $$
diff --git a/OpenHPL/Waterway/VolumeFlowSource.mo b/OpenHPL/Waterway/VolumeFlowSource.mo index 33a3772..e1e8f10 100644 --- a/OpenHPL/Waterway/VolumeFlowSource.mo +++ b/OpenHPL/Waterway/VolumeFlowSource.mo @@ -11,8 +11,11 @@ model VolumeFlowSource "Volume flow source (either fixed or variable)" annotation (choices(checkBox = true),Dialog(enable=useInput)); parameter SI.Time T_f=0.01 "Time constant of the first order filter." annotation (Dialog(enable=useInput and useFilter)); - - Interfaces.Contact_o o "Outlet flow connector" + parameter Boolean fixElevation=false "If true (fixed), z_0 is enforced as initial value; if false (derived), elevation is determined by connected topology" + annotation (Dialog(group="Geometry"), choices(checkBox=true)); + parameter SI.Position z_0=0 "Elevation of the outlet connection" + annotation (Dialog(group="Geometry", enable=fixElevation)); + Interfaces.Contact_o o(showElevation = data.showElevation) "Outlet flow connector" annotation (Placement(transformation(extent={{90,-10},{110,10}}))); Modelica.Blocks.Interfaces.RealInput outFlow if useInput "Conditional input for defining the outlet flow [m3/s]" annotation (Placement(transformation(extent={{-140,-20},{-100,20}}))); @@ -36,6 +39,15 @@ equation color={0,0,127}, pattern=LinePattern.Dot)); o.mdot = -data.rho*Vdot; + if fixElevation then + Connections.root(o.elevation) "This source is the elevation reference root"; + o.elevation.z = z_0 "Set absolute elevation at outlet"; + else + Connections.potentialRoot(o.elevation) "May become root if no other root exists"; + if Connections.isRoot(o.elevation) then + o.elevation.z = 0 "Default elevation if this becomes root"; + end if; + end if; connect(constantVolumeFlow.y, Vdot) annotation (Line(points={{-39,40},{40,40},{40,0},{80,0}}, color={0,0,127})); connect(firstOrder.u, outFlow) annotation (Line( points={{-62,-20},{-80,-20},{-80,0},{-120,0}}, @@ -59,4 +71,4 @@ or via the input connectorinFlow.
In addition the input can be passed through a first order filter which is sometimes necessary
for numerical reasons depending on the nature of the input data stream.
"));
-end VolumeFlowSource;
+end VolumeFlowSource;
\ No newline at end of file