Numerics and Physics
MagmaThermoKinematics.jl is built around a finite-difference energy solver with semi-Lagrangian advection and tracer-based tracking of injected sill material.
Governing Equation
The thermal state of the magmatic system is described by the advection–diffusion equation for temperature
where
| Symbol | Description |
|---|---|
| Rock density (kg m⁻³) | |
| Isobaric heat capacity (J kg⁻¹ K⁻¹) | |
| Temperature (K or °C) | |
| Time (s) | |
| Solid-state velocity field (m s⁻¹) induced by dike/sill emplacement | |
| Thermal conductivity (W m⁻¹ K⁻¹) | |
| Latent heat of crystallisation (J kg⁻¹) | |
| Solid fraction (dimensionless, 0–1), with | |
| Radiogenic heat production (W m⁻³) |
Operator Splitting
Equation (A1) is solved with a first-order operator split that separates advection from diffusion+latent heat. Each time step
Step 1 — advection (semi-Lagrangian):
The departure point
Step 2 — diffusion and latent heat:
Effective Heat Capacity Formulation
Because melt fraction
Substituting into (A2b) and rearranging yields a modified heat capacity:
where the effective heat capacity absorbs the latent heat contribution:
Where we made use of the fact that
An important point to keep in mind, though, is that GeoParams package implements smoothening functions for any melting curve (as many parameterisations in use are discontinuous).
Explicit Time Discretisation
The diffusion operator in (A3) is discretised explicitly:
Staggered-Grid Finite Differences
The spatial derivatives in (A4) are evaluated on a staggered grid:
Temperature
and scalar material properties ( , , ) are defined at cell centres. Heat fluxes
are defined on cell faces (half-integer indices). Conductivity
is harmonically averaged to cell faces to conserve flux continuity across material interfaces.
The discrete Laplacian in 2D is:
with the analogous 3D extension for the
CFL Stability Criterion
For the explicit thermal diffusion step the time step must satisfy the standard parabolic CFL condition:
where the thermal diffusivity is
Nonlinear Iterations (Picard)
Because
Predictor — evaluate material properties at the current iterate
Corrector — advance temperature with the updated effective heat capacity:
Damping — to aid convergence the update is damped:
Convergence — iterations continue until the maximum pointwise temperature change falls below a prescribed tolerance
Typically three to five Picard iterations are sufficient per time step.
Melt Intrusion Algorithms
Three distinct emplacement modes are available for adding new melt to the system:
| Mode | Description |
|---|---|
| Geneva sill (under-accretion) | New magma is injected at the base of the existing melt body and solid host-rock is displaced downward. |
| UCLA-HD (central injection) | Melt is added at the centre of the intrusion; host rock is displaced radially outward while conserving volume. |
| Elastic dike | An elliptical dike geometry is used and host rock is displaced by an analytically prescribed elastic displacement field. |
All three modes inject a Dike object, update the velocity field
Tracers and Temperature–Time Paths
Passive tracer particles are advected with the host-rock velocity field using the same semi-Lagrangian scheme as the temperature field. At each time step each tracer records its current temperature, producing a continuous
Tracers are kept on the CPU, as they generally use a lot of memory.
Dimensions and Geometry
Supported configurations include:
2D Cartesian.
2D axisymmetric (via specific workflows in examples).
3D Cartesian.
Material Parameter Handling
Material properties are integrated through GeoParams-based parameterizations and package-level helper routines for conductivity, density, heat capacity, melt fraction, and related quantities.
One of the highlights is that melting parameterizations and material properties can be changed very easily by using GeoParams (see ).
Changing Melting Parameterizations
Material setup is defined with SetMaterialParams, so changing physics is extremely simple and only requires you to change your MatParam struct. For example, you can switch between the Caricchi melting parameterization and a simple 4th-order polynomial melting curve with:
MatParam = (
SetMaterialParams(Name="Rock", Phase=1,
Density=ConstantDensity(ρ=2700kg/m^3),
HeatCapacity=ConstantHeatCapacity(Cp=1000J/kg/K),
Conductivity=T_Conductivity_Whittington_parameterised(),
Melting=MeltingParam_Caricchi()
),
)MatParam = (
SetMaterialParams(Name="Rock", Phase=1,
Density=ConstantDensity(ρ=2700kg/m^3),
HeatCapacity=ConstantHeatCapacity(Cp=1000J/kg/K),
Conductivity=T_Conductivity_Whittington_parameterised(),
Melting=SmoothMelting(MeltingParam_4thOrder())
),
)
# Example alternatives:
# Conductivity=ConstantConductivity(k=3.3W/K/m)This design makes it straightforward to test sensitivity to melt models and thermophysical assumptions without changing solver internals.
Performance and Parallelism
Backend selection through environment! configures CPU threads, or CUDA execution, and the package composes with ParallelStencil finite-difference modules.
- CPU and CUDA workflows are typically run with
Float64precision.
When your own script uses ParallelStencil macros directly (for example @zeros or @parallel), call @init_parallel_stencil(...) in script scope after environment!(...).
If you run this on a CPU, you can run it in parallel by starting julia in multi-threading mode:
$julia -t auto