Buildings.BoundaryConditions.WeatherData.BaseClasses

Package with base classes for Buildings.BoundaryConditions.WeatherData

Information

This package contains base classes that are used to construct the models in Buildings.BoundaryConditions.WeatherData.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

NameDescription
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckCeilingHeight CheckCeilingHeight Ensures that the ceiling height is above a lower bound
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRadiation CheckRadiation Ensure that the radiation is not smaller than 0
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRelativeHumidity CheckRelativeHumidity Check the validity of relative humidity
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckPressure CheckPressure Ensures that the interpolated pressure is between prescribed bounds
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckSkyCover CheckSkyCover Constrains the sky cover to [0, 1]
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckTemperature CheckTemperature Check the validity of temperature data
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindDirection CheckWindDirection Constrains the wind direction to [0, 2*pi] degree
Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindSpeed CheckWindSpeed Ensures that the wind speed is non-negative
Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRadiation ConvertRadiation Convert the unit of solar radiation received from the TMY3 data file
Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRelativeHumidity ConvertRelativeHumidity Convert the relative humidity from percentage to real
Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime ConvertTime Converts the simulation time to calendar time in scale of 1 year (365 days)
Buildings.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime EquationOfTime Equation of time
Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime LocalCivilTime Converts the clock time to local civil time.
Buildings.BoundaryConditions.WeatherData.BaseClasses.SolarTime SolarTime Solar time
Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3 getHeaderElementTMY3 Gets an element from the header of a TMY3 weather data file
Buildings.BoundaryConditions.WeatherData.BaseClasses.getLongitudeTMY3 getLongitudeTMY3 Gets the longitude from a TMY3 weather data file
Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3 getTimeZoneTMY3 Gets the time zone from a TMY3 weather data file
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples Examples Collection of models that illustrate model use and test models


Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckCeilingHeight Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckCeilingHeight

Ensures that the ceiling height is above a lower bound

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckCeilingHeight

Information

This component ensures that the ceiling height is at least 0 meters.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputceiHeiInInput ceiling height [m]
output RealOutputceiHeiOutCeiling height [m]

Modelica definition

block CheckCeilingHeight 
  "Ensures that the ceiling height is above a lower bound"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput ceiHeiIn(final quantity="Height", final unit=
           "m") "Input ceiling height";
  Modelica.Blocks.Interfaces.RealOutput ceiHeiOut(final quantity="Height",
      final unit="m") "Ceiling height";
  constant Modelica.SIunits.Height ceiHeiMin=0 "Minimum allowed ceiling height";
equation 

  ceiHeiOut = Buildings.Utilities.Math.Functions.smoothMax(
    ceiHeiIn,
    ceiHeiMin,
    0.1);

end CheckCeilingHeight;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRadiation Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRadiation

Ensure that the radiation is not smaller than 0

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRadiation

Information

This component ensures that the radiation is not smaller than 0. Modelica Table will interpolate data when it reads the data from a file. Thus, it is possible to generate negative value due to the interpolation.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputHInInput radiation [W/m2]
output RealOutputHOutRadiation [W/m2]

Modelica definition

block CheckRadiation 
  "Ensure that the radiation is not smaller than 0"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput HIn(final quantity=
        "RadiantEnergyFluenceRate", final unit="W/m2") "Input radiation";
  Modelica.Blocks.Interfaces.RealOutput HOut(final quantity=
        "RadiantEnergyFluenceRate", final unit="W/m2") "Radiation";

  constant Modelica.SIunits.RadiantEnergyFluenceRate HMin=0.0001 
    "Minimum value for radiation";
equation 

  HOut = Buildings.Utilities.Math.Functions.smoothMax(
    x1=HIn,
    x2=HMin,
    deltaX=HMin/10);
end CheckRadiation;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRelativeHumidity Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRelativeHumidity

Check the validity of relative humidity

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckRelativeHumidity

Information

This component constrains the value of relative humidity to a range of [0, 1].

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputrelHumInInput relative humidity [1]
output RealOutputrelHumOutRelative humidity [1]

Modelica definition

block CheckRelativeHumidity "Check the validity of relative humidity"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput relHumIn(final unit="1") 
    "Input relative humidity";
  Modelica.Blocks.Interfaces.RealOutput relHumOut(final unit="1") 
    "Relative humidity";
  constant Real delta=0.01 "Smoothing parameter";
protected 
  constant Real relHumMin=delta "Lower bound";
  constant Real relHumMax=1 - delta "Upper bound";

