Dear prof. Bangerth,
Thanks for your response. Two things: 1) I am using symbolic
differentiation. 2) Here's a simpler implementation of my problem in line
with your example:
const Differentiation::SD::Expression x("x");
const Differentiation::SD::Expression y = std::pow(x,2);
std::cout << "y: " << y << std::endl;
const Differentiation::SD::Expression g = std::pow(y,2);
std::cout << "g: " << g << std::endl;
const Differentiation::SD::Expression dg_dy = Differentiation::SD::
differentiate(g,y);
std::cout << "dg_dy: " << dg_dy << std::endl;
const Differentiation::SD::Expression dg_dx = Differentiation::SD::
differentiate(g,x);
std::cout << "dg_dx: " << dg_dx << std::endl;
Output:
y: x**2
g: x**4
dg_dy: 0
dg_dx: 4*x**3
Here, I have a function g=g(y(x)). I wish to know its derivative with
respect to x and y. Manually, we would obtain both using the chain rule.
But here, it looks like the information about the composition of the
functions is not being stored somehow, maybe because it reduces the
expressions to the independent variables ("x" in this case). What change
should I make to obtain dg_dy? The independent variable remains "x" of
course.
Regards
Vinayak
On Wednesday, July 17, 2024 at 11:47:48 PM UTC+5:30 Wolfgang Bangerth wrote:
> On 7/17/24 09:15, Vinayak Vijay wrote:
> >
> > In line 63, the differentiation of the energy function (psi_sd) with
> respect
> > to left cauchy green tensor (b_sd) results in the Kirchhoff stress
> tensor
> > tau_sd = zero tensor. I believe this is due to the fact that tau_sd is
> stored
> > as a function of F_sd (symbolic deformation gradient) and is therefore
> unable
> > to recognise the dependence with b_sd (symbolic left cauchy green
> tensor).
> >
> > How can i resolve this issue? Thanks in advance.
>
> If I understand your question right, you have a function
> f(x)
> and you are computing
> d/dy f(x)
> which is indeed zero because you have not said anything about how x and y
> are
> related. If x can be expressed as a function of y, say x=g(y), then you
> need
> to tell the autodifferentiation machinery that your function f is really
> f(g(y))
> i.e., everywhere where you previously used x, you need to replace it by
> g(y)
> to make it clear that f is a function of y.
>
> Does this help?
>
> Best
> W.
>
> --
> ------------------------------------------------------------------------
> Wolfgang Bangerth email: [email protected]
> www: http://www.math.colostate.edu/~bangerth/
>
>
>
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/d8c89bee-f904-44a8-9cbb-d14da6f464f6n%40googlegroups.com.