Skip to content

Commit

Permalink
Ibpsa sync issue1764 add electrical package (#3456)
Browse files Browse the repository at this point in the history
* Corrected typo

* Formatted file

* Added new file, and formatted it

* Added changes from IBPSA, issue1764_add_electrical_package_revMW
  • Loading branch information
mwetter authored Jul 19, 2023
1 parent be981bf commit 6207337
Show file tree
Hide file tree
Showing 14 changed files with 973 additions and 24 deletions.
671 changes: 671 additions & 0 deletions Buildings/.copiedFiles.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Buildings/Electrical/AC/OnePhase/Sources/WindTurbine.mo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
within Buildings.Electrical.AC.OnePhase.Sources;
model WindTurbine "Simple wind turbine model"
extends Buildings.Electrical.Interfaces.PartialWindTurbine(
extends Buildings.Electrical.BaseClasses.WindTurbine.PartialWindTurbine(
redeclare package PhaseSystem = Buildings.Electrical.PhaseSystems.OnePhase,
redeclare replaceable Interfaces.Terminal_p terminal,
V_nominal(start = 110));
Expand Down
14 changes: 7 additions & 7 deletions Buildings/Electrical/AC/ThreePhasesUnbalanced/Lines/TwoPortRL.mo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ model TwoPortRL
max=Buildings.Electrical.Types.Load.FixedZ_dynamic) = Buildings.Electrical.Types.Load.FixedZ_steady_state
"Type of model (e.g., steady state, dynamic, prescribed power consumption, etc.)"
annotation (Evaluate=true, Dialog(group="Modeling assumption"));
OnePhase.Lines.TwoPortRL phase1(
OnePhase.Lines.TwoPortRL phase1(
final T_ref=T_ref,
final M=M,
final R=R/3,
Expand Down Expand Up @@ -57,27 +57,27 @@ equation
LossPower = phase1.LossPower + phase2.LossPower + phase3.LossPower;

connect(terminal_n.phase[1], phase1.terminal_n) annotation (Line(
points={{-100,0},{-20,0},{-20,30},{-10,30}},
points={{-99.95,0.05},{-20,0.05},{-20,30},{-10,30}},
color={0,120,120},
smooth=Smooth.None));
connect(terminal_n.phase[2], phase2.terminal_n) annotation (Line(
points={{-100,0},{-10,0}},
points={{-99.95,0.05},{-54,0.05},{-54,0},{-10,0}},
color={0,120,120},
smooth=Smooth.None));
connect(terminal_n.phase[3], phase3.terminal_n) annotation (Line(
points={{-100,4.44089e-16},{-20,4.44089e-16},{-20,-30},{-10,-30}},
points={{-99.95,0.05},{-20,0.05},{-20,-30},{-10,-30}},
color={0,120,120},
smooth=Smooth.None));
connect(phase1.terminal_p, terminal_p.phase[1]) annotation (Line(
points={{10,30},{20,30},{20,0},{100,0}},
points={{10,30},{20,30},{20,0.05},{100.05,0.05}},
color={0,120,120},
smooth=Smooth.None));
connect(phase2.terminal_p, terminal_p.phase[2]) annotation (Line(
points={{10,0},{100,0}},
points={{10,0},{56,0},{56,0.05},{100.05,0.05}},
color={0,120,120},
smooth=Smooth.None));
connect(phase3.terminal_p, terminal_p.phase[3]) annotation (Line(
points={{10,-30},{20,-30},{20,0},{100,0}},
points={{10,-30},{20,-30},{20,0.05},{100.05,0.05}},
color={0,120,120},
smooth=Smooth.None));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ partial model BaseUnbalancedWindTurbine
"Partial model for an unbalanced wind power source"
extends Buildings.Electrical.Interfaces.PartialPluggableUnbalanced;
extends Buildings.Electrical.Interfaces.PartialAcDcParameters;
extends Buildings.Electrical.Interfaces.PartialWindTurbineBase(V_nominal(start = 480));
extends Buildings.Electrical.BaseClasses.WindTurbine.PartialWindTurbineBase(
V_nominal(start = 480));
parameter Real scaleFraction[3](each min=0, each max=1.0) = ones(3)/3
"Fraction of power allocated to the wind turbines of each phase";
replaceable OnePhase.Sources.WindTurbine
wt_phase2(
replaceable OnePhase.Sources.WindTurbine wt_phase2(
pf=pf,
eta_DCAC=eta_DCAC,
scale=scale*scaleFraction[2],
Expand All @@ -19,10 +19,10 @@ partial model BaseUnbalancedWindTurbine
tableName=tableName,
fileName=fileName,
V_nominal=V_nominal/sqrt(3))
if plugPhase2 "Wind turbine phase 2"
if plugPhase2 "Wind turbine phase 2"
annotation (Placement(transformation(extent={{-20,-10},{-40,10}})));
replaceable OnePhase.Sources.WindTurbine
wt_phase3(

replaceable OnePhase.Sources.WindTurbine wt_phase3(
pf=pf,
eta_DCAC=eta_DCAC,
scale=scale*scaleFraction[3],
Expand All @@ -34,10 +34,10 @@ partial model BaseUnbalancedWindTurbine
tableName=tableName,
fileName=fileName,
V_nominal=V_nominal/sqrt(3))
if plugPhase3 "Wind turbine phase 3"
if plugPhase3 "Wind turbine phase 3"
annotation (Placement(transformation(extent={{-20,-60},{-40,-40}})));
replaceable OnePhase.Sources.WindTurbine
wt_phase1(

replaceable OnePhase.Sources.WindTurbine wt_phase1(
pf=pf,
eta_DCAC=eta_DCAC,
scale=scale*scaleFraction[1],
Expand All @@ -49,7 +49,7 @@ partial model BaseUnbalancedWindTurbine
tableName=tableName,
fileName=fileName,
V_nominal=V_nominal/sqrt(3))
if plugPhase1 "Wind turbine phase 1"
if plugPhase1 "Wind turbine phase 1"
annotation (Placement(transformation(extent={{-18,40},{-38,60}})));
Modelica.Blocks.Math.Add3 sumBlock "Sum of th epower generated on each phase"
annotation (Placement(transformation(extent={{32,50},{52,70}})));
Expand Down
188 changes: 188 additions & 0 deletions Buildings/Electrical/BaseClasses/WindTurbine/PartialWindTurbine.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
within Buildings.Electrical.BaseClasses.WindTurbine;
model PartialWindTurbine
"Partial model of a wind turbine with power output based on table as a function of wind speed"
extends Buildings.Electrical.BaseClasses.WindTurbine.PartialWindTurbineBase;
replaceable package PhaseSystem =
Buildings.Electrical.PhaseSystems.PartialPhaseSystem
constrainedby Buildings.Electrical.PhaseSystems.PartialPhaseSystem
"Phase system"
annotation (choicesAllMatching=true);

replaceable Buildings.Electrical.Interfaces.Terminal terminal(
redeclare package PhaseSystem = PhaseSystem) "Generalized terminal"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
protected
Modelica.Blocks.Tables.CombiTable1Ds per(
final tableOnFile=tableOnFile,
final table=cat(1, cat(1, [0, 0], table),
[vOut+10*Modelica.Constants.eps, 0;
vOut+20*Modelica.Constants.eps, 0]),
final tableName=tableName,
final fileName=fileName,
final columns=2:2,
final smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments)
"Performance table that maps wind speed to electrical power output"
annotation (Placement(transformation(extent={{-30,20},{-10,40}})));
Modelica.Blocks.Math.Gain gain(final k=scale)
"Gain, used to allow a user to easily scale the power"
annotation (Placement(transformation(extent={{2,20},{22,40}})));
DC.Sources.BaseClasses.WindCorrection cor(
final h=h,
final hRef=hRef,
final n=nWin) "Correction for wind"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
origin={-50,30})));
initial equation
assert(abs(table[1,2]) < Modelica.Constants.eps,
"First data point of performance table must be at cut-in wind speed,
and be equal to 0 Watts.
Received + " + String(table[1,1]) + " m/s with " + String(table[1,2]) + " Watts");
equation
assert(gain.y>=0, "Wind power must be positive");
connect(per.y[1],gain. u) annotation (Line(
points={{-9,30},{0,30}},
color={0,0,127},
smooth=Smooth.None));
connect(vWin,cor. vRef) annotation (Line(
points={{1.77636e-15,120},{1.77636e-15,90},{-70,90},{-70,30},{-62.2,30}},
color={0,0,127},
smooth=Smooth.None));
connect(cor.vLoc,per. u) annotation (Line(
points={{-39,30},{-32,30}},
color={0,0,127},
smooth=Smooth.None));
connect(gain.y, P) annotation (Line(
points={{23,30},{60,30},{60,60},{110,60}},
color={0,0,127},
smooth=Smooth.None));
annotation ( Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics={
Rectangle(
extent={{-100,102},{100,-98}},
pattern=LinePattern.None,
fillColor={202,230,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Rectangle(
extent={{42,46},{46,-52}},
fillColor={233,233,233},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Rectangle(
extent={{-42,14},{-38,-84}},
fillColor={233,233,233},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Polygon(
points={{-44,12},{-26,-40},{-38,16},{-44,12}},
smooth=Smooth.None,
fillColor={222,222,222},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Polygon(
points={{-38,12},{8,46},{-42,18},{-38,12}},
smooth=Smooth.None,
fillColor={222,222,222},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Polygon(
points={{-42,12},{-90,40},{-38,18},{-42,12}},
smooth=Smooth.None,
fillColor={222,222,222},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Polygon(
points={{40,44},{100,40},{42,50},{40,44}},
smooth=Smooth.None,
fillColor={222,222,222},
fillPattern=FillPattern.Solid,
lineColor={0,0,0}),
Polygon(
points={{-21,-17},{27,17},{-25,-11},{-21,-17}},
smooth=Smooth.None,
fillColor={222,222,222},
fillPattern=FillPattern.Solid,
origin={29,69},
rotation=90,
lineColor={0,0,0}),
Polygon(
points={{24,-14},{-20,22},{26,-8},{24,-14}},
smooth=Smooth.None,
fillColor={222,222,222},
fillPattern=FillPattern.Solid,
origin={32,20},
rotation=90,
lineColor={0,0,0}),
Ellipse(
extent={{-46,20},{-34,8}},
lineColor={0,0,0},
fillColor={222,222,222},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{38,52},{50,40}},
lineColor={0,0,0},
fillColor={222,222,222},
fillPattern=FillPattern.Solid),
Text(
extent={{-42,134},{-20,108}},
textColor={0,0,127},
textString="v"),
Text(
extent={{100,100},{122,74}},
textColor={0,0,127},
textString="P")}),
Documentation(info="<html>
<p>
Model of a wind turbine whose power is computed as a function of wind-speed as defined in a table.
</p>
<p>
Input to the model is the local wind speed.
The model requires the specification of a table that maps wind speed in meters per second to generated
power <i>P<sub>t</sub></i> in Watts.
The model has a parameter called <code>scale</code> with a default value of one
that can be used to scale the power generated by the wind turbine.
The generated electrical power is
<p align=\"center\" style=\"font-style:italic;\">
P = P<sub>t</sub> scale
</p>
<p>
For example, the following specification (with default <code>scale=1</code>) of a wind turbine
</p>
<pre>
WindTurbine_Table tur(
table=[3.5, 0;
5.5, 100;
12, 900;
14, 1000;
25, 1000]) \"Wind turbine\";
</pre>
<p>
yields the performance shown below. In this example, the cut-in wind speed is
<i>3.5</i> meters per second,
and the cut-out wind speed is <i>25</i> meters per second,
as entered by the first and last entry of the wind speed column.
Below and above these wind speeds, the generated power is zero.
</p>
<p align=\"center\">
<img alt=\"alt-image\" src=\"modelica://Buildings/Resources/Images/Electrical/DC/Sources/WindTurbine_Table.png\"/>
</p>
</html>", revisions="<html>
<ul>
<li>
March 1, 2016, by Michael Wetter:<br/>
Removed test for equality of <code>Real</code> variables.
This is for
<a href=\"https://github.com/lbl-srg/modelica-Buildings/issues/493\">issue 493</a>.
</li>
<li>
January 10, 2013, by Michael Wetter:<br/>
First implementation.
</li>
<li>
October 31, 2013, by Marco Bonvini:<br/>
Models included in the Buildings library. Modified the information section.
</li>
</ul>
</html>"));
end PartialWindTurbine;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
within Buildings.Electrical.BaseClasses.WindTurbine;
partial model PartialWindTurbineBase
"Base class for turbine model that contains basic parameters"
final parameter Modelica.Units.SI.Velocity vIn=table[1, 1]
"Cut-in steady wind speed";
final parameter Modelica.Units.SI.Velocity vOut=table[size(table, 1), 1]
"Cut-out steady wind speed";
parameter Real scale(min=0)=1
"Scaling factor, used to allow adjusting the power output without changing the table";

parameter Real h "Height over ground"
annotation (Dialog(group="Wind correction"));
parameter Modelica.Units.SI.Height hRef=10
"Reference height for wind measurement"
annotation (Dialog(group="Wind correction"));
parameter Real nWin(min=0) = 0.4
"Height exponent for wind profile calculation"
annotation (Dialog(group="Wind correction"));

parameter Boolean tableOnFile=false
"true, if table is defined on file or in function usertab";
parameter Real table[:,2]=
[3.5, 0;
5.5, 0.1;
12, 0.9;
14, 1;
25, 1]
"Table of generated power (first column is wind speed, second column is power)";
parameter String tableName="NoName"
"Table name on file or in function usertab (see documentation)";
parameter String fileName="NoName" "File where matrix is stored";
parameter Modelica.Units.SI.Voltage V_nominal(min=0, start=110)
"Nominal voltage (V_nominal >= 0)"
annotation (Evaluate=true, Dialog(group="Nominal conditions"));
Modelica.Blocks.Interfaces.RealInput vWin(unit="m/s") "Steady wind speed"
annotation (Placement(transformation(
origin={0,120},
extent={{-20,-20},{20,20}},
rotation=270), iconTransformation(
extent={{-20,-20},{20,20}},
rotation=270,
origin={0,120})));
Modelica.Blocks.Interfaces.RealOutput P(unit="W") "Generated power"
annotation (Placement(transformation(extent={{100,50},{120,70}})));
annotation (Documentation(info="<html>
<p>
This partial model contains the minimum set of parameters necessary to describe
a wind turbine.
The model defines also an output <code>P</code> for the power generated by the wind turbine.
</p>
</html>", revisions="<html>
<ul>
<li>
January 10, 2013, by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"));
end PartialWindTurbineBase;
16 changes: 16 additions & 0 deletions Buildings/Electrical/BaseClasses/WindTurbine/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
within Buildings.Electrical.BaseClasses;
package WindTurbine
annotation(preferredView="info",Documentation(info="<html>
<p>
This package contains base classes that are used model the WindTurbine models.
</p>
</html>",
revisions="<html>
<ul>
<li>
June 9, 2023, by Laura Maier:<br/>
Added documentation.
</li>
</ul>
</html>"));
end WindTurbine;
2 changes: 2 additions & 0 deletions Buildings/Electrical/BaseClasses/WindTurbine/package.order
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PartialWindTurbine
PartialWindTurbineBase
11 changes: 11 additions & 0 deletions Buildings/Electrical/BaseClasses/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
within Buildings.Electrical;
package BaseClasses "Package with base classes for Buildings.Electrical"
extends Modelica.Icons.BasesPackage;

annotation (preferredView="info", Documentation(info="<html>
<p>
This package contains base classes that are used to construct the models in
<a href=\"modelica://Buildings.Electrical\">Buildings.Electrical</a>.
</p>
</html>"));
end BaseClasses;
1 change: 1 addition & 0 deletions Buildings/Electrical/BaseClasses/package.order
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WindTurbine
4 changes: 2 additions & 2 deletions Buildings/Electrical/Interfaces/Ground.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ model Ground "Generalized model of a ground connection."
Buildings.Electrical.PhaseSystems.PartialPhaseSystem "Phase system"
annotation (choicesAllMatching=true);

replaceable Buildings.Electrical.Interfaces.Terminal terminal(redeclare
package PhaseSystem = PhaseSystem) "Generalized terminal"
replaceable Buildings.Electrical.Interfaces.Terminal terminal(
redeclare package PhaseSystem = PhaseSystem) "Generalized terminal"
annotation (Placement(transformation(extent={{-8,92},{8,108}}),
iconTransformation(extent={{-8,92},{8,108}})));
equation
Expand Down
Loading

0 comments on commit 6207337

Please sign in to comment.