[GiNaC-list] Differentiation of a function with respect to a tensor
Stephen Montgomery-Smith
stephen at missouri.edu
Fri Feb 11 06:30:35 CET 2011
Bernardo Rocha wrote:
> Hi everyone,
>
> I've recently discovered GiNaC and I'm really excited about its
> capabilities. There is one thing that I would like to know if it is able
> to do that I haven't found in the tutorial.pdf or in any other place
> that I've searched.
>
> I would like to know if, given a function \Psi=\Psi(E), like the strain
> energy function for the St. Venant-Kirchhoff material
>
> \Psi(E) = 0.5 * \lambda * (tr E)^2 + \mu E:E
>
> is it possible to differentiate it with respect to E, that is i would
> like to compute \frac{\partial \Psi}{\partial E}. If this is possible,
> could someone please send some examples or maybe point to which classes
> should I use to do that?
>
> That's all for now. Many thanks in advance.
>
> Best regards,
> Bernardo M. R.
>
>
Couldn't you do it this way? Write \Psi(E) as an expression involving
the variables e11,e12,e13,...,e33 which are the entries of E. Then
compute the partial derivatives \frac{\partial \Psi}{\partial eij} for
1<=i,j<=3. (Presumably you suppose that E is symmetric so only six
partial derivatives need to be computed, but even if it is not
necessarily symmetric you still only need 9 partial derivatives.) Just
store this as something like:
expr dPsi_dE[3][3]
or
vector<expr> dPsi_dE
or something similar.
More information about the GiNaC-list
mailing list