Translation¶
Translation into CasADi
FastSmoothBuildings.UsersGuide.Translation, class (source)
Extends FastSmoothBuildings.Icons.Information.
rumoca translates a model of the library into a CasADi function
dx/dt = f(t, x, u, p), the inputs u being the top-level inputs
of the model (weather, gains, controls). From Python, with the package fastsmoothbuildings:
import rumoca import fastsmoothbuildings session = rumoca.Session(roots=[str(fastsmoothbuildings.LIBRARY)]) model = session.loads(source, model="MyBuilding.building").to_casadi()
The library keeps to what rumoca translates, and a model built from it has to as well:
- the sizes of arrays and the subscripts are evaluated from literal parameters only, not from a sum, a function or the default of a record: the records of the constructions carry their counts and node indices written out;
- the model is an explicit ODE: no algebraic loop that rumoca would have to solve, no event;
- every function is smooth (see Smoothing), and conditions on parameters only are evaluated before the translation;
- equations carry no description strings;
- a table given to dayTable is a parameter, not a literal matrix in the call, and at the top level of a model the call is an equation, not the binding of a declaration: rumoca 0.10.3 expands the loop of the function into extra equations otherwise (the zones and the ideal systems of the library call it this way).
The release 0.10.3 of rumoca on PyPI keeps "residual projection stages" for five more shapes, which its CasADi
target refuses (residual_equations, initialization); the library avoids them:
- in a function, a variable set by an if-expression and used by a later statement: one assignment per function, as smoothLimit calls smoothLimitBelow and smoothLimitAbove;
- in a function, a scalar reassigned in a loop (an accumulation, or a value passed to a smooth function): an array
element per step, or one
sum; - in an equation, a smooth function of a smooth function (
smoothMin(a, smoothMax(b, c))): the inner value in a variable of its own; - in a
forloop of equations, a derivative multiplied by a coefficient (C[i]*der(T[i]) = Q[i]): the derivative alone,der(T[i]) = Q[i]/C[i]; - a parameter bound to an if-expression whose branch is more than a name or a literal: the branch in a parameter of its own.
The library translates with rumoca 0.10.3 from PyPI and with the commit 33c21141 of its main branch;
the release 0.10.2 does not export connected models to CasADi.