MilaDy · 2027

Experiments

Code, results, and reproducibility of experiments E1–E3

About All the experiments on this site run on an ordinary processor (Intel Xeon, 4 cores, 2.30 GHz, no GPU), in Python 3.13 with NumPy 2.5, SciPy 1.18, Matplotlib 3.11 and PyTorch 2.15 (CPU build). They are small-scale test benches: they test ideas and mechanisms, not performance on real dynamo data. All the numbers quoted in the report come from the result files described here.

Three rows, E1, E2 and E3. In each row: a thumbnail of the system (time series of the dipole D, 2D MHD map, periodic box), two lines on the numerical scheme, a small plot of the response against the parameter with the training and test values on the axis, and the corresponding infrastructure campaign.

The three test benches on one template: system, numerical scheme, parameter sweep with the system’s response, data kept and place in the compute pipeline. Responses: E1, frequency of zero crossings of D in the fine-grid simulations; E2, mean magnetic energy E_B (± one standard deviation), recomputed for this diagram with E2’s solver and settings; E3, growth rate \gamma, axis restricted to \pm 0.012 (three points below the scale, at Rm = 2, 4 and 6, marked with an arrow). Filled points: training values; open points: test values. Shaded zones: reversal threshold (E1) and dynamo windows (E3).

Code organization

The experiments/ folder of the repository contains everything needed to reproduce the results. The generic tools (flow matching, Heun sampler, distances, tilting, the 2D MHD and ABC induction solvers) live in the milady package (src/milady/), which the thesis reuses; the scripts import them with the exact settings of the published runs, and tests/test_shared_tools.py checks that they reproduce the earlier code bit for bit.

File Role
common.py Networks (MLP, equivariant symmetrization) and training loop; re-exports, with the settings of the runs, conditional flow matching and the Heun scheme (milady.train.flow), the metrics (energy distance, sliced Wasserstein: milady.eval.metrics) and exponential tilting (regularized I-projection: milady.eval.tilt).
e1_gissinger.py E1: invariant distribution of the Gissinger (2012) reversal model, conditioned on \Gamma; symmetry, stationarity identities, Rice formula. Costly steps are cached in results/cache_e1/.
mhd2d.py Pseudo-spectral solver for forced incompressible 2D MHD, in potentials (\omega, a) (re-export of milady.sim.mhd2d).
e2_data.py E2: 2D MHD snapshots for eleven values of \eta (six for training, five for testing).
e2_mhd2d.py E2: free baseline and four divergence-constraint mechanisms, distributional stationarity loss, tilting versus per-sample rescaling.
e3_abc.py E3: kinematic dynamo of the ABC flow, growth rate as a function of Rm (solver milady.sim.induction3d).
unet.py Small periodic U-Net (not used in the final results: too slow on CPU, see below).
figures.py Plots of the results (figures/<name>.png and .svg).
digest.py Numerical digest results/digest.md, the source of the tables of the report.

Reproducing the results

cd experiments
./run_stage.sh                    # E1-E3, five seeds, then figures and digest: about 6 h on 4 cores
# or step by step:
python3 e3_abc.py                 # E3, about 24 min
python3 e2_data.py                # E2, data: about 30 min
python3 e2_mhd2d.py --seed k      # E2, models, seed k = 0..4: about 38 min each
python3 e1_gissinger.py --train-only --seeds k   # E1, training of seed k (resumable cache)
python3 e1_gissinger.py --seeds 0 1 2 3 4        # E1, evaluation over the seeds: about 25 min
python3 figures.py && python3 digest.py > results/digest.md

Each script accepts --quick for a reduced version (from a few minutes to about twenty minutes for E1), useful for checking the installation. The published runs use seeds 0 to 4 for E1 and E2 (./run_stage.sh, one process per seed, two at a time); the digest reports the spread across seeds. The durations given were measured on the machine described above.

E1 — dipole reversals

Gissinger’s three-mode model serves as a “pocket dynamo”: it has the symmetry \mathbf{B}\to-\mathbf{B}, an onset threshold for reversals (between \Gamma = 0.86 and 0.865) and exactly known dynamics. We learn the stationary distribution p(Q, D, V \mid \Gamma) by conditional flow matching, then measure the effect of the symmetry imposed by construction, of the stationarity loss, and of the per-sample projection. The frequency of zero crossings of D (reversals and excursions) is estimated from the generated distribution alone, through the Rice formula.

