Derivative of a Function in Modelica
<p>First, excuse me for not providing a minimal working example, it is that I just can't think of one, really. I'll just give some pieces of code and ask my question "in principle".</p>

<p>I'm doing thermophysical properties calculation with a real gas model (Peng-Robinson) and here I am having problems when translating a model, where I use pressure <em>p</em> and specific enthalpy <em>h</em> as inputs to calculate all other properties. When it comes to calculating the temperature <em>T</em>, it is linked to the enthalpy <em>h</em> via an equation called <em>departure function</em>, which is itself a function of <em>T</em>. In Modelica it looks like this:</p>

<pre><code>Dh_real = R_m*T*(Z - 1) + (T*dadT - a)/(sqrt(8)*b)*log((Z + (1 + sqrt(2))*B)/(Z + (1 - sqrt(2))*B));
</code></pre>

<p>Here <code>a</code>, <code>dadT</code> and <code>Z</code> are also temperature-dependent scalars and partly calculated using matrix operations (<code>dadT</code>) or polynomial-root-calculation (<code>Z</code>) in functions, <code>b</code> and <code>B</code> are parameters.</p>

<p>Calculating the enthalpy from an input temperature (in another model) is straightforward and working fine, the solver can solve the <em>departure function</em> analytically. The other direction has to be solved numerically and this is, I think, why Dymola gives me this error, when translating.</p>

<pre><code>Cannot find differentiation function:
DadT_Unique2([some parameters and T])
with respect to time

Failed to differentiate the equation
dadT = DadT_Unique2([some parameters and T]);

in order to reduce the DAE index.

Failed to reduce the DAE index.
</code></pre>

<p>Now <code>DadT</code> is a function within the model, where I use some simple matrix operations to calculate <code>dadT</code> from some parameters and the temperature <em>T</em>. Obviously, Dymola is in need of the derivative of some internal <code>_Unique2</code>-function.
I couldn't find anything in the specification nor in the web about this. Can I provide a derivative of the functions somehow? I tried the <code>smoothOrder</code>-annotation, but without effect. How can I deal with this?</p>