Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples

Collection of models that illustrate model use and test models

Information

This package contains examples for the use of models that can be found in Buildings.BoundaryConditions.WeatherData.BaseClasses.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

Name Description
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckBlackBodySkyTemperature CheckBlackBodySkyTemperature Test model for CheckBlackBodySkyTemperature
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckPressure CheckPressure Test model for pressure check
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckTemperature CheckTemperature Test model for CheckTemperature
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTime ConvertTime Test model for converting time
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimeNegativeStart ConvertTimeNegativeStart Validation of time conversion for negative start time
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimePositiveStart ConvertTimePositiveStart Validation of time conversion for positive start time
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.EquationOfTime EquationOfTime Test model for equation of time
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetAbsolutePath GetAbsolutePath Test model to get the absolute path of a URI
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetHeaderElement GetHeaderElement Test model to get header element
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3 GetTimeSpanTMY3 Test model to get the time span of a weather file
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3_NonzeroStart GetTimeSpanTMY3_NonzeroStart Test model to get time span of a weather file, start time is non zero
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.LimitMin LimitMin Test model for ceiling height check
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.LocalCivilTime LocalCivilTime Test model for calculate local civil time
Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.SolarTime SolarTime Test model for solar time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckBlackBodySkyTemperature Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckBlackBodySkyTemperature

Test model for CheckBlackBodySkyTemperature

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckBlackBodySkyTemperature

Information

This example tests the model that checks the black-body sky temperature.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model CheckBlackBodySkyTemperature "Test model for CheckBlackBodySkyTemperature" extends Modelica.Icons.Example; Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckBlackBodySkyTemperature cheSkyBlaBodTem "Check for the black body sky temperature"; Modelica.Blocks.Sources.Ramp TBlaBod( height=140-0.02, duration=1, offset=273.15 - 69.99) "Black body sky temperature"; equation connect(TBlaBod.y, cheSkyBlaBodTem.TIn); end CheckBlackBodySkyTemperature;

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

Test model for pressure check

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckPressure

Information

This example tests the model that asserts that the pressure is within acceptable bounds.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model CheckPressure "Test model for pressure check" extends Modelica.Icons.Example; Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckPressure chePre "Block that checks the pressure"; Buildings.Utilities.Time.ModelTime modTim "Block that outputs simulation time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime conTim( weaDatStaTim=0, weaDatEndTim=31536000) "Block that converts time"; protected Modelica.Blocks.Tables.CombiTable1Ds datRea( tableOnFile=true, tableName="tab1", fileName=Modelica.Utilities.Files.loadResource( Modelica.Utilities.Files.loadResource("modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos")), columns=2:30, smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "Data reader"; equation connect(datRea.y[4], chePre.PIn); connect(modTim.y, conTim.modTim); connect(conTim.calTim, datRea.u); end CheckPressure;

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

Test model for CheckTemperature

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.CheckTemperature

Information

This example tests the model that checks the temperature.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model CheckTemperature "Test model for CheckTemperature" extends Modelica.Icons.Example; Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckDryBulbTemperature cheTemDryBul "Check dry bulb temperature "; Buildings.BoundaryConditions.WeatherData.BaseClasses.CheckDewPointTemperature cheTemDewPoi "Check dew point temperature"; Buildings.Utilities.Time.ModelTime modTim "Block that outputs the model time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime conTim( weaDatStaTim=0, weaDatEndTim=31536000) "Block that converts time"; Modelica.Blocks.Math.UnitConversions.From_degC from_degC "Block that converts temperature"; Modelica.Blocks.Math.UnitConversions.From_degC from_degC1 "Block that converts temperature"; protected Modelica.Blocks.Tables.CombiTable1Ds datRea( tableOnFile=true, tableName="tab1", fileName=Modelica.Utilities.Files.loadResource( Modelica.Utilities.Files.loadResource("modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos")), columns=2:30, smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "Data reader"; equation connect(modTim.y, conTim.modTim); connect(conTim.calTim, datRea.u); connect(datRea.y[1], from_degC.u); connect(from_degC.y, cheTemDryBul.TIn); connect(datRea.y[2], from_degC1.u); connect(from_degC1.y, cheTemDewPoi.TIn); end CheckTemperature;

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

