Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1373 weather file in FMU #1374

Merged
merged 4 commits into from
Jun 10, 2020
Merged
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
30 changes: 12 additions & 18 deletions IBPSA/BoundaryConditions/SolarGeometry/BaseClasses/SolarAzimuth.mo
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 IBPSA.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://IBPSA.BoundaryConditions.SolarGeometry.BaseClasses.SolarAzimuth\">
IBPSA.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 IBPSA.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://IBPSA.BoundaryConditions.SolarGeometry.BaseClasses.SolarAzimuth\">
IBPSA.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;