Skip to content

Usage

Aragog is primarily used as a Python library, either directly via EntropySolver or, in coupled simulations, through the PROTEUS framework wrapper. The standalone command-line interface is minimal and intentional: production runs go through the Python API.

Running Aragog from Python

The minimal workflow is load configuration → instantiate solver → set initial entropy → solve → read SolverOutput.

from pathlib import Path
from aragog.solver import EntropySolver

# Build a solver from a TOML configuration file and a directory
# of SPIDER-format pressure-entropy EOS tables.
solver = EntropySolver.from_file(
    filename="src/aragog/cfg/abe_solid.toml",
    eos_dir="data/lookup",
)

solver.initialize()

# When core_bc = "energy_balance", the CMB entropy gradient is part
# of the state vector. If you need to set its initial value explicitly,
# do it BEFORE set_initial_entropy; otherwise the solver derives it
# from S_init via one-sided finite differences.
# solver.set_initial_dSdr_cmb(0.0)

# Set the initial entropy profile at staggered nodes (J/kg/K).
# A scalar S_init produces a uniform isentropic profile.
solver.set_initial_entropy(2900.0)

solver.solve()

# Retrieve a SolverOutput dataclass with profiles, fluxes, and
# scalar diagnostics.
out = solver.get_state()
print(f"Status:           {out.status}")           # 0 success, -1 failure
print(f"T_magma:          {out.T_magma:.0f} K")    # surface temperature
print(f"T_core:           {out.T_core:.0f} K")
print(f"Phi_global:       {out.Phi_global:.4f}")
print(f"F_heat_total:     {out.F_heat_total:.3e} W/m^2")

EntropySolver.from_file is a convenience constructor; in PROTEUS, the wrapper builds Parameters and EntropyEOS programmatically and passes them to the constructor directly.

What SolverOutput contains

get_state() returns a SolverOutput dataclass. The fields are flat NumPy arrays except where noted:

Profiles (staggered nodes, length \(N\)):

Field Unit Description
S_final J/kg/K Specific entropy at the end of the integration
T_stag K Temperature derived from \((P, S)\) via EOS
phi_stag -- Melt fraction
rho_stag kg/m³ Density
visc_stag Pa·s Dynamic viscosity (after the SPIDER-parity solid/liquid blend)

Mesh geometry:

Field Unit Description
P_stag Pa Pressure at staggered nodes
r_basic m Basic-node radii (length \(N+1\))
r_stag m Staggered-node radii (length \(N\))
vol m³ Cell volume per staggered node
mass_stag kg Mass per staggered cell

Per-component fluxes (basic nodes, length \(N+1\)):

Field Unit Description
jcond_b W/m² Conductive flux
jconv_b W/m² Convective (MLT) flux
jgrav_b W/m² Gravitational-separation heat flux
jmix_b W/m² Chemical-mixing heat flux
dSdr_b J/kg/K/m Entropy gradient at basic nodes
phi_basic -- Melt fraction at basic nodes
T_basic K Temperature at basic nodes
cp_basic J/kg/K Heat capacity at basic nodes
rho_basic kg/m³ Density at basic nodes
porosity_b -- Density-derived porosity at basic nodes, not the melt fraction (see NetCDF output)
rho_solid_b kg/m³ Solid density at the phase boundary at basic nodes
rho_melt_b kg/m³ Melt density at the phase boundary at basic nodes
g_b m/s² Gravitational acceleration at basic nodes
heat_flux W/m² Total heat flux at basic nodes
heating W/kg Internal heating at staggered nodes (length \(N\))
eddy_diff m²/s Thermal eddy diffusivity at basic nodes
cap_stag J/m³/K Capacitance \(\rho T\) at staggered nodes

Scalar diagnostics:

