Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lbl-srg/modelica-buildings
Browse files Browse the repository at this point in the history
…into issue2028_dualMin
  • Loading branch information
AntoineGautier committed Jul 30, 2020
2 parents e9ee609 + 56e25c5 commit ab105a6
Show file tree
Hide file tree
Showing 27 changed files with 1,653 additions and 280 deletions.
2 changes: 2 additions & 0 deletions Buildings/.copiedFiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Buildings/BoundaryConditions/SolarGeometry/BaseClasses/WallSolarAzimuth.mo
Buildings/BoundaryConditions/SolarGeometry/BaseClasses/ZenithAngle.mo
Buildings/BoundaryConditions/SolarGeometry/BaseClasses/package.mo
Buildings/BoundaryConditions/SolarGeometry/BaseClasses/package.order
Buildings/BoundaryConditions/SolarGeometry/BaseClasses/solarAzimuthNoEvent.mo
Buildings/BoundaryConditions/SolarGeometry/BaseClasses/solarAzimuthWithEvent.mo
Buildings/BoundaryConditions/SolarGeometry/Examples/IncidenceAngle.mo
Buildings/BoundaryConditions/SolarGeometry/Examples/ZenithAngle.mo
Buildings/BoundaryConditions/SolarGeometry/Examples/package.mo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,16 @@ protected
equation
tmp = (Modelica.Math.sin(lat)*Modelica.Math.cos(zen) - Modelica.Math.sin(
decAng))/(Modelica.Math.cos(lat)*Modelica.Math.sin(zen));

arg = min(1.0, max(-1.0, tmp));

solAziTem = Modelica.Math.acos(arg); // Solar azimuth (A4.9a and b) as a positive number

if outsidePolarCircle then
// Outside the polar circle, the only non-differentiability is at night when the sun is set.
// Hence, we use noEvent.
if noEvent(solTim - integer(solTim/day)*day < 43200) then
solAzi =-solAziTem;
else
solAzi = solAziTem;
end if;
else
// Inside the polar circle, there is a jump at (solar-)midnight when the sun can
// be above the horizon. Hence, we do not use noEvent(...)
if solTim - integer(solTim/day)*day < 43200 then
solAzi =-solAziTem;
else
solAzi = solAziTem;
end if;
end if;
// If outside the polar circle, the only non-differentiability is at night when the sun is set.
// Hence, we use noEvent.
// If inside the polar circle, there is a jump at (solar-)midnight when the sun can
// be above the horizon. Hence, we do not use noEvent(...)
// Written as one line with functions so that lat does not become structural parameter with JModelica.org
solAzi = if outsidePolarCircle then solarAzimuthNoEvent(solAziTem, solTim, day) else solarAzimuthWithEvent(solAziTem, solTim, day);

