diff --git a/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo b/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo new file mode 100644 index 0000000..ec08ae2 --- /dev/null +++ b/OpenHPL/ElectroMech/BaseClasses/BaseValve.mo @@ -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="

+This is a simple model of hydraulic valve. +The model can use a constant efficiency or varying +efficiency from a lookup-table. +

+

+This model is based on the energy balance of a valve. +The valve capacity can either be specified +directly by the user by specifying C_v or it will be calculated from +the nominal head H_n and nominal flow rate Vdot_n. +

+

+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. +

+

+Besides hydraulic input and output, +there is an input u for controlling the valve opening. +

+")); +end BaseValve; diff --git a/OpenHPL/ElectroMech/BaseClasses/package.order b/OpenHPL/ElectroMech/BaseClasses/package.order index 8f78c69..ba4a2d0 100644 --- a/OpenHPL/ElectroMech/BaseClasses/package.order +++ b/OpenHPL/ElectroMech/BaseClasses/package.order @@ -1 +1,2 @@ Power2Torque +BaseValve diff --git a/OpenHPL/ElectroMech/Turbines/Turbine.mo b/OpenHPL/ElectroMech/Turbines/Turbine.mo index 07e7cc5..ad06f15 100644 --- a/OpenHPL/ElectroMech/Turbines/Turbine.mo +++ b/OpenHPL/ElectroMech/Turbines/Turbine.mo @@ -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="

This is a simple model of the turbine that give possibilities for simplified diff --git a/OpenHPL/Examples/Detailed.mo b/OpenHPL/Examples/Detailed.mo deleted file mode 100644 index 49092e9..0000000 --- a/OpenHPL/Examples/Detailed.mo +++ /dev/null @@ -1,5 +0,0 @@ -within OpenHPL.Examples; -model Detailed "Hydropower system using KP scheme based penstock" - extends Simple(redeclare Waterway.PenstockKP penstock); - annotation (experiment(StopTime=1000)); -end Detailed; diff --git a/OpenHPL/Examples/DetailedTurbine.mo b/OpenHPL/Examples/DetailedTurbine.mo new file mode 100644 index 0000000..1c66a01 --- /dev/null +++ b/OpenHPL/Examples/DetailedTurbine.mo @@ -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; diff --git a/OpenHPL/Examples/SimpleGen.mo b/OpenHPL/Examples/SimpleGen.mo index f5f77b3..3dc85ac 100644 --- a/OpenHPL/Examples/SimpleGen.mo +++ b/OpenHPL/Examples/SimpleGen.mo @@ -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}}))); diff --git a/OpenHPL/Examples/Simple.mo b/OpenHPL/Examples/SimpleTurbine.mo similarity index 78% rename from OpenHPL/Examples/Simple.mo rename to OpenHPL/Examples/SimpleTurbine.mo index 483f912..80a50a8 100644 --- a/OpenHPL/Examples/Simple.mo +++ b/OpenHPL/Examples/SimpleTurbine.mo @@ -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}, @@ -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 @@ -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; diff --git a/OpenHPL/Examples/SimpleValve.mo b/OpenHPL/Examples/SimpleValve.mo new file mode 100644 index 0000000..44ec59c --- /dev/null +++ b/OpenHPL/Examples/SimpleValve.mo @@ -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=" +

+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; diff --git a/OpenHPL/Examples/package.order b/OpenHPL/Examples/package.order index 7f0f9f9..a75a0f1 100644 --- a/OpenHPL/Examples/package.order +++ b/OpenHPL/Examples/package.order @@ -1,8 +1,9 @@ BranchingPipes -Simple +SimpleValve +SimpleTurbine SimpleGen SimpleGenFrancis -Detailed +DetailedTurbine DetailedGen DetailedGenFrancis PowerSystemSimple diff --git a/OpenHPL/Icons/Valve.mo b/OpenHPL/Icons/Valve.mo new file mode 100644 index 0000000..4fe246c --- /dev/null +++ b/OpenHPL/Icons/Valve.mo @@ -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; diff --git a/OpenHPL/Icons/package.order b/OpenHPL/Icons/package.order index f98bf83..fd95340 100644 --- a/OpenHPL/Icons/package.order +++ b/OpenHPL/Icons/package.order @@ -6,6 +6,7 @@ BendPipe Surge Fitting DraftTube +Valve OpenChannel ElectroMech Turbine diff --git a/OpenHPL/Interfaces/TurbineContacts.mo b/OpenHPL/Interfaces/TurbineContacts.mo index a4cd0e5..32cb18b 100644 --- a/OpenHPL/Interfaces/TurbineContacts.mo +++ b/OpenHPL/Interfaces/TurbineContacts.mo @@ -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( diff --git a/OpenHPL/Waterway/Valve.mo b/OpenHPL/Waterway/Valve.mo new file mode 100644 index 0000000..1dc9603 --- /dev/null +++ b/OpenHPL/Waterway/Valve.mo @@ -0,0 +1,38 @@ +within OpenHPL.Waterway; +model Valve "Simple hydraulic valve" + extends ElectroMech.BaseClasses.BaseValve; + extends Icons.Valve; + + Modelica.Blocks.Interfaces.RealInput opening(min=0, max=1) + "=1: completely open, =0: completely closed" + annotation (Placement(transformation( + origin={0,120}, + extent={{-20,-20},{20,20}}, + rotation=270), iconTransformation( + extent={{-20,-20},{20,20}}, + rotation=270, + origin={0,80}))); +equation + connect(opening, u) annotation (Line(points={{0,120},{0,70}}, color={0,0,127})); + annotation ( + Documentation(info="

+This is a simple model of hydraulic valve. +The model can use a constant efficiency or varying +efficiency from a lookup-table. +

+

+This model is based on the energy balance of a valve. +The valve capacity can either be specified +directly by the user by specifying C_v or it will be calculated from +the nominal head H_n and nominal flow rate Vdot_n. +

+

+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. +

+

+Besides hydraulic input and output, +there is an input u for controlling the valve opening. +

+")); +end Valve; diff --git a/OpenHPL/Waterway/package.order b/OpenHPL/Waterway/package.order index 9c79a5a..4f131d6 100644 --- a/OpenHPL/Waterway/package.order +++ b/OpenHPL/Waterway/package.order @@ -2,6 +2,7 @@ Internal BendPipe DraftTube Fitting +Valve Pipe PenstockKP SurgeTank