Field Unit Description
T_magma K Top basic-node temperature; the value passed to the atmosphere module in coupled runs
T_core K Bottom staggered-node temperature (or the integrated T_core state in the bower2018 and core_module modes)
Phi_global -- Mass-weighted mean melt fraction (M_liq / M_mantle)
Phi_global_vol -- Volume-weighted mean melt fraction (V_liq / V_mantle)
M_mantle kg Total mantle mass
M_mantle_liquid kg Liquid mantle mass
M_mantle_solid kg Solid mantle mass
RF_depth -- Rheological front depth, \(1 - r_\mathrm{rf}/R_\mathrm{surf}\)
E_th J Legacy thermal-energy proxy, \(\sum m_i c_p(P_i, S_i) T_i\). Carries phase-dependent jumps in the mushy band; not suitable for energy-conservation residuals. Use E_state_cons for that.
Cp_eff J/kg/K Mass-weighted mean heat capacity
F_heat_total W/m² Total surface heat flux
dt_actual yr Wall-clock integration span achieved by the solver
status int 0 on success; -1 on solver failure (drives the PROTEUS retry ladder)

Driving Aragog from PROTEUS

When Aragog is invoked as a PROTEUS submodule, the wrapper (proteus.interior_energetics.aragog.AragogRunner) constructs Parameters from the PROTEUS config object and the current helpfile row, instantiates EntropySolver directly, sets the initial entropy from the previous step (or from a Zalmoxis-derived profile on the first iteration), runs solve(), and reads the results from get_state().

PROTEUS handles:

  • The mapping of PROTEUS config keys (config.interior_energetics.*, config.interior_struct.*) onto Aragog's Parameters.
  • The choice of EOS table directory (output/data/aragog_pt/ for PALEOS-generated tables, or a SPIDER-bundled directory for parity runs).
  • The four-column external mesh file (output/data/zalmoxis_output.dat for Zalmoxis-coupled runs, output/data/spider_mesh.dat for spider or dummy structure modes) when eos_method = 2.
  • A retry ladder around solve() that calls set_initial_dSdr_cmb() and _atol_sf to recover after a status = -1 failure.

For an end-to-end coupled run, see the PROTEUS documentation.

Resetting and re-running the solver

To run multiple configurations or restart from a saved entropy profile, call reset() and then set_initial_entropy() again:

solver.reset()                 # rebuilds the mesh and BCs from current parameters
# Optional in energy_balance mode (must be called BEFORE set_initial_entropy):
# solver.set_initial_dSdr_cmb(dSdr_cmb_new)
solver.set_initial_entropy(S_new)
solver.solve()
out = solver.get_state()

reset() does not change the parameters; mutate solver.parameters first if a different time window or boundary value is needed.

NetCDF output

Standalone Aragog writes a NetCDF snapshot via SolverOutput.to_netcdf(path) (also exposed as EntropySolver.write_netcdf(path) and as aragog run --out path.nc on the CLI). The PROTEUS wrapper builds its own per-iteration int.nc snapshot from SolverOutput arrays for the PROTEUS analysis pipeline; that path is independent. See Inspecting NetCDF output for the snapshot schema.

Logging

aragog.aragog_file_logger(log_dir=output_dir) configures a console+file logger that writes aragog.log into the supplied directory. The logger is shared between the solver and the EOS layer; the standalone path uses it implicitly.

Command-line interface

Aragog exposes the aragog console entry point with seven subcommands: new, list-configs, validate, show-config, run, inspect, and vnv. The CLI is a thin wrapper over the Python API — anything it does is also reachable from from aragog.solver import EntropySolver — but it covers the recommended standalone-user loop without writing Python:

aragog new my_first --from abe_solid
aragog validate my_first.toml
aragog run my_first.toml --eos-dir $FWL_DATA/spider/lookup-fs
aragog inspect my_first.nc

aragog run derives the initial entropy from [initial_condition].surface_temperature when the bundled config provides it (the abe_* templates do); pass --initial-entropy <S0> to override. Repeatable --set <key.path>=<value> flags accept one-shot overrides without editing the TOML. The full subcommand reference, including the --set type-coercion rules, is in Reference: CLI. PROTEUS-coupled runs bypass the CLI and call EntropySolver directly via AragogRunner.