Skip to content

Commit

Permalink
Bugfix for sky cover if not obtained from weather file.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Oct 17, 2014
1 parent 42288ed commit cdc706d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 11 deletions.
Expand Up @@ -2,9 +2,11 @@ within Buildings.BoundaryConditions.WeatherData.BaseClasses;
block CheckSkyCover "Constrains the sky cover to [0, 1]"
extends Modelica.Blocks.Icons.Block;
public
Modelica.Blocks.Interfaces.RealInput nIn "Input sky cover [0, 10]"
Modelica.Blocks.Interfaces.RealInput nIn(min=0, max=1, unit="1")
"Input sky cover [0, 10]"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
Modelica.Blocks.Interfaces.RealOutput nOut(unit="1") "Sky cover [0, 10]"
Modelica.Blocks.Interfaces.RealOutput nOut(min=0, max=1, unit="1")
"Sky cover [0, 1]"
annotation (Placement(transformation(extent={{100,-10},{120,10}})));

constant Real delta=0.01 "Smoothing parameter";
Expand All @@ -16,27 +18,36 @@ equation
nIn,
nMin,
nMax,
delta/10)/10;
delta/10);
annotation (
defaultComponentName="cheSkyCov",
Documentation(info="<html>
<p>
This component constrains the interpolated sky cover between <i>0</i> and <i>10</i>.
This component constrains the interpolated sky cover between <i>0</i> and <i>1</i>.
</p>
</html>
", revisions="<html>
<ul>
<li>
October 17, 2014, by Michael Wetter:<br/>
Changed model as
<a href=\"modelica://Buildings.BoundaryConditions.WeatherData.ReaderTMY3\">
Buildings.BoundaryConditions.WeatherData.ReaderTMY3</a>
send a signal between <i>0</i> and <i>1</i>.
Added <code>min</code> and <code>max</code>
attributes.
</li>
<li>
July 14, 2010, by Wangda Zuo:<br/>
First implementation.
</li>
</ul>
</html>"),
Diagram(coordinateSystem(preserveAspectRatio=true,extent={{-100,-100},{100,
100}})),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
Icon(coordinateSystem(preserveAspectRatio=false,extent={{-100,-100},{100,
100}}), graphics={Text(
extent={{-34,56},{46,-48}},
extent={{-64,48},{70,-48}},
lineColor={0,0,255},
textString="Sky")}));
end CheckSkyCover;
37 changes: 33 additions & 4 deletions Buildings/BoundaryConditions/WeatherData/ReaderTMY3.mo
Expand Up @@ -42,7 +42,8 @@ block ReaderTMY3 "Reader for TMY3 weather data"
parameter Real totSkyCov(
min=0,
max=1,
unit="1") = 0.5 "Total sky cover (used if totSkyCov=Parameter)"
unit="1") = 0.5
"Total sky cover (used if totSkyCov=Parameter). Use 0 <= totSkyCov <= 1"
annotation (Dialog(group="Data source"));
Modelica.Blocks.Interfaces.RealInput totSkyCov_in(
min=0,
Expand All @@ -57,7 +58,8 @@ block ReaderTMY3 "Reader for TMY3 weather data"
parameter Real opaSkyCov(
min=0,
max=1,
unit="1") = 0.5 "Opaque sky cover (used if opaSkyCov=Parameter)"
unit="1") = 0.5
"Opaque sky cover (used if opaSkyCov=Parameter). Use 0 <= opaSkyCov <= 1"
annotation (Dialog(group="Data source"));
Modelica.Blocks.Interfaces.RealInput opaSkyCov_in(
min=0,
Expand Down Expand Up @@ -369,6 +371,16 @@ protected
TDryBul(displayUnit="degC")) if computeWetBulbTemperature
annotation (Placement(transformation(extent={{244,-66},{264,-46}})));