equation 
  relHumOut = Buildings.Utilities.Math.Functions.smoothLimit(
    relHumIn,
    relHumMin,
    relHumMax,
    delta/10);
end CheckRelativeHumidity;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckPressure Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckPressure

Ensures that the interpolated pressure is between prescribed bounds

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckPressure

Information

This component ensures that the interpolated pressure is between 31,000 Pa and 120,000 Pa.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputPInInput pressure [Pa]
output RealOutputPOutAtmospheric pressure [Pa]

Modelica definition

block CheckPressure 
  "Ensures that the interpolated pressure is between prescribed bounds"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput PIn(final quantity="Pressure", final unit=
           "Pa") "Input pressure";
  Modelica.Blocks.Interfaces.RealOutput POut(final quantity="Pressure", final unit=
           "Pa") "Atmospheric pressure";
  constant Modelica.SIunits.Pressure PMin=3100 "Minimum allowed pressure";
  constant Modelica.SIunits.Pressure PMax=120000 "Maximum allowed pressure";
equation 
  assert(PIn > PMin, "Pressure out of bounds.\n" + "   PIn = " + String(PIn));
  assert(PIn < PMax, "Pressure out of bounds.\n" + "   PIn = " + String(PIn));
  POut = PIn;

end CheckPressure;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckSkyCover Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckSkyCover

Constrains the sky cover to [0, 1]

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckSkyCover

Information

This component constrains the interpolated sky cover between 0 and 10.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputnInInput sky cover [0, 10]
output RealOutputnOutSky cover [0, 10] [1]

Modelica definition

block CheckSkyCover "Constrains the sky cover to [0, 1]"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput nIn "Input sky cover [0, 10]";
  Modelica.Blocks.Interfaces.RealOutput nOut(unit="1") "Sky cover [0, 10]";

  constant Real delta=0.01 "Smoothing parameter";
protected 
  constant Real nMin=delta "Lower bound";
  constant Real nMax=10 - delta "Upper bound";
equation 
  nOut = Buildings.Utilities.Math.Functions.smoothLimit(
    nIn,
    nMin,
    nMax,
    delta/10)/10;
end CheckSkyCover;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckTemperature Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckTemperature

Check the validity of temperature data

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckTemperature

Information

This component checks the value of temperature. If the temperature is outside TMin and TMax, the simulation will stop with an error.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
TemperatureTMin203.15Minimum allowed temperature [K]
TemperatureTMax343.15Maximum allowed temperature [K]

Connectors

TypeNameDescription
input RealInputTInInput Temperature [K]
output RealOutputTOutOutput temperature [K]

Modelica definition

block CheckTemperature "Check the validity of temperature data"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput TIn(
    final quantity="Temperature",
    final unit="K",
    displayUnit="degC") "Input Temperature";
  Modelica.Blocks.Interfaces.RealOutput TOut(
    final quantity="Temperature",
    final unit="K",
    displayUnit="degC") "Output temperature";

  parameter Modelica.SIunits.Temperature TMin(displayUnit="degC") = 203.15 
    "Minimum allowed temperature";
  parameter Modelica.SIunits.Temperature TMax(displayUnit="degC") = 343.15 
    "Maximum allowed temperature";

equation 
  TOut = TIn;
  assert(TOut > TMin, "Temperature out of bounds.\n" + "   TOut = " + String(
    TOut));
  assert(TOut < TMax, "Temperature out of bounds.\n" + "   TOut = " + String(
    TOut));

end CheckTemperature;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindDirection Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindDirection

Constrains the wind direction to [0, 2*pi] degree

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindDirection

Information

This component constrains the interpolated wind direction between 0 and 360 degree.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputnInInput wind direction [rad]
output RealOutputnOutWind direction [rad]

Modelica definition

block CheckWindDirection 
  "Constrains the wind direction to [0, 2*pi] degree"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput nIn(
    final quantity="Angle",
    final unit="rad",
    displayUnit="deg") "Input wind direction";
  Modelica.Blocks.Interfaces.RealOutput nOut(
    final quantity="Angle",
    final unit="rad",
    displayUnit="deg") "Wind direction";

  constant Real delta=0.01 "Smoothing parameter";
protected 
  constant Real nMin=0 "Lower bound";
  constant Real nMax=2*Modelica.Constants.pi "Upper bound";
