# METHODS — E4-H034

## 1. The elastic dipole

For a defect in a periodic cell, the elastic dipole (Kanzaki / double-force) tensor is

    P_ij = −∂E/∂ε_ij ,

the strain derivative of the total energy at fixed cell shape. It is the leading moment of the defect's
force field and the coefficient of the `1/r³` term in its strain field.

## 2. Strain field and stored energy outside a cutoff

In an infinite isotropic medium, a point dipole produces

    ε_ij(r) ≈ P_ij / (κ r³)      (κ = bulk modulus scale)

up to angular factors. The elastic energy density is `∼ κ ε²`, so

    E_out(R_c) = ∫_{r>R_c} κ ε² d³r  ∼  κ ∫_{R_c}^∞ (P²/κ² r⁶) r² dr
               = (P²/κ) ∫_{R_c}^∞ r⁻⁴ dr
               = P² / (3 κ R_c³) .

**This is the derived law**: `E_out ∝ P² / (κ R_c³)`. Written with a numerical prefactor chosen for
the tabulation in `RESULTS.md`:

    E_out ≈ 0.18 · P² / (κ R_c³)      [eV, with P in eV, κ in eV/Å³, R_c in Å]

The prefactor 0.18 is `1/3` times the angular average of the dipole strain pattern and is **not
independently derived here** — it is a stated constant, and the tabulated values should be read as
order-of-magnitude, with the *exponents* being the content.

## 3. Why this becomes an MLIP error law

An MLIP with cutoff `R_c` cannot represent any energy contribution arising beyond `R_c`. If the error
on a defect is dominated by the missing `E_out`, then

    error ≈ c · E_out ≈ c' · P² / (κ R_c³) ,

where `c` absorbs how much of the missing energy propagates into the predicted quantity (energy,
forces, relaxation geometry). **`c` is a property of the model and the target quantity; the exponents
are not.**

## 4. Consequences, stated as predictions

| Prediction | Test |
|---|---|
| Quadratic in `|P|` | log–log slope 2 at fixed material |
| Inverse-cube in `R_c` | same architecture family, varying cutoff |
| Inverse-linear in `κ` | across materials, after normalisation |
| Same exponents, different prefactor, across architectures | compare fitted slopes, not intercepts |
| Saturates when `R_c` exceeds the defect-separation scale | periodic-cell size series |

## 5. Protocol (the part that was actually executed)

A synthetic generator produces defects with:

- a material identity carrying stiffness `κ`, cutoff `R_c`, and a material-level nuisance bias;
- a dipole magnitude `P`, a correlated size descriptor, and a chemistry proxy;
- an error target that is either (**signal**) `simple + 40·E_out + noise` or (**null**)
  `simple + noise`.

Two splits are compared:

- **random** 70/30 — the standard mistake;
- **grouped**, leaving whole materials out, 6 folds.

Four nested models (M0–M3 in `PREREGISTRATION.md`) are fit by ordinary least squares; RMSE is
averaged over folds.

**What this demonstrates:** that the protocol distinguishes "the dipole adds information" from "the
dipole correlates with the material", and that a random split cannot. **What it does not demonstrate:**
anything about real potentials.

## 6. What would be done with real data

1. Join defect configurations → DFT energies/forces → computed `P` → MLIP predictions, on identical
   cells and charge states.
2. Fit `log error` on `log |P|` with material fixed effects; report the slope with a CI.
3. Compare M1 vs M3 under material-grouped CV; report the incremental RMSE and its CI.
4. Normalise by `κ` and repeat; report VIF between `|P|` and volume.
5. Report high-error detection ROC.

Steps 2–5 are implemented in `code/h034_theory_and_protocol.py` and would run unchanged on real data
with the same column names.
