Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ end
@publish PhysicalModels IncompressibleNeoHookean2D
@publish PhysicalModels IncompressibleNeoHookean2D_CV
@publish PhysicalModels VolumetricEnergy
@publish PhysicalModels CoerciveVolumetric
@publish PhysicalModels MooneyRivlin3D
@publish PhysicalModels MooneyRivlin2D
@publish PhysicalModels NonlinearMooneyRivlin3D
Expand Down
33 changes: 30 additions & 3 deletions src/PhysicalModels/MechanicalModels.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@


# ============================================
# Coercive volumetric Mechanical models
# Volumetric Mechanical models
# ============================================

"""
Coercive volumetric energy term of the form:
Volumetric energy term of the form:

```math
\\Psi = \\frac{1}{\\kappa} (J-1)^2
\\Psi = \\frac{\\kappa}{2} (J-1)^2
```
"""
struct VolumetricEnergy <: Volumetric
Expand Down Expand Up @@ -36,6 +36,33 @@ function (obj::VolumetricEnergy)(Λ::Float64=1.0)
end


"""
Coercive volumetric energy term of the form:

```math
\\Psi = \\frac{\\kappa}{4} (J^2-1+\\log(J))
```
"""
struct CoerciveVolumetric <: Volumetric
κ::Float64
function CoerciveVolumetric(; κ::Float64)
new(κ)
end
end

function (obj::CoerciveVolumetric)(::Float64=1.0)
κ = obj.κ
J(F) = det(F)
H(F) = det(F) * inv(F)'
Ψ(F) = (κ / 4) * (J(F)^2 - 1 - 2logreg(J(F)))
∂Ψ_∂J(F) = (κ / 2) * (J(F) - ∂log∂J(J(F)))
∂Ψ2_∂J2(F) = (κ / 2) * (1 - ∂∂log∂JJ(J(F)))
∂Ψu(F) = ∂Ψ_∂J(F) * H(F)
∂Ψuu(F) = ∂Ψ2_∂J2(F) * (H(F) ⊗ H(F)) + ×ᵢ⁴(∂Ψ_∂J(F) * F)
return (Ψ, ∂Ψu, ∂Ψuu)
end


# ============================================
# Regularization of Mechanical models
# ============================================
Expand Down
1 change: 1 addition & 0 deletions src/PhysicalModels/PhysicalModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export ARAP2D
export ARAP2D_regularized
export NonlinearARAP2D
export VolumetricEnergy
export CoerciveVolumetric
export MooneyRivlin3D
export MooneyRivlin2D
export NonlinearMooneyRivlin3D
Expand Down
30 changes: 27 additions & 3 deletions src/TensorAlgebra/Functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,35 @@ end
"""
Jacobian regularization
"""
function logreg(J; Threshold=0.01)
if J >= Threshold
function logreg(J; threshold=0.01)
if J >= threshold
return log(J)
else
return log(Threshold) - (3.0 / 2.0) + (2 / Threshold) * J - (1 / (2 * Threshold^2)) * J^2
return log(threshold) - (3.0 / 2.0) + (2 / threshold) * J - (1 / (2 * threshold^2)) * J^2
end
end


"""
Jacobian regularization
"""
function ∂log∂J(J; threshold=0.01)
if J >= threshold
1 / J
else
2 / threshold - J / (threshold^2)
end
end


"""
Jacobian regularization
"""
function ∂∂log∂JJ(J; threshold=0.01)
if J >= threshold
-1 / (J^2)
else
-1 / (threshold^2)
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/TensorAlgebra/TensorAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export zerotensor3
export zerotensor9

export logreg
export ∂log∂J
export ∂∂log∂JJ
export Tensorize
export δᵢⱼδₖₗ2D
export δᵢₖδⱼₗ2D
Expand Down
12 changes: 10 additions & 2 deletions test/TestConstitutiveModels/PhysicalModelTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,20 @@ end
@testset "VolumetricEnergy" begin
# Memory estimate: 0 bytes, allocs estimate: 0.
∇u = TensorValue(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0) * 1e-3
model = VolumetricEnergy(λ=0.0)
test_derivatives_3D_(model, Kinematics(Mechano, Solid))
model = VolumetricEnergy(λ=1.0)
test_derivatives_3D_(model, Kinematics(Mechano, Solid), rtol=1e-12)
test_equilibrium_at_rest_3D(model)
end


@testset "CoerciveVolumetric" begin
# Memory estimate: 0 bytes, allocs estimate: 0.
∇u = TensorValue(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0) * 1e-3
model = CoerciveVolumetric(κ=1.0)
test_derivatives_3D_(model, Kinematics(Mechano, Solid), rtol=1e-12)
test_equilibrium_at_rest_3D(model)
end



@testset "ThermoElectroMech_Govindjee" begin
Expand Down
4 changes: 3 additions & 1 deletion test/TestTensorAlgebra/TensorAlgebraTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ using Test
F = one(∇u) + ∇u
J = det(F)
@test J == 1.0149819999999996
@test logreg(J; Threshold=0.01) == 0.014870878346353422
@test logreg(J; threshold=0.01) == 0.014870878346353422
@test ForwardDiff.derivative(logreg, J) ≈ ∂log∂J(J)
@test ForwardDiff.derivative(∂log∂J, J) ≈ ∂∂log∂JJ(J)
end


Expand Down
Loading