LBL logo

Buildings.BoundaryConditions.WeatherData

Weather data reader

Information

This package contains models to read weather data. It also contains an expandable connector called Bus that is used in the library to provide weather data to the different models.

Extends from Modelica.Icons.VariantsPackage (Icon for package containing variants).

Package Content

NameDescription
Buildings.BoundaryConditions.WeatherData.UsersGuide UsersGuide User's Guide
Buildings.BoundaryConditions.WeatherData.ReaderTMY3 ReaderTMY3 Reader for TMY3 weather data
Buildings.BoundaryConditions.WeatherData.Bus Bus Data bus that stores weather data
Buildings.BoundaryConditions.WeatherData.Examples Examples Collection of models that illustrate model use and test models
Buildings.BoundaryConditions.WeatherData.BaseClasses BaseClasses Package with base classes for Buildings.BoundaryConditions.WeatherData


Buildings.BoundaryConditions.WeatherData.ReaderTMY3 Buildings.BoundaryConditions.WeatherData.ReaderTMY3

Reader for TMY3 weather data

Buildings.BoundaryConditions.WeatherData.ReaderTMY3

Information

This component reads TMY3 weather data (Wilcox and Marion, 2008) or user specified weather data. The parameter lon is the longitude of the weather station, and the parameter timZone is the time zone relative to Greenwich Mean Time. By default, the reader obtains values for these parameters by scanning the TMY3 weather data file except the atmospheric pressure which use 101325 Pascals as default value.

This model has the option of using a constant value, using the data from the weather file, or from an input connector for the following variables: atmospheric pressure, relative humidity, dry bulb temperature, global horizontal radiation, diffuse horizontal radiation, wind direction and wind speed.

For instance, the atmospheric pressure is set to the parameter pAtm = 101325 Pascals. The parameter pAtmSou can be used to change the source that is used as the atmospheric pressure. The input connector will be enabled if pAtmSou = Buildings.BoundaryConditions.Types.DataSource.Input. The the weather file will be read if pAtmSou = Buildings.BoundaryConditions.Types.DataSource.File.

    Notes
  1. In HVAC systems, when the fan is off, changes in atmospheric pressure can cause small air flow rates in the duct system due to change in pressure and hence in the mass of air that is stored in air volumes (such as in fluid junctions or in the room model). This may increase computing time. Therefore, the default value for the atmospheric pressure is set to a constant. Furthermore, if the initial pressure of air volumes are different from the atmospheric pressure, then fast pressure transients can happen in the first few seconds of the simulation. This can cause numerical problems for the solver. To avoid this problem, set the atmospheric pressure to the same value as the medium default pressure, which is typically set to the parameter Medium.p_default.

  2. The data units of user specified input files should be SI units consistent with Modelica standard. For instance, the unit for the solar radiation should be W/m2 and that for the wind direction should be rad.

  3. The ReaderTMY3 should only be used with TMY3 data. It contains a time shift for solar radiation data that is explained below. This time shift should be removed if the user may want to use the ReaderTMY3 for other weather data types.

Implementation

To read weather data from the TMY3 weather data file, there are two data readers in this model. One data reader obtains all data except solar radiation, and the other data reader reads only the solar radiation data, shifted by 30 minutes. The reason for this time shift is as follows: The TMY3 weather data file contains for solar radiation the "...radiation received on a horizontal surface during the 60-minute period ending at the timestamp." Thus, as the figure below shows, a more accurate interpolation is obtained if time is shifted by 30 minutes prior to reading the weather data.

References

Parameters

