From aaecf8012b2edceecea1b2154b0ddd7af9303d86 Mon Sep 17 00:00:00 2001 From: Albert de Montserrat Date: Wed, 27 Mar 2024 11:03:41 +0100 Subject: [PATCH] finish nondim-ing the miniapp --- .../Layered_convection2D.jl | 75 ++++++++++++++----- .../Particles2D_nonDim/Layered_rheology.jl | 56 ++++++++------ 2 files changed, 90 insertions(+), 41 deletions(-) diff --git a/miniapps/convection/Particles2D_nonDim/Layered_convection2D.jl b/miniapps/convection/Particles2D_nonDim/Layered_convection2D.jl index 36341292..1f8313cf 100644 --- a/miniapps/convection/Particles2D_nonDim/Layered_convection2D.jl +++ b/miniapps/convection/Particles2D_nonDim/Layered_convection2D.jl @@ -51,21 +51,21 @@ end if depth < nondimensionalize(0e0km, CharDim) T[i + 1, j] = nondimensionalize(273e0K, CharDim) - elseif nondimensionalize(0e0km, CharDim) ≤ (depth) < nondimensionalize(35e3km, CharDim) - dTdZ = nondimensionalize((923-273)/35e3 * K/km, CharDim) + elseif nondimensionalize(0e0km, CharDim) ≤ (depth) < nondimensionalize(35km, CharDim) + dTdZ = nondimensionalize((923-273)/35 * K/km, CharDim) offset = nondimensionalize(273e0K, CharDim) T[i + 1, j] = (depth) * dTdZ + offset - elseif nondimensionalize(110e3km, CharDim) > (depth) ≥ nondimensionalize(35e3km, CharDim) - dTdZ = nondimensionalize((1492-923)/75e3 * K/km, CharDim) + elseif nondimensionalize(110km, CharDim) > (depth) ≥ nondimensionalize(35km, CharDim) + dTdZ = nondimensionalize((1492-923)/75 * K/km, CharDim) offset = nondimensionalize(923K, CharDim) - T[i + 1, j] = (depth - nondimensionalize(35e3km, CharDim)) * dTdZ + offset + T[i + 1, j] = (depth - nondimensionalize(35km, CharDim)) * dTdZ + offset - elseif (depth) ≥ nondimensionalize(110e3km, CharDim) - dTdZ = nondimensionalize((1837 - 1492)/590e3 * K/km, CharDim) + elseif (depth) ≥ nondimensionalize(110km, CharDim) + dTdZ = nondimensionalize((1837 - 1492)/590 * K/km, CharDim) offset = nondimensionalize(1492e0K, CharDim) - T[i + 1, j] = (depth - nondimensionalize(110e3km, CharDim)) * dTdZ + offset + T[i + 1, j] = (depth - nondimensionalize(110km, CharDim)) * dTdZ + offset end @@ -78,9 +78,9 @@ function rectangular_perturbation!(T, xc, yc, r, xvi, thick_air, CharDim) @parallel_indices (i, j) function _rectangular_perturbation!(T, xc, yc, r, CharDim, x, y) @inbounds if ((x[i]-xc)^2 ≤ r^2) && ((y[j] - yc - thick_air)^2 ≤ r^2) depth = -y[j] - thick_air - dTdZ = nondimensionalize((2047 - 2017)K / 50e3km, CharDim) + dTdZ = nondimensionalize((2047 - 2017)K / 50km, CharDim) offset = nondimensionalize(2017e0K, CharDim) - T[i + 1, j] = (depth - nondimensionalize(585e3km, CharDim)) * dTdZ + offset + T[i + 1, j] = (depth - nondimensionalize(585km, CharDim)) * dTdZ + offset end return nothing end @@ -96,10 +96,11 @@ end ## BEGIN OF MAIN SCRIPT -------------------------------------------------------------- function main2D(igg; ar=8, ny=16, nx=ny*8, figdir="figs2D", do_vtk =false) - thickness = 700e3 * km - η0 = 1e20 * Pa * s - CharDim = GEO_units(; length = thickness, viscosity = η0) - + thickness = 700 * km + η0 = 1e21 + CharDim = GEO_units(; + length = thickness, viscosity = η0, temperature = 1e3K + ) # Physical domain ------------------------------------ thick_air = nondimensionalize(0e0km, CharDim) # thickness of sticky air layer ly = nondimensionalize(thickness, CharDim) + thick_air # domain length in y @@ -132,8 +133,8 @@ function main2D(igg; ar=8, ny=16, nx=ny*8, figdir="figs2D", do_vtk =false) # Elliptical temperature anomaly xc_anomaly = lx/2 # origin of thermal anomaly - yc_anomaly = nondimensionalize(-610e3km, CharDim) # origin of thermal anomaly - r_anomaly = nondimensionalize(25e3km, CharDim) # radius of perturbation + yc_anomaly = nondimensionalize(-610km, CharDim) # origin of thermal anomaly + r_anomaly = nondimensionalize(25km, CharDim) # radius of perturbation init_phases!(pPhases, particles, lx, yc_anomaly, r_anomaly, thick_air, CharDim) phase_ratios = PhaseRatio(ni, length(rheology)) @parallel (@idx ni) phase_ratios_center(phase_ratios.center, pPhases) @@ -191,7 +192,7 @@ function main2D(igg; ar=8, ny=16, nx=ny*8, figdir="figs2D", do_vtk =false) # IO ------------------------------------------------ # if it does not exist, make folder where figures are stored if do_vtk - vtk_dir = figdir*"\\vtk" + vtk_dir = joinpath(figdir, "vtk") take(vtk_dir) end take(figdir) @@ -395,4 +396,42 @@ end # run main script -# main2D(igg; figdir = figdir, ar = ar, nx = nx, ny = ny, do_vtk = do_vtk); \ No newline at end of file +# main2D(igg; figdir = figdir, ar = ar, nx = nx, ny = ny, do_vtk = do_vtk); + + +# @parallel_indices (I...) function compute_viscosity!( +# η, ν, ratios_center, εxx, εyy, εxyv, args, rheology, cutoff +# ) + +I=5,5 +εxx, εyy, εxyv = stokes.ε.xx, stokes.ε.yy,stokes.ε.xy + # convenience closure + @inline gather(A) = _gather(A, I...) + + # @inbounds begin + # cache + ε = εxx[I...], εyy[I...] + + # we need strain rate not to be zero, otherwise we get NaNs + εII_0 = all(ε.==0) * eps() + + # argument fields at local index + args_ij = JustRelax.local_viscosity_args(args, I...) + + # local phase ratio + ratio_ij = ratios_center[I...] + + # compute second invariant of strain rate tensor + εij = εII_0 + ε[1], -εII_0 + ε[1], gather(εxyv) + εII = second_invariant(εij...) + + # compute and update stress viscosity + ηi = JustRelax.compute_phase_viscosity_εII(rheology, ratio_ij, εII, args_ij) + ηi = continuation_log(ηi, η[I...], ν) + η[I...] = clamp(ηi, cutoff...) + # end + +# return nothing +# end + +compute_viscosity_εII(rheology[1], εII, (; P=7400, T=0.2)) diff --git a/miniapps/convection/Particles2D_nonDim/Layered_rheology.jl b/miniapps/convection/Particles2D_nonDim/Layered_rheology.jl index 527fe95f..7bda50fb 100644 --- a/miniapps/convection/Particles2D_nonDim/Layered_rheology.jl +++ b/miniapps/convection/Particles2D_nonDim/Layered_rheology.jl @@ -5,52 +5,52 @@ function init_rheologies(CharDim; is_plastic = true) # Dislocation and Diffusion creep disl_upper_crust = DislocationCreep( A=5.07e-18Pa^(-23//10) / s, # units are Pa^(-n) / s - n=2.3, + n=2.3NoUnits, E=154e3J/mol, V=6e-6m^3/mol, - r=0.0, + r=0.0NoUnits, R=8.3145J/mol/K ) disl_lower_crust = DislocationCreep( A=2.08e-23Pa^(-32//10) / s, # units are Pa^(-n) / s - n=3.2, + n=3.2NoUnits, E=238e3J/mol, V=6e-6m^3/mol, - r=0.0, - R=8.3145J/mol/K + r=0.0NoUnits, + R=8.3145J/mol/K, ) disl_lithospheric_mantle = DislocationCreep( A=2.51e-17Pa^(-35//10) / s, # units are Pa^(-n) / s - n=3.5, + n=3.5NoUnits, E=530e3J/mol, V=6e-6m^3/mol, - r=0.0, + r=0.0NoUnits, R=8.3145J/mol/K ) disl_sublithospheric_mantle = DislocationCreep( A=2.51e-17Pa^(-35//10) / s, # units are Pa^(-n) / s - n=3.5, + n=3.5NoUnits, E=530e3J/mol, V=6e-6m^3/mol, - r=0.0, + r=0.0NoUnits, R=8.3145J/mol/K ) diff_lithospheric_mantle = DiffusionCreep( - A=2.51e-17Pa^(-1 - 0) / s * m^(-0), # units are Pa^(-n - r) / s * m^(-p) - n=1.0, + A=2.51e-17Pa^(-1) / s, # units are Pa^(-n - r) / s * m^(-p) + n=1.0NoUnits, E=530e3J/mol, V=6e-6m^3/mol, - r=0.0, - p=0.0, + r=0.0NoUnits, + p=0.0NoUnits, R=8.3145J/mol/K ) diff_sublithospheric_mantle = DiffusionCreep( - A=2.51e-17Pa^(-1 - 0) / s * m^(-0), # units are Pa^(-n - r) / s * m^(-p) - n=1.0, + A=2.51e-17Pa^(-1) / s, # units are Pa^(-n - r) / s * m^(-p) + n=1.0NoUnits, E=530e3J/mol, V=6e-6m^3/mol, - r=0.0, - p=0.0, + r=0.0NoUnits, + p=0.0NoUnits, R=8.3145J/mol/K ) @@ -80,7 +80,7 @@ function init_rheologies(CharDim; is_plastic = true) 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 + DruckerPrager_regularised(; C = 2e6Pa, ϕ=2.0, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity else DruckerPrager_regularised(; C = Inf, ϕ=friction, η_vp=η_reg, Ψ=0.0) # non-regularized plasticity end @@ -100,49 +100,58 @@ function init_rheologies(CharDim; is_plastic = true) d = 0.00004*1e-6, ) + g = -9.81m/s^2 + # Define rheolgy struct rheology = ( # Name = "UpperCrust", SetMaterialParams(; Phase = 1, - Density = PT_Density(; ρ0=2.75e3kg / m^3, β=β_upper_crust, T0=273K, α = 3.5e-5/ K), + Density = PT_Density(; ρ0=2.75e3kg / m^3, β=β_upper_crust, T0=0e0C, α = 3.5e-5/ K), HeatCapacity = ConstantHeatCapacity(; Cp=7.5e2J / kg / K), Conductivity = K_crust, + # CompositeRheology = CompositeRheology((LinearViscous(; η=1e22Pa*s),)), CompositeRheology = CompositeRheology((disl_upper_crust, el_upper_crust, pl_crust)), Elasticity = el_upper_crust, RadioactiveHeat = ConstantRadioactiveHeat(0.0), - Gravity = ConstantGravity(; g=9.81m/s^2), + Gravity = ConstantGravity(; g=g), CharDim = CharDim, ), # Name = "LowerCrust", SetMaterialParams(; Phase = 2, - Density = PT_Density(; ρ0=3e3kg / m^3, β=β_upper_crust, T0=273K, α = 3.5e-5/ K), + Density = PT_Density(; ρ0=3e3kg / m^3, β=β_upper_crust, T0=0e0C, α = 3.5e-5/ K), HeatCapacity = ConstantHeatCapacity(; Cp=7.5e2J / kg / K), Conductivity = K_crust, RadioactiveHeat = ConstantRadioactiveHeat(0.0), + # CompositeRheology = CompositeRheology((LinearViscous(; η=5e21Pa*s),)), CompositeRheology = CompositeRheology((disl_lower_crust, el_lower_crust, pl_crust)), + Gravity = ConstantGravity(; g=g), Elasticity = el_lower_crust, CharDim = CharDim, ), # Name = "LithosphericMantle", SetMaterialParams(; Phase = 3, - Density = PT_Density(; ρ0=3.3e3kg / m^3, β=β_upper_crust, T0=273K, α = 3.5e-5/ K), + Density = PT_Density(; ρ0=3.3e3kg / m^3, β=β_upper_crust, T0=0e0C, α = 3.5e-5/ K), HeatCapacity = ConstantHeatCapacity(; Cp=1.25e3J / kg / K), Conductivity = K_mantle, RadioactiveHeat = ConstantRadioactiveHeat(0.0), + # CompositeRheology = CompositeRheology((LinearViscous(; η=1e19Pa*s),)), CompositeRheology = CompositeRheology((disl_lithospheric_mantle, diff_lithospheric_mantle, el_lithospheric_mantle, pl)), + Gravity = ConstantGravity(; g=g), Elasticity = el_lithospheric_mantle, CharDim = CharDim, ), SetMaterialParams(; Phase = 4, - Density = PT_Density(; ρ0=(3.3e3-50)kg / m^3, β=β_upper_crust, T0=273K, α = 3.5e-5/ K), + Density = PT_Density(; ρ0=(3.3e3-50)kg / m^3, β=β_upper_crust, T0=0e0C, α = 3.5e-5/ K), HeatCapacity = ConstantHeatCapacity(; Cp=1.25e3J / kg / K), Conductivity = K_mantle, RadioactiveHeat = ConstantRadioactiveHeat(0.0), + # CompositeRheology = CompositeRheology((LinearViscous(; η=1e19Pa*s),)), CompositeRheology = CompositeRheology((disl_sublithospheric_mantle, diff_sublithospheric_mantle, el_sublithospheric_mantle)), + Gravity = ConstantGravity(; g=g), Elasticity = el_sublithospheric_mantle, CharDim = CharDim, ), @@ -153,6 +162,7 @@ function init_rheologies(CharDim; is_plastic = true) HeatCapacity = ConstantHeatCapacity(; Cp=3e3J / kg / K), RadioactiveHeat = ConstantRadioactiveHeat(0.0), Conductivity = ConstantConductivity(; k=1.0Watt / m / K), + Gravity = ConstantGravity(; g=g), CompositeRheology = CompositeRheology((LinearViscous(; η=1e19Pa*s),)), CharDim = CharDim, ),