Thermodynamic modelling of Li enrichment during partial melting: the importance of partition coefficients

This section accompanies Riel et al. (2026, Geochemistry, Geophysics, Geosystems) and provides fully reproducible tutorial scripts for modelling lithium (Li) enrichment during partial melting of pelitic rocks. All calculations use MAGEMin_C.jl for thermodynamic equilibrium and a custom trace-element partitioning engine built on top of it.
Scientific context
When crustal rocks partially melt, Li is redistributed between minerals and the melt. This section explores how Li concentrations in granitic melts depend on:
Pressure and water content of the source rock (P–H₂O space)
The number and size of successive melt extraction events (fractional melting)
The natural variability of pelite bulk compositions (Forshaw & Pattison 2023 database)
Tutorial overview
The tutorials are organized from single-condition diagnostics to large multi-sample sweeps:
Info
Tip
Tutorials 1–4 work on a single representative pelite composition and are good starting points. Tutorials 6–7 require the Forshaw & Pattison (2023) database and are computationally heavier (multi-threaded, ~600 samples).
Getting started
1 — Download the files
Download all scripts into a single directory on your machine (the shared helper files must be in the same folder as the main scripts).
2 — Set up the Julia environment
The project ships with a Project.toml that pins all required packages. To install them:
# In the Julia REPL, navigate to the directory containing the scripts
julia> using Pkg
julia> Pkg.activate(".") # activate the project environment
julia> Pkg.instantiate() # download and precompile all dependenciesOr equivalently from the terminal:
cd /path/to/scripts
julia --project=. -e "using Pkg; Pkg.instantiate()"3 — Run a tutorial script
# single-threaded scripts (Tutorials 2–4)
julia --project=. compute_PT_curves.jl
# multi-threaded scripts (Tutorials 1, 6–7) — use as many threads as your machine has cores
julia --project=. --threads 8 compute_P-H2O_systematics.jlNote
Tutorials 6 and 7 sweep ~600 pelite compositions and benefit significantly from multi-threading. Set --threads to the number of physical cores available (check with Sys.CPU_THREADS in Julia).
Script files
All scripts are available for download below. The shared helper files (TE_functions.jl, TE_fractional.jl, plot_figures.jl) are required by most of the main scripts and should be placed in the same directory.
Main scripts
Shared helper files
Environment file
| File | Description |
|---|---|
<a href="https://raw.githubusercontent.com/ComputationalThermodynamics/MAGEMin_C.jl/main/docs/src/Riel_2026_gcubed/Project.toml" download>Project.toml</a> | Julia package environment — lists all dependencies (MAGEMin_C, Plots, PlotlyJS, DataFrames, …) |