TypeNameDefaultDescription
StringfilNam Name of weather data file
Data source
DataSourcepAtmSouBuildings.BoundaryConditions...Atmospheric pressure
PressurepAtm101325Atmospheric pressure (used if pAtmSou=Parameter) [Pa]
DataSourceTDryBulSouBuildings.BoundaryConditions...Dry bulb temperature
TemperatureTDryBul293.15Dry bulb temperature (used if TDryBul=Parameter) [K]
DataSourcerelHumSouBuildings.BoundaryConditions...Relative humidity
RealrelHum0.5Relative humidity (used if relHum=Parameter) [1]
DataSourcewinSpeSouBuildings.BoundaryConditions...Wind speed
VelocitywinSpe1Wind speed (used if winSpe=Parameter) [m/s]
DataSourcewinDirSouBuildings.BoundaryConditions...Wind direction
AnglewinDir1.0Wind direction (used if winDir=Parameter) [rad]
DataSourceHGloHorSouBuildings.BoundaryConditions...Global horizontal radiation
RadiantEnergyFluenceRateHGloHor100Global horizontal radiation (used if HGloHor=Parameter) [W/m2]
DataSourceHDifHorSouBuildings.BoundaryConditions...Diffuse horizontal radiation
RadiantEnergyFluenceRateHDifHor50Diffuse horizontal radiation (used if HDifHor=Parameter) [W/m2]
Sky temperature
SkyTemperatureCalculationcalTSkyBuildings.BoundaryConditions...Computation of black-body sky temperature

Connectors

TypeNameDescription
input RealInputpAtm_inInput pressure [Pa]
input RealInputTDryBul_inInput dry bulb temperature [K]
input RealInputrelHum_inInput relative humidity [1]
input RealInputwinSpe_inInput wind speed [m/s]
input RealInputwinDir_inInput wind direction [rad]
input RealInputHGloHor_inInput global horizontal radiation [W/m2]
input RealInputHDifHor_inInput diffuse horizontal radiation [W/m2]
BusweaBusWeather Data Bus

Modelica definition

