kimauth / MaterialModels.jl

A libary of mechanical material models for finite element simulations.
MIT License
12 stars 6 forks source link

test stress and tangent by strain energy function for large strain models #34

Closed koehlerson closed 3 years ago

koehlerson commented 3 years ago

@lijas I got this invariant formulation of the strain energy function, but I'm getting for the tangent a result which doubles all entries. Could it be that your AD of the stress needs a factor of 2? Otherwise, I need to double check the strain energy formula again

and maybe we should declare one ElasticState which is shared by all hyperelastic materials, if you agree, I can include it in this PR

We can also think about using the analytic forms in material_response and use the AD ones only for testing

codecov-commenter commented 3 years ago

Codecov Report

Merging #34 (ee5859a) into main (2a4ef29) will increase coverage by 0.10%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
+ Coverage   94.87%   94.97%   +0.10%     
==========================================
  Files          10       10              
  Lines         351      358       +7     
==========================================
+ Hits          333      340       +7     
  Misses         18       18              
Impacted Files Coverage Δ
src/FiniteStrain/stvenant.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2a4ef29...ee5859a. Read the comment docs.

lijas commented 3 years ago

Good to add proper testing :P I dont know where the factor 2 is coming from... C = 4 d^2PhidC^2 as you have written, and S = 2dPhidC. I will check the _SPK function

  1. I kind of like that all materials have their own state, even though it adds some extra code
  2. Sounds good to AD only for testing.
koehlerson commented 3 years ago

do you have some pdf with the analytic derivatives of Yeoh and/or NeoHook? Too lazy to do them on my own :D

lijas commented 3 years ago

No PDF unfortunately.

In Nonlinear continuum mechanics for finite elment analysis by Javier Bonet, I found derivations of the tangent and stress for the NeoHook material:

function check_tangents_AD(material::NeoHook,loading::Vector)
    state = initial_material_state(material)
    for C in loading

        invC = inv(C)
        J = sqrt(det(C))

        S = material.μ*(one(SymmetricTensor{2,3}) - inv(C)) + material.λ*log(J)*inv(C)
        T = material.λ*(invC⊗invC) + 2*(material.μ-material.λ*log(J))*otimesu(invC,invC)
        T = symmetric(T)

        ∂²Ψ∂C², ∂Ψ∂C, _ =  hessian(C -> MaterialModels.ψ(material, C), C, :all)
        S_AD = 2*∂Ψ∂C
        T_AD = 4*∂²Ψ∂C²

        @show S_AD ≈ S
        @show T_AD ≈ T
    end
end

I had to take symmetrize the analytical tangent for some reason. I remember my proffessor mentioning this at one time, but i never understood why.

I also found analytical derivations for Yeoh material in an old matlab code (voigt notiation):

S2 = 2*( mu/2*I + ...
    2*c2*(Ic-3)*I + ...
    3*c3*(Ic-3)^2*I + ...
    -mu*dlnJdc + ...
    lambda * log(J) * dlnJdc );

dS2_dE = 4 * (...
         2*c2*(I*I') + ...
         6*c3*(Ic-3)*(I*I') + ...
         -mu*d2lnJdcdc + ...
         lambda*(log(J)*d2lnJdcdc + (dlnJdc*dlnJdc')) );

with


invC=m_2_v9( inv(v9_2_m(C) ) );
detC=det(v9_2_m(C)); 
J=sqrt(detC);

dlnJdc = 1/2*invC; %Transpose C mayby.
d2lnJdcdc = 1/2*inv((f9_open_u_9(-C,C)));

%2nd order identity tensor
I=[1 1 1 0 0 0 0 0 0]';
Ic = trace(v9_2_m(C));

No derivation for StVenant material though :P

lijas commented 3 years ago

I (or someone else) can add these for analytical derivations for the meterial_response instead of the using AD as we are doing now

koehlerson commented 3 years ago

hm it's true that the symmetric statement is needed, otherwise the test fails, also for Yeoh model

lijas commented 3 years ago

Can this be merged? Tests are passing, but I guess we are unsure why we need Symmetric for Yeoh and StVenand material...

koehlerson commented 3 years ago

Other than the symmetric issues this should be good to go. Im not sure where or how to investigate into this, if you ever find it out please let me know :)