In short: the equivariant velocity field keeps the distribution symmetric at every value of \Gamma, whereas data augmentation symmetrizes it only at training values; projecting each sample onto \mathrm{d}E/\mathrm{d}t = 0 multiplies the energy distance to the true distribution by about 10; Rice’s formula recovers the crossing frequency with a cumulative error of 12% far from the threshold (up to 41% at a single value) and of 59% near the threshold (one seed); over five seeds, the stationarity loss does no better than a control run on a good model and diverges on a biased model.

Results and discussion: report, section E1. Interactive diagram: Gissinger model.

Two plots as a function of Gamma from 0.80 to 1.00: on the left, the frequency of zero crossings of D, zero below 0.865 and then increasing; on the right, the probability that |D| is less than 0.25.

Frequency of zero crossings of D and mass of the “bridge” |D| < 0.25 as a function of \Gamma: simulation, Rice formula on the reference distribution and on the generated distributions.

Four horizontal bar charts, one bar per variant, with a dashed line for the noise floor or the reference value.

Comparison of the variants at test values of \Gamma: energy distance, control Liouville residual (degree 3), asymmetry |\mathbb{P}(D>0) - 1/2| and ratio \sigma(\mathrm{d}E/\mathrm{d}t)/\sigma_{\mathrm{ref}}, with the noise floors.

Three panels: histograms of dE/dt, then two scatter plots in the Q-D plane over the grey reference.

Symmetry and per-sample constraint: density of dE/dt at \Gamma = 0.93 (the projection concentrates everything at zero) and (Q, D) scatter plots at \Gamma = 0.85 for the baseline model, which is asymmetric, and the equivariant model.

E2 — 2D MHD and divergence constraints

Forced 2D MHD produces fields (\mathbf{u}, \mathbf{B}) that are divergence-free by construction. We generate these fields conditionally on the parameter \eta in the truncated Fourier basis (220 independent modes per scalar field), which is a POD basis without reduction for a translation-invariant law on a periodic domain (up to a rotation of the modes once the cross helicity couples \mathbf{u} and \mathbf{B}). We compare the free baseline with four ways of handling the divergence, then the effect of a distributional constraint on the energy budget.

Results and discussion: report, section E2.

Three horizontal bar charts, logarithmic scale, for eight variants.

Relative divergence, spectrum error and residual of the mean energy budget for variants V0 to V5 on the test values of \eta, compared with a subsample of the data.

Three horizontal bar charts for four variants.

Distributional constraint versus per-sample constraint (test values of \eta): residual of the energy budget, spread of the dissipation and energy distance, for the V4 model, its exponential tilting, its sample-by-sample rescaling, and the V5 model trained with the stationarity loss.

A first attempt with a periodic U-Net on the 32\times32 grid (file unet.py) cost about 0.3 s per training step on this processor: five variants would have required several hours in total (about 30 min each at the 6000-iteration budget). Switching to the truncated Fourier basis keeps the comparison clean (same network, same budget for all variants) at a cost compatible with a CPU. The internship itself would run on GPU, with field architectures (U-Nets, transformers, functional decoders).

E3 — ABC kinematic dynamo

The induction equation with the imposed ABC flow is solved by a 32^3 pseudo-spectral method. The growth rate \gamma(Rm) changes sign at Rm \approx 8.87, 17.6 and 26.8, in agreement with the known windows. The curl form of the equation keeps \nabla\cdot\mathbf{B} at machine precision (\sim 10^{-16}).

Results: report, section E3. Interactive diagram: ABC dynamo.

Curve of the growth rate as a function of Rm, positive between 8.9 and 17.6 and then beyond 26.8.

Growth rate \gamma of the ABC kinematic dynamo as a function of Rm = 1/\eta (32^3 grid, checks at 48^3); the shaded areas are the dynamo windows.

Result files

File Contents
results/digest.md Numerical tables of all the experiments (generated).
results/e1_gissinger.json E1: configuration, data statistics, evaluation per variant and per \Gamma (mean and standard deviation across seeds), fine grid, noise floors.
results/e2_mhd2d.json, e2_mhd2d_s1.json to e2_mhd2d_s4.json E2, seeds 0 to 4: configuration, evaluation per variant and per \eta, “distributional” part.
results/e3_abc.json E3: growth rates, resolution convergence, interpolated thresholds.
results/*.npz Generated samples and eigenmodes, for the figures and the widgets.

The files are in the repository: https://github.com/knoel99/milady-2027/tree/main/experiments.