Skip to content

Commit 2a4ef29

Browse files
authored
Hyperelastic materials (#30)
* add three hyperelastic materials
1 parent 34ab8ef commit 2a4ef29

File tree

11 files changed

+167
-0
lines changed

11 files changed

+167
-0
lines changed

src/FiniteStrain/neohook.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
NeoHook(; E, ν)
3+
4+
Hyperelastic material
5+
#Arguments
6+
- `λ::Float64`: Lamé parameter
7+
- `μ::Float64`: Lamé parameter (shear modulus)
8+
"""
9+
10+
struct NeoHook <: AbstractMaterial
11+
λ::Float64
12+
μ::Float64
13+
end
14+
15+
struct NeoHookState <: AbstractMaterialState
16+
end
17+
18+
function initial_material_state(::NeoHook)
19+
return NeoHookState()
20+
end
21+
22+
function NeoHook(; λ::T, μ::T) where T
23+
24+
return NeoHook(λ, μ)
25+
end
26+
27+
function ψ(mp::NeoHook, C::SymmetricTensor{2,3})
28+
J = sqrt(det(C))
29+
I = tr(C)
30+
return mp.μ/2 * (I-3) - mp.μ*log(J) + mp.λ/2 * log(J)^2
31+
end
32+
33+
function material_response(mp::NeoHook, C::SymmetricTensor{2,3}, state::NeoHookState = NeoHookState(),
34+
Δt=nothing; cache=nothing, options=nothing)
35+
∂²Ψ∂C², ∂Ψ∂C, _ = hessian((C) -> ψ(mp, C), C, :all)
36+
S = 2.0 * ∂Ψ∂C
37+
∂S∂C = 2.0 * ∂²Ψ∂C²
38+
return S, ∂S∂C, NeoHookState()
39+
end

src/FiniteStrain/stvenant.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
StVenant(; E, ν)
3+
4+
Hyperelastic material
5+
#Arguments
6+
- `λ::Float64`: Lamé parameter
7+
- `μ::Float64`: Lamé parameter (shear modulus)
8+
"""
9+
10+
struct StVenant <: AbstractMaterial
11+
λ::Float64
12+
μ::Float64
13+
end
14+
15+
struct StVenantState <: AbstractMaterialState
16+
end
17+
18+
function initial_material_state(::StVenant)
19+
return StVenantState()
20+
end
21+
22+
function StVenant(; λ::T, μ::T) where T
23+
return StVenant(λ, μ)
24+
end
25+
26+
function _SPK(mp::StVenant, C::SymmetricTensor{2,3})
27+
I = one(C)
28+
return 0.5*mp.λ*(tr(C) - 3)*I + mp.μ*(C - I)
29+
end
30+
31+
function material_response(mp::StVenant, C::SymmetricTensor{2,3}, state::StVenantState = StVenantState(),
32+
Δt=nothing; cache=nothing, options=nothing)
33+
34+
∂S∂C, S = gradient((C) -> _SPK(mp, C), C, :all)
35+
return S, ∂S∂C, StVenantState()
36+
end
37+
38+

src/FiniteStrain/yeoh.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Yeoh(; λ, μ, c₂, c₃)
3+
4+
Hyper elastic material
5+
#Arguments
6+
- `λ::Float64`: Lamé parameter
7+
- `μ::Float64`: Lamé parameter (shear modulus)
8+
- `c₂::Float64`: Material constant
9+
- `c₃::Float64`: Material constant
10+
"""
11+
struct Yeoh <: AbstractMaterial
12+
λ::Float64
13+
μ::Float64
14+
c₂::Float64
15+
c₃::Float64
16+
end
17+
18+
struct YeohState <: AbstractMaterialState
19+
end
20+
21+
function initial_material_state(::Yeoh)
22+
return YeohState()
23+
end
24+
25+
function Yeoh(; λ::T, μ::T, c₂::T, c₃::T) where T <: AbstractFloat
26+
return Yeoh(λ, μ, c₂, c₃)
27+
end
28+
29+
function ψ(mp::Yeoh, C::SymmetricTensor{2,3})
30+
J = sqrt(det(C))
31+
I = tr(C)
32+
return mp.μ/2 * (I-3) + mp.c₂*(I-3)^2 + mp.c₃*(I-3)^3 - mp.μ*log(J) + mp.λ/2 * log(J)^2
33+
end
34+
35+
function material_response(mp::Yeoh, C::SymmetricTensor{2,3}, state::YeohState = YeohState(),
36+
Δt=nothing; cache=nothing, options=nothing)
37+
∂²Ψ∂C², ∂Ψ∂C, _ = hessian((C) -> ψ(mp, C), C, :all)
38+
S = 2.0 * ∂Ψ∂C
39+
∂S∂C = 2.0 * ∂²Ψ∂C²
40+
return S, ∂S∂C, YeohState()
41+
end
42+

src/MaterialModels.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ include("CrystalViscoPlastic/slipsystems.jl")
7272
include("CrystalViscoPlastic/CrystalViscoPlastic.jl")
7373
include("CrystalViscoPlastic/CrystalViscoPlasticRed.jl")
7474

75+
include("FiniteStrain/neohook.jl")
76+
include("FiniteStrain/yeoh.jl")
77+
include("FiniteStrain/stvenant.jl")
78+
7579
include("nonlinear_solver.jl")
7680
include("wrappers.jl")
7781

@@ -83,4 +87,5 @@ export LinearElastic, Plastic
8387
export LinearElasticState, PlasticState
8488
export OneD, UniaxialStrain, UniaxialStress, PlaneStrain, PlaneStress
8589

90+
export NeoHook, Yeoh, StVenant
8691
end

test/jld2_files/NeoHook.jld2

9.54 KB
Binary file not shown.

test/jld2_files/StVenant.jld2

9.54 KB
Binary file not shown.

test/jld2_files/Yeoh.jld2

9.54 KB
Binary file not shown.

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ include("test_plastic.jl")
1010
include("test_crystal_visco_plastic.jl")
1111
include("test_crystal_visco_plastic_red.jl")
1212
include("test_wrappers.jl")
13+
include("test_neohook.jl")
14+
include("test_yeoh.jl")
15+
include("test_stvenant.jl")

test/test_neohook.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
function get_NeoHook_loading()
4+
_C = range(0.0, 0.005, length=3)
5+
C = [SymmetricTensor{2,3}((x +1.0, x/10, 0.0, 1.0, 0.0, 1.0)) for x in _C]
6+
return C
7+
end
8+
9+
@testset "NeoHook" begin
10+
m = NeoHook=76.9, λ=115.0)
11+
12+
loading = get_NeoHook_loading()
13+
check_jld2(m, loading, "NeoHook")#, debug_print=false, OVERWRITE_JLD2=true)
14+
end

test/test_stvenant.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function get_StVenant_loading()
2+
_C = range(0.0, 0.005, length=3)
3+
C = [SymmetricTensor{2,3}((x + 1.0, x/10, 0.0, 1.0, 0.0, 1.0)) for x in _C]
4+
5+
return C
6+
end
7+
8+
@testset "StVenant" begin
9+
m = StVenant=6.8, λ=62.1)
10+
11+
loading = get_StVenant_loading()
12+
check_jld2(m, loading, "StVenant")#, debug_print=false, OVERWRITE_JLD2=true)
13+
end

0 commit comments

Comments
 (0)