Skip to content

Commit 43e3a47

Browse files
authored
Merge pull request #206 from MultiSimOLab/fix-visco-test
Fixed return mapping test
2 parents 5de58ab + 0e03117 commit 43e3a47

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/PhysicalModels/ViscousPolyconvex.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,22 @@ end
9494

9595
function dissipation(obj::ViscousPolyconvex, F, Fn, Cvn)
9696
γ = obj.μ / obj.τ
97-
Τ = obj.τ / obj.Δt
97+
Τ = obj.τ / obj.Δt[]
9898
C, Cn = Cauchy.((F, Fn))
9999
Cv = return_mapping(obj, C, Cn, Cvn)
100100
invC = inv(C)
101101
λ_algo = 1 / (det(invC + Τ*inv(Cvn))^(1/3) - Τ) # λ = 3 / (Cv ⊙ invC)
102102
-0.5γ * (C -λ_algo*Cv) (invC - (1/λ_algo)*inv(Cv))
103103
end
104104

105-
# --- Return mapping and derivatives for underlying neo-Hookean ---
105+
# --- Return mapping and derivatives for the underlying neo-Hookean ---
106106

107107
function return_mapping(obj::ViscousPolyconvex, C, Cn, Cvn)
108108
Τ = obj.Δt[] / obj.τ
109109
B = Τ * inv(C) + inv(Cvn)
110110
invCv = det(B)^(-1/3) * B
111111
inv(invCv)
112+
# Cv = det(B)^(1/3) * inv(B)
112113
end
113114

114115
function ∂invCv∂C(obj::ViscousPolyconvex, C, Cn, Cvn)
@@ -118,6 +119,11 @@ function ∂invCv∂C(obj::ViscousPolyconvex, C, Cn, Cvn)
118119
IIIb = det(B)
119120
IIIc = det(C)
120121
Τ * IIIb^(-1/3) * IIIc^(-1) * (IIsym(I3) -1/3*Binv(B)) * (-IIIc^(-1) * GG + ×ᵢ⁴(C))
122+
# invC = inv(C)
123+
# B = Τ * invC + inv(Cvn)
124+
# ∂invCv∂B = det(B)^(-1/3) * (IIsym(I3) - (1/3) * (B ⊗ inv(B)))
125+
# ∂B∂C = -Τ * IIsym(invC)
126+
# ∂invCv∂B · ∂B∂C
121127
end
122128

123129
function return_mapping(obj::ViscousPolyconvex)

test/TestConstitutiveModels/ViscousModelsTests.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ end
234234

235235
@testset "ViscousPolyconvex" begin
236236
model = ViscousPolyconvex=1.15, μ=7e4)
237+
update_time_step!(model, 0.1)
237238
Fn = I3
238239
F1 = I3 + 0.1*TensorValue(rand(9)...)
239240
C1 = F1' · F1
241+
Cn = I3
240242
Cv = I3
241243

242244
# --- Test neo-Hookean model ---
@@ -254,8 +256,10 @@ end
254256
return_mapping = HyperFEM.PhysicalModels.return_mapping
255257
∂invCv∂C = HyperFEM.PhysicalModels.∂invCv∂C
256258

257-
∂invCv_ref = TensorValue(ForwardDiff.jacobian(C -> get_array(return_mapping(model, TensorValue(C), C1, Cv)), get_array(C1)))
258-
@test isapprox(∂invCv∂C(model, C1, C1, Cv), ∂invCv_ref, rtol=1e-8)
259+
∂invCv_ref = TensorValue(ForwardDiff.jacobian(
260+
C -> get_array(inv(return_mapping(model, 0.5*TensorValue(C+C'), Cn, Cv))), # Enforce symmetry of C within ForwardDiff
261+
get_array(C1)))
262+
@test isapprox(∂invCv∂C(model, C1, Cn, Cv), ∂invCv_ref, rtol=1e-8)
259263

260264
# --- Test full model tangent operator ---
261265
Ψ, ∂Ψ∂F, ∂∂Ψ∂FF = model()

0 commit comments

Comments
 (0)