# Gradients of strain

**URL:** <https://discourse.julialang.org/t/gradients-of-strain/112344>\
**Category:** New to Julia\
**Tags:** gridap, gradient\
**Created:** [March 31, 2024, 4:09am UTC](https://discourse.julialang.org/t/gradients-of-strain/112344 "2024-03-31T04:09:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)\
**Post date:** [March 31, 2024, 4:09am UTC](https://discourse.julialang.org/t/gradients-of-strain/112344/1 "2024-03-31T04:09:37Z")

</div>

HI,  
I want to take the derivative of strain with respect to displacement without using the the shape functions and find the gradients in cells in gridap (I can not figure out this derivative mathematically). I used this gradient to find the gradient of energy wrt displacement.

```julia
function ψPos(ε_in)
   σ_elas = C_mat⊙ε_in
    if tr(ε_in) >= 0
        ψPlus = 0.5*(ε_in ⊙ σ_elas)
    elseif tr(ε_in) < 0
        ψPlus = 0.5*((P_dev ⊙ σ_elas)⊙(P_dev⊙ε_in))
    end
    return ψPlus
end

```
