Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/PhysicalModels/ThermoMechanicalModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ end
function derivatives(law::LogisticLaw)
@unpack θr, μ, σ = law
z(x) = (log(x) - μ) / σ
std_pdf(x) = 1/σ/sqrt(2 * π) * exp(-z(x)^2 / 2)
std_pdf(x) = 1/(σ*sqrt(2 * π)) * exp(-z(x)^2 / 2)
std_cdf(x) = 0.5 * (1 + erf(z(x) / sqrt(2)))
ξR = 1 / (1-std_cdf(θr))
f(θ) = ξR * (1-std_cdf(θ))
Expand Down
2 changes: 1 addition & 1 deletion src/TensorAlgebra/Functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end
"""
Fast and dependency-free implementation of erf function, up to 1e-6 precision.
"""
@inline function erf(x::Float64)
@inline function erf(x::Real)
p = 0.3275911
a1 = 0.254829592
a2 = -0.284496736
Expand Down
12 changes: 12 additions & 0 deletions test/TestConstitutiveModels/ThermalLawsTests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using ForwardDiff
using HyperFEM
using Test

@testset "LogisticLaw" begin
law = LogisticLaw(273.15, log(300.1), 0.11)
f, df, ddf = derivatives(law)
for θ ∈ 200.0:50:400 # NOTE: The numerical derivative of erf is a bad approximation, while the analyitical function uses the exact value.
@test isapprox(df(θ), ForwardDiff.derivative(f, θ), rtol=1e-3)
@test isapprox(ddf(θ), ForwardDiff.derivative(df, θ), rtol=1e-10)
end
end
4 changes: 4 additions & 0 deletions test/TestConstitutiveModels/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ using Test
include("ElectroMechanicalTests.jl")
end

@time begin
include("ThermalLawsTests.jl")
end

end
Loading