regStep¶
Once continuously differentiable step from y2 (x < -x_small) to y1 (x > x_small)
FastSmoothBuildings.Utilities.regStep, function (source)
Purpose
A step from y2 to y1 around x = 0 whose value and first derivative are
continuous. It replaces the if conditions and the events of a switch, so that the model stays an
explicit ODE with continuous derivatives that CasADi and IPOPT can differentiate.
Equations
With ε = x_small,
| Range | Value |
|---|---|
| x > ε | y = y1 |
| x < −ε | y = y2 |
| |x| ≤ ε | y = (x/ε) ((x/ε)2 − 3) (y2 − y1)/4 + (y1 + y2)/2 |
The cubic meets both constants with a zero slope at x = ±ε; its slope at x = 0 is 3 (y1 − y2)/(4 ε).
Relation to Buildings
The same function as
Buildings.Utilities.Math.Functions.regStep, without its derivative annotation (rumoca
differentiates the expression itself).
Use
The width ε is the trade-off of every smooth switch of the library: the wider it is, the easier the optimal control problem and the further the model from the switching controller it replaces. The controllers of FastSmoothBuildings.Controls expose it as a parameter.
Revisions¶
- October 2026: moved from trano's
FastModel.Utilities.