Extends from Buildings.BaseClasses.BaseIconExamples (Icon for Examples packages).
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.
model PolynomialDerivativeCheckReal x; Real y; initial equation y=x; equation x=Buildings.Utilities.Math.Functions.polynomial( x=time-2, a={2, 4, -4, 5}); der(y)=der(x); assert(abs(x-y) < 1E-2, "Model has an error"); end PolynomialDerivativeCheck;
model RegNonZeroPowerReal y "Function value"; equation y=Buildings.Utilities.Math.Functions.regNonZeroPower( time, 0.3, 0.5); end RegNonZeroPower;
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.
Type | Name | Default | Description |
---|---|---|---|
Real | n | 0.33 | Exponent |
Real | delta | 0.1 | Abscissa value where transition occurs |
model RegNonZeroPowerDerivative_2_Checkparameter Real n=0.33 "Exponent"; parameter Real delta = 0.1 "Abscissa value where transition occurs"; Real x; Real y; initial equation y=x; equation x=Buildings.Utilities.Math.Functions.BaseClasses.der_regNonZeroPower( time,n, delta, time); der(y)=der(x); assert(abs(x-y) < 1E-2, "Model has an error"); end RegNonZeroPowerDerivative_2_Check;
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.
Type | Name | Default | Description |
---|---|---|---|
Real | n | 0.33 | Exponent |
Real | delta | 0.1 | Abscissa value where transition occurs |
model RegNonZeroPowerDerivativeCheckparameter Real n=0.33 "Exponent"; parameter Real delta = 0.1 "Abscissa value where transition occurs"; Real x; Real y; initial equation y=x; equation x=Buildings.Utilities.Math.Functions.regNonZeroPower( time,n, delta); der(y)=der(x); assert(abs(x-y) < 1E-2, "Model has an error"); end RegNonZeroPowerDerivativeCheck;
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.
model SmoothExponentialDerivativeCheckReal x; Real y; Real ex "exact function value"; initial equation y=x; equation x=Buildings.Utilities.Math.Functions.smoothExponential( x=time-2, delta=0.5); der(y)=der(x); assert(abs(x-y) < 1E-2, "Model has an error"); ex=exp(-abs(time-2)); end SmoothExponentialDerivativeCheck;
model SpliceFunctionReal y "Function value"; equation y=Buildings.Utilities.Math.Functions.spliceFunction( 10, -10, time+0.1, 0.2); end SpliceFunction;
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.
model SpliceFunctionDerivativeCheckReal x; Real y; initial equation y=x; equation x=Buildings.Utilities.Math.Functions.spliceFunction( 10, -10, time+0.1, 0.2); der(y)=der(x); assert(abs(x-y) < 1E-2, "Model has an error"); end SpliceFunctionDerivativeCheck;