equation 

  nOut = Buildings.Utilities.Math.Functions.smoothLimit(
    nIn,
    nMin,
    nMax,
    delta/10);
end CheckWindDirection;

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindSpeed Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindSpeed

Ensures that the wind speed is non-negative

Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckWindSpeed

Information

This component ensures that the wind speed is non-negative.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputwinSpeInInput wind speed [m/s]
output RealOutputwinSpeOutWind speed [m/s]

Modelica definition

block CheckWindSpeed "Ensures that the wind speed is non-negative"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput winSpeIn(final quantity="Velocity",
      final unit="m/s") "Input wind speed";
  Modelica.Blocks.Interfaces.RealOutput winSpeOut(final quantity="Velocity",
      final unit="m/s") "Wind speed";
  constant Modelica.SIunits.Velocity winSpeMin=1e-6 
    "Minimum allowed wind speed";

equation 
  // Modelica Table will interpolate data when it reads the weather data file.
  // It can generate negative values due to the interpolation.
  winSpeOut = Buildings.Utilities.Math.Functions.smoothMax(
    x1=winSpeIn,
    x2=winSpeMin,
    deltaX=winSpeMin/10);

end CheckWindSpeed;

Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRadiation Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRadiation

Convert the unit of solar radiation received from the TMY3 data file

Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRadiation

Information

The TMY3 data for solar radiation is the radiation accumulated in one hour. Thus, it used a unit of Wh/m2. This component converts Wh/m2 to W/m2 that is the standard unit in Modelica.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputHInInput radiation [W.h/m2]
output RealOutputHOutRadiation [W/m2]

Modelica definition

block ConvertRadiation 
  "Convert the unit of solar radiation received from the TMY3 data file"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput HIn(final unit="W.h/m2") 
    "Input radiation";
  Modelica.Blocks.Interfaces.RealOutput HOut(final quantity=
        "RadiantEnergyFluenceRate", final unit="W/m2") "Radiation";

protected 
  constant Modelica.SIunits.Time Hou=3600 "1 hour";

equation 
  HOut = HIn/Modelica.SIunits.Conversions.to_hour(Hou);
end ConvertRadiation;

Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRelativeHumidity Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRelativeHumidity

Convert the relative humidity from percentage to real

Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertRelativeHumidity

Information

This component converts the relative humidity from percentage to real. Input is the relative humidity in percentage, as this is the data format that is used in the Typical Meteorological Year weather data.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputrelHumInValue of relative humidity in percentage [1]
output RealOutputrelHumOutRelative humidity between 0 and 1 [1]

Modelica definition

block ConvertRelativeHumidity 
  "Convert the relative humidity from percentage to real"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput relHumIn(unit="1") 
    "Value of relative humidity in percentage";
  Modelica.Blocks.Interfaces.RealOutput relHumOut(unit="1") 
    "Relative humidity between 0 and 1";
equation 
  relHumOut = relHumIn/100;
end ConvertRelativeHumidity;

Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime

Converts the simulation time to calendar time in scale of 1 year (365 days)

Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime

Information

This component converts the simulation time to calendar time in a scale of 1 year (365 days).

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputsimTimSimulation time [s]
output RealOutputcalTimCalendar time [s]

Modelica definition

block ConvertTime 
  "Converts the simulation time to calendar time in scale of 1 year (365 days)"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput simTim(final quantity="Time", final unit=
       "s") "Simulation time";
  Modelica.Blocks.Interfaces.RealOutput calTim(final quantity="Time", final 
      unit="s") "Calendar time";

protected 
  constant Modelica.SIunits.Time year=31536000 "Number of seconds in a year";
  discrete Modelica.SIunits.Time tStart "Start time of period";
  //Integer count "Period count";

initial algorithm 
  tStart := integer(simTim/year)*year;
equation 
  when simTim - pre(tStart) > year then
    tStart = integer(simTim/year)*year;
  end when;
  calTim = simTim - tStart;
end ConvertTime;

Buildings.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime Buildings.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime

Equation of time

Buildings.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime

Information

This component computes the difference between solar noon and noon of local civic time.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputnDayZero-based day number in seconds (January 1=0, January 2=86400) [s]
output RealOutputeqnTimEquation of time [s]

Modelica definition

block EquationOfTime "Equation of time"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput nDay(quantity="Time", unit="s") 
    "Zero-based day number in seconds (January 1=0, January 2=86400)";
  Modelica.Blocks.Interfaces.RealOutput eqnTim(
    final quantity="Time",
    final unit="s",
    displayUnit="min") "Equation of time";
