Theory¶
This page summarises the mathematical foundations implemented in scpn_control.phase.
Stochastic Petri Net (SPN)¶
An SPN is a bipartite directed graph \(G = (P, T, W^{-}, W^{+})\) where \(P\) is a set of places, \(T\) a set of transitions, and \(W^{\pm}\) are the input/output weight matrices. The marking vector \(\mathbf{m}(t) \in \mathbb{R}^{|P|}_{\ge 0}\) evolves via stochastic firing:
where \(\mathbf{f}(t) \in \{0,1\}^{|T|}\) is the firing vector, sampled from transition-specific hazard functions.
The FusionCompiler maps each place → LIF neuron membrane potential, each
transition → synaptic connection with weight from \(W^{\pm}\), producing a
CompiledNet for closed-loop control.
Kuramoto–Sakaguchi Model¶
The phase of oscillator \(n\) in layer \(l\) evolves as (Paper 27, Eq. 3):
where \(\omega^{(l)}_n\) are natural frequencies, \(K_{ll}\) is the intra-layer coupling, \(\alpha\) is the Sakaguchi phase-lag, and \(\zeta_l\) is the exogenous global-field coupling strength.
The order parameter for layer \(l\) is:
Implementation: scpn_control.phase.kuramoto.kuramoto_sakaguchi_step.
Unified Phase Dynamics Equation (UPDE)¶
The UPDE extends the Kuramoto model to \(L\) coupled layers with inter-layer coupling matrix \(\mathbf{K} \in \mathbb{R}^{L \times L}_{\ge 0}\):
The cross-layer term uses the mean-field approximation: layer \(l'\) acts on layer \(l\) through its order parameter \(R_{l'} e^{i\Psi_{l'}}\).
PAC gating (Phase-Amplitude Coupling): when enabled, the cross-layer coupling \(K_{ll'}\) is modulated by \(R_{l'}\), suppressing influence from incoherent layers.
Implementation: scpn_control.phase.upde.UPDESystem.
Paper 27 Coupling Matrix (\(K_{nm}\))¶
The \(16 \times 16\) inter-layer coupling matrix follows exponential distance decay with calibration anchors (Paper 27, Table 2):
with \(K_{\text{base}} = 0.45\), \(\alpha = 0.3\), and four calibration overrides:
| Pair | \(K_{nm}\) | Source |
|---|---|---|
| (1,2) | 0.302 | Paper 27 Table 2 |
| (2,3) | 0.201 | Paper 27 Table 2 |
| (3,4) | 0.252 | Paper 27 Table 2 |
| (4,5) | 0.154 | Paper 27 Table 2 |
Implementation: scpn_control.phase.knm.build_knm_paper27.
Lyapunov Stability Monitor¶
A candidate Lyapunov function for the synchronised state:
satisfies \(V \ge 0\), \(V = 0\) iff \(\theta_n = \Psi \;\forall n\). The guard estimates the Lyapunov exponent \(\lambda\) via finite differences over a sliding window:
A session is flagged unstable when \(\lambda > 0\) persists for more than
max_violations consecutive windows.
Implementation: scpn_control.phase.lyapunov_guard.LyapunovGuard.
Bosch-Hale DT Reactivity¶
The DT fusion reactivity \(\langle \sigma v \rangle\) is estimated using the Padé polynomial fit (Bosch & Hale 1992):
where \(\xi = (\frac{B_G^2}{4\theta})^{1/3}\) and \(\theta\) is the modified temperature. This provides accurate cross-sections from 0.1 keV to 100 keV.
Ref: Bosch, H.-S. and Hale, G. M. (1992). Nuclear Fusion, 32, 611.
Implementation: scpn_control.core.uncertainty.bosch_hale_reactivity.
Bremsstrahlung Radiation¶
Losses from electron-ion Bremsstrahlung are calculated per unit volume:
where \(n_e\) is in \(m^{-3}\) and \(T_e\) is in keV.
Ref: Wesson, J. (2011). Tokamaks. 4th Edition, Chapter 14.
Implementation: scpn_control.control.tokamak_digital_twin.TokamakDigitalTwin.
Energy Conservation Diagnostic¶
The transport solver monitors the global energy balance error \(\epsilon_W\):
where \(W = \frac{3}{2} \int (n_e T_e + n_i T_i) dV\) is the stored energy.
Implementation: scpn_control.core.integrated_transport_solver.TransportSolver.evolve_profiles.
Disruption Mechanisms¶
- NTM (Neoclassical Tearing Mode): Evolved via the Modified Rutherford Equation for island width \(w\): $\(\frac{\tau_R}{r} \frac{dw}{dt} = r \Delta' + r \beta_p \frac{L_q}{L_p} \frac{w}{w^2 + w_c^2}\)$
- Greenwald Limit: Disruption risk increases as density approaches \(n_G = I_p / (\pi a^2)\).
- VDE (Vertical Displacement Event): Exponential growth of vertical position \(z\) driven by plasma elongation \(\kappa\).
Implementation: scpn_control.control.disruption_predictor.simulate_tearing_mode.
IPB98(y,2) Scaling Law¶
Global H-mode thermal energy confinement time \(\tau_E\) scaling:
The implementation includes a \(\pm 2\sigma\) uncertainty band based on the ITPA database variance.
Ref: ITER Physics Basis (1999). Nuclear Fusion, 39, 2175.
Implementation: scpn_control.core.scaling_laws.ipb98y2_with_uncertainty.
Free-Boundary Grad-Shafranov¶
The free-boundary equilibrium is determined by solving \(\Delta^* \psi = -\mu_0 R J_\phi\) where the boundary value \(\psi_{bc}\) is the sum of contributions from all external coils:
\(G\) is the toroidal Green's function involving complete elliptic integrals \(K(k)\) and \(E(k)\).
Ref: Lao, L. L. et al. (1985). Nuclear Fusion, 25, 1611.
Implementation: scpn_control.core.fusion_kernel.FusionKernel.
How the mathematical components connect to production code¶
The formulas above map directly to runtime surfaces in this repository. The goal is to avoid a gap between symbol-level derivation and implementation detail.
- SPN and phase equations provide control-time structure, and their invariants are enforced by contracts before action publication.
- Transport and scaling laws provide admissibility windows used by disruption risk and actuator-limiter surfaces.
- Reactivity and confinement equations contribute to bounded diagnostics and are compared against validated reference domains through validators.
- Disruption dynamics are not treated as full predictive guarantees; they are warning surfaces with explicit assumptions and admitted validity regions.
The practical interpretation is:
- Mathematical form defines intent.
- Controller implementation chooses the admissible control law.
- Evidence gates decide where a mathematical claim may be communicated as bounded, reference-validated, or measured-facility admissible.
For external reviewers, this separation makes it easier to separate what is implemented correctly from what is approved for external use.
Practical use and scope¶
Use this document as the formal foundation for stochastic and control formulations.
- Use it to align mathematical terms with implementation contracts in controller and transport modules.
- Keep terminology updates here synchronized with
docs/learning/control_theory_primer.md. - Route formal-language changes through release and validation checks before external publication.