Skip to content

Commit

Permalink
Several bugfixes and features (#175)
Browse files Browse the repository at this point in the history
* add kwargs to SetDiffusionCreep

* add small test

* remove GLMakie from [deps]

* add kwargs to remaining SetXCreep

* corrected a number of obvious typos in the activation volume

* cosmetics

* missing @test

* fix SetPeierlsCreep

* minor formatting

---------

Co-authored-by: Boris Kaus <kaus@uni-mainz.de>
  • Loading branch information
albert-de-montserrat and boriskaus authored Feb 19, 2024
1 parent ce7dcb8 commit 6581b53
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 91 deletions.
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ version = "0.5.6"
BibTeX = "7b0aa2c9-049f-5cec-894a-2b6b781bb25e"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
KernelDensitySJ = "49dc5b4e-6806-4504-b2cc-a81764e7a38b"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Expand Down
2 changes: 1 addition & 1 deletion src/CreepLaw/Data/DiffusionCreep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function wet_anorthite_rybacki_2006()
p=-3.0NoUnits, # grain size exponent
A=(10^-0.7)MPa^(-1) * μm^3 * s^(-1), # material specific rheological parameter
E=159.0kJ / mol, # activation energy
V=38.0m^3 / mol, # activation Volume
V=38.0e-6m^3 / mol, # activation Volume
Apparatus=AxialCompression,
)
info = MaterialParamsInfo(;
Expand Down
10 changes: 5 additions & 5 deletions src/CreepLaw/Data/DislocationCreep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function wet_olivine2_Hirth_2003()
n=3.0NoUnits,
A=1600MPa^(-3) / s,
E=520.0kJ / mol,
V=22.0m^3 / mol,
V=22.0e-6m^3 / mol,
r=1.2NoUnits,
Apparatus=AxialCompression,
)
Expand Down Expand Up @@ -430,7 +430,7 @@ function wet_anorthite_Rybacki_2006()
n=3.0NoUnits,
A=(10^0.2)MPa^(-3) / s,
E=345kJ / mol,
V=38m^3 / mol,
V=38e-6m^3 / mol,
r=1NoUnits,
Apparatus=AxialCompression,
)
Expand Down Expand Up @@ -663,7 +663,7 @@ function wet_olivine_Mei_2000b()
n=3.0NoUnits,
A=(10^3.2)MPa^(-3) / s,
E=470.0kJ / mol,
V=20.0m^3 / mol,
V=20.0e-6m^3 / mol,
r=0.98NoUnits,
Apparatus=AxialCompression,
)
Expand Down Expand Up @@ -692,7 +692,7 @@ function dry_olivine_Karato_2003()
n=3.0NoUnits,
A=(10^6.1)MPa^(-3) / s,
E=510.0kJ / mol,
V=14.0m^3 / mol,
V=14.0e-6m^3 / mol,
r=0.0NoUnits,
Apparatus=AxialCompression,
)
Expand Down Expand Up @@ -721,7 +721,7 @@ function wet_olivine_Karato_2003()
n=3.0NoUnits,
A=(10^2.9)MPa^(-3) / s,
E=510.0kJ / mol,
V=24.0m^3 / mol,
V=24.0e-6m^3 / mol,
r=1.2NoUnits,
Apparatus=AxialCompression,
)
Expand Down
10 changes: 5 additions & 5 deletions src/CreepLaw/Data/GrainBoundarySliding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export GrainBoundarySliding_database, GrainBoundarySliding_database_info
function cold_dry_olivine_Hirth_2003()
data = GrainBoundarySliding(;
Name="Dry Olivine < 1523K | Hirth and Kohlstedt (2003)",
n=3.5NoUnits, # power-law exponent
p=-2.0NoUnits, # grain size exponent
A=6500.0MPa^(-7//2) * μm^(2) * s^(-1), # material specific rheological parameter
E=400.0kJ / mol, # activation energy
V=18.0e-6m^3 / mol, # activation Volume
n=3.5NoUnits, # power-law exponent
p=-2.0NoUnits, # grain size exponent
A=6500.0MPa^(-7//2) * μm^(2) * s^(-1), # material specific rheological parameter
E=400.0kJ / mol, # activation energy
V=18.0e-6m^3 / mol, # activation Volume
Apparatus=AxialCompression,
)
info = MaterialParamsInfo(;
Expand Down
30 changes: 15 additions & 15 deletions src/CreepLaw/Data/PeierlsCreep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export peierls_database, peierls_database_info
function dry_olivine_Goetze_1979()
data = PeierlsCreep(;
Name="Dry Olivine | Goetze and Evans (1979)",
n=1.0NoUnits, # power-law exponent
o=2.0NoUnits, # exponent of water-fugacity
q=1.0NoUnits, # grain size exponent
TauP=8.5e9Pa, # Peierls stress
A=(5.7e11)s^(-1), # material specific rheological parameter
n=1.0NoUnits, # power-law exponent
o=2.0NoUnits, # exponent of water-fugacity
q=1.0NoUnits, # grain size exponent
TauP=8.5e9Pa, # Peierls stress
A=(5.7e11)s^(-1), # material specific rheological parameter
E=536.0kJ / mol, # activation energy
Apparatus=AxialCompression,
)
Expand All @@ -36,11 +36,11 @@ end
function dry_olivine_Demouchy_2013()
data = PeierlsCreep(;
Name="Dry Olivine | Demouchy (2013)",
n=1.0NoUnits, # power-law exponent
o=2.0NoUnits, # exponent of water-fugacity
q=0.5NoUnits, # grain size exponent
TauP=15.0e9Pa, # Peierls stress
A=(1.0e6)s^(-1), # material specific rheological parameter
n=1.0NoUnits, # power-law exponent
o=2.0NoUnits, # exponent of water-fugacity
q=0.5NoUnits, # grain size exponent
TauP=15.0e9Pa, # Peierls stress
A=(1.0e6)s^(-1), # material specific rheological parameter
E=450.0kJ / mol, # activation energy
Apparatus=AxialCompression,
)
Expand All @@ -64,11 +64,11 @@ end
function dry_olivine_Idrissei_2016()
data = PeierlsCreep(;
Name="Dry Olivine | Idrissei (2016)",
n=1.0NoUnits, # power-law exponent
o=2.0NoUnits, # exponent of water-fugacity
q=0.5NoUnits, # grain size exponent
TauP=3.8e9Pa, # Peierls stress
A=(1e6)s^(-1), # material specific rheological parameter
n=1.0NoUnits, # power-law exponent
o=2.0NoUnits, # exponent of water-fugacity
q=0.5NoUnits, # grain size exponent
TauP=3.8e9Pa, # Peierls stress
A=(1e6)s^(-1), # material specific rheological parameter
E=566.0kJ / mol, # activation energy
Apparatus=AxialCompression,
)
Expand Down
73 changes: 60 additions & 13 deletions src/CreepLaw/DiffusionCreep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,39 @@ using .Diffusion
SetDiffusionCreep["Name of Diffusion Creep"]
This is a dictionary with pre-defined creep laws
"""
SetDiffusionCreep(name::F) where F = Transform_DiffusionCreep(name)
function SetDiffusionCreep(
name::F;
n = nothing,
r = nothing,
p = nothing,
A = nothing,
E = nothing,
V = nothing,
) where F
kwargs = (; n, r, p, A, E, V)
Transform_DiffusionCreep(name, kwargs)
end

function SetDiffusionCreep(name::F, CharDim::GeoUnits{T}) where {F, T<:Union{GEO, SI}}
return nondimensionalize(Transform_DiffusionCreep(name), CharDim)
function SetDiffusionCreep(
name::F,
CharDim::GeoUnits{T};
n = nothing,
r = nothing,
p = nothing,
A = nothing,
E = nothing,
V = nothing,
) where {F, T<:Union{GEO, SI}}
kwargs = (; n, r, p, A, E, V)
nondimensionalize(Transform_DiffusionCreep(name, kwargs), CharDim)
end

"""
Transform_DiffusionCreep(name)
Transforms units from MPa, kJ etc. to basic units such as Pa, J etc.
"""
Transform_DiffusionCreep(name::F) where F = Transform_DiffusionCreep(diffusion_database(name))
Transform_DiffusionCreep(name::F, kwargs::NamedTuple) where F = Transform_DiffusionCreep(diffusion_database(name), kwargs)

function Transform_DiffusionCreep(name::F, CharDim::GeoUnits{U}) where {F, U<:Union{GEO,SI}}
Transform_DiffusionCreep(diffusion_database(name), CharDim)
Expand All @@ -363,16 +385,41 @@ function Transform_DiffusionCreep(pp::AbstractCreepLaw{T}) where T
@inline f1(A::T) where T = typeof(A).parameters[2].parameters[1][2].power
@inline f2(A::T) where T = typeof(A).parameters[2].parameters[1][1].power

n = Value(pp.n)
r = Value(pp.r)
p = Value(pp.p)
power_Pa = f1(pp.A)
power_m = f2(pp.A)
A_Pa = uconvert(Pa^(power_Pa) * m^(power_m) / s, Value(pp.A))
E_J = uconvert(J / mol, Value(pp.E))
V_m3 = uconvert(m^3 / mol, Value(pp.V))
n = Value(pp.n)
r = Value(pp.r)
p = Value(pp.p)
power_Pa = f1(pp.A)
power_m = f2(pp.A)
A_Pa = uconvert(Pa^(power_Pa) * m^(power_m) / s, Value(pp.A))
E_J = uconvert(J / mol, Value(pp.E))
V_m3 = uconvert(m^3 / mol, Value(pp.V))
Apparatus = pp.Apparatus
args = (Name=pp.Name, n=n, p=p, r=r, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)

return DiffusionCreep(; args...)
end

function Transform_DiffusionCreep(pp::AbstractCreepLaw{T}, kwargs::NamedTuple) where T

@inline f1(A::T) where T = typeof(A).parameters[2].parameters[1][2].power
@inline f2(A::T) where T = typeof(A).parameters[2].parameters[1][1].power

(; n, r, p, A, E, V) = kwargs

n_new = isnothing(n) ? Value(pp.n) : Value(GeoUnit(n))
r_new = isnothing(r) ? Value(pp.r) : Value(GeoUnit(r))
p_new = isnothing(p) ? Value(pp.p) : Value(GeoUnit(p))
A_new = isnothing(A) ? pp.A : GeoUnit(A)
E_new = isnothing(E) ? Value(pp.E) : Value(GeoUnit(E))
V_new = isnothing(E) ? Value(pp.V) : Value(GeoUnit(V))

power_Pa = f1(A_new)
power_m = f2(A_new)
A_Pa = uconvert(Pa^(power_Pa) * m^(power_m) / s, Value(A_new))
E_J = uconvert(J / mol, E_new)
V_m3 = uconvert(m^3 / mol, V_new)
Apparatus = pp.Apparatus
args = (Name=pp.Name, n=n, p=p, r=r, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)
args = (Name=pp.Name, n=n_new, p=p_new, r=r_new, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)

return DiffusionCreep(; args...)
end
end
56 changes: 48 additions & 8 deletions src/CreepLaw/DislocationCreep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,36 @@ function param_info(s::DislocationCreep)
)
end

SetDislocationCreep(name::F) where F = Transform_DislocationCreep(name)
function SetDislocationCreep(
name::F;
n = nothing,
r = nothing,
A = nothing,
E = nothing,
V = nothing,
) where F
kwargs = (; n, r, A, E, V)
Transform_DislocationCreep(name, kwargs)
end

function SetDislocationCreep(name::F, CharDim::GeoUnits{T}) where {F, T<:Union{GEO,SI}}
return nondimensionalize(Transform_DislocationCreep(name), CharDim)
function SetDislocationCreep(
name::F,
CharDim::GeoUnits{T};
n = nothing,
r = nothing,
A = nothing,
E = nothing,
V = nothing,
) where {F, T<:Union{GEO, SI}}
kwargs = (; n, r, A, E, V)
nondimensionalize(Transform_DislocationCreep(name, kwargs), CharDim)
end

"""
Transforms units from MPa, kJ etc. to basic units such as Pa, J etc.
"""
Transform_DislocationCreep(name::F) where F = Transform_DislocationCreep(dislocation_database(name))
Transform_DislocationCreep(name::F, kwargs::NamedTuple) where F = Transform_DislocationCreep(dislocation_database(name), kwargs)

function Transform_DislocationCreep(name::F, CharDim::GeoUnits{U}) where {U<:Union{GEO,SI}} where F
Transform_DislocationCreep(dislocation_database(name), CharDim)
Expand All @@ -327,14 +347,34 @@ function Transform_DislocationCreep(p::AbstractCreepLaw{T}, CharDim::GeoUnits{U}
end

function Transform_DislocationCreep(p::AbstractCreepLaw{T}) where T
n = Value(p.n)
A_Pa = uconvert(Pa^unit_power(p.A) / s, Value(p.A))
E_J = uconvert(J / mol, Value(p.E))
V_m3 = uconvert(m^3 / mol, Value(p.V))
n = Value(p.n)
A_Pa = uconvert(Pa^unit_power(p.A) / s, Value(p.A))
E_J = uconvert(J / mol, Value(p.E))
V_m3 = uconvert(m^3 / mol, Value(p.V))
Apparatus = p.Apparatus
r = Value(p.r)
r = Value(p.r)
# args from database
args = (Name=p.Name, n=n, r=r, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)

return DislocationCreep(; args...)
end

function Transform_DislocationCreep(p::AbstractCreepLaw{T}, kwargs::NamedTuple) where T

(; n, r, A, E, V) = kwargs

n_new = isnothing(n) ? Value(p.n) : Value(GeoUnit(n))
r_new = isnothing(r) ? Value(p.r) : Value(GeoUnit(r))
A_new = isnothing(A) ? p.A : GeoUnit(A)
E_new = isnothing(E) ? Value(p.E) : Value(GeoUnit(E))
V_new = isnothing(E) ? Value(p.V) : Value(GeoUnit(V))

A_Pa = uconvert(Pa^unit_power(A_new) / s, Value(A_new))
E_J = uconvert(J / mol, E_new)
V_m3 = uconvert(m^3 / mol, V_new)
Apparatus = p.Apparatus
# args from database
args = (Name=p.Name, n=n_new, r=r_new, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)

return DislocationCreep(; args...)
end
49 changes: 45 additions & 4 deletions src/CreepLaw/GrainBoundarySliding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,37 @@ export SetGrainBoundarySliding
SetGrainBoundarySliding["Name of GBS"]
This is a dictionary with pre-defined creep laws
"""
function SetGrainBoundarySliding(name::F) where F
return Transform_GrainBoundarySliding(name)
function SetGrainBoundarySliding(
name::F;
n = nothing,
p = nothing,
A = nothing,
E = nothing,
V = nothing,
) where F
kwargs = (; n, p, A, E, V)
Transform_GrainBoundarySliding(name, kwargs)
end

function SetGrainBoundarySliding(name::F, CharDim::GeoUnits{T}) where {F, T<:Union{GEO, SI}}
nondimensionalize(Transform_GrainBoundarySliding(name), CharDim)
function SetGrainBoundarySliding(
name::F,
CharDim::GeoUnits{T};
n = nothing,
p = nothing,
A = nothing,
E = nothing,
V = nothing,
) where {F, T<:Union{GEO, SI}}
kwargs = (; n, p, A, E, V)
nondimensionalize(Transform_GrainBoundarySliding(name, kwargs), CharDim)
end

"""
Transform_GrainBoundarySliding(name)
Transforms units from MPa, kJ etc. to basic units such as Pa, J etc.
"""
Transform_GrainBoundarySliding(name::F) where F = Transform_GrainBoundarySliding(GrainBoundarySliding_database(name))
Transform_GrainBoundarySliding(name::F, kwargs::NamedTuple) where F = Transform_GrainBoundarySliding(GrainBoundarySliding_database(name), kwargs)

function Transform_GrainBoundarySliding(name::F, CharDim::GeoUnits{U}) where {U<:Union{GEO,SI}} where F
Transform_GrainBoundarySliding(GrainBoundarySliding_database(name), CharDim)
Expand All @@ -354,5 +372,28 @@ function Transform_GrainBoundarySliding(pp::AbstractCreepLaw{T}) where T
Apparatus = pp.Apparatus
args = (Name=pp.Name, n=n, p=p, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)

return GrainBoundarySliding(; args...)
end

function Transform_GrainBoundarySliding(pp::AbstractCreepLaw, kwargs::NamedTuple)
@inline f1(A::T) where T = typeof(A).parameters[2].parameters[1][2].power
@inline f2(A::T) where T = typeof(A).parameters[2].parameters[1][1].power

(; n, p, A, E, V) = kwargs

n_new = isnothing(n) ? Value(pp.n) : Value(GeoUnit(n))
p_new = isnothing(p) ? Value(pp.p) : Value(GeoUnit(p))
A_new = isnothing(A) ? pp.A : GeoUnit(A)
E_new = isnothing(E) ? Value(pp.E) : Value(GeoUnit(E))
V_new = isnothing(E) ? Value(pp.V) : Value(GeoUnit(V))

power_Pa = f1(A_new)
power_m = f2(A_new)
A_Pa = uconvert(Pa^(power_Pa) * m^(power_m) / s, Value(A_new))
E_J = uconvert(J / mol, E_new)
V_m3 = uconvert(m^3 / mol, V_new)
Apparatus = pp.Apparatus
args = (Name=pp.Name, n=n_new, p=p_new, A=A_Pa, E=E_J, V=V_m3, Apparatus=Apparatus)

return GrainBoundarySliding(; args...)
end
Loading

0 comments on commit 6581b53

Please sign in to comment.