protected 
  Real Bt;
equation 
  Bt = Modelica.Constants.pi*((nDay + 86400)/86400 - 81)/182 
    "Our unit is s instead of day in (A.4.2b)";
  eqnTim = 60*(9.87*Modelica.Math.sin(2*Bt) - 7.53*Modelica.Math.cos(Bt) - 1.5*
    Modelica.Math.sin(Bt)) "Our unit is s instead of min in (A.4.2a)";
end EquationOfTime;

Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime

Converts the clock time to local civil time.

Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime

Information

This component converts the clock time to local civil time. The parameter timZon represents the time zone of the facility (relative to Greenwich Mean Time or the 0th meridian). Time zones west of GMT (e.g. North America) are represented as negative; east of GMT as positive. Fraction of hours are represented in decimals (e.g. for 6:30, use 6.5).

The formula is based on Michael Wetter's thesis (A4.1):

  locTim = greTim + (lon*180/pi)*86400/360 = cloTim - timZon + lon*43200/pi 

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
TimetimZon Time zone [s]
Anglelon Longitude [rad]

Connectors

TypeNameDescription
input RealInputcloTimClock time [s]
output RealOutputlocTimLocal civil time [s]

Modelica definition

block LocalCivilTime "Converts the clock time to local civil time."
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput cloTim(final quantity="Time", final unit=
       "s") "Clock time";
  parameter Modelica.SIunits.Time timZon(displayUnit="h") "Time zone";
  parameter Modelica.SIunits.Angle lon(displayUnit="deg") "Longitude";
  Modelica.Blocks.Interfaces.RealOutput locTim(final quantity="Time", final unit=
           "s") "Local civil time";

equation 
  locTim = cloTim - timZon + lon*43200/Modelica.Constants.pi;

end LocalCivilTime;

Buildings.BoundaryConditions.WeatherData.BaseClasses.SolarTime Buildings.BoundaryConditions.WeatherData.BaseClasses.SolarTime

Solar time

Buildings.BoundaryConditions.WeatherData.BaseClasses.SolarTime

Information

This component computes the local solar time.

Extends from Modelica.Blocks.Interfaces.BlockIcon (Basic graphical layout of input/output block).

Connectors

TypeNameDescription
input RealInputlocTimLocal time [s]
input RealInputequTimEquation of time [s]
output RealOutputsolTimSolar time [s]

Modelica definition

block SolarTime "Solar time"
  extends Modelica.Blocks.Interfaces.BlockIcon;
public 
  Modelica.Blocks.Interfaces.RealInput locTim(quantity="Time", unit="s") 
    "Local time";
  Modelica.Blocks.Interfaces.RealInput equTim(quantity="Time", unit="s") 
    "Equation of time";
  Modelica.Blocks.Interfaces.RealOutput solTim(
    final quantity="Time",
    final unit="s",
    displayUnit="s") "Solar time";
algorithm 
  solTim := locTim + equTim "Our unit is s in stead of h in (A.4.3)";

end SolarTime;

Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3

Gets an element from the header of a TMY3 weather data file

Information

This function scans the weather data file for a line that starts with the string
start
where start is a parameter. When this line is found, the function returns the element at the position number position, where position is a parameter. A comma is used as the delimiter of the elements.

Inputs

TypeNameDefaultDescription
StringfilNam Name of weather data file
Stringstart Start of the string that contains the elements
Stringname"longitude"Name of data element, used in error reporting
Integerposition Position of the element on the line that contains 'start'

Outputs

TypeNameDescription
StringelementElement at position 'pos' of the line that starts with 'start'

Modelica definition

function getHeaderElementTMY3 
  "Gets an element from the header of a TMY3 weather data file"
 input String filNam "Name of weather data file";
 input String start "Start of the string that contains the elements";
 input String name = "longitude" 
    "Name of data element, used in error reporting";
 input Integer position(min=1) 
    "Position of the element on the line that contains 'start'";
 output String element 
    "Element at position 'pos' of the line that starts with 'start'";
protected 
 String lin "Line that is used in parser";
 Integer iLin "Line number";
 Integer index "Index of string #LOCATION";
 Integer staInd "Start index used when parsing a real number";
 Integer nexInd "Next index used when parsing a real number";
 Boolean found "Flag, true if #LOCATION has been found";
 Boolean EOF "Flag, true if EOF has been reached";
 String fouDel "Found delimiter";