Test model for converting time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTime

Information

This example tests the model that converts time.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model ConvertTime "Test model for converting time" extends Modelica.Icons.Example; Buildings.Utilities.Time.ModelTime modTim "Block that outputs simulation time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime conTim( weaDatStaTim=0, weaDatEndTim=31536000) "Block that converts time"; equation connect(modTim.y, conTim.modTim); end ConvertTime;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimeNegativeStart Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimeNegativeStart

Validation of time conversion for negative start time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimeNegativeStart

Information

This example tests the model that converts time for negative start time.

Extends from Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTime (Test model for converting time).

Modelica definition

model ConvertTimeNegativeStart "Validation of time conversion for negative start time" extends Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTime; end ConvertTimeNegativeStart;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimePositiveStart Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimePositiveStart

Validation of time conversion for positive start time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTimePositiveStart

Information

This example tests the model that converts time for positive start time.

Extends from Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTime (Test model for converting time).

Modelica definition

model ConvertTimePositiveStart "Validation of time conversion for positive start time" extends Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.ConvertTime; end ConvertTimePositiveStart;

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

Test model for equation of time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.EquationOfTime

Information

This example tests the model that computes the equation of time.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model EquationOfTime "Test model for equation of time" extends Modelica.Icons.Example; Utilities.Time.ModelTime modTim "Block that outputs simulation time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime eqnTim "Block that computes the equation of time"; equation connect(modTim.y, eqnTim.nDay); end EquationOfTime;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetAbsolutePath Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetAbsolutePath

Test model to get the absolute path of a URI

Information

This model tests the function that gets the absolute path of a URI.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
Stringf"modelica://Buildings/packag...Name of a file that exists
StringfAbsBuildings.BoundaryConditions...Absolute path of f

Modelica definition

model GetAbsolutePath "Test model to get the absolute path of a URI" extends Modelica.Icons.Example; parameter String f = "modelica://Buildings/package.mo" "Name of a file that exists"; parameter String fAbs= Buildings.BoundaryConditions.WeatherData.BaseClasses.getAbsolutePath(uri=f) "Absolute path of f"; final parameter Integer dummy = 1 "Dummy variable, used to have a result as needed for the unit tests"; initial algorithm Modelica.Utilities.Streams.print("Absolute path = " + fAbs); end GetAbsolutePath;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetHeaderElement Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetHeaderElement

Test model to get header element

Information

This example tests getting the header of the TMY3 weather data file.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
Anglelongitude Longitude [rad]
Anglelatitude Latitude [rad]
TimetimeZone Time zone [s]
StringfilNamModelica.Utilities.Files.loa...Name of weather data file

Modelica definition

model GetHeaderElement "Test model to get header element" extends Modelica.Icons.Example; parameter Modelica.SIunits.Angle longitude(fixed=false, displayUnit="deg") "Longitude"; parameter Modelica.SIunits.Angle latitude(fixed=false, displayUnit="deg") "Latitude"; parameter Modelica.SIunits.Time timeZone(fixed=false, displayUnit="h") "Time zone"; parameter String filNam = Modelica.Utilities.Files.loadResource("modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos") "Name of weather data file"; final parameter String absFilNam = Buildings.BoundaryConditions.WeatherData.BaseClasses.getAbsolutePath(filNam) "Absolute path of the file"; initial equation longitude = Buildings.BoundaryConditions.WeatherData.BaseClasses.getLongitudeTMY3( filNam=absFilNam); latitude = Buildings.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3( filNam=absFilNam); timeZone = Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3( filNam=absFilNam); assert(abs(longitude*180/Modelica.Constants.pi+87.92) < 1, "Error when parsing longitude, longitude = " + String(longitude)); assert(abs(latitude*180/Modelica.Constants.pi-41.98) < 1, "Error when parsing latitude, latitude = " + String(latitude)); assert(abs(timeZone+6*3600) < 1, "Error when parsing time zone, timeZone = " + String(timeZone)); end GetHeaderElement;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3 Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3

Test model to get the time span of a weather file

Information

This example tests getting the time span of a TMY3 weather data file.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
StringfilNamModelica.Utilities.Files.loa...Name of weather data file
StringtabNam"tab1"Name of table on weather file
TimetimeSpan[2] Start time, end time of weather data [s]

