For extending this library with further components for your
purpose, the following elementary steps are needed:
This step is concerned with preparing the desired components for
algorithmic differentiation. This is done by a slight modification
to make the declaration part be replaceable. If you are
differentiating your own library, you can modify the components
directly. But since the Modelica standard library is something you
should not play with, you should place your desired components
within ADMSL.MSL package.
Formally, given the component Modelica.X1.X2...XN.C
1. Insert the package X1.X2...XN into MSL (if not yet exist)
2. Insert all declared components in C into MSL, if not yet inserted
3. Make all connectors and models within C be replaceable, if any
As examples, see ADMSL.MSL.Electrical.Analog.Interfaces.OnePort & ADMSL.MSL.Electrical.Analog.Basic.Capacitor
Now for each new inserted component C in MSL, algorithmically
differentiate C as follows:
1. Duplicate the component ADMSL.MSL.X1.X2...XN.C into ADMSL.T1.X1.X2...XN.C
- See for e.g. ADMSL.MSL.Electrical.Analog.Interfaces.Pin & ADMSL.T1.Electrical.Analog.Interfaces.Pin
2. Make the new component C extend from ADMSL.Utilities.GradientInfo
for specifiying the number of active parameters
i.e.:
model C extends ADMSL.Utilities.GradientInfo;
3. redeclare any component x of type MSL.*.T as T1.*.T
- See e.g. ADMSL.MSL.Analog.Interfaces.OnePort vs. ADMSL.T1.Analog.Interfaces.OnePort
4. redeclare a gradient array object for each variable or parameter
of type Real
- e.g. for Real x => Real g_x[NG];
5. differentiate the equation directly w.r.t. the parameters
- See e.g. ADMSL.MSL.Analog.Basic.Inductor vs. ADMSL.T1.Analog.Basic.Inductor
a. For long equations, see UserGuide.References for straightforward easy algorithms for differentiation using notions of abstract syntax trees