Hi Simon,

Unfortunately I don’t have the time at this moment to give you a full 
explanation as to why the logic of your code is wrong, but in essence you have 
the sequence of operations inverted. You need to compute your energy based on 
the “sensitive” DoF values that would come from the reinit’d FEValues 
operation. You cannot compute something like C_ad ahead of time, like it 
appears that you have.

Take a look at these lines in the (unfinished) tutorial that will illustrate 
the steps required to linearise an energy functional. This should hopefully 
help steer you in the right direction.
https://github.com/dealii/dealii/pull/10394/files#diff-fc8b83d1370bfd7eb558ea76175bfc0e8d6305023d54b17ec9cccb0fba9b1e02R1758-R1831
 
<https://github.com/dealii/dealii/pull/10394/files#diff-fc8b83d1370bfd7eb558ea76175bfc0e8d6305023d54b17ec9cccb0fba9b1e02R1758-R1831>

Best,
Jean-Paul

> On 18. Jul 2022, at 19:46, Simon <simon.wieshe...@gmail.com> wrote:
> 
> Dear all,
> 
> I want to retrieve a tangent at quadrature point level using AD - attached is 
> a snippet of my code:
> 
> The computation of the dependent variable 'S_ad' in line 36 involves the call 
> get_function_gradients (solution_energy, grad_energy_at_ref_point), 
> see line 35. 
> 'solution_energy' is a scalar function which depends on the independent 
> variable 'C_ad' as can be seen in the derivations from line 8 on.
> My issue is that I see no way to pass the NumberTypes type 
> (=Differentiation::AD::NumberTypes::sacado_dfad_dfad) to the corrosponding 
> FEValues object, and, as a consequence, the AD framework is not aware that 
> 'solution_energy' is a function of 'C_ad'. 
> In particular, 'grad_energy_at_ref_point' will be treated as a constant with 
> respect to 'C_ad' in line 36f. 
> 
> How can I incorporate this dependency in the AD framework?
> 
> Thank you,
> Simon
> 
> -- 
> The deal.II project is located at http://www.dealii.org/ 
> <http://www.dealii.org/>
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en 
> <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 dealii+unsubscr...@googlegroups.com 
> <mailto:dealii+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/990f7f7f-37a2-4f9d-b6c2-bbf7dda21e8dn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/dealii/990f7f7f-37a2-4f9d-b6c2-bbf7dda21e8dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
> <Code_AD.PNG>

-- 
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 dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/D175C472-E708-4129-A15E-3FA67666AE9A%40gmail.com.

Reply via email to