>[!warning]
>This content has not been peer reviewed.
# Quantum Geometry — Code
Scripts for [[Quantum Geometry (RST)]]:
- **`rst_quantum_geometry_compute.py`** — framework test: compute QG from TB model, compare to RST prediction (no fitting)
- **`rst_quantum_geometry_calibration.py`** — calibration: fit $n$ from experimental/proxy data (CoSn, Black P proxy, Berry phase)
- **`run_all_tests.py`** — run compute, calibration, and mu landscape; `--falsification` runs `run_falsification.py`
- **`run_falsification.py`** — falsification dashboard: Tests 1–4, `--json` for machine-readable report
- **`qg/`** — atomic library (one function per file). See `qg/ARCHITECTURE.md` for module index and data flow.
---
## A. Compute & test (structure-derived, no fit)
**Script:** `rst_quantum_geometry_compute.py`
**Purpose:** Test whether RST can *calculate* quantum geometry from structure. No fitting of $n$ or $\eta$.
1. Kagome tight-binding H(k) from Comin et al. (Nature Physics 2024)
2. Compute Berry curvature $\Omega(k)$ and quantum metric $g(k)$ from eigenstates
3. **Derive** $\eta(k) = |k - k_{\text{Dirac}}|/k_{\text{scale}}$ from band structure
4. **Derive** $n = 5$ from 2D Crystal Lattice Classes (Kagome $\in [4,6]$)
5. Compare: $g(k)$, $|\Omega(k)|$ vs RST predictions $\mu(\eta,n)$ and $1/\mu - 1$
**Output:** `quantum_geometry_compute_test.png`; shape correlations; PASS/INFORMATIVE result.
**Finding:** Energy-based $\eta$ (eta_def_2) gives $r \approx 0.59$ (best predictor); $\mu$ correlates better than $1/\mu-1$ with quantum metric. See [[Quantum Geometry Results#5. Interpretation of test results]].
**TB parameters:** Generic Kagome (Comin Figure2_Code): $e_0=1$, $t=-1$, $\lambda=0.015$. CoSn-specific parameters may be found in Kang et al. / Nature Comms CoSn literature; not yet implemented. See `data/Request_QGT_from_authors.md` for experimental QGT request template.
---
## B. Calibration (fit from data)
**Purpose:** Documents **`rst_quantum_geometry_calibration.py`** — fits effective $n_{\text{qgeom}}$ from Berry curvature / quantum metric data.
---
## 1. Purpose (calibration)
- **Problem:** Map Bloch-sector quantum geometry (Berry curvature, quantum metric) onto the RST fidelity $\mu(\eta, n)$.
- **Input:** Parameter $\eta_{\text{qgeom}}$ (e.g. momentum scale, band-width ratio) and response (metric magnitude, curvature, or proxy).
- **Output:** Fitted $n_{\text{qgeom}}$, amplitude $A$, $R^2$; comparison with [[2D Crystal Lattice Classes (RST)]] predictions.
- **Data:** Loads real CoSn CD-ARPES from `data/Raw_data_Experimental.xlsx` (Comin et al. Harvard Dataverse) when present; Black P uses proxy until Kang et al. data is available. Requires `openpyxl` for Excel.
---
## 2. Engine
Imports from **`rst_engine`**:
```python
from rst_engine.core import mu_rst
```
Model: $\text{response} = r_0 + A \cdot [1/\mu(\eta, n) - 1]$, analogous to resistivity $\rho = \rho_0 + A \cdot [1/\mu - 1]$ in [[Electronic Transport (RST)]].
---
## 3. Embedded logic
```python
def _mu_inv(eta, n):
mu = mu_rst(np.clip(eta, 1e-12, 1e12), n)
return (1.0 / mu - 1.0) if mu > 1e-12 else 0.0
def fit_n_qgeom(eta, response, A_scale=1.0):
# Fit: response = A * [1/mu(eta, n) - 1]
# Returns (n_fit, A_fit, R2, pred)
```
`curve_fit` (scipy) varies $n$ and $A$ to minimise residual between `response` and $A \cdot [1/\mu(\eta, n) - 1]$.
---
## 4. Parameters
| Parameter | Meaning |
|:---|:---|
| $\eta_{\text{qgeom}}$ | Dimensionless parameter driving the transition (momentum scale, band ratio, etc.) |
| response | Observable (quantum metric proxy, integrated Berry curvature, or extracted value from ARPES) |
| $n_{\text{qgeom}}$ | Transition sharpness (fitted) |
| $A$ | Amplitude scale (fitted) |
---
## 5. Output
| File | Description |
|:---|:---|
| `quantum_geometry_calibration.png` | Two or three panels: CoSn CD-ARPES, Black P proxy, Berry phase (alpha-T3) when data loaded |
| `quantum_geometry_mu_landscape.png` | $\mu(\eta, n)$ for $n = 2, 4, 6$ (rugosity interpretation) |
---
## 6. Results
**Results:** [[Quantum Geometry Results]]
---
## 7. Links
- **Application:** [[Quantum Geometry (RST)]]
- **2D lattice predictions:** [[2D Crystal Lattice Classes (RST)]]
- **Fidelity:** [[expanded theory/Fidelity]]
- **Electronic Transport (analogous model):** [[expanded theory applied/further applications/Electronic Transport/Electronic Transport (RST)]]