algorithm 
  // Get line that starts with 'start'
  iLin :=0;
  EOF :=false;
  while (not EOF) and (index == 0) loop
    iLin:=iLin + 1;
    (lin, EOF) :=Modelica.Utilities.Streams.readLine(fileName=filNam,
      lineNumber=iLin);
    index :=Modelica.Utilities.Strings.find(
      string=lin,
      searchString=start,
      startIndex=1,
      caseSensitive=false);
  end while;
  assert(not EOF, "Error: Did not find '" + start + "' when scanning the weather file."
                      + "\n   Check for correct weather file syntax.");
  // Loop over the tokens until the position is reached
  nexInd :=1;
  for i in 1:position-1 loop
  nexInd :=Modelica.Utilities.Strings.find(
      string=lin,
      searchString=  ",",
      startIndex=nexInd+1);
   assert(nexInd > 0, "Error when scanning weather file. Not enough tokens to find " + name + "."
         + "\n   Check for correct file syntax." + "\n   The scanned line is '" +
        lin + "'.");
  end for;
  staInd := nexInd;
  // Find the next delimiter
  nexInd :=Modelica.Utilities.Strings.find(
      string=lin,
      searchString=  ",",
      startIndex=nexInd+1);
  assert(nexInd > 0, "Error when scanning weather file. Not enough tokens to find " + name + "."
         + "\n   Check for correct file syntax." + "\n   The scanned line is '" +
         lin + "'.");
  // Get the element
  element :=Modelica.Utilities.Strings.substring(lin, startIndex=staInd+1, endIndex=nexInd-1);
end getHeaderElementTMY3;

Buildings.BoundaryConditions.WeatherData.BaseClasses.getLongitudeTMY3

Gets the longitude from a TMY3 weather data file

Information

This function returns the longitude of the TMY3 weather data file.

Inputs

TypeNameDefaultDescription
StringfilNam Name of weather data file

Outputs

TypeNameDescription
AnglelonLongitude from the weather file [rad]

Modelica definition

function getLongitudeTMY3 
  "Gets the longitude from a TMY3 weather data file"
 input String filNam "Name of weather data file";
 output Modelica.SIunits.Angle lon "Longitude from the weather file";
protected 
 Integer nexInd "Next index, used for error handling";
 String element "String representation of the returned element";
algorithm 
  element :=
    Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3(
      filNam=filNam,
      start="#LOCATION",
      name=  "longitude",
      position=8);
   (nexInd, lon) :=Modelica.Utilities.Strings.Advanced.scanReal(
    string=element,
    startIndex=1,
    unsigned=false);
   assert(nexInd > 1, "Error when converting the longitude '" +
                      element + "' from a String to a Real.");
   // Convert from degree to rad
   lon :=lon*Modelica.Constants.pi/180;
   // Check if longitude is valid
   assert(abs(lon) < 2*Modelica.Constants.pi,
       "Wrong value for longitude. Received lon = " +
       String(lon) + " (= " + String(lon*180/Modelica.Constants.pi) + " degrees).");

end getLongitudeTMY3;

Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3

Gets the time zone from a TMY3 weather data file

Information

This function returns the time zone of the TMY3 weather data file.

Inputs

TypeNameDefaultDescription
StringfilNam Name of weather data file

Outputs

TypeNameDescription
TimetimZonTime zone from the weather file [s]

Modelica definition

function getTimeZoneTMY3 
  "Gets the time zone from a TMY3 weather data file"
 input String filNam "Name of weather data file";
 output Modelica.SIunits.Time timZon "Time zone from the weather file";
protected 
 Integer nexInd "Next index, used for error handling";
 String element "String representation of the returned element";
algorithm 
  element :=
    Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3(
      filNam=filNam,
      start="#LOCATION",
      name=  "longitude",
      position=9);
   (nexInd, timZon) :=Modelica.Utilities.Strings.Advanced.scanReal(
    string=element,
    startIndex=1,
    unsigned=false);
   assert(nexInd > 1, "Error when converting the time zone '" +
                      element + "' from a String to a Real.");
   timZon :=timZon*3600;
   // Check if time zone is valid
   assert(abs(timZon) < 24*3600,
       "Wrong value for time zone. Received timZon = " +
       String(timZon) + " (= " + String(timZon/3600) + " hours).");

end getTimeZoneTMY3;

Automatically generated Thu Dec 8 16:33:35 2011.