Skip to content

Commit

Permalink
Change to one-line if-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
dhblum committed Jun 9, 2020
1 parent 3ec71e5 commit 06b0389
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions IBPSA/BoundaryConditions/SolarGeometry/BaseClasses/SolarAzimuth.mo
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ protected
"Latitude of polar circle (66 degree 33 min 44 sec)";
final parameter Boolean outsidePolarCircle = lat < polarCircle and lat > -polarCircle
"Flag, true if latitude is outside polar region";

// 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 so that lat does not become structural parameter with JModelica.org
Real tmp2 = if outsidePolarCircle then noEvent(solTim - integer(solTim/day)) else solTim - integer(solTim/day) "Temporary variable for night check";
equation
tmp = (Modelica.Math.sin(lat)*Modelica.Math.cos(zen) - Modelica.Math.sin(
decAng))/(Modelica.Math.cos(lat)*Modelica.Math.sin(zen));
Expand All @@ -35,23 +42,7 @@ equation

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;
solAzi = solAziTem*(if (tmp2*day < 43200) then -1 else 1);

annotation (
defaultComponentName="solAzi",
Expand Down

0 comments on commit 06b0389

Please sign in to comment.