block ReaderTMY3 "Reader for TMY3 weather data "
  //--------------------------------------------------------------
  // Atmospheric pressure
  parameter Buildings.BoundaryConditions.Types.DataSource pAtmSou=Buildings.BoundaryConditions.Types.DataSource.Parameter 
    "Atmospheric pressure";
  parameter Modelica.SIunits.Pressure pAtm=101325 
    "Atmospheric pressure (used if pAtmSou=Parameter)";
  Modelica.Blocks.Interfaces.RealInput pAtm_in(
    final quantity="Pressure",
    final unit="Pa",
    displayUnit="Pa") if (pAtmSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input pressure";
  //--------------------------------------------------------------
  // Dry bulb temperature
  parameter Buildings.BoundaryConditions.Types.DataSource TDryBulSou=Buildings.BoundaryConditions.Types.DataSource.File 
    "Dry bulb temperature";
  parameter Modelica.SIunits.Temperature TDryBul(displayUnit="degC") = 293.15 
    "Dry bulb temperature (used if TDryBul=Parameter)";
  Modelica.Blocks.Interfaces.RealInput TDryBul_in(
    final quantity="Temperature",
    final unit="K",
    displayUnit="degC") if (TDryBulSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input dry bulb temperature";
  //--------------------------------------------------------------
  // Relative humidity
  parameter Buildings.BoundaryConditions.Types.DataSource relHumSou=Buildings.BoundaryConditions.Types.DataSource.File 
    "Relative humidity";
  parameter Real relHum(
    min=0,
    max=1,
    unit="1") = 0.5 "Relative humidity (used if relHum=Parameter)";
  Modelica.Blocks.Interfaces.RealInput relHum_in(
    min=0,
    max=1,
    unit="1") if (relHumSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input relative humidity";
  //--------------------------------------------------------------
  // Wind speed
  parameter Buildings.BoundaryConditions.Types.DataSource winSpeSou=Buildings.BoundaryConditions.Types.DataSource.File 
    "Wind speed";
  parameter Modelica.SIunits.Velocity winSpe(min=0) = 1 
    "Wind speed (used if winSpe=Parameter)";
  Modelica.Blocks.Interfaces.RealInput winSpe_in(
    final quantity="Velocity",
    final unit="m/s",
    min=0,
    displayUnit="m/s") if (winSpeSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input wind speed";
  //--------------------------------------------------------------
  // Wind direction
  parameter Buildings.BoundaryConditions.Types.DataSource winDirSou=Buildings.BoundaryConditions.Types.DataSource.File 
    "Wind direction";
  parameter Modelica.SIunits.Angle winDir=1.0 
    "Wind direction (used if winDir=Parameter)";
  Modelica.Blocks.Interfaces.RealInput winDir_in(
    final quantity="Angle",
    final unit="rad",
    displayUnit="deg") if (winDirSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input wind direction";
  //--------------------------------------------------------------
  // Global horizontal radiation
  parameter Buildings.BoundaryConditions.Types.DataSource HGloHorSou=Buildings.BoundaryConditions.Types.DataSource.File 
    "Global horizontal radiation";
  parameter Modelica.SIunits.RadiantEnergyFluenceRate HGloHor=100 
    "Global horizontal radiation (used if HGloHor=Parameter)";
  Modelica.Blocks.Interfaces.RealInput HGloHor_in(
    final quantity="RadiantEnergyFluenceRate",
    final unit="W/m2",
    displayUnit="W/m2") = 100 if (HGloHorSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input global horizontal radiation";
  //--------------------------------------------------------------
  // Diffuse horizontal radiation
  parameter Buildings.BoundaryConditions.Types.DataSource HDifHorSou=Buildings.BoundaryConditions.Types.DataSource.File 
    "Diffuse horizontal radiation";
  parameter Modelica.SIunits.RadiantEnergyFluenceRate HDifHor=50 
    "Diffuse horizontal radiation (used if HDifHor=Parameter)";
  Modelica.Blocks.Interfaces.RealInput HDifHor_in(
    final quantity="RadiantEnergyFluenceRate",
    final unit="W/m2",
    displayUnit="W/m2") if (HDifHorSou == Buildings.BoundaryConditions.Types.DataSource.Input) 
    "Input diffuse horizontal radiation";
  parameter String filNam "Name of weather data file";
  final parameter Modelica.SIunits.Angle lon(displayUnit="deg")=
    Buildings.BoundaryConditions.WeatherData.BaseClasses.getLongitudeTMY3(
    filNam) "Longitude";
  final parameter Modelica.SIunits.Time timZon(displayUnit="h")=
    Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3(filNam) 
    "Time zone";
  Bus weaBus "Weather Data Bus";
  parameter Buildings.BoundaryConditions.Types.SkyTemperatureCalculation
    calTSky=Buildings.BoundaryConditions.Types.SkyTemperatureCalculation.TemperaturesAndSkyCover 
    "Computation of black-body sky temperature";
protected 
  Modelica.Blocks.Tables.CombiTable1Ds datRea(
    final tableOnFile=true,
    final tableName="tab1",
    final fileName=filNam,
    final smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative,
    final columns={2,3,4,5,6,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
        28,29,30}) "Data reader";
  Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckTemperature
    cheTemDryBul "Check dry bulb temperature ";
  Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckTemperature
    cheTemDewPoi "Check dew point temperature";
  Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRelativeHumidity
    conRelHum "Convert the relative humidity from percentage to [0, 1] ";
  BaseClasses.CheckPressure chePre "Check the air pressure";
  BaseClasses.CheckSkyCover cheTotSkyCov "Check the total sky cover";
  BaseClasses.CheckSkyCover cheOpaSkyCov "Check the opaque sky cover";
  BaseClasses.CheckRadiation cheGloHorRad 
    "Check the global horizontal radiation";
  BaseClasses.CheckRadiation cheDifHorRad 
    "Check the diffuse horizontal radiation";
  BaseClasses.CheckRadiation cheDirNorRad "Check the direct normal radiation";
  BaseClasses.CheckCeilingHeight cheCeiHei "Check the ceiling height";
  BaseClasses.CheckWindSpeed cheWinSpe "Check the wind speed";
  BaseClasses.CheckRadiation cheHorRad "Check the horizontal radiation";
  BaseClasses.CheckWindDirection cheWinDir "Check the wind direction";
  SkyTemperature.BlackBody TBlaSky(final calTSky=calTSky) 
    "Check the sky black-body temperature";
  Utilities.SimulationTime simTim "Simulation time";
  Modelica.Blocks.Math.Add add 
    "Add 30 minutes to time to shift weather data reader";
  Modelica.Blocks.Sources.Constant con30mins(final k=1800) 
    "Constant used to shift weather data reader";
  Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime locTim(
      final lon=lon, final timZon=timZon) "Local civil time";
  Modelica.Blocks.Tables.CombiTable1Ds datRea1(
    final tableOnFile=true,
    final tableName="tab1",
    final fileName=filNam,
    final smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative,
    final columns=8:11) "Data reader";
  Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime conTim1 
    "Convert simulation time to calendar time";
  BaseClasses.ConvertTime conTim "Convert simulation time to calendar time";
  BaseClasses.EquationOfTime eqnTim "Equation of time";
  BaseClasses.SolarTime solTim "Solar time";
  // Conditional connectors
  Modelica.Blocks.Interfaces.RealInput pAtm_in_internal(
    final quantity="Pressure",
    final unit="Pa",
    displayUnit="bar") "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput TDryBul_in_internal(
    final quantity="Temperature",
    final unit="K",
    displayUnit="degC") "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput relHum_in_internal(
    final quantity="1",
    min=0,
    max=1) "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput winSpe_in_internal(
    final quantity="Velocity",
    final unit="m/s",
    displayUnit="m/s") "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput winDir_in_internal(
    final quantity="Angle",
    final unit="rad",
    displayUnit="deg") "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput HGloHor_in_internal(
    final quantity="RadiantEnergyFluenceRate",
    final unit="W/m2",
    displayUnit="W/m2") "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput HDifHor_in_internal(
    final quantity="RadiantEnergyFluenceRate",
    final unit="W/m2",
    displayUnit="W/m2") "Needed to connect to conditional connector";
  Modelica.Blocks.Math.UnitConversions.From_deg conWinDir 
    "Convert the wind direction unit from [deg] to [rad]";
  Modelica.Blocks.Math.UnitConversions.From_degC conTDryBul;
  BaseClasses.ConvertRadiation conHorRad;
  Modelica.Blocks.Math.UnitConversions.From_degC conTDewPoi 
    "Convert the dew point temperature form [degC] to [K]";
  BaseClasses.ConvertRadiation conDirNorRad;
  BaseClasses.ConvertRadiation conGloHorRad;
  BaseClasses.ConvertRadiation conDifHorRad;
  BaseClasses.CheckRelativeHumidity cheRelHum;
