Skip to content
Draft
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
28 changes: 28 additions & 0 deletions OpenHPL/ElectroMech/Turbines/EmpiricalTurbine.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
within OpenHPL.ElectroMech.Turbines;
model EmpiricalTurbine
extends OpenHPL.ElectroMech.BaseClasses.TorqueEquation;
extends OpenHPL.Interfaces.TurbineContacts;
extends OpenHPL.Icons.Turbine;

parameter OpenHPL.Types.TurbineCharacteristics turbineCharacteristics;
parameter OpenHPL.Types.TurbineData turbineData;
SI.Length Ht(start=100) "Turbine head";
SI.VolumeFlowRate Qt "Turbine flow rate";

SI.Torque Tt "Turbine torque";
Modelica.Blocks.Sources.RealExpression realExpression(y=Tt) annotation (Placement(transformation(extent={{-70,-10},{-50,10}})));
protected
Real opening=u_t;
SI.Frequency nrps=speedSensor.w/(2*C.pi) "Rotational speed (in revolutions per seconds)";
equation
Ht = abs(i.p - o.p)/(data.rho*data.g);
i.mdot + o.mdot = 0;
i.mdot = Qt*data.rho;
(Qt, Tt) = OpenHPL.Functions.TurbineLookUp(Ht, nrps, opening, turbineData, turbineCharacteristics);
connect(realExpression.y, torque.tau) annotation (Line(points={{-49,0},{-37.2,0}}, color={0,0,127}));
annotation (
Documentation(info = "<html>
<p>Turbine model based on normalized, empirical turbine characteristics and turbine data for the best efficiency point.</p>
<p>In this intial release, the turbine characteristics and tubine data must be constructed separately passed to the model. This may change in future releases.</p>
</html>"));
end EmpiricalTurbine;
1 change: 1 addition & 0 deletions OpenHPL/ElectroMech/Turbines/package.order
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Turbine
Francis
Pelton
EmpiricalTurbine
81 changes: 81 additions & 0 deletions OpenHPL/Functions/TurbineLookUp.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
within OpenHPL.Functions;
function TurbineLookUp
extends Modelica.Icons.Function;
//
input SI.Length Ht;
input SI.Frequency nrps;
input Real opening;
input OpenHPL.Types.TurbineData td "Turbine data";
input OpenHPL.Types.TurbineCharacteristics hc "Turbine characteristics";
output SI.VolumeFlowRate Qt "Discharge";
output SI.Torque Tt "Hydraulic torque";
protected
constant Real phi = (1 + sqrt(5))/2 "Golden ratio";
constant Real resphi = 2 - phi "Reciprocal of golden ratio (0.618...)";
constant Real eps = 1.0e-08;
constant Integer nitr = 99;
Real a "Current left bound";
Real b "Current right bound";
Real t1 "First interior point";
Real t2 "Second interior point";
Real f1 "Function value at x1";
Real f2 "Function value at x2";
Real x_min "Current estimate of minimum location";
Real f_min "Current estimate of minimum value";
Real controlPoints[hc.nPoints, hc.nDim];
Real[hc.nDim] cP1;
Real[hc.nDim] cP2;
Real target;
Real err;
Integer itr;
algorithm
controlPoints:=WeightedControlPoints(opening,hc);
// Added the: max(abs(Ht),eps) due to errors when initializing the model.
target:=((nrps*td.Dn)/sqrt(max(abs(Ht),eps)*td.g))/((td.nrps*td.Dn)/sqrt(td.Hbep*td.g));
a:=0;
b:=1;
itr:=0;
err:=1.e+10;
t1 := a + resphi*(b - a);
cP1 := deCasteljau(t1, hc.nDim, controlPoints);
f1 := sqrt((cP1[1] - target)^2);
t2 := b - resphi*(b - a);
cP2 := deCasteljau(t2, hc.nDim, controlPoints);
f2 := sqrt((cP2[1] - target)^2);
while ((err > eps) and (itr < nitr)) loop
if f1 < f2 then
// Minimum is in [a, x2]
b := t2;
t2 := t1;
f2 := f1;
t1 := a + resphi*(b - a);
cP1 :=deCasteljau(t1, hc.nDim, controlPoints);
f1 := sqrt((cP1[1] - target)^2);
else
// Minimum is in [x1, b]
a := t1;
t1 := t2;
f1 := f2;
t2 := b - resphi*(b - a);
cP2 := deCasteljau(t2, hc.nDim, controlPoints);
f2 := sqrt((cP2[1] - target)^2);
end if;
itr := itr + 1;
err := min(f1, f2);
end while;
Qt := (cP1[2] + cP2[2])*0.5*(td.Qbep*sqrt(Ht/td.Hbep));
Tt := (cP1[3] + cP2[3])*0.5*(td.Tbep*(Ht/td.Hbep));

annotation(
Documentation(info="<html>
<p>Compute the physical discharge (Q) and torque (T) based on the turbine speed [nrps],
turbine head [Ht] and opening. The algorithm is briely summarized below.</p>
<ol>
<li>Find the actual charateristic curve by weighted interpolation of the two closest curves</li>
<li>Use golden section search to find the correct position along the speed curve</li>
<li>Compute physcal discharge and torque based on normalized unit data and the turbine information</li>
</ol>
<p>At the moment the algorithm assumes that \\(n_{ED}\\) is monotonously increasing as function of the
parametric value and is not able to handle s-shaped curves.</p>
</html>"));
end TurbineLookUp;
48 changes: 48 additions & 0 deletions OpenHPL/Functions/WeightedControlPoints.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
within OpenHPL.Functions;
function WeightedControlPoints
extends Modelica.Icons.Function;
/*
*/
input Real opening;
input OpenHPL.Types.TurbineCharacteristics hc "Turbine characteristics";
output Real data[hc.nPoints, hc.nDim];
protected
Real td[hc.nPoints, hc.nDim];
Real beta;
Integer i;

algorithm
//if (opening >= hc.opening[1] and opening <= hc.opening[hc.nPoints]) then
i:=1;
while (i < hc.nCurves) loop
if (opening < hc.opening[i]) then
// Defined as closed guide vanes
for j in 1:hc.nPoints loop
td[j,1] := hc.data[1, j, 1];
td[j,2] := 0.0;
// Torque set to zero. Must be corrected in the future
td[j,3] := 0.0;
end for;
break;
elseif ( (hc.opening[i] <= opening) and (opening <= hc.opening[i+1])) then
beta:=(opening-hc.opening[i])/(hc.opening[i+1]-hc.opening[i]);
for j in 1:hc.nPoints loop
for k in 1:hc.nDim loop
td[j,k] := (1.-beta)*hc.data[i, j, k]+ beta*hc.data[i+1, j, k];
end for;
end for;
break;
else
i:=i+1;
end if;
end while;

data:=td;
annotation(
Documentation(info="<html>
<p>Compute an intermediate turbine characteristics based on linear interpolation of the two closest curves.
The turbine opening is used as argument for finding the closest curves. Assumes that the opening in the HillChart data is monotonously increasing.
If data at small opening is missing, the flow and speed data for the first curve is used and the torque is set to zero.</p>
</html>"));

end WeightedControlPoints;
34 changes: 34 additions & 0 deletions OpenHPL/Functions/deCasteljau.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
within OpenHPL.Functions;
function deCasteljau
extends Modelica.Icons.Function;
input Real t "Parameter between 0 and 1";
input Integer ndim "Dimensional space";
input Real[:, ndim] controlPoints "Array of control points [n,ndim]";
output Real[ndim] point "Computed point on the curve";
protected
Integer n = size(controlPoints, 1);
Real temp[n, ndim];
algorithm
// Initialize temp with control points
temp := controlPoints;
// Perform De Casteljau iterations
for r in 1:n - 1 loop
for i in 1:n - r loop
for k in 1:ndim loop
temp[i, k] := (1 - t)*temp[i, k] + t*temp[i + 1, k];
end for;
end for;
end for;
// The first element now contains the point on the curve
for k in 1:ndim loop
point[k] := temp[1, k];
end for;
annotation(
Documentation(info = "<html>
<p>
Implementation of Bezier curve evaluation using the deCasteljau algorithm.</p>
<p>At the moment only one single Bezier curve per parameter dimension is assumed,
but the order of the curve is arbritray, but define by the number of control points
(e.g., curve order = number of control points - 1).</p>
</html>"));
end deCasteljau;
3 changes: 3 additions & 0 deletions OpenHPL/Functions/package.order
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Fitting
DarcyFriction
KP07
deCasteljau
WeightedControlPoints
TurbineLookUp
13 changes: 13 additions & 0 deletions OpenHPL/Types/ReactionTurbines.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
within OpenHPL.Types;

record ReactionTurbines "Collection of empirical turbine characteristics for use together with the EmpiricalTurbine model"
extends Modelica.Icons.Record;
protected
parameter Real oA[5]={0.10,0.25,0.50,0.75,1.00};
parameter Real cP1[5,4,3]={{{ 0.00,0.27,0.45 },{ 0.58,0.33,0.42 },{ 1.04,0.16,0.11 },{ 1.43,-0.13,-0.42 }},{{ 0.00,0.64,1.17 },{ 0.70,0.74,1.04 },{ 1.13,0.31,0.13 },{ 1.43,-0.17,-0.50 }},{{ 0.00,1.25,2.27 },{ 0.90,1.30,1.71 },{ 1.29,0.53,-0.05 },{ 1.43,-0.18,-0.52 }},{{ 0.00,1.71,2.95 },{ 1.05,1.71,1.99 },{ 1.31,0.63,-0.17 },{ 1.44,-0.16,-0.53 }},{{ 0.00,2.10,3.41 },{ 1.15,1.98,2.04 },{ 1.31,0.76,-0.18 },{ 1.45,-0.13,-0.54 }}};

parameter Real cP2[5,4,3]={{{ 0.00,0.18,0.26 },{ 0.41,0.10,0.17 },{ 1.04,0.31,0.25 },{ 1.32,-0.04,-0.21 }},{{ 0.00,0.44,0.73 },{ 0.43,0.37,0.67 },{ 1.27,0.55,0.29 },{ 1.38,0.00,-0.19 }},{{ 0.00,0.91,1.55 },{ 0.59,0.89,1.33 },{ 1.57,0.79,0.19 },{ 1.51,0.00,-0.29 }},{{ 0.00,1.30,2.11 },{ 0.78,1.33,1.77 },{ 1.72,0.92,-0.12 },{ 1.58,0.00,-0.28 }},{{ 0.00,1.57,2.41 },{ 0.92,1.63,1.91 },{ 1.82,1.02,-0.30 },{ 1.63,0.00,-0.35 }}};
public
TurbineCharacteristics turbine1(nCurves = 5, nDim = 3, nPoints = 4, opening = oA, data = cPoints) "N_QE=0.07";
TurbineCharacteristics turbine2(nCurves = 5, nDim = 3, nPoints = 4, opening = oA, data = cPoints) "N_EQ=0.20";
end ReactionTurbines;
27 changes: 27 additions & 0 deletions OpenHPL/Types/TurbineCharacteristics.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
within OpenHPL.Types;
record TurbineCharacteristics
extends Modelica.Icons.Record;
parameter Integer nCurves;
parameter Integer nPoints;
parameter Integer nDim "parameter space, currently 3";
parameter Real opening[nCurves];
parameter Real data[nCurves, nPoints, nDim];

annotation(
Documentation(info="<html>
<p>This data record is based on the first version of the empirical turbine model, where normalized data for nED, QED and TED are given for
a number of normalized openings.</p>
<p>The HillChart record contains <strong>three</strong> integer values:</p>
<ol>
<li><font color=\"#0000ff\">nCurves</font> - number of Bezier curves</li>
<li><font color=\"#0000ff\">nPoints</font> - number of Bezier control points (order of curve +1)</li>
<li><font color=\"#0000ff\">nDim</font> - parameter space (currently assumed to be 3. (Model may/will (?) fail for other values).</li>
</ol>
<p>The data itself is contained in <strong>two</strong> multidimensional arrays:</p>
<ul>
<li><font color=\"#0000ff\">opening[nCurves]</font> - gives the opening \\(\\in [0,1]\\) for each curve. It is assumed that the array is sorted from smallest to larges value.</li>
<li><font color=\"#0000ff\">data[nCurves, nPoints, nDim]</font> - gives the Bezier control points for each curve and each parameter (nED,QED,TED).</li>
</ul>
</html>"));

end TurbineCharacteristics;
31 changes: 31 additions & 0 deletions OpenHPL/Types/TurbineData.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
within OpenHPL.Types;
record TurbineData
extends Modelica.Icons.Record;
//
parameter SI.Length Dn "Nominal diameter";
parameter SI.Frequency nrps "Best efficiency rotational speed";
parameter SI.Length Hbep "Best efficiency head";
parameter SI.VolumeFlowRate Qbep "Best efficiency discharge";
parameter SI.Torque Tbep "Best efficiency shaft torque";
parameter Real openingBep "Best efficiency opening";
parameter SI.Acceleration g;
parameter SI.Density rho;

annotation(
Documentation(info = "<html>
<p>Data record with key turbine information. Used together with the normalized turbine characteristics to calculate physical values.</p>
<table>
<thead>
<tr><th>Variable</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td>Dn [m]</td><td>Nominal diameter</td></tr>
<tr><td>nrps [1/s]</td><td>Best efficiency rotational speed</td></tr>
<tr><td>Hbep [m]</td><td>Best efficiency head</td></tr>
<tr><td>Qbep [m³/s]</td><td>Best efficiency discharge</td></tr>
<tr><td>Tbep [Nm]</td><td>Best efficiency torque</td></tr>
<tr><td>openingBep [-]</td><td>Normalize best efficiency opening (must be between 0 and 1)</td></tr>
</tbody>
</table></html>"));

end TurbineData;
3 changes: 3 additions & 0 deletions OpenHPL/Types/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ Fitting
FrictionMethod
Lambda
SurgeTank
TurbineData
TurbineCharacteristics
ReactionTurbines
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model CaseStudingValentynasCase "HP system model for Valentyna's Master case"
extends Modelica.Icons.Example;
Real coef2, coef3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPAllTypeFittingsTest "Test for comparing fitting behaviour"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir headWater(h_0=10) annotation (Placement(transformation(extent={{-100,-10},{-80,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPBjarneBorresen "Model of HP system with simplified models for penstock, turbine, etc."
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=503 - 499.5) annotation (Placement(transformation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPDraftTube "Testing the draft tube models."
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstock "Model of HP system with elastic penctock (KP), but simplified models for turbine, etc."
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(origin={-92,66}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstockANDIntake "Model of HP system with elastic penctock and intake (KP), but simplified models for turbine, etc."
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(origin={-92,66}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstockCompres "Model of HP system with elastic penctock (KP), but simplified models for turbine, etc."
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(origin={-92,66}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstockFrancis "HP system model with Francis turbine and elastic penstock"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(origin={-92,66}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstockFrancisGov "HP system model with Francis turbine and elastic penstock and governor"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(origin={-92,66}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstockHalfSurgeD "Similar to previous HP system, but with twice reduced surge tank diameter"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir annotation (Placement(transformation(origin={-92,66}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPElasticKPPenstockWithoutSurge "Model of HP system without surge tank and with elastic penctock (KP), but simplified models for turbine, etc."
extends Modelica.Icons.Example;
OpenHPL.Waterway.Reservoir reservoir(h_0=48) annotation (Placement(transformation(origin={-90,62}, extent={{-10,-10},{10,10}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLinTest
extends Modelica.Icons.Example;
OpenHPLTest.HPLiniarizationKPFran hpl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLiniarization "Simple HP system model for liniarization"
extends Modelica.Icons.Example;
input Real u(start = 0.7493);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLiniarization2 "Simple HP system model for liniarization"
extends Modelica.Icons.Example;
input Real u(start = 0.7493);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLiniarization3 "Simple HP system model for liniarization"
extends Modelica.Icons.Example;
input Real u(start = 0.7493);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLiniarization4 "Simple HP system model for liniarization"
extends Modelica.Icons.Example;
input Real u(start = 0.7493);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLiniarizationFranGen "HP system model for liniarization with Francis turbine + generator"
extends Modelica.Icons.Example;
OpenHPL.Waterway.Pipe intake(H=23, Vdot_0=18.5952) annotation (Placement(transformation(extent={{-72,50},{-52,70}})));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
within OpenHPLTest;
within OpenHPLTest.Archive;
model HPLiniarizationGenIPSL "Synergy with OpenIPSL library(generator + governor)"
extends Modelica.Icons.Example;
input Real u = 0.574;
Expand Down
Loading