Modelica definition

model GetTimeSpanTMY3 "Test model to get the time span of a weather file" extends Modelica.Icons.Example; parameter String filNam = Modelica.Utilities.Files.loadResource( "modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos") "Name of weather data file"; parameter String tabNam = "tab1" "Name of table on weather file"; parameter Modelica.SIunits.Time[2] timeSpan(each fixed=false) "Start time, end time of weather data"; protected constant Modelica.SIunits.Time endTim = 365*24*3600.; constant Modelica.SIunits.Time staTim = 0.; initial equation timeSpan = Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeSpanTMY3( filNam, tabNam); assert(abs(timeSpan[2]-endTim) < 1E-5 and abs(timeSpan[1]-staTim) < 1E-5, "Error in weather file, start time " + String(timeSpan[1]) + " and end time " + String(timeSpan[2]) + ", but expected " + String(staTim) + " and " + String(endTim) + "."); end GetTimeSpanTMY3;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3_NonzeroStart Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3_NonzeroStart

Test model to get time span of a weather file, start time is non zero

Information

This example tests getting time span of a TMY3 weather data file that starts at a non-zero time.

Extends from Modelica.Icons.Example (Icon for runnable examples), Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3 (Test model to get the time span of a weather file).

Parameters

TypeNameDefaultDescription
StringfilNamModelica.Utilities.Files.loa...Name of weather data file
StringtabNam"tab1"Name of table on weather file
TimetimeSpan[2] Start time, end time of weather data [s]

Modelica definition

model GetTimeSpanTMY3_NonzeroStart "Test model to get time span of a weather file, start time is non zero" extends Modelica.Icons.Example; extends Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetTimeSpanTMY3 ( filNam = Modelica.Utilities.Files.loadResource( "modelica://Buildings/Resources/Data/BoundaryConditions/WeatherData/Validation/DecemberToJanuary.mos"), staTim = 30992400, endTim = 31863600); end GetTimeSpanTMY3_NonzeroStart;

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.LimitMin Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.LimitMin

Test model for ceiling height check

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.LimitMin

Information

This example tests the model that constrains the ceiling height.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model LimitMin "Test model for ceiling height check" extends Modelica.Icons.Example; Buildings.Utilities.Time.ModelTime modTim; Buildings.BoundaryConditions.WeatherData.BaseClasses.LimiterCeilingHeight limCeiHei "Block that constrains the ceiling height"; Buildings.BoundaryConditions.WeatherData.BaseClasses.ConvertTime conTim( weaDatStaTim=0, weaDatEndTim=31536000) "Block that converts time"; protected Modelica.Blocks.Tables.CombiTable1Ds datRea( tableOnFile=true, tableName="tab1", fileName=Modelica.Utilities.Files.loadResource( Modelica.Utilities.Files.loadResource("modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos")), columns=2:30, smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "Data reader"; equation connect(datRea.y[20],limCeiHei.u); connect(modTim.y, conTim.modTim); connect(conTim.calTim, datRea.u); end LimitMin;

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

Test model for calculate local civil time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.LocalCivilTime

Information

This example tests the model that computes the local civil time.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model LocalCivilTime "Test model for calculate local civil time" extends Modelica.Icons.Example; Buildings.Utilities.Time.ModelTime modTim "Block that outputs the model time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime locTim( timZon=-21600, lon=-1.5293932423067); equation connect(modTim.y, locTim.cloTim); end LocalCivilTime;

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

Test model for solar time

Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.SolarTime

Information

This example tests the model that computes the solar time.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Modelica definition

model SolarTime "Test model for solar time" extends Modelica.Icons.Example; Utilities.Time.ModelTime modTim "Block that outputs simulation time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime locTim( timZon=-21600, lon=-1.7039261675061) "Block that computes the local civil time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.SolarTime solTim "Block that computes the solar time"; Buildings.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime eqnTim "Block that computes the equation of time"; equation connect(modTim.y, locTim.cloTim); connect(locTim.locTim, solTim.locTim); connect(modTim.y, eqnTim.nDay); connect(eqnTim.eqnTim, solTim.equTim); end SolarTime;