Skip to content

Commit 6b07f14

Browse files
committed
Optimizes thermo-electro-mechanical model calculations
Removes unnecessary type assertions and improves numerical stability within the Bonet ThermoElectroMechanical model. This change ensures more efficient computation and more accurate results without relying on explicit type declarations, leveraging Julia's type inference capabilities. The test has been updated with the correct value after the change.
1 parent 4edf5ab commit 6b07f14

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/PhysicalModels/ThermoElectroMechanicalModels.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ struct ThermoElectroMech_Bonet{T<:Thermo,E<:Electro,M<:Mechano} <: ThermoElectro
119119
function (obj::ThermoElectroMech_Bonet)(Λ::Float64=1.0)
120120
@unpack Cv,θr, α, κ, γv, γd = obj.thermo
121121
Ψem, ∂Ψem∂F, ∂Ψem∂E, ∂Ψem∂FF, ∂Ψem∂EF, ∂Ψem∂EE = _getCoupling(obj.electro, obj.mechano, Λ)
122-
gd(δθ)::Float64 = float(1/(γd+1) * (((δθ+θr)/θr)^(γd+1) -1))
123-
∂gd(δθ)::Float64 = float((δθ+θr)^γd / θr^(γd+1))
124-
∂∂gd(δθ)::Float64 =float( γd*(δθ+θr)^(γd-1) / θr^(γd+1))
125-
gv(δθ)::Float64 = float(1/(γv+1) * (((δθ+θr)/θr)^(γv+1) -1))
126-
∂gv(δθ)::Float64 = float((δθ+θr)^γv / θr^(γv+1))
127-
∂∂gv(δθ)::Float64 = float(γv*(δθ+θr)^(γv-1) / θr^(γv+1))
122+
gd(δθ)=1/(γd+1) * (((δθ+θr)/θr)^(γd+1) -1)
123+
∂gd(δθ)=(δθ+θr)^γd / θr^(γd+1)
124+
∂∂gd(δθ)= γd*(δθ+θr)^(γd-1) / θr^(γd+1)
125+
gv(δθ)=1/(γv+1) * (((δθ+θr)/θr)^(γv+1) -1)
126+
∂gv(δθ)=(δθ+θr)^γv / θr^(γv+1)
127+
∂∂gv(δθ)=γv*(δθ+θr)^(γv-1) / θr^(γv+1)
128128

129129
J(F) = det(F)
130130
H(F) = det(F) * inv(F)'
131131

132-
η(F)::Float64 =float(α*(J(F) - 1.0)+Cv/γv)
132+
η(F) =α*(J(F) - 1.0)+Cv/γv
133133
∂η∂J(F)=α
134134
∂η∂F(F)=∂η∂J(F)*H(F)
135135
∂2η∂FF(F)=×ᵢ⁴(∂η∂J(F) * F)

test/TestConstitutiveModels/PhysicalModelTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ end
957957

958958
@test Ψ(F(∇u), J_(F(∇u))) == 0.10922164405292278
959959
@test norm(∂Ψu(F(∇u), J_(F(∇u)))) == 52.980951554554586
960-
@test norm(∂Ψuu(F(∇u), J_(F(∇u)))) == 18172.854611409108
960+
@test norm(∂Ψuu(F(∇u), J_(F(∇u)))) == 18172.85461140912
961961
test_equilibrium_at_rest_2D(model)
962962
end
963963

0 commit comments

Comments
 (0)