equation 
  //---------------------------------------------------------------------------
  // Select atmospheric pressure connector
  if pAtmSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    pAtm_in_internal = pAtm;
  elseif pAtmSou == Buildings.BoundaryConditions.Types.DataSource.File then
    connect(datRea.y[4], pAtm_in_internal);
  else
    connect(pAtm_in, pAtm_in_internal);
  end if;
  connect(pAtm_in_internal, chePre.PIn);
  //---------------------------------------------------------------------------
  // Select dry bulb temperature connector
  if TDryBulSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    TDryBul_in_internal = TDryBul;
  elseif TDryBulSou == Buildings.BoundaryConditions.Types.DataSource.Input then
    connect(TDryBul_in, TDryBul_in_internal);
  else
    connect(conTDryBul.y, TDryBul_in_internal);
  end if;
  connect(TDryBul_in_internal, cheTemDryBul.TIn);
  //---------------------------------------------------------------------------
  // Select relative humidity connector
  if relHumSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    relHum_in_internal = relHum;
  elseif relHumSou == Buildings.BoundaryConditions.Types.DataSource.Input then
    connect(relHum_in, relHum_in_internal);
  else
    connect(conRelHum.relHumOut, relHum_in_internal);
  end if;
  connect(relHum_in_internal, cheRelHum.relHumIn);
  //---------------------------------------------------------------------------
  // Select wind speed connector
  if winSpeSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    winSpe_in_internal = winSpe;
  elseif winSpeSou == Buildings.BoundaryConditions.Types.DataSource.Input then
    connect(winSpe_in, winSpe_in_internal);
  else
    connect(datRea.y[12], winSpe_in_internal);
  end if;
  connect(winSpe_in_internal, cheWinSpe.winSpeIn);
  //---------------------------------------------------------------------------
  // Select wind direction connector
  if winDirSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    winDir_in_internal = winDir;
  elseif winDirSou == Buildings.BoundaryConditions.Types.DataSource.Input then
    connect(winDir_in, winDir_in_internal);
  else
    connect(conWinDir.y, winDir_in_internal);
  end if;
  connect(winDir_in_internal, cheWinDir.nIn);
  //---------------------------------------------------------------------------
  // Select global horizontal radiation connector
  if HGloHorSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    HGloHor_in_internal = HGloHor;
  elseif HGloHorSou == Buildings.BoundaryConditions.Types.DataSource.Input then
    connect(HGloHor_in, HGloHor_in_internal);
  else
    connect(conGloHorRad.HOut, HGloHor_in_internal);
  end if;
  connect(HGloHor_in_internal, cheGloHorRad.HIn);
  //---------------------------------------------------------------------------
  // Select diffuse horizontal radiation connector
  if HDifHorSou == Buildings.BoundaryConditions.Types.DataSource.Parameter then
    HDifHor_in_internal = HDifHor;
  elseif HDifHorSou == Buildings.BoundaryConditions.Types.DataSource.Input then
    connect(HDifHor_in, HDifHor_in_internal);
  else
    connect(conDifHorRad.HOut, HDifHor_in_internal);
  end if;
  connect(HDifHor_in_internal, cheDifHorRad.HIn);
  connect(chePre.POut, weaBus.pAtm);
  connect(cheTotSkyCov.nOut, weaBus.nTot);
  connect(cheOpaSkyCov.nOut, weaBus.nOpa);
  connect(cheGloHorRad.HOut, weaBus.HGloHor);
  connect(cheDifHorRad.HOut, weaBus.HDifHor);
  connect(cheDirNorRad.HOut, weaBus.HDirNor);
  connect(cheCeiHei.ceiHeiOut, weaBus.celHei);
  connect(cheWinSpe.winSpeOut, weaBus.winSpe);
  connect(cheHorRad.HOut, weaBus.radHor);
  connect(cheWinDir.nOut, weaBus.winDir);
  connect(cheOpaSkyCov.nOut, TBlaSky.nOpa);
  connect(cheHorRad.HOut, TBlaSky.radHor);
  connect(TBlaSky.TBlaSky, weaBus.TBlaSky);
  connect(simTim.y, weaBus.cloTim);
  connect(simTim.y, add.u2);
  connect(con30mins.y, add.u1);
  connect(add.y, conTim1.simTim);
  connect(conTim1.calTim, datRea1.u);
  connect(simTim.y, locTim.cloTim);
  connect(simTim.y, conTim.simTim);
  connect(conTim.calTim, datRea.u);
  connect(simTim.y, eqnTim.nDay);
  connect(eqnTim.eqnTim, solTim.equTim);
  connect(locTim.locTim, solTim.locTim);
  connect(solTim.solTim, weaBus.solTim);
  connect(datRea.y[13], cheTotSkyCov.nIn);
  connect(datRea.y[14], cheOpaSkyCov.nIn);
  connect(datRea.y[16], cheCeiHei.ceiHeiIn);
  connect(datRea.y[11], conWinDir.u);
  connect(datRea1.y[1], conHorRad.HIn);
  connect(conHorRad.HOut, cheHorRad.HIn);
  connect(cheTemDryBul.TOut, TBlaSky.TDryBul);
  connect(datRea.y[1], conTDryBul.u);
  connect(datRea.y[2], conTDewPoi.u);
  connect(conTDewPoi.y, cheTemDewPoi.TIn);
  connect(cheTemDewPoi.TOut, weaBus.TDewPoi);
  connect(TBlaSky.TDewPoi, cheTemDewPoi.TOut);
  connect(datRea1.y[3], conDirNorRad.HIn);
  connect(conDirNorRad.HOut, cheDirNorRad.HIn);
  connect(datRea1.y[2], conGloHorRad.HIn);
  connect(datRea1.y[4], conDifHorRad.HIn);
  connect(conRelHum.relHumIn, datRea.y[3]);
  connect(cheRelHum.relHumOut, weaBus.relHum);
  connect(cheTemDryBul.TOut, weaBus.TDryBul);
end ReaderTMY3;

Buildings.BoundaryConditions.WeatherData.Bus Buildings.BoundaryConditions.WeatherData.Bus

Data bus that stores weather data

Buildings.BoundaryConditions.WeatherData.Bus

Information

This component is an expandable connector that is used to implement a bus that contains the weather data.

Extends from Modelica.Icons.SignalBus (Icon for signal bus).

Modelica definition

expandable connector Bus "Data bus that stores weather data"
  extends Modelica.Icons.SignalBus;

end Bus;

Automatically generated Wed Feb 22 15:21:21 2012.