annotation (
defaultComponentName="solAzi",
Expand All @@ -62,6 +50,12 @@ This component computes the solar azimuth angle.
</html>", revisions="<html>
<ul>
<li>
June 9, 2020, by David Blum:<br/>
Reformulated to use one-line if-statements.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1373\">issue 1373</a>.
</li>
<li>
October 13, 2017, by Michael Wetter:<br/>
Reformulated to use equation rather than algorithm section.<br/>
This is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ SolarAzimuth
SolarHourAngle
WallSolarAzimuth
ZenithAngle
solarAzimuthNoEvent
solarAzimuthWithEvent
Examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
within Buildings.BoundaryConditions.SolarGeometry.BaseClasses;
function solarAzimuthNoEvent "Determines solar azimuth with no event"
input Real solAziTem(quantity="Angle",unit="rad",displayUnit="deg") "Temporary solar azimuth";
input Real solTim(quantity="Time", unit="s") "Solar time";
input Real day(quantity="Time", unit="s") "Number of seconds in day";
output Real solAzi(quantity="Angle",unit="rad",displayUnit="deg") "Solar azimuth";
algorithm
if noEvent(solTim - integer(solTim/day)*day<43200) then
solAzi := -solAziTem;
else
solAzi := solAziTem;
end if;

annotation (
Documentation(info="<html>
<p>
This function is used within
<a href=\"modelica://Buildings.BoundaryConditions.SolarGeometry.BaseClasses.SolarAzimuth\">
Buildings.BoundaryConditions.SolarGeometry.BaseClasses.SolarAzimuth</a>
to calculate solar azimuth with no events.
</p>
</html>", revisions="<html>
<ul>
<li>
June 9, 2020 by David Blum:<br/>
Initial implementation.
This is for issue
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1373\">#1373</a>.
</li>
</ul>
</html>"));
end solarAzimuthNoEvent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
within Buildings.BoundaryConditions.SolarGeometry.BaseClasses;
function solarAzimuthWithEvent "Determines solar azimuth with event"
input Real solAziTem(quantity="Angle",unit="rad",displayUnit="deg") "Temporary solar azimuth";
input Real solTim(quantity="Time", unit="s") "Solar time";
input Real day(quantity="Time", unit="s") "Number of seconds in day";
output Real solAzi(quantity="Angle",unit="rad",displayUnit="deg") "Solar azimuth";
algorithm
if (solTim - integer(solTim/day)*day<43200) then
solAzi := -solAziTem;
else
solAzi := solAziTem;
end if;
annotation (
Documentation(info="<html>
<p>
This function is used within
<a href=\"modelica://Buildings.BoundaryConditions.SolarGeometry.BaseClasses.SolarAzimuth\">
Buildings.BoundaryConditions.SolarGeometry.BaseClasses.SolarAzimuth</a>
to calculate solar azimuth with events.
</p>
</html>", revisions="<html>
<ul>
<li>
June 9, 2020 by David Blum:<br/>
Initial implementation.
This is for issue
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1373\">#1373</a>.
</li>
</ul>
</html>"));
end solarAzimuthWithEvent;
19 changes: 18 additions & 1 deletion Buildings/Controls/OBC/CDL/Logical/IntegerSwitch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Otherwise, it outputs <code>y = u3</code>.
</html>", revisions="<html>
<ul>
<li>
July 17, 2020, by Jianjun Hu:<br/>
Changed icon to display dynamically which input signal is being outputted.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2033\"># 2033</a>.
</li>
<li>
July 10, 2019, by Milica Grahovac:<br/>
First implementation.
</li>
Expand Down Expand Up @@ -61,7 +67,8 @@ First implementation.
Line(points={{-40,12},{-40,-10}}, color={255,0,255}),
Line(points={{-100,80},{-40,80}}, color={244,125,35}),
Line(
points={{-40,80},{8,2}},
points=DynamicSelect({{8,2},{-40,80}},
{{8,2},if u2 then {-40,80} else {-40,-80}}),
color={244,125,35},
thickness=1),
Ellipse(lineColor={0,0,127},
Expand All @@ -75,6 +82,16 @@ First implementation.
fillColor=DynamicSelect({235,235,235}, if u2 then {0,255,0}
else {235,235,235}),
fillPattern=FillPattern.Solid),
Text(
extent={{-90,80},{-46,54}},
lineColor=DynamicSelect({0,0,0},
if u2 then {0,0,0} else {235,235,235}),
textString="true"),
Text(
extent={{-90,-46},{-38,-76}},
lineColor=DynamicSelect({0,0,0},
if u2 then {235,235,235} else {0,0,0}),
textString="false"),
Text(
extent={{-150,150},{150,110}},
lineColor={0,0,255},
Expand Down
19 changes: 18 additions & 1 deletion Buildings/Controls/OBC/CDL/Logical/LogicalSwitch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Otherwise, it outputs <code>y = u3</code>.
</html>", revisions="<html>
<ul>
<li>
July 17, 2020, by Jianjun Hu:<br/>
Changed icon to display dynamically which input signal is being outputted.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2033\"># 2033</a>.
</li>
<li>
January 3, 2017, by Michael Wetter:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
Expand Down Expand Up @@ -61,7 +67,8 @@ Modelica Standard Library.
Line(points={{-40,12},{-40,-10}}, color={255,0,255}),
Line(points={{-100,80},{-40,80}}, color={255,0,255}),
Line(
points={{-40,80},{8,2}},
points=DynamicSelect({{8,2},{-40,80}},
{{8,2},if u2 then {-40,80} else {-40,-80}}),
color={255,0,255},
thickness=1),
Ellipse(lineColor={0,0,127},
Expand Down Expand Up @@ -96,6 +103,16 @@ Modelica Standard Library.
fillColor=DynamicSelect({235,235,235}, if y then {0,255,0}
else {235,235,235}),
fillPattern=FillPattern.Solid),
Text(
extent={{-90,76},{-46,50}},
lineColor=DynamicSelect({0,0,0},
if u2 then {0,0,0} else {235,235,235}),
textString="true"),
Text(
extent={{-90,-42},{-38,-72}},
lineColor=DynamicSelect({0,0,0},
if u2 then {235,235,235} else {0,0,0}),
textString="false"),
Text(
extent={{-150,150},{150,110}},
lineColor={0,0,255},
Expand Down
23 changes: 20 additions & 3 deletions Buildings/Controls/OBC/CDL/Logical/Switch.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Otherwise, it outputs <code>y = u3</code>.
</html>", revisions="<html>
<ul>
<li>
July 17, 2020, by Jianjun Hu:<br/>
Changed icon to display dynamically which input signal is being outputted.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2033\"># 2033</a>.
</li>
<li>
January 3, 2017, by Michael Wetter:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
Expand All @@ -57,9 +63,10 @@ Modelica Standard Library.
color={0,0,127}),
Line(points={{-40.0,12.0},{-40.0,-12.0}},
color={255,0,255}),
Line(points={{-100.0,80.0},{-38.0,80.0}},
color={0,0,127}),
Line(points={{-38.0,80.0},{6.0,2.0}},
Line(points={{-100.0,80.0},{-40.0,80.0}}, color={0,0,127}),
Line(
points=DynamicSelect({{10,0},{-40,80}},
{{10,0},if u2 then {-40,80} else {-40,-80}}),
color={0,0,127},
thickness=1.0),
Ellipse(lineColor={0,0,255},
Expand All @@ -73,6 +80,16 @@ Modelica Standard Library.
fillColor=DynamicSelect({235,235,235}, if u2 then {0,255,0}
else {235,235,235}),
fillPattern=FillPattern.Solid),
Text(
extent={{-90,80},{-46,54}},
lineColor=DynamicSelect({0,0,0},
if u2 then {0,0,0} else {235,235,235}),
textString="true"),
Text(
extent={{-90,-46},{-38,-76}},
lineColor=DynamicSelect({0,0,0},
if u2 then {235,235,235} else {0,0,0}),
textString="false"),
Text(
extent={{-150,150},{150,110}},
lineColor={0,0,255},
Expand Down
Loading

0 comments on commit ab105a6

Please sign in to comment.