Buildings.Utilities.Psychrometrics.Functions.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.Utilities.Psychrometrics.Functions.BaseClasses.

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

Package Content

Name Description
Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck DewPointTemperatureDerivativeCheck Model to test correct implementation of derivative
Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck_amb DewPointTemperatureDerivativeCheck_amb Model to test correct implementation of derivative
Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.InverseDewPointTemperatureDerivativeCheck_amb InverseDewPointTemperatureDerivativeCheck_amb Model to test correct implementation of derivative
Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.SaturationPressureDerivativeCheck SaturationPressureDerivativeCheck Model to test correct implementation of derivative
Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.WaterVaporPressureDerivativeCheck WaterVaporPressureDerivativeCheck Model to test correct implementation of derivative

Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck

Model to test correct implementation of derivative

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

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

Modelica definition

model DewPointTemperatureDerivativeCheck "Model to test correct implementation of derivative" extends Modelica.Icons.Example; Real y "Function value"; Real y_comp "Function value for comparison"; Real err "Integration error"; Modelica.SIunits.Temperature T "Temperature"; initial equation y = y_comp; equation T = 273.15 + 50 + time^3*50; y = Buildings.Utilities.Psychrometrics.Functions.pW_TDewPoi(T=T); der(y) = der(y_comp); err = y - y_comp; assert(abs(err)/max(1, abs(y)) < 1E-2, "Derivative implementation has an error or solver tolerance is too low."); end DewPointTemperatureDerivativeCheck;

Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck_amb Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck_amb

Model to test correct implementation of derivative

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

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

Modelica definition

model DewPointTemperatureDerivativeCheck_amb "Model to test correct implementation of derivative" extends Modelica.Icons.Example; Real y "Function value"; Real y_comp "Function value for comparison"; Real err "Integration error"; Modelica.SIunits.Temperature T "Temperature"; initial equation y = y_comp; equation T = 273.15 + 50 + time^3*50; y = Buildings.Utilities.Psychrometrics.Functions.pW_TDewPoi_amb(T=T); der(y) = der(y_comp); err = y - y_comp; assert(abs(err)/max(1, abs(y)) < 1E-2, "Derivative implementation has an error or solver tolerance is too low."); end DewPointTemperatureDerivativeCheck_amb;

Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.InverseDewPointTemperatureDerivativeCheck_amb Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.InverseDewPointTemperatureDerivativeCheck_amb

Model to test correct implementation of derivative

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

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

Modelica definition

model InverseDewPointTemperatureDerivativeCheck_amb "Model to test correct implementation of derivative" extends Modelica.Icons.Example; Real y "Function value"; Real y_comp "Function value for comparison"; Real err(unit="K", displayUnit="K") "Integration error"; Modelica.SIunits.Pressure p_w "Water vapor partial pressure"; initial equation y = y_comp; equation p_w = 611 + (7383 - 661)/2 + (7383 - 661)/2*time^3; y = Buildings.Utilities.Psychrometrics.Functions.TDewPoi_pW_amb(p_w=p_w); der(y) = der(y_comp); err = y - y_comp; assert(abs(err) < 1E-2, "Derivative implementation has an error or solver tolerance is too low."); end InverseDewPointTemperatureDerivativeCheck_amb;

Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.SaturationPressureDerivativeCheck Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.SaturationPressureDerivativeCheck

Model to test correct implementation of derivative

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

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

Parameters

TypeNameDefaultDescription
TemperatureTMin190Temperature [K]
TemperatureTMax373.16Temperature [K]

Modelica definition

model SaturationPressureDerivativeCheck "Model to test correct implementation of derivative" extends Modelica.Icons.Example; parameter Modelica.SIunits.Temperature TMin=190 "Temperature"; parameter Modelica.SIunits.Temperature TMax=373.16 "Temperature"; Real y "Function value"; Real y_comp "Function value for comparison"; Real err "Integration error"; Modelica.SIunits.Temperature T "Temperature"; initial equation y = y_comp; equation T = TMin + (TMax - TMin)/2 + (TMax - TMin)/2*time^3; y = Buildings.Utilities.Psychrometrics.Functions.saturationPressure(TSat=T); der(y) = der(y_comp); err = y - y_comp; assert(abs(err)/max(1, abs(y)) < 1E-2, "Derivative implementation has an error or solver tolerance is too low."); end SaturationPressureDerivativeCheck;

Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.WaterVaporPressureDerivativeCheck Buildings.Utilities.Psychrometrics.Functions.BaseClasses.Examples.WaterVaporPressureDerivativeCheck

Model to test correct implementation of derivative

Information

This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.

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

Modelica definition

model WaterVaporPressureDerivativeCheck "Model to test correct implementation of derivative" extends Modelica.Icons.Example; Real y "Function value"; Real y_comp "Function value for comparison"; Real err "Integration error"; Modelica.SIunits.MassFraction X_w "Water vapor mass fraction at dry bulb temperature"; Modelica.SIunits.Pressure p "Total pressure"; initial equation y = y_comp; equation X_w = 1.001 + 0.999/2*time^3; p = 101325 + 300*time^3; y = Buildings.Utilities.Psychrometrics.Functions.pW_X(X_w=X_w, p=p); der(y) = der(y_comp); err = y - y_comp; assert(abs(err)/max(1, abs(y)) < 1E-2, "Derivative implementation has an error or solver tolerance is too low."); end WaterVaporPressureDerivativeCheck;