//---------------------------------------------------------------------------
// Conversion blocks for sky cover
Modelica.Blocks.Math.Gain conTotSkyCov(final k=0.1) if
totSkyCovSou == Buildings.BoundaryConditions.Types.DataSource.File
"Convert sky cover from [0...10] to [0...1]"
annotation (Placement(transformation(extent={{120,-40},{140,-20}})));
Modelica.Blocks.Math.Gain conOpaSkyCov(final k=0.1) if
opaSkyCovSou == Buildings.BoundaryConditions.Types.DataSource.File
"Convert sky cover from [0...10] to [0...1]"
annotation (Placement(transformation(extent={{120,-158},{140,-138}})));
equation
//---------------------------------------------------------------------------
// Select atmospheric pressure connector
Expand Down Expand Up @@ -398,7 +410,11 @@ equation
elseif totSkyCovSou == Buildings.BoundaryConditions.Types.DataSource.Input then
connect(totSkyCov_in, totSkyCov_in_internal);
else
connect(datRea.y[13], totSkyCov_in_internal);
connect(conTotSkyCov.u, datRea.y[13]) annotation (Line(
points={{118,-30},{-59,-30}},
color={0,0,127},
smooth=Smooth.None));
connect(conTotSkyCov.y, totSkyCov_in_internal);
end if;
connect(totSkyCov_in_internal, cheTotSkyCov.nIn);
//---------------------------------------------------------------------------
Expand All @@ -408,9 +424,14 @@ equation
elseif opaSkyCovSou == Buildings.BoundaryConditions.Types.DataSource.Input then
connect(opaSkyCov_in, opaSkyCov_in_internal);
else
connect(datRea.y[14], opaSkyCov_in_internal);
connect(conOpaSkyCov.u, datRea.y[14]) annotation (Line(
points={{118,-148},{30,-148},{30,-29.92},{-59,-29.92}},
color={0,0,127},
smooth=Smooth.None));
connect(conOpaSkyCov.y, opaSkyCov_in_internal);
end if;
connect(opaSkyCov_in_internal, cheOpaSkyCov.nIn);

//---------------------------------------------------------------------------
// Select dew point temperature connector
if TDewPoiSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
Expand Down Expand Up @@ -1189,6 +1210,14 @@ Technical Report, NREL/TP-581-43156, revised May 2008.
", revisions="<html>
<ul>
<li>
October 17, 2014, by Michael Wetter<br/>
Corrected error that led the total and opaque sky cover to be ten times
too low if its value was obtained from the parameter or the input connector.
For the standard configuration in which the sky cover is obtained from
the weather data file, the model was correct. This error only affected
the other two possible configurations.
</li>
<li>
September 12, 2014, by Michael Wetter:<br/>
Removed redundant connection <code>connect(conHorRad.HOut, cheHorRad.HIn);</code>.
</li>
Expand Down
13 changes: 12 additions & 1 deletion Buildings/package.mo
Expand Up @@ -390,7 +390,18 @@ The following <b style=\"color:red\">critical errors</b> have been fixed (i.e.,
that can lead to wrong simulation results):
</p>
<table class=\"releaseTable\" summary=\"summary\" border=\"1\" cellspacing=0 cellpadding=2 style=\"border-collapse:collapse;\">
<tr><td colspan=\"2\"><b>Buildings.Fluid</b>
<tr><td colspan=\"2\"><b>Buildings.BoundaryConditions</b>
</td>
</tr>
<tr><td valign=\"top\">Buildings.BoundaryConditions.WeatherData.ReaderTMY3
</td>
<td valign=\"top\">Corrected error that led the total and opaque sky cover to be ten times
too low if its value was obtained from the parameter or the input connector.
For the standard configuration in which the sky cover is obtained from
the weather data file, the model was correct. This error only affected
the other two possible configurations.
</td>
</tr><tr><td colspan=\"2\"><b>Buildings.Fluid</b>
</td>
</tr>
<tr><td valign=\"top\">Buildings.Fluid.Data.Pipes
Expand Down

0 comments on commit cdc706d

Please sign in to comment.