Skip to content

Commit

Permalink
WENO 5 advection scheme (#65)
Browse files Browse the repository at this point in the history
* interpolate velocities from P nodes

* weno5 advection scheme

* Weno5 convection miniapp

* add comment referring to Hugo's paper

* improve comment

* remove dead function from script

* format

* add MuladdMacro and Adapt
  • Loading branch information
albert-de-montserrat authored Nov 1, 2023
1 parent da45d76 commit 11899b5
Show file tree
Hide file tree
Showing 6 changed files with 846 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ version = "0.1.0"

[deps]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CellArrays = "d35fcfd7-7af4-4c67-b1aa-d78070614af4"
GeoParams = "e018b62d-d9de-4a26-8697-af89c310ae38"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
ImplicitGlobalGrid = "4d7a3746-15be-11ea-1130-334b0c4f5fa0"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
ParallelStencil = "94395366-693c-11ea-3b26-d9b7aac5d958"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down
160 changes: 160 additions & 0 deletions miniapps/convection/WENO5/Layered_rheology.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# from "Fingerprinting secondary mantle plumes", Cloetingh et al. 2022

function init_rheologies(; is_plastic = true)

# Dislocation and Diffusion creep
disl_upper_crust = DislocationCreep(A=5.07e-18, n=2.3, E=154e3, V=6e-6, r=0.0, R=8.3145)
disl_lower_crust = DislocationCreep(A=2.08e-23, n=3.2, E=238e3, V=6e-6, r=0.0, R=8.3145)
disl_lithospheric_mantle = DislocationCreep(A=2.51e-17, n=3.5, E=530e3, V=6e-6, r=0.0, R=8.3145)
disl_sublithospheric_mantle = DislocationCreep(A=2.51e-17, n=3.5, E=530e3, V=6e-6, r=0.0, R=8.3145)
diff_lithospheric_mantle = DislocationCreep(A=2.51e-17, n=1.0, E=530e3, V=6e-6, r=0.0, R=8.3145)
diff_sublithospheric_mantle = DislocationCreep(A=2.51e-17, n=1.0, E=530e3, V=6e-6, r=0.0, R=8.3145)

# Elasticity
el_upper_crust = SetConstantElasticity(; G=25e9, ν=0.5)
el_lower_crust = SetConstantElasticity(; G=25e9, ν=0.5)
el_lithospheric_mantle = SetConstantElasticity(; G=67e9, ν=0.5)
el_sublithospheric_mantle = SetConstantElasticity(; G=67e9, ν=0.5)
β_upper_crust = inv(get_Kb(el_upper_crust))
β_lower_crust = inv(get_Kb(el_lower_crust))
β_lithospheric_mantle = inv(get_Kb(el_lithospheric_mantle))
β_sublithospheric_mantle = inv(get_Kb(el_sublithospheric_mantle))

# Physical properties using GeoParams ----------------
η_reg = 1e16
cohesion = 3e6
friction = asind(0.2)
pl_crust = if is_plastic
DruckerPrager_regularised(; C = cohesion, ϕ=friction, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity
else
DruckerPrager_regularised(; C = Inf, ϕ=friction, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity
end
friction = asind(0.3)
pl = if is_plastic
DruckerPrager_regularised(; C = cohesion, ϕ=friction, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity
else
DruckerPrager_regularised(; C = Inf, ϕ=friction, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity
end
pl_wz = if is_plastic
DruckerPrager_regularised(; C = 2e6, ϕ=2.0, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity
else
DruckerPrager_regularised(; C = Inf, ϕ=friction, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity
end

# crust
K_crust = TP_Conductivity(;
a = 0.64,
b = 807e0,
c = 0.77,
d = 0.00004*1e-6,
)

K_mantle = TP_Conductivity(;
a = 0.73,
b = 1293e0,
c = 0.77,
d = 0.00004*1e-6,
)

# Define rheolgy struct
rheology = (
# Name = "UpperCrust",
SetMaterialParams(;
Phase = 1,
Density = PT_Density(; ρ0=2.75e3, β=β_upper_crust, T0=0.0, α = 3.5e-5),
HeatCapacity = ConstantHeatCapacity(; cp=7.5e2),
Conductivity = K_crust,
CompositeRheology = CompositeRheology((disl_upper_crust, el_upper_crust, pl_crust)),
Elasticity = el_upper_crust,
RadioactiveHeat = ConstantRadioactiveHeat(0.0),
Gravity = ConstantGravity(; g=9.81),
),
# Name = "LowerCrust",
SetMaterialParams(;
Phase = 2,
Density = PT_Density(; ρ0=3e3, β=β_lower_crust, T0=0.0, α = 3.5e-5),
HeatCapacity = ConstantHeatCapacity(; cp=7.5e2),
Conductivity = K_crust,
RadioactiveHeat = ConstantRadioactiveHeat(0.0),
CompositeRheology = CompositeRheology((disl_lower_crust, el_lower_crust, pl_crust)),
Elasticity = el_lower_crust,
),
# Name = "LithosphericMantle",
SetMaterialParams(;
Phase = 3,
Density = PT_Density(; ρ0=3.3e3, β=β_lithospheric_mantle, T0=0.0, α = 3e-5),
HeatCapacity = ConstantHeatCapacity(; cp=1.25e3),
Conductivity = K_mantle,
RadioactiveHeat = ConstantRadioactiveHeat(0.0),
CompositeRheology = CompositeRheology((disl_lithospheric_mantle, diff_lithospheric_mantle, el_lithospheric_mantle, pl)),
Elasticity = el_lithospheric_mantle,
),
# Name = "SubLithosphericMantle",
# SetMaterialParams(;
# Phase = 4,
# Density = PT_Density(; ρ0=3.3e3, β=β_sublithospheric_mantle, T0=0.0, α = 3e-5),
# HeatCapacity = ConstantHeatCapacity(; cp=1.25e3),
# Conductivity = K_mantle,
# RadioactiveHeat = ConstantRadioactiveHeat(0.0),
# CompositeRheology = CompositeRheology((disl_sublithospheric_mantle, diff_sublithospheric_mantle, el_sublithospheric_mantle)),
# Elasticity = el_sublithospheric_mantle,
# ),
# Name = "Plume",
SetMaterialParams(;
Phase = 4,
Density = PT_Density(; ρ0=3.3e3-50, β=β_sublithospheric_mantle, T0=0.0, α = 3e-5),
HeatCapacity = ConstantHeatCapacity(; cp=1.25e3),
Conductivity = K_mantle,
RadioactiveHeat = ConstantRadioactiveHeat(0.0),
CompositeRheology = CompositeRheology((disl_sublithospheric_mantle, diff_sublithospheric_mantle, el_sublithospheric_mantle)),
Elasticity = el_sublithospheric_mantle,
),
# Name = "StickyAir",
SetMaterialParams(;
Phase = 5,
Density = ConstantDensity(; ρ=1e3),
HeatCapacity = ConstantHeatCapacity(; cp=1.25e3),
RadioactiveHeat = ConstantRadioactiveHeat(0.0),
Conductivity = ConstantConductivity(; k=15.0),
CompositeRheology = CompositeRheology((LinearViscous(; η=1e21),)),
),
)
end

function init_phases!(phases, particles, Lx; d=650e3, r=50e3)
ni = size(phases)

@parallel_indices (i, j) function init_phases!(phases, px, py, index, r, Lx)
@inbounds for ip in JustRelax.cellaxes(phases)
# quick escape
JustRelax.@cell(index[ip, i, j]) == 0 && continue

x = JustRelax.@cell px[ip, i, j]
depth = -(JustRelax.@cell py[ip, i, j])
if 0e0 depth 21e3
@cell phases[ip, i, j] = 1.0

elseif 35e3 depth > 21e3
@cell phases[ip, i, j] = 2.0

elseif 90e3 depth > 35e3
@cell phases[ip, i, j] = 3.0

elseif depth > 90e3
@cell phases[ip, i, j] = 3.0

elseif depth < 0e0
@cell phases[ip, i, j] = 5.0

end

# plume - rectangular
if ((x - Lx * 0.5)^2 r^2) && ((depth - d)^2 r^2)
JustRelax.@cell phases[ip, i, j] = 4.0
end
end
return nothing
end

@parallel (JustRelax.@idx ni) init_phases!(phases, particles.coords..., particles.index, r, Lx)
end
Loading

0 comments on commit 11899b5

Please sign in to comment.