Thermal
Heat-diffusion state, the pseudo-transient solver, shear heating, WENO5 advection, and the subgrid diffusion time scale.
JustRelax.JustRelax2D.ThermalArrays Method
ThermalArrays(nx::Integer, ny::Integer, nz::Integer)3D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx, ny and nz.
Fields
T: Temperature at cell centers with one ghost node on every boundary(nx + 2, ny + 2, nz + 2)Told: Temperature at previous time step at cell centers with ghost nodes(nx + 2, ny + 2, nz + 2)ΔT: Temperature change at cell centers with ghost nodes(nx + 2, ny + 2, nz + 2)adiabatic: Adiabatic term α (u ⋅ ∇P) at cell centers(nx, ny, nz)dT_dt: Time derivative of temperature at cell centers(nx, ny, nz)qTx: Conductive heat flux in x direction on cell faces(nx + 1, ny, nz)qTy: Conductive heat flux in y direction on cell faces(nx, ny + 1, nz)qTz: Conductive heat flux in z direction on cell faces(nx, ny, nz + 1)qTx2: Conductive heat flux in x direction on cell faces for second order scheme(nx + 1, ny, nz)qTy2: Conductive heat flux in y direction on cell faces for second order scheme(nx, ny + 1, nz)qTz2: Conductive heat flux in z direction on cell faces for second order scheme(nx, ny, nz + 1)H: Source terms at cell centers(nx, ny, nz)shear_heating: Shear heating terms at cell centers(nx, ny, nz)ResT: Residual of the temperature equation at cell centers(nx, ny, nz)
JustRelax.JustRelax2D.ThermalArrays Method
ThermalArrays(nx::Integer, ny::Integer)2D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx and ny.
Fields
T: Temperature at cell centers with one ghost node on every boundary(nx + 2, ny + 2)Told: Temperature at previous time step at cell centers with ghost nodes(nx + 2, ny + 2)ΔT: Temperature change at cell centers with ghost nodes(nx + 2, ny + 2)adiabatic: Adiabatic term α (u ⋅ ∇P) at cell centers(nx, ny)dT_dt: Time derivative of temperature at cell centers(nx, ny)qTx: Conductive heat flux in x direction on cell faces(nx + 1, ny)qTy: Conductive heat flux in y direction on cell faces(nx, ny + 1)qTx2: Conductive heat flux in x direction on cell faces for second order scheme(nx + 1, ny)qTy2: Conductive heat flux in y direction on cell faces for second order scheme(nx, ny + 1)H: Source terms at cell centers(nx, ny)shear_heating: Shear heating terms at cell centers(nx, ny)ResT: Residual of the temperature equation at cell centers(nx, ny)
JustRelax.JustRelax2D.ThermalArrays Method
ThermalArrays(ni::NTuple{N, Integer}) where {N}Create the thermal arrays for the heat diffusion solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).
JustRelax.JustRelax2D.ThermalArrays Method
ThermalArrays(::Backend, ni::NTuple{N, Integer}) where {N}Internal entry point function for the ThermalArrays constructor. This allows for dispatching on the backend type and then calling the main constructor with the dimensions.
sourceJustRelax.JustRelax2D.compute_α Method
compute_α(rheology, phase)Return the thermal expansivity α used by the adiabatic heating kernels.
phase can be a single phase index, nothing, or a phase-ratio vector. In the latter case the result is phase-weighted.
JustRelax.JustRelax2D.update_pt_thermal_arrays! Method
update_pt_thermal_arrays!(pt_thermal, phase_ratios, rheology, args, _dt)Recompute the pseudo-transient thermal coefficient arrays stored in pt_thermal from phase-weighted material properties.
This helper is used by the pseudo-transient thermal solver when the local phase mixture changes over time.
sourceJustRelax.JustRelax2D.adiabatic_heating! Method
adiabatic_heating!(thermal, stokes, rheology, phases, _dt, grid)Fill thermal.adiabatic with the adiabatic heating term inferred from the pressure change between stokes.P0 and stokes.P.
The kernels average the local thermal expansivity over the temperature nodes and scale the pressure increment by inv(dt), passed here as _dt. When stokes is nothing, the no-op overloads leave the field unchanged.
JustRelax.JustRelax2D.update_T Method
update_T(::Nothing, b_width, thermal, ρCp, pt_thermal, dirichlet, _dt, _di, ni)
update_T(::Nothing, b_width, thermal, rheology, phase, pt_thermal, dirichlet, _dt, _di, ni, args)Launch the pseudo-transient temperature update kernel over the active thermal domain.
These wrappers select the appropriate kernel overload depending on whether the solver works with precomputed ρCp fields or rheology-derived properties.
JustRelax.JustRelax2D.PTThermalCoeffs Method
PTThermalCoeffs(rheology, phase_ratios, args, dt, ni, di, li; ϵ = 1.0e-8, CFL = 0.9 / √3)Construct pseudo-transient thermal coefficients from a multi-phase rheology.
The coefficient arrays are evaluated on the thermal grid of size ni using the phase ratios in phase_ratios.center together with the thermodynamic state stored in args.
JustRelax.JustRelax2D.PTThermalCoeffs Method
PTThermalCoeffs(K, ρCp, dt, di, li; ϵ = 1.0e-8, CFL = 0.9 / √3)Construct pseudo-transient thermal coefficients from conductivity and volumetric heat-capacity arrays.
di and li are the grid spacing and domain-length tuples used to estimate the local pseudo-time step and relaxation factor stored in the returned JustRelax.PTThermalCoeffs.
JustRelax.JustRelax2D.PTThermalCoeffs Method
PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ = 1.0e-8, CFL = 0.9 / √3)Construct pseudo-transient thermal coefficients from a single rheology state.
This method evaluates conductivity and ρCp from rheology and the cellwise fields in args, then stores the resulting relaxation arrays in a JustRelax.PTThermalCoeffs object.
JustRelax.JustRelax2D.update_thermal_coeffs! Method
update_thermal_coeffs!(pt_thermal, rheology, phase_ratios, args, dt)
update_thermal_coeffs!(pt_thermal, rheology, args, dt)Refresh the pseudo-transient coefficient arrays stored in pt_thermal.
Use this when conductivity or volumetric heat capacity changes during the solve, for example because temperature, pressure, or phase ratios evolve. The update is performed in place on pt_thermal.θr_dτ and pt_thermal.dτ_ρ.
JustRelax.JustRelax2D.compute_shear_heating! Method
compute_shear_heating!(thermal, stokes, rheology, dt)Populate thermal.shear_heating from the current deviatoric stress and strain-rate fields stored in stokes.
The kernel evaluates the elastic strain-rate contribution from stokes.τ, stokes.τ_o, the shear modulus in rheology, and the pseudo-time step dt. The resulting volumetric heating term is written in place on thermal cell centers.
When phase ratios are passed as an extra positional argument, phase-weighted material properties are used instead of a single rheology state.
sourceJustRelax.JustRelax2D._heatdiffusion_PT! Method
_heatdiffusion_PT!(thermal, pt_thermal, thermal_bc, K, ρCp, dt, grid;
igg, b_width, iterMax, nout, verbose)Solve the heat equation with pseudo-transient iterations using precomputed, cell-centered material properties.
K is the thermal conductivity field and ρCp is the volumetric heat-capacity field on the thermal grid. pt_thermal supplies the pseudo-transient coefficients, thermal_bc applies the temperature boundary conditions after each update, and grid provides metric terms and halo layout.
Returns a named tuple containing the iteration numbers and residual norms sampled every nout iterations.
JustRelax.JustRelax2D._heatdiffusion_PT! Method
_heatdiffusion_PT!(thermal, pt_thermal, thermal_bc, rheology, args, dt, grid;
igg, phase, stokes, b_width, iterMax, nout, verbose)Solve the heat equation with pseudo-transient iterations using thermal properties derived from rheology.
args is a named tuple of thermodynamic fields, typically including T and P. Entries sized like the thermal cell centers are read as-is; larger entries are offset by one to skip their ghost nodes. When phase is provided, pseudo-transient coefficients are recomputed from the local phase ratios each iteration. When stokes is provided, thermal.adiabatic is refreshed before the iteration loop to include the adiabatic heating contribution.
Returns a named tuple containing the sampled iteration counts and residual history.
sourceJustRelax.JustRelax2D.heatdiffusion_PT! Method
heatdiffusion_PT!(thermal, args...; kwargs...)Dispatch pseudo-transient thermal diffusion to the backend associated with thermal.
See the _heatdiffusion_PT! methods below for the supported argument groups: constant K and ρCp fields, or rheology-driven properties with optional phase ratios and Stokes fields for adiabatic heating.
JustRelax.JustRelax2D.WENO5 Method
WENO5(backend, method::Val, ni::NTuple)
WENO5(method::Val, ni::NTuple)Allocate a WENO5 advection scheme state for a grid of size ni. method selects the smoothness-indicator variant: Val(1) for Jiang-Shu, Val(2) for the Z-variant.
JustRelax.JustRelax2D.WENO_advection! Method
WENO_advection!(u, Vxi, weno, di, ni, dt)Perform the advection step of the Weighted Essentially Non-Oscillatory (WENO) scheme for the solution of hyperbolic partial differential equations.
Arguments
u: field to be advected.Vxi: velocity field.weno: structure containing the WENO scheme parameters and temporary variables.di: grid spacing.ni: number of grid points.dt: time step.
Description
The function approximates the advected fluxes using the WENO scheme and use a strong-stability preserving (SSP) Runge-Kutta method of order 3 for the time integration.
sourceJustRelax.JustRelax2D.subgrid_characteristic_time! Method
subgrid_characteristic_time!(subgrid_arrays, particles, dt₀, phases, rheology, thermal::ThermalArrays, stokes::StokesArrays[, di])Compute, per cell, the characteristic thermal diffusion timescale dt₀ = ρCp / (2 K Σ dxi⁻²) used for JustPIC's subgrid-diffusion correction of particle temperature, evaluating rheology's density/heat-capacity/conductivity at the local phase (from phases, either a JustPIC.PhaseRatios or an integer phase-id array) and temperature/pressure.
JustRelax.JustRelax3D.ThermalArrays Method
ThermalArrays(nx::Integer, ny::Integer, nz::Integer)3D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx, ny and nz.
Fields
T: Temperature at cell centers with one ghost node on every boundary(nx + 2, ny + 2, nz + 2)Told: Temperature at previous time step at cell centers with ghost nodes(nx + 2, ny + 2, nz + 2)ΔT: Temperature change at cell centers with ghost nodes(nx + 2, ny + 2, nz + 2)adiabatic: Adiabatic term α (u ⋅ ∇P) at cell centers(nx, ny, nz)dT_dt: Time derivative of temperature at cell centers(nx, ny, nz)qTx: Conductive heat flux in x direction on cell faces(nx + 1, ny, nz)qTy: Conductive heat flux in y direction on cell faces(nx, ny + 1, nz)qTz: Conductive heat flux in z direction on cell faces(nx, ny, nz + 1)qTx2: Conductive heat flux in x direction on cell faces for second order scheme(nx + 1, ny, nz)qTy2: Conductive heat flux in y direction on cell faces for second order scheme(nx, ny + 1, nz)qTz2: Conductive heat flux in z direction on cell faces for second order scheme(nx, ny, nz + 1)H: Source terms at cell centers(nx, ny, nz)shear_heating: Shear heating terms at cell centers(nx, ny, nz)ResT: Residual of the temperature equation at cell centers(nx, ny, nz)
JustRelax.JustRelax3D.ThermalArrays Method
ThermalArrays(nx::Integer, ny::Integer)2D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx and ny.
Fields
T: Temperature at cell centers with one ghost node on every boundary(nx + 2, ny + 2)Told: Temperature at previous time step at cell centers with ghost nodes(nx + 2, ny + 2)ΔT: Temperature change at cell centers with ghost nodes(nx + 2, ny + 2)adiabatic: Adiabatic term α (u ⋅ ∇P) at cell centers(nx, ny)dT_dt: Time derivative of temperature at cell centers(nx, ny)qTx: Conductive heat flux in x direction on cell faces(nx + 1, ny)qTy: Conductive heat flux in y direction on cell faces(nx, ny + 1)qTx2: Conductive heat flux in x direction on cell faces for second order scheme(nx + 1, ny)qTy2: Conductive heat flux in y direction on cell faces for second order scheme(nx, ny + 1)H: Source terms at cell centers(nx, ny)shear_heating: Shear heating terms at cell centers(nx, ny)ResT: Residual of the temperature equation at cell centers(nx, ny)
JustRelax.JustRelax3D.ThermalArrays Method
ThermalArrays(ni::NTuple{N, Integer}) where {N}Create the thermal arrays for the heat diffusion solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).
JustRelax.JustRelax3D.ThermalArrays Method
ThermalArrays(::Backend, ni::NTuple{N, Integer}) where {N}Internal entry point function for the ThermalArrays constructor. This allows for dispatching on the backend type and then calling the main constructor with the dimensions.
sourceJustRelax.JustRelax3D.compute_α Method
compute_α(rheology, phase)Return the thermal expansivity α used by the adiabatic heating kernels.
phase can be a single phase index, nothing, or a phase-ratio vector. In the latter case the result is phase-weighted.
JustRelax.JustRelax3D.update_pt_thermal_arrays! Method
update_pt_thermal_arrays!(pt_thermal, phase_ratios, rheology, args, _dt)Recompute the pseudo-transient thermal coefficient arrays stored in pt_thermal from phase-weighted material properties.
This helper is used by the pseudo-transient thermal solver when the local phase mixture changes over time.
sourceJustRelax.JustRelax3D.adiabatic_heating! Method
adiabatic_heating!(thermal, stokes, rheology, phases, _dt, grid)Fill thermal.adiabatic with the adiabatic heating term inferred from the pressure change between stokes.P0 and stokes.P.
The kernels average the local thermal expansivity over the temperature nodes and scale the pressure increment by inv(dt), passed here as _dt. When stokes is nothing, the no-op overloads leave the field unchanged.
JustRelax.JustRelax3D.update_T Method
update_T(::Nothing, b_width, thermal, ρCp, pt_thermal, dirichlet, _dt, _di, ni)
update_T(::Nothing, b_width, thermal, rheology, phase, pt_thermal, dirichlet, _dt, _di, ni, args)Launch the pseudo-transient temperature update kernel over the active thermal domain.
These wrappers select the appropriate kernel overload depending on whether the solver works with precomputed ρCp fields or rheology-derived properties.
JustRelax.JustRelax3D.PTThermalCoeffs Method
PTThermalCoeffs(rheology, phase_ratios, args, dt, ni, di, li; ϵ = 1.0e-8, CFL = 0.9 / √3)Construct pseudo-transient thermal coefficients from a multi-phase rheology.
The coefficient arrays are evaluated on the thermal grid of size ni using the phase ratios in phase_ratios.center together with the thermodynamic state stored in args.
JustRelax.JustRelax3D.PTThermalCoeffs Method
PTThermalCoeffs(K, ρCp, dt, di, li; ϵ = 1.0e-8, CFL = 0.9 / √3)Construct pseudo-transient thermal coefficients from conductivity and volumetric heat-capacity arrays.
di and li are the grid spacing and domain-length tuples used to estimate the local pseudo-time step and relaxation factor stored in the returned JustRelax.PTThermalCoeffs.
JustRelax.JustRelax3D.PTThermalCoeffs Method
PTThermalCoeffs(rheology, args, dt, ni, di, li; ϵ = 1.0e-8, CFL = 0.9 / √3)Construct pseudo-transient thermal coefficients from a single rheology state.
This method evaluates conductivity and ρCp from rheology and the cellwise fields in args, then stores the resulting relaxation arrays in a JustRelax.PTThermalCoeffs object.
JustRelax.JustRelax3D.update_thermal_coeffs! Method
update_thermal_coeffs!(pt_thermal, rheology, phase_ratios, args, dt)
update_thermal_coeffs!(pt_thermal, rheology, args, dt)Refresh the pseudo-transient coefficient arrays stored in pt_thermal.
Use this when conductivity or volumetric heat capacity changes during the solve, for example because temperature, pressure, or phase ratios evolve. The update is performed in place on pt_thermal.θr_dτ and pt_thermal.dτ_ρ.
JustRelax.JustRelax3D.compute_shear_heating! Method
compute_shear_heating!(thermal, stokes, rheology, dt)Populate thermal.shear_heating from the current deviatoric stress and strain-rate fields stored in stokes.
The kernel evaluates the elastic strain-rate contribution from stokes.τ, stokes.τ_o, the shear modulus in rheology, and the pseudo-time step dt. The resulting volumetric heating term is written in place on thermal cell centers.
When phase ratios are passed as an extra positional argument, phase-weighted material properties are used instead of a single rheology state.
sourceJustRelax.JustRelax3D._heatdiffusion_PT! Method
_heatdiffusion_PT!(thermal, pt_thermal, thermal_bc, K, ρCp, dt, grid;
igg, b_width, iterMax, nout, verbose)Solve the heat equation with pseudo-transient iterations using precomputed, cell-centered material properties.
K is the thermal conductivity field and ρCp is the volumetric heat-capacity field on the thermal grid. pt_thermal supplies the pseudo-transient coefficients, thermal_bc applies the temperature boundary conditions after each update, and grid provides metric terms and halo layout.
Returns a named tuple containing the iteration numbers and residual norms sampled every nout iterations.
JustRelax.JustRelax3D._heatdiffusion_PT! Method
_heatdiffusion_PT!(thermal, pt_thermal, thermal_bc, rheology, args, dt, grid;
igg, phase, stokes, b_width, iterMax, nout, verbose)Solve the heat equation with pseudo-transient iterations using thermal properties derived from rheology.
args is a named tuple of thermodynamic fields, typically including T and P. Entries sized like the thermal cell centers are read as-is; larger entries are offset by one to skip their ghost nodes. When phase is provided, pseudo-transient coefficients are recomputed from the local phase ratios each iteration. When stokes is provided, thermal.adiabatic is refreshed before the iteration loop to include the adiabatic heating contribution.
Returns a named tuple containing the sampled iteration counts and residual history.
sourceJustRelax.JustRelax3D.heatdiffusion_PT! Method
heatdiffusion_PT!(thermal, args...; kwargs...)Dispatch pseudo-transient thermal diffusion to the backend associated with thermal.
See the _heatdiffusion_PT! methods below for the supported argument groups: constant K and ρCp fields, or rheology-driven properties with optional phase ratios and Stokes fields for adiabatic heating.
JustRelax.JustRelax3D.WENO5 Method
WENO5(backend, method::Val, ni::NTuple)
WENO5(method::Val, ni::NTuple)Allocate a WENO5 advection scheme state for a grid of size ni. method selects the smoothness-indicator variant: Val(1) for Jiang-Shu, Val(2) for the Z-variant.
JustRelax.JustRelax3D.WENO_advection! Method
WENO_advection!(u, Vxi, weno, di, ni, dt)Perform the advection step of the Weighted Essentially Non-Oscillatory (WENO) scheme for the solution of hyperbolic partial differential equations.
Arguments
u: field to be advected.Vxi: velocity field.weno: structure containing the WENO scheme parameters and temporary variables.di: grid spacing.ni: number of grid points.dt: time step.
Description
The function approximates the advected fluxes using the WENO scheme and use a strong-stability preserving (SSP) Runge-Kutta method of order 3 for the time integration.
sourceJustRelax.JustRelax3D.subgrid_characteristic_time! Method
subgrid_characteristic_time!(subgrid_arrays, particles, dt₀, phases, rheology, thermal::ThermalArrays, stokes::StokesArrays[, di])Compute, per cell, the characteristic thermal diffusion timescale dt₀ = ρCp / (2 K Σ dxi⁻²) used for JustPIC's subgrid-diffusion correction of particle temperature, evaluating rheology's density/heat-capacity/conductivity at the local phase (from phases, either a JustPIC.PhaseRatios or an integer phase-id array) and temperature/pressure.