RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Raya docs · Exact and higher mathematics

Gauge fields

Superconductivity as a lattice Higgs model stepped by exact rational updates: U(1) links as rational unit complex numbers turned by Cayley maps, next to the classic angle form.

import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'package:riptide_rational_gauge/classic.ray';
16 classes150 functions and methods200 of 297 documented172 runnable examples

Overview

Superconductivity and the Higgs field two ways, from Richard Behiel's "Superconductivity and the Higgs Field". Pure Raya.

A 2-D lattice Ginzburg–Landau / abelian Higgs model (lattice.ray):

F = Σ_ℓ |ψ_j − U_ℓ ψ_i|² + Σ_i (αQ_i + (β/2)Q_i²) + (1/g²) Σ_p (1 − Re U_p h̄), Q = |\psi|^{2},

Gauge transformation \psi_{i} \to g_{i}\psi_{i}, U_ℓ → g_j U_ℓ ḡ_i. Two steppers: time-dependent GL (relax) and the Hamiltonian step (evolve, symplectic Euler, Gauss's law div E + 2 \operatorname{Im} \bar{\pi}\psi kept).

Classic (classic.ray, Transcendental)Rational (Rational, Geometric)
Linksangle \theta, \theta + = \Delta\theta, U = \cos \theta + i \sin \thetaU \leftarrow e(\tau)U, e(\tau) = \frac{(1 - \tau^{2}) + 2i\tau}{1 + \tau^{2}}, \tau = \frac{\Delta\theta}{2}; in doubles \frac{U(3 - Q)}{2}
Vortex / fluxoidΣ atan2 / 2\piquarter turns by signs and one cross product (winding.ray): exact integer
Flux quantization\sum \theta_{p} / 2\piholonomy W (= \prod U_{p} exactly), half-turn spread \frac{1 - \operatorname{Re} W}{2} = \sin^{2}(\frac{\pi\Phi}{\Phi_{0}})
Londone^{-x/\lambda}B_{n} = B_{0}r^{n}, r + \frac{1}{r} = 2 + \frac{1}{\lambda^{2}} (r: Root), \lambda^{2} = \frac{1}{2g^{2}Q_{0}}
Hat\sqrt{-\frac{\alpha}{\beta}} e^{i\varphi}V(Q) = \alpha Q + (\frac{\beta}{2})Q^{2}, Q_{0} = -\frac{\alpha}{\beta}, rim points like (\frac{3}{10}, \frac{2}{5})
Electroweak\theta_{W} = \operatorname{atan}(g'/g), m_{Z} = \frac{m_{W}}{\cos \theta_{W}}s_{W} = \frac{g'^{2}}{g^{2} + g'^{2}}, \frac{m_{W}^{2}}{m_{Z}^{2}} = 1 - s_{W}

exact.ray is the same model over any field (\mathbb{Q} with riptide_precision's Rational), rational way only. experiments.ray: the lab's runs (Meissner disc cooled by a growing front, type-II vortex entry, flux trapped in a ring, the Higgs strip). bin/gauge_probe.ray <preset> [steps] [classic] prints their readouts.

Functions and constants

Functions

cayleyfunction
(double, double) cayley(double t)

The Cayley point e(t) = ((1 − t²) + 2it)/(1 + t^{2}) in doubles: (re, im).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The Cayley point e(t) = ((1 − t²) + 2it)/(1 + t²): a U(1) phase with rational coordinates for rational t.
  for (final t in [0.0, 0.5, 1.0, 2.0]) {
    final (re, im) = cayley(t);
    print('e($t) = ($re, $im), re² + im² = ${re * re + im * im}');
  }
}
Output
e(0.0) = (1.0, 0.0), re² + im² = 1.0
e(0.5) = (0.6, 0.8), re² + im² = 1.0
e(1.0) = (0.0, 1.0), re² + im² = 1.0
e(2.0) = (-0.6, 0.8), re² + im² = 1.0
turnRulefunction
double turnRule(double t1, double t2)

The turn rule: the parameter of e(t_{1}) \cdot e(t_{2}), \frac{t_{1} + t_{2}}{1 - t_{1}t_{2}} (infinite when t_{1}t_{2} = 1: the half turn -1).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The turn rule: e(t₁)·e(t₂) = e((t₁ + t₂)/(1 − t₁t₂)), tangent addition with no angle.
  const c = CayleyArith<Rational>(ExactArith());
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final (ar, ai) = c.point(r(1, 2));
  final (br, bi) = c.point(r(1, 3));
  final (pr, pi) = c.mul(ar, ai, br, bi);
  print('turnRule(1/2, 1/3) = ${turnRule(0.5, 1 / 3)}');
  print('e(1/2)·e(1/3) = ($pr, $pi) = e(1) = ${c.point(r(1))}');
}
Output
turnRule(1/2, 1/3) = 0.9999999999999999
e(1/2)·e(1/3) = (0, 1) = e(1) = (0, 1)
double halfTurnSpread(double re)

The half-turn spread of a unit complex number (re, im): \frac{1 - re}{2}. Zero exactly when the phase is 1.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The half-turn spread of a unit number: (1 − re)/2. Zero exactly when the phase is 1.
  for (final t in [0.0, 0.5, 1.0, 3.0]) {
    final (re, _) = cayley(t);
    print('t = $t: halfTurnSpread = ${halfTurnSpread(re)} (t²/(1 + t²) = ${t * t / (1 + t * t)})');
  }
}
Output
t = 0.0: halfTurnSpread = 0.0 (t²/(1 + t²) = 0.0)
t = 0.5: halfTurnSpread = 0.2 (t²/(1 + t²) = 0.2)
t = 1.0: halfTurnSpread = 0.5 (t²/(1 + t²) = 0.5)
t = 3.0: halfTurnSpread = 0.9 (t²/(1 + t²) = 0.9)
spreadOffunction
double spreadOf(double re, double im)

The spread between a unit complex number (re, im) and 1: \frac{im^{2}}{re^{2} + im^{2}}, which is im^{2} for a unit number.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The spread of a unit number from 1: im²/(re² + im²) = 4t²/(1 + t²)².
  for (final t in [0.5, 1.0, 2.0]) {
    final (re, im) = cayley(t);
    print('t = $t: spread = ${spreadOf(re, im)}, 4t²/(1 + t²)² = ${4 * t * t / ((1 + t * t) * (1 + t * t))}');
  }
}
Output
t = 0.5: spread = 0.6400000000000001, 4t²/(1 + t²)² = 0.64
t = 1.0: spread = 1.0, 4t²/(1 + t²)² = 1.0
t = 2.0: spread = 0.6400000000000001, 4t²/(1 + t²)² = 0.64
londonRatiofunction
double londonRatio(double lambda2)

The lattice London decay ratio r (B_{n + 1} = r \cdot B_{n} into the sample): the root of r + \frac{1}{r} = 2 + \frac{1}{\lambda^{2}} below 1. Root: r = 1 + \frac{1}{2\lambda^{2}} - \sqrt{(1 + \frac{1}{2\lambda^{2}})^{2} - 1}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The lattice London decay ratio r < 1 with r + 1/r = 2 + 1/λ² (one square root).
  for (final l2 in [1.0, 4.0, 9.0]) {
    final r = londonRatio(l2);
    print('λ² = $l2: r = ${r.toStringAsFixed(12)}, r + 1/r = ${(r + 1 / r).toStringAsFixed(12)}');
  }
}
Output
λ² = 1.0: r = 0.381966011250, r + 1/r = 3.000000000000
λ² = 4.0: r = 0.609611796798, r + 1/r = 2.250000000000
λ² = 9.0: r = 0.717624303872, r + 1/r = 2.111111111111
double lambda2ForRatio(double r)

The other way round, rational: choose the ratio r \in \mathbb{Q} and \lambda^{2} = \frac{r}{(1 - r)^{2}}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The other way round, rational: choose r and λ² = r/(1 − r)²; then londonRatio(λ²) gives r back.
  for (final r in [0.5, 0.75, 0.8]) {
    final l2 = lambda2ForRatio(r);
    print('r = $r: λ² = $l2, londonRatio(λ²) = ${londonRatio(l2).toStringAsFixed(12)}');
  }
}
Output
r = 0.5: λ² = 2.0, londonRatio(λ²) = 0.500000000000
r = 0.75: λ² = 12.0, londonRatio(λ²) = 0.750000000000
r = 0.8: λ² = 20.00000000000001, londonRatio(λ²) = 0.800000000000
londonPowersfunction
double londonPowers(double b0, double r, int n)

The lattice London profile with a rational ratio: B_{n} = B_{0} r^{n} (multiplications only).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The lattice London profile B_n = B₀rⁿ with a rational r: multiplications only. Next to it, B₀e^{−x/λ}.
  const r = 0.75;
  final l2 = lambda2ForRatio(r);
  print('r = 3/4: λ² = $l2');
  print('B at n = 0…6: ${[for (var n = 0; n <= 6; n++) londonPowers(1, r, n)].join(', ')}');
}
Output
r = 3/4: λ² = 12.0
B at n = 0…6: 1.0, 0.75, 0.5625, 0.421875, 0.31640625, 0.2373046875, 0.177978515625
double latticeSpread(double u)

The lattice wave's spread \frac{\hat{k}^{2}}{4} for the Cayley parameter u: \frac{u^{2}}{1 + u^{2}}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The lattice wave's spread u²/(1 + u²) for the Cayley parameter u.
  for (final u in [0.0, 0.3, 1.0]) print('u = $u: spread = ${latticeSpread(u)}');
}
Output
u = 0.0: spread = 0.0
u = 0.3: spread = 0.08256880733944953
u = 1.0: spread = 0.5
stepSpreadfunction
double stepSpread(double dt, double mass2, double u)

The leapfrog oscillator's per-step spread s = (\frac{dt^{2}}{4})(m^{2} + \hat{k}^{2}) (Rational): the discrete dispersion relation with no angle. Stable while s \le 1.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The leapfrog oscillator's per-step spread s = (dt²/4)(m² + k̂²): the discrete dispersion relation, stable while s ≤ 1.
  for (final (dt, m2, u) in [(0.25, 0.5, 0.3), (0.25, 0.0, 1.0), (1.0, 2.0, 1.0)]) {
    final s = stepSpread(dt, m2, u);
    print('dt = $dt, m² = $m2, u = $u: s = $s${s <= 1 ? '' : '  (unstable)'}');
  }
}
Output
dt = 0.25, m² = 0.5, u = 0.3: s = 0.012973050458715597
dt = 0.25, m² = 0.0, u = 1.0: s = 0.03125
dt = 1.0, m² = 2.0, u = 1.0: s = 1.0
redQuadrancefunction
double redQuadrance(double omega, double k)

The red quadrance \omega^{2} - k^{2} of (\omega, k) (chromogeometry): m^{2} on the mass shell, 0 on the light cone.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The red quadrance ω² − k²: m² on the mass shell, 0 on the light cone.
  print('(ω, k) = (5, 3): ${redQuadrance(5, 3)} (mass 4)');
  print('(ω, k) = (2, 2): ${redQuadrance(2, 2)} (light)');
}

// Display only: ω for drawing the shells.
double _root(double q) {
  if (q == 0) return 0;
  var r = q;
  for (var i = 0; i < 40; i++) r = (r + q / r) / 2;
  return r;
}
Output
(ω, k) = (5, 3): 16.0 (mass 4)
(ω, k) = (2, 2): 0.0 (light)
quadrantOffunction
int quadrantOf(double re, double im)

The quadrant of (re, im): 0 for re > 0, im \ge 0; 1 for re \le 0, im > 0; 2 for re < 0, im \le 0; 3 for re \ge 0, im < 0. -1 for the origin (no direction).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The quadrant of (re, im), read off signs only; −1 for the origin.
  for (final (r, i) in [(1.0, 0.0), (0.0, 1.0), (-1.0, -0.5), (0.3, -2.0), (0.0, 0.0)]) print('($r, $i) → ${quadrantOf(r, i)}');
}
Output
(1.0, 0.0) → 0
(0.0, 1.0) → 1
(-1.0, -0.5) → 2
(0.3, -2.0) → 3
(0.0, 0.0) → -1
quarterTurnsfunction
int? quarterTurns(double ar, double ai, double br, double bi)

Signed quarter turns from a to b along the straight segment (-2 \cdots 2); null if either is the origin.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Signed quarter turns along a straight segment a → b; opposite quadrants decided by the cross product's sign.
  print('(1, 0) → (0, 1): ${quarterTurns(1, 0, 0, 1)}');
  print('(0, 1) → (1, 0): ${quarterTurns(0, 1, 1, 0)}');
  print('(1, 0.1) → (−1, 0.2): ${quarterTurns(1, 0.1, -1, 0.2)} (cross > 0)');
  print('(1, 0.1) → (−1, −0.2): ${quarterTurns(1, 0.1, -1, -0.2)} (cross < 0)');
  print('to the origin: ${quarterTurns(1, 0, 0, 0)}');
}
Output
(1, 0) → (0, 1): 1
(0, 1) → (1, 0): -1
(1, 0.1) → (−1, 0.2): 1 (cross > 0)
(1, 0.1) → (−1, −0.2): -2 (cross < 0)
to the origin: null
windingOffunction
int? windingOf(List<double> re, List<double> im)

The winding number of the closed polygon through (rek, imk) around 0 (closed back to the first point), or null if a vertex is the origin. Exact for every input: only signs and one cross product per opposite-quadrant step.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The winding number of a closed polygon around 0, by signs and one cross product per opposite-quadrant step.
  final sq = (re: [1.0, -1.0, -1.0, 1.0], im: [1.0, 1.0, -1.0, -1.0]);
  print('square around 0: ${windingOf(sq.re, sq.im)}');
  final twice = [for (var k = 0; k < 8; k++) [sq.re[k % 4], sq.im[k % 4]]];
  print('round twice: ${windingOf([for (final p in twice) p[0]], [for (final p in twice) p[1]])}');
  print('reversed: ${windingOf(sq.re.reversed.toList(), sq.im.reversed.toList())}');
  print('not around 0: ${windingOf([2.0, 3.0, 3.0], [1.0, 1.0, 2.0])}');
}
Output
square around 0: 1
round twice: 2
reversed: -1
not around 0: 0
int? windingOfExact<T>(List<T> re, List<T> im, {required int Function(T) sign, required T Function(T, T) mul, required T Function(T, T) sub})

The same count over any ordered field, given its sign function (exact rationals: Rational.compareTo).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The same count over exact rationals: give it sign, multiply and subtract. 20 powers of e(1/2) (each turn about 53°).
  const c = CayleyArith<Rational>(ExactArith());
  final re = <Rational>[], im = <Rational>[];
  final (zr, zi) = c.point(Rational.fromInt(1, 2)); // 3/5 + 4/5 i
  var p = (Rational.one, Rational.zero);
  for (var k = 0; k < 20; k++) {
    re.add(p.$1);
    im.add(p.$2);
    p = c.mul(p.$1, p.$2, zr, zi);
  }
  final n = windingOfExact<Rational>(re, im, sign: (x) => x.sign, mul: (a, b) => a * b, sub: (a, b) => a - b);
  print('e(1/2)^k, k = 0…19, closed back to 1: winding = $n; |e^19|² = ${c.quadrance(re[19], im[19])}');
}
Output
e(1/2)^k, k = 0…19, closed back to 1: winding = 3; |e^19|² = 1
expIfunction
(double, double) expI(double theta)

e^{i\theta} = (\cos \theta, \sin \theta).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';
import 'raya:math' as math;

void main() {
  // e^{iθ} = (cos θ, sin θ), next to the Cayley point for t = tan(θ/2).
  for (final th in [0.5, 1.0, math.pi / 2]) {
    final (c, s) = expI(th);
    final (r, i) = cayley(math.tan(th / 2));
    print('θ = ${th.toStringAsFixed(4)}: e^{iθ} = (${c.toStringAsFixed(12)}, ${s.toStringAsFixed(12)}), e(tan θ/2) = (${r.toStringAsFixed(12)}, ${i.toStringAsFixed(12)})');
  }
}
Output
θ = 0.5000: e^{iθ} = (0.877582561890, 0.479425538604), e(tan θ/2) = (0.877582561890, 0.479425538604)
θ = 1.0000: e^{iθ} = (0.540302305868, 0.841470984808), e(tan θ/2) = (0.540302305868, 0.841470984808)
θ = 1.5708: e^{iθ} = (0.000000000000, 1.000000000000), e(tan θ/2) = (0.000000000000, 1.000000000000)
argOffunction
double argOf(double re, double im)

Arg z by atan2.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';

void main() {
  // arg z by atan2: the angle of e(t) is 2·atan t.
  for (final t in [0.5, 1.0, 2.0]) {
    final (r, i) = cayley(t);
    print('t = $t: arg e(t) = ${argOf(r, i).toStringAsFixed(12)}');
  }
}
Output
t = 0.5: arg e(t) = 0.927295218002
t = 1.0: arg e(t) = 1.570796326795
t = 2.0: arg e(t) = 2.214297435588
int windingByAngles(List<double> re, List<double> im)

The classic vortex count: n = \operatorname{round}((\frac{1}{2\pi}) \sum_{k} \arg(\frac{s_{k + 1}}{s_{k}})) round a closed polygon, each arg by atan2.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';
import 'raya:math' as math;

void main() {
  // The classic vortex count: (1/2π)Σ arg(s_{k+1}/s_k) by atan2, rounded. It agrees with the exact sign count here.
  final re = <double>[], im = <double>[];
  for (var k = 0; k < 12; k++) {
    final a = 2 * math.pi * 2 * k / 12; // round twice
    re.add(math.cos(a) * (1 + 0.3 * (k % 3)));
    im.add(math.sin(a) * (1 + 0.3 * (k % 3)));
  }
  print('by angles: ${windingByAngles(re, im)}, by signs: ${windingOf(re, im)}');
}
Output
by angles: 2, by signs: 2
fluxQuantafunction
double fluxQuanta(Iterable<(double, double)> plaquettes)

\sum \theta_{p}: the flux of a set of plaquettes in units of the flux quantum, (\frac{1}{2\pi}) \sum \operatorname{atan2}(Im U_{p}, \operatorname{Re} U_{p}).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';

void main() {
  // Σθ_p/2π over plaquettes: 8 plaquettes each with phase e(tan(π/8)) hold 8·(π/4)/(2π) = 1 quantum.
  final t = 0.41421356237309503; // tan(π/8)
  final p = cayley(t);
  print('flux = ${fluxQuanta(List.filled(8, p)).toStringAsFixed(12)} quanta');
}
Output
flux = 1.000000000000 quanta
double londonProfile(double b0, double x, double lambda)

London's profile B(x) = B_{0} e^{-x/\lambda}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';

void main() {
  // London's continuum profile B₀e^{−x/λ}, next to the lattice profile B₀rⁿ with the matching rational r.
  const r = 0.75;
  final lambda = 1 / _ln(1 / r); // the continuum λ with e^{−1/λ} = r, for comparison
  print('x = 0…4: continuum ${[for (var x = 0; x <= 4; x++) londonProfile(1, x.toDouble(), lambda).toStringAsFixed(6)].join(', ')}');
  print('         lattice   ${[for (var n = 0; n <= 4; n++) londonPowers(1, r, n).toStringAsFixed(6)].join(', ')}');
}

double _ln(double x) {
  // ln x by the series of atanh((x − 1)/(x + 1)), display only.
  final y = (x - 1) / (x + 1);
  var s = 0.0, p = y;
  for (var k = 1; k < 60; k += 2) {
    s += p / k;
    p *= y * y;
  }
  return 2 * s;
}
Output
x = 0…4: continuum 1.000000, 0.750000, 0.562500, 0.421875, 0.316406
         lattice   1.000000, 0.750000, 0.562500, 0.421875, 0.316406
weinbergfunction
(double, double) weinberg(double g, double gp, double mW)

The weak mixing angle \theta_{W} = \operatorname{atan}(g'/g) and m_{Z} = m_{W} / \cos \theta_{W}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';

void main() {
  // The classic weak mixing angle θ_W = atan(g′/g) and m_Z = m_W/cos θ_W, next to the spread s_W.
  final (theta, mZ) = weinberg(0.652, 0.357, 80.2);
  print('θ_W = ${theta.toStringAsFixed(9)} rad, m_Z = ${mZ.toStringAsFixed(6)} GeV');
  print('spread s_W = ${Electroweak.standard.sW.toStringAsFixed(9)}');
}
Output
θ_W = 0.500957199 rad, m_Z = 91.435268 GeV
spread s_W = 0.230654797
carrierfunction
double carrier(double k, double x)

The classic wave carrier cos(kx) for a gauge-field wave packet.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';
import 'raya:math' as math;

void main() {
  // The classic wave carrier cos(kx); the rational side uses Re of the exact powers of e(u), u = tan(k/2).
  const u = 0.3;
  final k = 2 * math.atan(u);
  var pr = 1.0, pi = 0.0;
  final (zr, zi) = cayley(u);
  for (var x = 0; x <= 4; x++) {
    print('x = $x: cos(kx) = ${carrier(k, x.toDouble()).toStringAsFixed(12)}, Re e(u)^x = ${pr.toStringAsFixed(12)}');
    (pr, pi) = (pr * zr - pi * zi, pr * zi + pi * zr);
  }
}
Output
x = 0: cos(kx) = 1.000000000000, Re e(u)^x = 1.000000000000
x = 1: cos(kx) = 0.834862385321, Re e(u)^x = 0.834862385321
x = 2: cos(kx) = 0.393990404848, Re e(u)^x = 0.393990404848
x = 3: cos(kx) = -0.177006846951, Re e(u)^x = -0.177006846951
x = 4: cos(kx) = -0.689543121775, Re e(u)^x = -0.689543121775
vacuumfunction
(double, double) vacuum(double alpha, double beta, double phi)

The classic vacuum: |\psi_{0}| = \sqrt{-\frac{\alpha}{\beta}} at the phase \varphi: |\psi_{0}| e^{i\varphi}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';
import 'raya:math' as math;

void main() {
  // The classic vacuum √(−α/β)·e^{iφ}; the rational lab instead picks a rational point on the rim, e.g. (3/10, 2/5).
  final (r, i) = vacuum(-0.5, 2, math.atan2(0.4, 0.3));
  print('classic: (${r.toStringAsFixed(12)}, ${i.toStringAsFixed(12)}), |ψ|² = ${(r * r + i * i).toStringAsFixed(12)}');
  print('rational (3/10, 2/5): |ψ|² = ${Rational.fromInt(9, 100) + Rational.fromInt(16, 100)} = Q0 = −α/β = 1/4');
}
Output
classic: (0.300000000000, 0.400000000000), |ψ|² = 0.250000000000
rational (3/10, 2/5): |ψ|² = 1/4 = Q0 = −α/β = 1/4
windingPhasefunction
(double, double) windingPhase(int n, double x, double y, double cx, double cy)

The phase winding n round a centre (cx, cy): e^{in\varphi}, \varphi = \operatorname{atan2}(y - cy, x - cx) (a ring's flux state, classic).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';

void main() {
  // e^{inφ} round a centre: the classic ring flux state; its polygon winds n times (counted by signs here).
  final re = <double>[], im = <double>[];
  for (final (x, y) in [(3, 0), (3, 3), (0, 3), (-3, 3), (-3, 0), (-3, -3), (0, -3), (3, -3)]) {
    final (r, i) = windingPhase(2, x.toDouble(), y.toDouble(), 0, 0);
    re.add(r);
    im.add(i);
  }
  print('n = 2 sampled at 8 points round the centre: winding by signs = ${windingOf(re, im)}');
}
Output
n = 2 sampled at 8 points round the centre: winding by signs = 2

Classes

final class CayleyArith<T>

Exact helpers over any field T (\mathbb{Q} with riptide_precision's Rational).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Exact U(1) phases over ℚ: points, products and powers stay exactly on the unit circle.
  const c = CayleyArith<Rational>(ExactArith());
  final (re, im) = c.point(Rational.fromInt(1, 2));
  final pts = <List<Object>>[];
  for (var n = 0; n <= 12; n++) {
    final (pr, pi) = c.power(re, im, n);
    pts.add([pr.toDouble(), pi.toDouble(), '$n']);
    if (n == 12) print('e(1/2)^12 = ($pr, $pi), quadrance ${c.quadrance(pr, pi)}');
  }
  print('half-turn spread of e(1/2): ${c.halfTurnSpread(re)}');
}
Output
e(1/2)^12 = (32125393/244140625, -242017776/244140625), quadrance 1
half-turn spread of e(1/2): 1/5

Constructors

CayleyArithconstructor
const CayleyArith(this.f)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // CayleyArith(f) over exact rationals or doubles.
  const q = CayleyArith<Rational>(ExactArith()), d = CayleyArith<double>(F64Arith());
  print('exact e(2/3) = ${q.point(Rational.fromInt(2, 3))}');
  print('float e(2/3) = ${d.point(2 / 3)}');
}
Output
exact e(2/3) = (5/13, 12/13)
float e(2/3) = (0.38461538461538464, 0.923076923076923)

Properties

ffield
final KeplerArith<T> f

Methods

pointmethod
(T, T) point(T t)

e(t): (\frac{1 - t^{2}}{1 + t^{2}}, \frac{2t}{1 + t^{2}}).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // point(t): Pythagorean triples come out: t = 1/2 → (3/5, 4/5), t = 2/3 → (5/13, 12/13), t = 3/4 → (7/25, 24/25).
  const c = CayleyArith<Rational>(ExactArith());
  for (final (n, d) in [(1, 2), (2, 3), (3, 4), (1, 5)]) print('e($n/$d) = ${c.point(Rational.fromInt(n, d))}');
}
Output
e(1/2) = (3/5, 4/5)
e(2/3) = (5/13, 12/13)
e(3/4) = (7/25, 24/25)
e(1/5) = (12/13, 5/13)
quadrancemethod
T quadrance(T re, T im)

re^{2} + im^{2} (1 exactly for every Cayley point and every product of them).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // quadrance(re, im) = re² + im²: exactly 1 for every Cayley point.
  const c = CayleyArith<Rational>(ExactArith());
  final (a, b) = c.point(Rational.fromInt(7, 11));
  print('e(7/11) = ($a, $b), quadrance = ${c.quadrance(a, b)}');
  print('quadrance(3, 4) = ${c.quadrance(Rational.fromInt(3), Rational.fromInt(4))}');
}
Output
e(7/11) = (36/85, 77/85), quadrance = 1
quadrance(3, 4) = 25
mulmethod
(T, T) mul(T a, T b, T c, T d)

(a + ib)(c + \operatorname{id}).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // mul(a, b, c, d) = (a + ib)(c + id): the product of two Cayley points is a Cayley point.
  const c = CayleyArith<Rational>(ExactArith());
  final (a, b) = c.point(Rational.fromInt(1, 2));
  final (x, y) = c.point(Rational.fromInt(2, 3));
  final (pr, pi) = c.mul(a, b, x, y);
  print('e(1/2)·e(2/3) = ($pr, $pi), quadrance ${c.quadrance(pr, pi)}, = e(7/4): ${c.point(Rational.fromInt(7, 4))}');
}
Output
e(1/2)·e(2/3) = (-33/65, 56/65), quadrance 1, = e(7/4): (-33/65, 56/65)
powermethod
(T, T) power(T re, T im, int n)

The n-th power of a unit number by repeated multiplication (n \ge 0); exact.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // power(re, im, n) by repeated multiplication; exact for every n.
  const c = CayleyArith<Rational>(ExactArith());
  final (a, b) = c.point(Rational.fromInt(1, 3));
  for (final n in [1, 2, 4, 8]) {
    final (pr, pi) = c.power(a, b, n);
    print('e(1/3)^$n = ($pr, $pi)');
  }
}
Output
e(1/3)^1 = (4/5, 3/5)
e(1/3)^2 = (7/25, 24/25)
e(1/3)^4 = (-527/625, 336/625)
e(1/3)^8 = (164833/390625, -354144/390625)
T halfTurnSpread(T re)

The half-turn spread \frac{1 - re}{2} of a unit number.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // halfTurnSpread(re) = (1 − re)/2 = t²/(1 + t²), exact.
  const c = CayleyArith<Rational>(ExactArith());
  for (final (n, d) in [(0, 1), (1, 2), (1, 1), (3, 1)]) {
    final t = Rational.fromInt(n, d);
    print('t = $t: ${c.halfTurnSpread(c.point(t).$1)}');
  }
}
Output
t = 0: 0
t = 1/2: 1/5
t = 1: 1/2
t = 3: 9/10
final class ExactGaugeLattice<T>

The lattice model over T, stepped the rational way.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The lattice over ℚ: Hamiltonian steps keep every |U|² = 1 and Gauss's law exactly.
  // The same start in doubles (the rational way, held to rounding) for the same 2 steps.
  const f = ExactArith(), c = CayleyArith<Rational>(ExactArith());
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final geo = LatticeGeometry(3, 3, periodicX: true, periodicY: true);
  final ex = ExactGaugeLattice<Rational>(geo, f, alpha: r(-1, 2), beta: r(1), g2: r(1), sign: (x) => x.sign);
  final fl = GaugeLattice(geo, alpha: -0.5, beta: 1, g2: 1);
  final taus = [r(1, 3), r(-1, 2), r(2, 5), r(1, 7), r(-3, 4), r(1, 2)];
  for (var i = 0; i < geo.sites; i++) {
    ex.pr[i] = r(i % 3 - 1, 2 + i % 2);
    ex.pi[i] = r((i * 5) % 7 - 3, 4);
    fl.pr[i] = ex.pr[i].toDouble();
    fl.pi[i] = ex.pi[i].toDouble();
    ex.qr[i] = r(1, 4 + i); // a momentum π, so Gauss's law starts nonzero
    fl.qr[i] = ex.qr[i].toDouble();
    for (var mu = 0; mu < 2; mu++) {
      final (re, im) = c.point(taus[(2 * i + mu) % taus.length]);
      ex.ur[2 * i + mu] = re;
      ex.ui[2 * i + mu] = im;
      fl.ur[2 * i + mu] = re.toDouble();
      fl.ui[2 * i + mu] = im.toDouble();
    }
  }
  final g0 = [for (var i = 0; i < geo.sites; i++) ex.gauss(i)];
  for (var k = 0; k < 2; k++) {
    ex.evolve(r(1, 10));
    fl.evolve(0.1);
  }
  print('exact, 2 steps: Gauss unchanged at every site: ${[for (var i = 0; i < geo.sites; i++) ex.gauss(i) == g0[i]].every((b) => b)}, every |U|² = 1: ${ex.linkQuadrances().every((q) => q == Rational.one)}');
  var worst = 0.0;
  for (var i = 0; i < geo.sites; i++) {
    final d = (fl.gauss(i) - g0[i].toDouble()).abs();
    if (d > worst) worst = d;
  }
  print('float, 2 steps: max |Gauss − start| = ${worst == 0 ? '0' : worst.toStringAsExponential(1)}, max ||U|² − 1| = ${fl.unitDrift().toStringAsExponential(1)}');
  print('exact energy after 2 steps ≈ ${ex.energy().toDouble().toStringAsFixed(12)} (denominator ${ex.energy().denominator.bitLength} bits); float ${fl.energy().toStringAsFixed(12)}');
}
Output
exact, 2 steps: Gauss unchanged at every site: true, every |U|² = 1: true
float, 2 steps: max |Gauss − start| = 1.7e-16, max ||U|² − 1| = 2.2e-16
exact energy after 2 steps ≈ 15.690112885332 (denominator 9502 bits); float 15.690112885332

Constructors

ExactGaugeLattice(this.geometry, this.f, {required this.alpha, required this.beta, required this.g2, required this.sign})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // ExactGaugeLattice(geometry, f, alpha:, beta:, g2:, sign:): ψ = 0, U = 1, E = 0; sign is for the exact winding.
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(2, 2, periodicX: true, periodicY: true), const ExactArith(),
      alpha: Rational.fromInt(-1), beta: Rational.one, g2: Rational.one, sign: (x) => x.sign);
  print('${l.pr.length} sites, ${l.ur.length} links, F = ${l.energy()}');
}
Output
4 sites, 8 links, F = 0

Properties

final LatticeGeometry geometry
ffield
final KeplerArith<T> f
signfield
final int Function(T) sign

The sign of a value (-1, 0, 1), for the exact winding count.

prfield
final List<T> pr
pifield
final List<T> pi
qrfield
final List<T> qr
qifield
final List<T> qi
urfield
final List<T> ur
uifield
final List<T> ui
elfield
final List<T> el
alphafield
T alpha
betafield
T beta
g2field
T g2
hrfield
T hr
hifield
T hi
grfield
late List<T> gr
gifield
late List<T> gi
flfield
late List<T> fl

Methods

void computeForces()
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // computeForces(): exact forces gr, gi (per site) and fl (per link).
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(2, 1), const ExactArith(), alpha: r(-1), beta: r(1), g2: r(1), sign: (x) => x.sign);
  l.pr[0] = r(1);
  l.pr[1] = r(1, 2);
  final (cr, ci) = const CayleyArith<Rational>(ExactArith()).point(r(1, 2));
  l.ur[0] = cr;
  l.ui[0] = ci;
  l.computeForces();
  print('∂F/∂ψ̄ = (${l.gr[0]}, ${l.gi[0]}), (${l.gr[1]}, ${l.gi[1]}); ∂F/∂θ on the link = ${l.fl[0]}');
}
Output
∂F/∂ψ̄ = (7/10, 2/5), (-19/40, -4/5); ∂F/∂θ on the link = 4/5
energymethod
T energy()

The free energy, exactly.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // energy(): the free energy as an exact rational; two exact relaxation steps lower it.
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(2, 2, periodicX: true, periodicY: true), const ExactArith(),
      alpha: r(-1, 2), beta: r(1), g2: r(1), sign: (x) => x.sign);
  for (var i = 0; i < 4; i++) {
    l.pr[i] = r(i + 1, 5);
    l.pi[i] = r(1, 3);
  }
  final e0 = l.energy();
  l.relax(r(1, 10));
  final e1 = l.energy();
  print('F = $e0 ≈ ${e0.toDouble().toStringAsFixed(9)}');
  print('after one step F ≈ ${e1.toDouble().toStringAsFixed(9)} (exact, ${e1.denominator.bitLength}-bit denominator), lower: ${e1 < e0}');
}
Output
F = 21212/50625 ≈ 0.419002469
after one step F ≈ -0.213771971 (exact, 91-bit denominator), lower: true
relaxmethod
void relax(T dt)

One time-dependent Ginzburg–Landau step (as GaugeLattice.relax, rational way).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // relax(dt): an exact gradient-flow step; links turn by Cayley points, so |U|² stays exactly 1.
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(3, 2), const ExactArith(), alpha: r(-1), beta: r(1), g2: r(1), sign: (x) => x.sign);
  for (var i = 0; i < 6; i++) {
    l.pr[i] = r(1, 2);
    l.pi[i] = r(i - 2, 4);
  }
  for (var k = 0; k < 2; k++) l.relax(r(1, 5));
  print('after 2 steps every |U|² = 1: ${l.linkQuadrances().every((q) => q == Rational.one)}');
  print('U of link 0 = (${l.ur[0].toDouble().toStringAsFixed(9)}, ${l.ui[0].toDouble().toStringAsFixed(9)}), denominators ${l.ur[0].denominator.bitLength} bits');
}
Output
after 2 steps every |U|² = 1: true
U of link 0 = (0.995698037, 0.092657534), denominators 62 bits
evolvemethod
void evolve(T dt)

One Hamiltonian step (as GaugeLattice.evolve, rational way, no friction).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // evolve(dt): an exact symplectic Euler step; Gauss's law at every site is unchanged, exactly.
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(2, 2, periodicX: true, periodicY: true), const ExactArith(),
      alpha: r(-1, 2), beta: r(2), g2: r(1), sign: (x) => x.sign);
  for (var i = 0; i < 4; i++) {
    l.pr[i] = r(3, 10);
    l.pi[i] = r(i, 5);
    l.qi[i] = r(1, 3 + i); // a momentum π, so Gauss's law starts nonzero
  }
  final g0 = [for (var i = 0; i < 4; i++) l.gauss(i)];
  for (var k = 0; k < 3; k++) l.evolve(r(1, 4));
  print('Gauss before ${g0.join(', ')}; after 3 steps ${[for (var i = 0; i < 4; i++) l.gauss(i)].join(', ')}');
}
Output
Gauss before -1/5, -3/20, -3/25, -1/10; after 3 steps -1/5, -3/20, -3/25, -1/10
gaussmethod
T gauss(int i)

Gauss's law at i: \sum_{\mathrm{out}} E - \sum_{in} E + 2 \operatorname{Im}(\bar{\pi}\psi).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // gauss(i): Σ_out E − Σ_in E + 2 Im(π̄ψ), exact.
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(3, 1, periodicX: true, periodicY: true), const ExactArith(),
      alpha: Rational.fromInt(-1), beta: Rational.one, g2: Rational.one, sign: (x) => x.sign);
  l.el[0] = Rational.fromInt(1, 3);
  l.pr[2] = Rational.one;
  l.qi[2] = Rational.fromInt(1, 2);
  print([for (var i = 0; i < 3; i++) l.gauss(i)].join(', '));
}
Output
1/3, -1/3, -1
Iterable<T> linkQuadrances()

Every link's quadrance |U|^{2}, which stays exactly 1.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // linkQuadrances(): |U|² of every existing link, exactly 1 after any number of exact steps.
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final l = ExactGaugeLattice<Rational>(LatticeGeometry(2, 2), const ExactArith(), alpha: r(-1), beta: r(1), g2: r(1), sign: (x) => x.sign);
  for (var i = 0; i < 4; i++) l.pr[i] = r(i, 3);
  l.relax(r(1, 3));
  print(l.linkQuadrances().join(', '));
}
Output
1, 1, 1, 1
void applyGauge(List<T> gRe, List<T> gIm)

\psi \to g\psi, \pi \to g\pi, U_{l} \to g_{j} U_{l} \bar{g}_{i}, exactly.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // applyGauge: a rational gauge turn at every site leaves the exact energy exactly equal.
  const c = CayleyArith<Rational>(ExactArith());
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final geo = LatticeGeometry(3, 3, periodicX: true, periodicY: true);
  final l = ExactGaugeLattice<Rational>(geo, const ExactArith(), alpha: r(-1, 2), beta: r(1), g2: r(1), sign: (x) => x.sign);
  for (var i = 0; i < geo.sites; i++) {
    l.pr[i] = r(i % 3, 4);
    l.pi[i] = r(1, 1 + i);
    final (a, b) = c.point(r(i, 5));
    l.ur[2 * i] = a;
    l.ui[2 * i] = b;
  }
  final e0 = l.energy();
  final g = [for (var i = 0; i < geo.sites; i++) c.point(r(i - 4, 3 + i))];
  l.applyGauge([for (final t in g) t.$1], [for (final t in g) t.$2]);
  print('F ≈ ${e0.toDouble().toStringAsFixed(12)} (exact, ${e0.denominator.bitLength}-bit denominator)');
  print('after the gauge transformation: equal exactly: ${l.energy() == e0}');
}
Output
F ≈ 7.973005846745 (exact, 82-bit denominator)
after the gauge transformation: equal exactly: true
vortexAtmethod
int vortexAt(int i)

The vortex number of the plaquette at i, by exact signs.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // vortexAt(i): exact vortex number by signs of exact rationals.
  Rational r(int n, [int d = 1]) => Rational.fromInt(n, d);
  final geo = LatticeGeometry(4, 4);
  final l = ExactGaugeLattice<Rational>(geo, const ExactArith(), alpha: r(-1), beta: r(1), g2: r(1), sign: (x) => x.sign);
  for (var i = 0; i < geo.sites; i++) {
    l.pr[i] = r(2 * geo.xOf(i) - 3, 2);
    l.pi[i] = r(2 * geo.yOf(i) - 3, 2);
  }
  print([for (var i = 0; i < geo.sites; i++) if (l.vortexAt(i) != 0) 'plaquette (${geo.xOf(i)}, ${geo.yOf(i)}): ${l.vortexAt(i)}'].join(', '));
}
Output
plaquette (1, 1): 1
class

Ramp

final class Ramp

A value that ramps linearly from from to to over length steps after start.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // A value ramping linearly from `from` to `to` over `length` steps after `start`: the labs' temperature and field knobs.
  const r = Ramp(-0.25, 0.25, 10, 20);
  print([for (final s in [0, 10, 15, 20, 30, 40]) 'at($s) = ${r.at(s)}'].join(', '));
  print('settled at 25: ${r.settledAt(25)}, at 30: ${r.settledAt(30)}');
}
Output
at(0) = -0.25, at(10) = -0.25, at(15) = -0.125, at(20) = 0.0, at(30) = 0.25, at(40) = 0.25
settled at 25: false, at 30: true

Constructors

Rampconstructor
const Ramp(this.from, [double? to, this.start = 0, this.length = 0])
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Ramp(from, [to, start, length]): with only `from` it is a constant.
  const c = Ramp(0.015), r = Ramp(0, 0.055, 0, 1500);
  print('constant: ${c.at(0)}, ${c.at(999)}; rising field at 750: ${r.at(750)}');
}
Output
constant: 0.015, 0.015; rising field at 750: 0.0275

Properties

fromfield
final double from
tofield
final double to
startfield
final int start
lengthfield
final int length

Methods

atmethod
double at(int step)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // at(step): the value at a step.
  const r = Ramp(1, 0, 5, 4);
  print([for (var s = 4; s <= 10; s++) '${r.at(s)}'].join(', '));
}
Output
1.0, 1.0, 0.75, 0.5, 0.25, 0.0, 0.0
settledAtmethod
bool settledAt(int step)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // settledAt(step): whether the ramp has finished.
  const r = Ramp(0, 1, 100, 50);
  print([for (final s in [0, 120, 149, 150]) 'settledAt($s) = ${r.settledAt(s)}'].join(', '));
}
Output
settledAt(0) = false, settledAt(120) = false, settledAt(149) = false, settledAt(150) = true
enum SuperconductorType

Type I (\kappa^{2} < \frac{1}{2}: the whole field is expelled) or type II (\kappa^{2} > \frac{1}{2}: it enters as vortices).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The materials of the lab: κ² = β/(2g²) decides type I (< 1/2) or type II (> 1/2); ψ₀² = depth/β exactly.
  for (final t in SuperconductorType.values) {
    final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
    print('${t.name}: β = ${t.beta}, g² = ${t.g2}, κ² = ${p.kappa2}, ${p.typeII ? 'type II' : 'type I'}, ξ² = ${p.xi2}, λ² = ${p.lambda2}, ψ0² = ${t.psi0 * t.psi0} = Q0 = ${p.q0}');
  }
}
Output
typeI: β = 1.0, g² = 2.0, κ² = 0.25, type I, ξ² = 36.0, λ² = 9.0, ψ0² = 0.027777777777777776 = Q0 = 0.027777777777777776
meissner: β = 1.0, g² = 0.5, κ² = 1.0, type II, ξ² = 9.0, λ² = 9.0, ψ0² = 0.1111111111111111 = Q0 = 0.1111111111111111
ring: β = 1.0, g² = 0.5, κ² = 1.0, type II, ξ² = 4.0, λ² = 4.0, ψ0² = 0.25 = Q0 = 0.25
thinRing: β = 1.0, g² = 0.02, κ² = 25.0, type II, ξ² = 16.0, λ² = 400.0, ψ0² = 0.0625 = Q0 = 0.0625
bulk: β = 4.0, g² = 0.125, κ² = 16.0, type II, ξ² = 4.0, λ² = 64.0, ψ0² = 0.0625 = Q0 = 0.0625
typeII: β = 4.0, g² = 0.5, κ² = 4.0, type II, ξ² = 4.0, λ² = 16.0, ψ0² = 0.0625 = Q0 = 0.0625

Values

typeIvalue
typeI(beta: 1, g2: 2, depth: 1 / 36, psi0: 1 / 6)

\kappa^{2} = \frac{\beta}{2g^{2}} = \frac{1}{4}: \xi = 6, \lambda = 3 sites (\xi^{2} = \frac{1}{|\alpha|} = 36, \lambda^{2} = \frac{1}{2g^{2}Q_{0}} = 9), \psi_{0} = \frac{1}{6}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorType.typeI: its parameters and what they make.
  const t = SuperconductorType.typeI;
  final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
  print('β = ${t.beta}, g² = ${t.g2}, depth |α| = ${t.depth}, ψ0 = ${t.psi0}');
  print('ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2} (${p.typeII ? 'type II' : 'type I'})');
}
Output
β = 1.0, g² = 2.0, depth |α| = 0.027777777777777776, ψ0 = 0.16666666666666666
ξ² = 36.0, λ² = 9.0, κ² = 0.25 (type I)
meissner(beta: 1, g2: 0.5, depth: 1 / 9, psi0: 1 / 3)

\kappa^{2} = 1 (just type II): \xi = \lambda = 3 sites, \psi_{0} = \frac{1}{3}. Below H_{c1} a vortex is pushed out by the surface: the Meissner disc.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorType.meissner: its parameters and what they make.
  const t = SuperconductorType.meissner;
  final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
  print('β = ${t.beta}, g² = ${t.g2}, depth |α| = ${t.depth}, ψ0 = ${t.psi0}');
  print('ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2} (${p.typeII ? 'type II' : 'type I'})');
}
Output
β = 1.0, g² = 0.5, depth |α| = 0.1111111111111111, ψ0 = 0.3333333333333333
ξ² = 9.0, λ² = 9.0, κ² = 1.0 (type II)
ringvalue
ring(beta: 1, g2: 0.5, depth: 0.25, psi0: 0.5)

\kappa^{2} = 1: \xi = \lambda = 2 sites, \psi_{0} = \frac{1}{2}: a ring several \lambda thick, so the flux it holds is close to whole quanta.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorType.ring: its parameters and what they make.
  const t = SuperconductorType.ring;
  final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
  print('β = ${t.beta}, g² = ${t.g2}, depth |α| = ${t.depth}, ψ0 = ${t.psi0}');
  print('ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2} (${p.typeII ? 'type II' : 'type I'})');
}
Output
β = 1.0, g² = 0.5, depth |α| = 0.25, ψ0 = 0.5
ξ² = 4.0, λ² = 4.0, κ² = 1.0 (type II)
thinRing(beta: 1, g2: 0.02, depth: 1 / 16, psi0: 0.25)

A thin ring (three sites across, under \xi): \xi = 4, \lambda = 20 sites (\kappa^{2} = 25), \psi_{0} = \frac{1}{4}. The field goes straight through (\lambda is far wider than the ring), the current grows with it until the condensate gives way at one point and the phase slips: the fluxoid changes by one.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorType.thinRing: its parameters and what they make.
  const t = SuperconductorType.thinRing;
  final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
  print('β = ${t.beta}, g² = ${t.g2}, depth |α| = ${t.depth}, ψ0 = ${t.psi0}');
  print('ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2} (${p.typeII ? 'type II' : 'type I'})');
}
Output
β = 1.0, g² = 0.02, depth |α| = 0.0625, ψ0 = 0.25
ξ² = 16.0, λ² = 400.0, κ² = 25.0 (type II)
bulkvalue
bulk(beta: 4, g2: 0.125, depth: 0.25, psi0: 0.25)

\kappa^{2} = 16: \xi = 2, \lambda = 8 sites, \psi_{0} = \frac{1}{4}: vortices 10 apart feel each other strongly and order.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorType.bulk: its parameters and what they make.
  const t = SuperconductorType.bulk;
  final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
  print('β = ${t.beta}, g² = ${t.g2}, depth |α| = ${t.depth}, ψ0 = ${t.psi0}');
  print('ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2} (${p.typeII ? 'type II' : 'type I'})');
}
Output
β = 4.0, g² = 0.125, depth |α| = 0.25, ψ0 = 0.25
ξ² = 4.0, λ² = 64.0, κ² = 16.0 (type II)
typeIIvalue
typeII(beta: 4, g2: 0.5, depth: 0.25, psi0: 0.25)

\kappa^{2} = 4: \xi = 2, \lambda = 4 sites, \psi_{0} = \frac{1}{4}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorType.typeII: its parameters and what they make.
  const t = SuperconductorType.typeII;
  final p = GLParameters(alpha: -t.depth, beta: t.beta, g2: t.g2);
  print('β = ${t.beta}, g² = ${t.g2}, depth |α| = ${t.depth}, ψ0 = ${t.psi0}');
  print('ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2} (${p.typeII ? 'type II' : 'type I'})');
}
Output
β = 4.0, g² = 0.5, depth |α| = 0.25, ψ0 = 0.25
ξ² = 4.0, λ² = 16.0, κ² = 4.0 (type II)

Constructors

const SuperconductorType({required this.beta, required this.g2, required this.depth, required this.psi0})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // const SuperconductorType({beta, g2, depth, psi0}): enum values only; read them through the values.
  print([for (final t in SuperconductorType.values) '${t.name} (β ${t.beta}, g² ${t.g2})'].join(', '));
}
Output
typeI (β 1.0, g² 2.0), meissner (β 1.0, g² 0.5), ring (β 1.0, g² 0.5), thinRing (β 1.0, g² 0.02), bulk (β 4.0, g² 0.125), typeII (β 4.0, g² 0.5)

Properties

betafield
final double beta
g2field
final double g2
depthfield
final double depth
\alphabelow T_{c}.
psi0field
final double psi0

A rational point on the rim: \psi_{0}^{2} = Q_{0} = depth/\beta exactly (no root).

enum SuperconductorPreset

The superconductor experiments: their shapes and presets.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The twelve presets, their material and shape.
  for (final p in SuperconductorPreset.values) {
    final e = SuperconductorExperiment(preset: p, size: 16);
    print('${p.name}: ${SuperconductorExperiment.typeFor(p).name}, ${e.shape.name}');
  }
}
Output
coolInField: meissner, disc
fieldAfterCooling: meissner, disc
warmUp: meissner, disc
fieldEnters: typeII, square
fieldCooled: typeII, square
strongField: typeII, square
typeIForComparison: typeI, square
triangularLattice: bulk, torus
trapFlux: ring, ring
screenField: ring, ring
fluxJumps: thinRing, thinRing
windThree: ring, ring

Values

coolInField

Cool a type-I disc through T_{c} in a field: the field is pushed out to a skin of depth \lambda.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.coolInField: A cold front grows from the middle of a disc in a field, pushing the field out.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.coolInField, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('field inside the disc / applied: ${e.insideFieldShare().toStringAsFixed(4)}');
}
Output
material meissner, shape disc, field parameter now 0.015000, cold: true
F: start 0.122039, after 100 steps -0.305748; vortices now 0
field inside the disc / applied: 0.9394
fieldAfterCooling

Cool first, then switch the field on: it never gets in.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.fieldAfterCooling: Cool first, then switch the field on: it stays out of the disc.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('field inside the disc / applied: ${e.insideFieldShare().toStringAsFixed(4)}');
}
Output
material meissner, shape disc, field parameter now 0.003000, cold: true
F: start -1.283951, after 100 steps -1.273180; vortices now 0
field inside the disc / applied: 0.0056
warmUpvalue
warmUp

Warm the cooled disc above T_{c}: the field floods back in.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.warmUp: A cooled disc in a field, warmed above T_c from step 150.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.warmUp, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('field inside the disc / applied: ${e.insideFieldShare().toStringAsFixed(4)}');
}
Output
material meissner, shape disc, field parameter now 0.015000, cold: false
F: start -0.807958, after 100 steps -1.176652; vortices now 0
field inside the disc / applied: 0.2963
fieldEnters

A type-II square in a rising field: flux enters as vortices from the edges and settles into a lattice.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.fieldEnters: A type-II square in a slowly rising field.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldEnters, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('flux in the sample: ${e.fluxQuantaInSample().toStringAsFixed(4)} quanta');
}
Output
material typeII, shape square, field parameter now 0.003667, cold: true
F: start -3.125000, after 100 steps -3.112700; vortices now 0
flux in the sample: 0.1053 quanta
fieldCooled

Cooled in the field: vortices and antivortices everywhere, annihilating, then ordering.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.fieldCooled: A type-II square cooled in a field from noise.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldCooled, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('flux in the sample: ${e.fluxQuantaInSample().toStringAsFixed(4)} quanta');
}
Output
material typeII, shape square, field parameter now 0.050000, cold: true
F: start 2.878984, after 100 steps -0.016644; vortices now 4
flux in the sample: 5.7400 quanta
strongField

A strong field: a dense vortex lattice.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.strongField: A type-II square in a strong rising field.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.strongField, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('flux in the sample: ${e.fluxQuantaInSample().toStringAsFixed(4)} quanta');
}
Output
material typeII, shape square, field parameter now 0.008333, cold: true
F: start -3.125000, after 100 steps -3.061470; vortices now 0
flux in the sample: 0.2393 quanta
typeIForComparison

The same field on a type-I square: no vortex lattice.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.typeIForComparison: The fieldEnters ramp on a type-I square.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.typeIForComparison, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('flux in the sample: ${e.fluxQuantaInSample().toStringAsFixed(4)} quanta');
}
Output
material typeI, shape square, field parameter now 0.003667, cold: true
F: start -0.154321, after 100 steps -0.149518; vortices now 0
flux in the sample: 0.0260 quanta
triangularLattice

A piece of the bulk, wrapped so it has no edges (a torus \sqrt{3} times taller than wide), holding exactly 32 flux quanta: cooled from noise, the vortices settle into Abrikosov's triangular lattice (six neighbours each).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.triangularLattice: A periodic 40 × 69 tile holding exactly 32 flux quanta, cooled from noise.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.triangularLattice, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('flux in the sample: ${e.fluxQuantaInSample().toStringAsFixed(4)} quanta');
}
Output
material bulk, shape torus, field parameter now 0.036440, cold: true
F: start 3.121255, after 100 steps 0.000000; vortices now 32
flux in the sample: 32.0000 quanta
trapFlux

Cool a ring in a field, then switch the field off: whole flux quanta stay trapped, held by a persistent current.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.trapFlux: A ring cooled in a field, the field then switched off.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.trapFlux, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('fluxoid round the ring: ${e.ringWinding()}, flux through the loop ${e.ringFluxQuanta().toStringAsFixed(4)} quanta');
}
Output
material ring, shape ring, field parameter now 0.011364, cold: true
F: start 1216.680930, after 100 steps -5.571958; vortices now 0
fluxoid round the ring: 4, flux through the loop 3.0181 quanta
screenField

Switch a field on round a cold ring: the hole stays at zero flux (the fluxoid can't change without a vortex).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.screenField: A field switched on round a cold ring.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.screenField, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('fluxoid round the ring: ${e.ringWinding()}, flux through the loop ${e.ringFluxQuanta().toStringAsFixed(4)} quanta');
}
Output
material ring, shape ring, field parameter now 0.000000, cold: true
F: start -11.000000, after 100 steps -11.000000; vortices now 0
fluxoid round the ring: 0, flux through the loop 0.0000 quanta
fluxJumps

A thin ring in a slowly rising field: the fluxoid steps up one quantum at a time (phase slips), a sawtooth of current.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.fluxJumps: A thin ring with a weak link in a slowly rising field.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fluxJumps, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('fluxoid round the ring: ${e.ringWinding()}, flux through the loop ${e.ringFluxQuanta().toStringAsFixed(4)} quanta');
}
Output
material thinRing, shape thinRing, field parameter now 0.000167, cold: true
F: start -0.005469, after 100 steps -0.020940; vortices now 0
fluxoid round the ring: 0, flux through the loop 0.0003 quanta
windThree

Start the ring's phase winding three times round (rational points that go round three times), no field.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorPreset.windThree: A ring whose phase starts wound three times round, no field.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.windThree, size: 24);
  final s0 = e.lattice.energy();
  e.advance(100);
  print('material ${e.type.name}, shape ${e.shape.name}, field parameter now ${e.field.toStringAsFixed(6)}, cold: ${e.cold}');
  print('F: start ${s0.toStringAsFixed(6)}, after 100 steps ${e.lattice.energy().toStringAsFixed(6)}; vortices now ${e.vortices().length}');
  print('fluxoid round the ring: ${e.ringWinding()}, flux through the loop ${e.ringFluxQuanta().toStringAsFixed(4)} quanta');
}
Output
material ring, shape ring, field parameter now 0.000000, cold: true
F: start 264.494073, after 100 steps -7.214624; vortices now 0
fluxoid round the ring: 3, flux through the loop 2.3866 quanta
enum SuperconductorShape
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The sample shapes: which sites are superconducting.
  for (final s in SuperconductorShape.values) print(s.name);
  final e = SuperconductorExperiment(preset: SuperconductorPreset.trapFlux, size: 20);
  final g = e.lattice.geometry;
  print('ring of size 20: ${[for (var i = 0; i < g.sites; i++) g.sc[i]].where((x) => x == 1).length} superconducting sites of ${g.sites}');
}
Output
disc
square
torus
ring
thinRing
ring of size 20: 244 superconducting sites of 400

Values

discvalue
disc
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorShape.disc (used by coolInField).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.coolInField, size: 20);
  final g = e.lattice.geometry;
  print('shape ${e.shape.name}: ${g.nx} × ${g.ny} sites, periodic: ${g.periodicX}, superconducting: ${[for (var i = 0; i < g.sites; i++) g.sc[i]].where((x) => x == 1).length}');
}
Output
shape disc: 20 × 20 sites, periodic: false, superconducting: 148
squarevalue
square
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorShape.square (used by fieldEnters).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldEnters, size: 20);
  final g = e.lattice.geometry;
  print('shape ${e.shape.name}: ${g.nx} × ${g.ny} sites, periodic: ${g.periodicX}, superconducting: ${[for (var i = 0; i < g.sites; i++) g.sc[i]].where((x) => x == 1).length}');
}
Output
shape square: 20 × 20 sites, periodic: false, superconducting: 256
torusvalue
torus
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorShape.torus (used by triangularLattice).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.triangularLattice, size: 20);
  final g = e.lattice.geometry;
  print('shape ${e.shape.name}: ${g.nx} × ${g.ny} sites, periodic: ${g.periodicX}, superconducting: ${[for (var i = 0; i < g.sites; i++) g.sc[i]].where((x) => x == 1).length}');
}
Output
shape torus: 40 × 69 sites, periodic: true, superconducting: 2760
ringvalue
ring
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorShape.ring (used by trapFlux).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.trapFlux, size: 20);
  final g = e.lattice.geometry;
  print('shape ${e.shape.name}: ${g.nx} × ${g.ny} sites, periodic: ${g.periodicX}, superconducting: ${[for (var i = 0; i < g.sites; i++) g.sc[i]].where((x) => x == 1).length}');
}
Output
shape ring: 20 × 20 sites, periodic: false, superconducting: 244
thinRing
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorShape.thinRing (used by fluxJumps).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fluxJumps, size: 20);
  final g = e.lattice.geometry;
  print('shape ${e.shape.name}: ${g.nx} × ${g.ny} sites, periodic: ${g.periodicX}, superconducting: ${[for (var i = 0; i < g.sites; i++) g.sc[i]].where((x) => x == 1).length}');
}
Output
shape thinRing: 20 × 20 sites, periodic: false, superconducting: 20
extension on SuperconductorPreset
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The extension on SuperconductorPreset gives each preset its shape (read here through SuperconductorExperiment.shape).
  for (final p in SuperconductorPreset.values) print('${p.name} → ${SuperconductorExperiment(preset: p, size: 12).shape.name}');
}
Output
coolInField → disc
fieldAfterCooling → disc
warmUp → disc
fieldEnters → square
fieldCooled → square
strongField → square
typeIForComparison → square
triangularLattice → torus
trapFlux → ring
screenField → ring
fluxJumps → thinRing
windThree → ring

Properties

shapegetter
SuperconductorShape get shape
final class SuperconductorExperiment

A superconducting sample on the lattice, relaxed by time-dependent Ginzburg–Landau.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // A ring whose condensate starts wound three times round, relaxed both ways (rational links and classic angles),
  // 400 steps each. The fluxoid is counted exactly by signs on the rational side, by atan2 on the classic side.
  final a = SuperconductorExperiment(preset: SuperconductorPreset.windThree, size: 28);
  final b = a.twin(LinkMaths.classic);
  final ea = <List<double>>[], eb = <List<double>>[];
  for (var k = 0; k <= 400; k += 20) {
    ea.add([k.toDouble(), a.lattice.energy()]);
    eb.add([k.toDouble(), b.lattice.energy()]);
    if (k < 400) {
      a.advance(20);
      b.advance(20);
    }
  }
  print('rational: fluxoid ${a.ringWinding()}, flux through the loop ${a.ringFluxQuanta().toStringAsFixed(6)} quanta, F = ${a.lattice.energy().toStringAsFixed(8)}');
  print('classic:  fluxoid ${b.ringWinding()}, flux through the loop ${b.ringFluxQuanta().toStringAsFixed(6)} quanta, F = ${b.lattice.energy().toStringAsFixed(8)}');
}
Output
rational: fluxoid 3, flux through the loop 2.697251 quanta, F = -11.95777735
classic:  fluxoid 3, flux through the loop 2.697251 quanta, F = -11.95777735

Constructors

SuperconductorExperiment({SuperconductorPreset preset = SuperconductorPreset.coolInField, LinkMaths maths = LinkMaths.rational, this.size = 64})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment({preset, maths, size}): builds the sample and its initial state.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 20);
  print('preset ${e.preset.name}, maths ${e.maths.name}, ${e.size} × ${e.size}, material ${e.type.name}, t = ${e.t}');
  print('dt = ${e.dt}, dtA = ${e.dtA}, depth = ${e.depth}');
}
Output
preset fieldAfterCooling, maths rational, 20 × 20, material meissner, t = 0
dt = 0.1, dtA = 0.1, depth = 0.1111111111111111

Static

typeForstaticmethod
static SuperconductorType typeFor(SuperconductorPreset p)

The material a preset starts with.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // typeFor(preset): the material each preset starts with.
  for (final p in SuperconductorPreset.values) print('${p.name} → ${SuperconductorExperiment.typeFor(p).name}');
}
Output
coolInField → meissner
fieldAfterCooling → meissner
warmUp → meissner
fieldEnters → typeII
fieldCooled → typeII
strongField → typeII
typeIForComparison → typeI
triangularLattice → bulk
trapFlux → ring
screenField → ring
fluxJumps → thinRing
windThree → ring
frontStepsconstant
static const int frontSteps = 1800

Steps for the front to cross the disc.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.frontSteps: steps for the cooling front to cross the disc in coolInField.
  print('frontSteps = ${SuperconductorExperiment.frontSteps}');
  print('front radius ramp of a 24-site disc: ${SuperconductorExperiment(size: 24).frontRamp!.length} steps');
}
Output
frontSteps = 1800
front radius ramp of a 24-site disc: 1800 steps
torusNxconstant
static const int torusNx = 40

The bulk tile: 40 \times 69 sites (\frac{69}{40} \approx \sqrt{3}, so a triangular lattice of spacing 10 fits: 4 \times 4 cells of 2 vortices), and the field per plaquette whose 2,760 plaquettes hold exactly torusQuanta quanta. Its Cayley parameter is the fraction \frac{6829}{187402} \approx \tan(\pi \cdot \frac{32}{2760}); the 5 \times 10^{-11} by which it misses collects in one plaquette (the torus forces the total to a whole number of quanta exactly).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.torusNx: the periodic tile's width (69/40 is close to √3, so a triangular vortex lattice fits).
  print('torusNx = ${SuperconductorExperiment.torusNx}');
  print('69/40 = ${69 / 40}');
}
Output
torusNx = 40
69/40 = 1.725
torusNyconstant
static const int torusNy = 69

The bulk tile: 40 \times 69 sites (\frac{69}{40} \approx \sqrt{3}, so a triangular lattice of spacing 10 fits: 4 \times 4 cells of 2 vortices), and the field per plaquette whose 2,760 plaquettes hold exactly torusQuanta quanta. Its Cayley parameter is the fraction \frac{6829}{187402} \approx \tan(\pi \cdot \frac{32}{2760}); the 5 \times 10^{-11} by which it misses collects in one plaquette (the torus forces the total to a whole number of quanta exactly).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.torusNy: the periodic tile's height.
  print('torusNy = ${SuperconductorExperiment.torusNy}');
  print('tile: ${SuperconductorExperiment.torusNx} × ${SuperconductorExperiment.torusNy} = ${SuperconductorExperiment.torusNx * SuperconductorExperiment.torusNy} plaquettes');
}
Output
torusNy = 69
tile: 40 × 69 = 2760 plaquettes
torusQuantaconstant
static const int torusQuanta = 32

The bulk tile: 40 \times 69 sites (\frac{69}{40} \approx \sqrt{3}, so a triangular lattice of spacing 10 fits: 4 \times 4 cells of 2 vortices), and the field per plaquette whose 2,760 plaquettes hold exactly torusQuanta quanta. Its Cayley parameter is the fraction \frac{6829}{187402} \approx \tan(\pi \cdot \frac{32}{2760}); the 5 \times 10^{-11} by which it misses collects in one plaquette (the torus forces the total to a whole number of quanta exactly).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.torusQuanta: the whole flux quanta the tile holds.
  print('torusQuanta = ${SuperconductorExperiment.torusQuanta}');
  print('flux per plaquette ≈ 32/2760 = ${(32 / 2760).toStringAsFixed(9)} quanta');
}
Output
torusQuanta = 32
flux per plaquette ≈ 32/2760 = 0.011594203 quanta
torusFieldconstant
static const double torusField = 6829 / 187402
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';
import 'package:riptide_rational_gauge/classic.ray';

void main() {
  // SuperconductorExperiment.torusField: the Cayley parameter per plaquette, 6829/187402, close to tan(π·32/2760).
  print('torusField = ${SuperconductorExperiment.torusField}');
  final (hr, hi) = cayley(SuperconductorExperiment.torusField);
  print('h = e(t) = (${hr.toStringAsFixed(12)}, ${hi.toStringAsFixed(12)}), 2760 plaquettes × flux 2·atan t / 2π ≈ ${(2760 * fluxQuanta([(hr, hi)])).toStringAsFixed(9)} quanta');
}
Output
torusField = 0.03644037950502129
h = e(t) = (0.997347719450, 0.072784108900), 2760 plaquettes × flux 2·atan t / 2π ≈ 31.999999958 quanta
weakShareconstant
static const double weakShare = 0.1
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.weakShare: |α| in the thin ring's weak link as a share of the rest.
  print('weakShare = ${SuperconductorExperiment.weakShare}');
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fluxJumps, size: 24);
  print('α in the ring: ${e.lattice.alphaMap!.reduce((a, b) => a < b ? a : b)}, in the weak link: ${e.lattice.alphaMap!.reduce((a, b) => a > b ? a : b)}');
}
Output
weakShare = 0.1
α in the ring: -0.0625, in the weak link: -0.00625
static const double weakHalfLength = 4.5
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.weakHalfLength: half the weak link's length in sites.
  print('weakHalfLength = ${SuperconductorExperiment.weakHalfLength}');

}
Output
weakHalfLength = 4.5
jumpFieldconstant
static const double jumpField = 0.04

The thin ring's slow ramp: to about six quanta through the loop.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.jumpField: the thin ring's final field parameter in fluxJumps.
  print('jumpField = ${SuperconductorExperiment.jumpField}');
  print('ramp: ${SuperconductorExperiment(preset: SuperconductorPreset.fluxJumps, size: 24).fieldRamp.to}');
}
Output
jumpField = 0.04
ramp: 0.04
jumpStepsconstant
static const int jumpSteps = 24000
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.jumpSteps: the length of the slow field ramp in fluxJumps.
  print('jumpSteps = ${SuperconductorExperiment.jumpSteps}');

}
Output
jumpSteps = 24000
static const double trapHalfField = 1 / 176

The field the ring is cooled in, by the Cayley parameter of half its flux per plaquette (h = e(t\tfrac{1}{2})^{2}, \theta_{H} \approx 0.0227: about 4.2 quanta through the middle of the ring), and the winding the condensate takes.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.trapHalfField: the Cayley parameter of half the flux per plaquette the ring is cooled in.
  print('trapHalfField = ${SuperconductorExperiment.trapHalfField}');
  final t = turnRule(SuperconductorExperiment.trapHalfField, SuperconductorExperiment.trapHalfField);
  print('full field parameter t = ${t.toStringAsFixed(12)} (turn rule of 1/176 with itself)');
}
Output
trapHalfField = 0.005681818181818182
full field parameter t = 0.011364003228 (turn rule of 1/176 with itself)
trapWindingconstant
static const int trapWinding = 4
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.trapWinding: the winding the ring's condensate starts with in trapFlux.
  print('trapWinding = ${SuperconductorExperiment.trapWinding}');
  print('fluxoid at the start (size 64): ${SuperconductorExperiment(preset: SuperconductorPreset.trapFlux).ringWinding()}');
}
Output
trapWinding = 4
fluxoid at the start (size 64): 4
static const double meissnerField = 0.015

The Meissner disc's field: about 0.4 H_{c} (\theta_{c}^{2} = 2g^{2} \cdot \frac{\alpha^{2}}{2\beta}: \theta_{c} \approx 0.079 per plaquette), below H_{c1}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.meissnerField: the Meissner disc's field parameter (below H_c1).
  print('meissnerField = ${SuperconductorExperiment.meissnerField}');

}
Output
meissnerField = 0.015
historyEveryconstant
static const int historyEvery = 100
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.historyEvery: how often the ring presets record (flux, fluxoid).
  print('historyEvery = ${SuperconductorExperiment.historyEvery}');
  final e = SuperconductorExperiment(preset: SuperconductorPreset.windThree, size: 24)..advance(300);
  print('history after 300 steps: ${e.history.map((h) => (h.$1.toStringAsFixed(3), h.$2)).toList()}');
}
Output
historyEvery = 100
history after 300 steps: [(0.000, 3), (0.000, 3), (0.000, 3)]
settleStepsconstant
static const int settleSteps = 2500

Steps a preset is given to settle after its script.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // SuperconductorExperiment.settleSteps: steps a preset is given to settle after its script.
  print('settleSteps = ${SuperconductorExperiment.settleSteps}');
  print('fieldAfterCooling settled at t = 0: ${SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 16).settled}');
}
Output
settleSteps = 2500
fieldAfterCooling settled at t = 0: false

Properties

sizefield
final int size

Sites along each side.

latticefield
late GaugeLattice lattice
presetfield
late SuperconductorPreset preset
typefield
late SuperconductorType type
late Ramp alphaRamp

The temperature knob: \alpha = -a below T_{c} (a > 0), +a above.

late Ramp fieldRamp

The applied field's Cayley parameter per plaquette (flux 2 \cdot \operatorname{atan} t \approx 2t per plaquette).

tfield
int t

Steps since the preset started.

dtgetter
double get dt

The step sizes of \psi and of the links.

dtAgetter
double get dtA

The links' step: 0.1, or \frac{g^{2}}{5} when the magnetic term is stiff (its rate goes up to \frac{8}{g^{2}}; gradient flow is stable below \frac{2g^{2}}{8}).

depthgetter
double get depth

The condensate's depth |\alpha| below T_{c}.

mathsgetter
LinkMaths get maths
mathssetter
set maths(LinkMaths m)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // maths = …: switch an experiment's link maths mid-run (the state carries over).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.windThree, size: 24)..advance(100);
  final f0 = e.lattice.energy();
  e.maths = LinkMaths.classic;
  print('F before ${f0.toStringAsFixed(12)}, after switching ${e.lattice.energy().toStringAsFixed(12)}');
  e.advance(100);
  print('classic fluxoid after 100 more steps: ${e.ringWinding()}');
}
Output
F before -7.214623702528, after switching -7.214623702528
classic fluxoid after 100 more steps: 3
loopgetter
List<int> get loop

The closed path of sites the ring's winding and holonomy are measured round (empty for other shapes).

shapegetter
SuperconductorShape get shape
centregetter
double get centre
Ramp? frontRamp

The cooling front's radius (sites), or null when the temperature is uniform.

double get discRadius
ringInnergetter
double get ringInner

The ring's radii (in sites) and the field it is cooled in.

ringOutergetter
double get ringOuter
(double, double)? get weakLinkAt

Where the weak link is (sites), for drawing; null without one.

List<int> loopInterior

The plaquettes inside loop.

historyfield
final history

For the ring presets, (field through the loop in quanta, fluxoid n) every historyEvery steps: the sawtooth.

double get appliedLoopQuanta

The applied field's flux through the ring's loop, in quanta (display: \theta_{h} by atan2, classic.ray).

settledgetter
bool get settled

Whether the preset's script has played out (its ramps and cooling front done, and some time to settle).

fieldgetter
double get field

The applied field per plaquette, as its Cayley parameter now.

coldgetter
bool get cold

Below T_{c}, or cooling towards it (the temperature's target).

double get fieldScale

The field scale the drawing uses: \operatorname{Im} h of the strongest field this preset applies.

GLParameters get parameters

Methods

startmethod
void start(SuperconductorPreset p)

Starts p from its initial state.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // start(preset): restart the same experiment object on another preset.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldEnters, size: 20)..advance(50);
  print('${e.preset.name} at t = ${e.t}');
  e.start(SuperconductorPreset.windThree);
  print('now ${e.preset.name} at t = ${e.t}, fluxoid ${e.ringWinding()}');
}
Output
fieldEnters at t = 50
now windThree at t = 0, fluxoid 3
advancemethod
void advance(int n)

Runs n relaxation steps, following the preset's temperature and field.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // advance(n): n relaxation steps following the preset's ramps. Field rising on a type-II square, both ways, 600 steps.
  final a = SuperconductorExperiment(preset: SuperconductorPreset.fieldEnters, size: 24);
  final b = a.twin(LinkMaths.classic);
  final fa = <List<double>>[], fb = <List<double>>[];
  for (var k = 0; k < 6; k++) {
    a.advance(100);
    b.advance(100);
    fa.add([a.t.toDouble(), a.fluxQuantaInSample()]);
    fb.add([b.t.toDouble(), b.fluxQuantaInSample()]);
  }
  print('after ${a.t} steps: flux in the sample ${a.fluxQuantaInSample().toStringAsFixed(6)} (rational), ${b.fluxQuantaInSample().toStringAsFixed(6)} (classic)');
}
Output
after 600 steps: flux in the sample 1.246828 (rational), 1.246828 (classic)
double? coordination()

How the vortices pack: for each vortex at least two nearest spacings from the sample's edge, the number of vortices within 1.3× its nearest neighbour's distance, compared by quadrances (Q < 1.69 \cdot Q_{\mathrm{min}}: no root). A triangular lattice gives 6, a square one 4. Null with fewer than one such vortex.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // coordination(): neighbours per vortex within 1.3× the nearest spacing (by quadrances); null with fewer than 7 vortices.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.triangularLattice)..advance(700);
  final v = e.vortices();
  print('${v.length} vortices on the 40 × 69 torus after 700 steps (cooled through T_c by step 400, still ordering); coordination = ${e.coordination()?.toStringAsFixed(3)}');
  final g = e.lattice.geometry;
}
Output
32 vortices on the 40 × 69 torus after 700 steps (cooled through T_c by step 400, still ordering); coordination = 2.156
twinmethod
SuperconductorExperiment twin(LinkMaths m)

The same experiment the other way (or this way), from this one's state now: the two run side by side.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // twin(maths): the same experiment the other way from this state; run both the same 300 steps.
  final a = SuperconductorExperiment(preset: SuperconductorPreset.coolInField, size: 24)..advance(100);
  final b = a.twin(LinkMaths.classic);
  a.advance(300);
  b.advance(300);
  print('rational: F = ${a.lattice.energy().toStringAsFixed(9)}, inside-field share ${a.insideFieldShare().toStringAsFixed(6)}');
  print('classic:  F = ${b.lattice.energy().toStringAsFixed(9)}, inside-field share ${b.insideFieldShare().toStringAsFixed(6)}');
}
Output
rational: F = -0.803282339, inside-field share 0.668299
classic:  F = -0.803282339, inside-field share 0.668299
setFieldmethod
void setField(double tField, {int steps = 200})

Moves the applied field to Cayley parameter tField per plaquette over steps from now.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // setField(t, steps:): ramp the applied field to Cayley parameter t from now.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 20)..advance(10);
  e.setField(0.03, steps: 50);
  print('t = ${e.t}: field ${e.field.toStringAsFixed(6)}');
  e.advance(25);
  print('t = ${e.t}: field ${e.field.toStringAsFixed(6)}');
  e.advance(25);
  print('t = ${e.t}: field ${e.field.toStringAsFixed(6)}');
}
Output
t = 10: field 0.000000
t = 35: field 0.015000
t = 60: field 0.030000
setColdmethod
void setCold(bool cold, {int steps = 60})

Cools below T_{c} or warms above it, everywhere, over steps from now.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // setCold(cold, steps:): cool below T_c or warm above it everywhere; warming destroys the condensate.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 20);
  double q() => e.lattice.pr[e.lattice.geometry.index(10, 10)] * e.lattice.pr[e.lattice.geometry.index(10, 10)];
  print('cold: ${e.cold}, Q at the centre ${q().toStringAsFixed(6)}');
  e.setCold(false, steps: 20);
  e.advance(300);
  print('after warming: cold ${e.cold}, α = ${e.lattice.alpha}, Q at the centre ${q().toStringAsExponential(2)}');
}
Output
cold: true, Q at the centre 0.111111
after warming: cold false, α = 0.1111111111111111, Q at the centre 8.51e-5
setTypemethod
void setType(SuperconductorType k)

Changes the material (type I or II) from now: \beta, g^{2} and the depth of the hat.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // setType(material): change β, g² and the hat's depth from now.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldEnters, size: 20);
  print('${e.type.name}: κ² = ${e.parameters.kappa2}');
  e.setType(SuperconductorType.typeI);
  e.advance(80);
  print('${e.type.name}: κ² = ${e.parameters.kappa2}, β = ${e.lattice.beta}, g² = ${e.lattice.g2}, α = ${e.lattice.alpha.toStringAsFixed(6)}');
}
Output
typeII: κ² = 4.0
typeI: κ² = 0.25, β = 1.0, g² = 2.0, α = -0.027778
vorticesmethod
List<(int, int)> vortices()

Every vortex: plaquette site and its winding (exact by signs the rational way, by atan2 the classic way).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // vortices(): every vortex (plaquette, winding), exact by signs the rational way, by atan2 the classic way.
  final a = SuperconductorExperiment(preset: SuperconductorPreset.fieldCooled, size: 24)..advance(300);
  final b = a.twin(LinkMaths.classic);
  print('rational: ${a.vortices().length} vortices, net winding ${a.vortices().fold(0, (s, v) => s + v.$2)}');
  print('classic (same state): ${b.vortices().length} vortices, net ${b.vortices().fold(0, (s, v) => s + v.$2)}');
  final g = a.lattice.geometry;
}
Output
rational: 4 vortices, net winding 4
classic (same state): 4 vortices, net 4
double fluxQuantaInSample()

The total flux through the sample, in flux quanta: \sum \theta_{p} / 2\pi (classic, atan2 per plaquette).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // fluxQuantaInSample(): Σθ_p/2π over the sample's plaquettes (atan2 per plaquette).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldCooled, size: 24);
  print('at the start: ${e.fluxQuantaInSample().toStringAsFixed(6)} quanta');
  e.advance(200);
  print('after 200 steps: ${e.fluxQuantaInSample().toStringAsFixed(6)} quanta');
}
Output
at the start: 5.740713 quanta
after 200 steps: 5.707774 quanta
double insideFieldShare()

The mean field inside the sample as a share of the applied field: \sum \operatorname{Im} U_{p} / (N \operatorname{Im} h) (Rational).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // insideFieldShare(): mean Im U_p inside the sample over Im h. Here the field is switched on
  // after the disc has cooled.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 24);
  final pts = <List<double>>[];
  for (var k = 0; k < 8; k++) {
    e.advance(50);
    pts.add([e.t.toDouble(), e.insideFieldShare()]);
  }
  print('after ${e.t} steps: field ${e.field.toStringAsFixed(4)}, inside share ${e.insideFieldShare().toStringAsFixed(6)}');
}
Output
after 400 steps: field 0.0150, inside share 0.484861
int ringWinding()

The fluxoid round the ring's loop: exact by signs (rational), by atan2 (classic).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // ringWinding(): the fluxoid round the ring, exact by signs (rational way).
  final e = SuperconductorExperiment(preset: SuperconductorPreset.windThree, size: 24);
  print('start: ${e.ringWinding()}');
  e.advance(300);
  print('after 300 steps: ${e.ringWinding()}');
}
Output
start: 3
after 300 steps: 3
double ringFluxQuanta()

The flux through the ring's loop in quanta (classic: \sum \frac{\theta_{p}}{2\pi} over the plaquettes inside).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // ringFluxQuanta(): the flux through the ring's loop (Σθ_p/2π), in a field switched on round a cold ring.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.screenField, size: 24);
  e.setField(0.02, steps: 100);
  e.advance(400);
  print('applied through the loop ${e.appliedLoopQuanta.toStringAsFixed(6)} quanta; actually through it ${e.ringFluxQuanta().toStringAsFixed(6)}; fluxoid ${e.ringWinding()}');
}
Output
applied through the loop 1.024821 quanta; actually through it 0.101579; fluxoid 0
double ringHolonomySpread()

The holonomy's half-turn spread s = \frac{1 - \operatorname{Re} W}{2} round the loop (Rational; classically \sin^{2}(\frac{\pi\Phi}{\Phi_{0}})): 0 exactly when the enclosed flux is a whole number of quanta.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // ringHolonomySpread(): s = (1 − Re W)/2 round the loop, 0 exactly at whole quanta.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.windThree, size: 24);
  print('no field: s = ${e.ringHolonomySpread()}');
  e.setField(0.02, steps: 1);
  e.advance(200);
  print('field 0.02: s = ${e.ringHolonomySpread().toStringAsFixed(9)}, flux ${e.ringFluxQuanta().toStringAsFixed(6)} quanta');
}
Output
no field: s = 0.0
field 0.02: s = 0.816376625, flux 2.640962 quanta
List<double> fieldProfile()

The magnetic field profile along the middle row: \operatorname{Im} U_{p} per plaquette (Rational).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // fieldProfile(): Im U_p along the middle row; the Meissner disc pushes the field out of its middle.
  final e = SuperconductorExperiment(preset: SuperconductorPreset.fieldAfterCooling, size: 32)..advance(400);
  final p = e.fieldProfile();
  print('Im U_p at x = 0, 8, 16: ${p[0].toStringAsFixed(6)}, ${p[8].toStringAsFixed(6)}, ${p[16].toStringAsExponential(2)}');
}
Output
Im U_p at x = 0, 8, 16: 0.028593, 0.008142, 2.59e-3
enum HiggsPreset

What the Higgs strip starts from.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The four Higgs-strip presets and where ψ starts.
  for (final p in HiggsPreset.values) {
    final h = HiggsExperiment(preset: p, length: 64);
    print('${p.name}: ψ = (${h.psi.$1}, ${h.psi.$2}), Q = ${h.q}, α(0) = ${h.lattice.alpha}');
  }
}
Output
rollIntoVacuum: ψ = (0.004, 0.003), Q = 0.000024999999999999998, α(0) = 0.5
lightInVacuum: ψ = (0.0, 0.0), Q = 0.0, α(0) = 0.5
lightInCondensate: ψ = (0.3, 0.4), Q = 0.25, α(0) = -0.5
higgsMode: ψ = (0.36, 0.48), Q = 0.36, α(0) = -0.5

Values

rollIntoVacuum

The field at the top of the hat, a light wave launched: as the field rolls into the vacuum the wave turns massive.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsPreset.rollIntoVacuum: Q and the photon mass m_A² = 2g²Q over 600 Hamiltonian steps.
  final h = HiggsExperiment(preset: HiggsPreset.rollIntoVacuum, length: 128);
  final pts = <List<double>>[];
  for (var k = 0; k <= 600; k += 20) {
    pts.add([k.toDouble(), h.q]);
    if (k < 600) h.advance(20);
  }
  print('Q: start ${pts.first[1].toStringAsFixed(6)}, end ${h.q.toStringAsFixed(6)} (rim Q0 = ${h.q0}); m_A² = ${h.photonMass2.toStringAsFixed(6)}');
}
Output
Q: start 0.000025, end 0.250947 (rim Q0 = 0.25); m_A² = 0.501894
lightInVacuum

No condensate (above T_{c}): the wave travels at the speed of light.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsPreset.lightInVacuum: Q and the photon mass m_A² = 2g²Q over 600 Hamiltonian steps.
  final h = HiggsExperiment(preset: HiggsPreset.lightInVacuum, length: 128);
  final pts = <List<double>>[];
  for (var k = 0; k <= 600; k += 20) {
    pts.add([k.toDouble(), h.q]);
    if (k < 600) h.advance(20);
  }
  print('Q: start ${pts.first[1].toStringAsFixed(6)}, end ${h.q.toStringAsFixed(6)} (rim Q0 = ${h.q0}); m_A² = ${h.photonMass2.toStringAsFixed(6)}');
}
Output
Q: start 0.000000, end 0.000000 (rim Q0 = 0.0); m_A² = 0.000000
lightInCondensate

Already in the vacuum: the wave is massive from the start (slower, spreading).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsPreset.lightInCondensate: Q and the photon mass m_A² = 2g²Q over 600 Hamiltonian steps.
  final h = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 128);
  final pts = <List<double>>[];
  for (var k = 0; k <= 600; k += 20) {
    pts.add([k.toDouble(), h.q]);
    if (k < 600) h.advance(20);
  }
  print('Q: start ${pts.first[1].toStringAsFixed(6)}, end ${h.q.toStringAsFixed(6)} (rim Q0 = ${h.q0}); m_A² = ${h.photonMass2.toStringAsFixed(6)}');
}
Output
Q: start 0.250000, end 0.241842 (rim Q0 = 0.25); m_A² = 0.483684
higgsMode

The field displaced outwards from the rim: it rings at the Higgs (amplitude) mass.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsPreset.higgsMode: Q and the photon mass m_A² = 2g²Q over 600 Hamiltonian steps.
  final h = HiggsExperiment(preset: HiggsPreset.higgsMode, length: 128);
  final pts = <List<double>>[];
  for (var k = 0; k <= 600; k += 20) {
    pts.add([k.toDouble(), h.q]);
    if (k < 600) h.advance(20);
  }
  print('Q: start ${pts.first[1].toStringAsFixed(6)}, end ${h.q.toStringAsFixed(6)} (rim Q0 = ${h.q0}); m_A² = ${h.photonMass2.toStringAsFixed(6)}');
}
Output
Q: start 0.360000, end 0.361245 (rim Q0 = 0.25); m_A² = 0.722490
final class HiggsExperiment

The Higgs strip: a periodic chain (ny = 1) whose y-links carry a transverse gauge wave A_{y}(x) along x, with a uniform \psi that rolls in the Mexican hat. Hamiltonian evolution (lattice.ray GaugeLattice.evolve).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The Higgs strip: the field rolls off the top of the hat and the gauge wave turns massive. Both ways, 500 steps.
  final a = HiggsExperiment(length: 128), b = a.twin(LinkMaths.classic);
  final qa = <List<double>>[], qb = <List<double>>[];
  for (var k = 0; k <= 500; k += 25) {
    qa.add([k.toDouble(), a.photonMass2]);
    qb.add([k.toDouble(), b.photonMass2]);
    if (k < 500) {
      a.advance(25);
      b.advance(25);
    }
  }
  print('rational: m_A² = ${a.photonMass2.toStringAsFixed(6)}, wave centre ${a.waveCentre().toStringAsFixed(3)}');
  print('classic:  m_A² = ${b.photonMass2.toStringAsFixed(6)}, wave centre ${b.waveCentre().toStringAsFixed(3)}');
}
Output
rational: m_A² = 0.483071, wave centre 33.127
classic:  m_A² = 0.483319, wave centre 33.162

Constructors

HiggsExperimentconstructor
HiggsExperiment({HiggsPreset preset = HiggsPreset.rollIntoVacuum, LinkMaths maths = LinkMaths.rational, this.length = 256})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment({preset, maths, length}): a periodic chain whose y-links carry a transverse wave.
  final h = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 64);
  print('length ${h.length}, maths ${h.maths.name}, Q = ${h.q}, rim ${h.q0}, m_A² = ${h.photonMass2}');
}
Output
length 64, maths rational, Q = 0.25, rim 0.25, m_A² = 0.5

Static

alphaBrokenconstant
static const double alphaBroken = -0.5

The hat: V = \alpha Q + (\frac{\beta}{2})Q^{2} with Q_{0} = \frac{1}{4} (\psi_{0} = \frac{1}{2} exactly), g^{2} = 1: m_{A}^{2} = 2g^{2}Q_{0} = \frac{1}{2}, m_{H}^{2} = 2\beta Q_{0} = \frac{1}{2}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.alphaBroken: α below T_c (the hat's coefficient).
  print('alphaBroken = ${HiggsExperiment.alphaBroken}');
  print('rim Q0 = ${MexicanHat(HiggsExperiment.alphaBroken, HiggsExperiment.beta).q0}');
}
Output
alphaBroken = -0.5
rim Q0 = 0.25
betaconstant
static const double beta = 2

The hat: V = \alpha Q + (\frac{\beta}{2})Q^{2} with Q_{0} = \frac{1}{4} (\psi_{0} = \frac{1}{2} exactly), g^{2} = 1: m_{A}^{2} = 2g^{2}Q_{0} = \frac{1}{2}, m_{H}^{2} = 2\beta Q_{0} = \frac{1}{2}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.beta: the hat's quartic coefficient.
  print('beta = ${HiggsExperiment.beta}');
  print('Higgs m² = 2βQ0 = ${2 * HiggsExperiment.beta * 0.25}');
}
Output
beta = 2.0
Higgs m² = 2βQ0 = 1.0
g2constant
static const double g2 = 1

The hat: V = \alpha Q + (\frac{\beta}{2})Q^{2} with Q_{0} = \frac{1}{4} (\psi_{0} = \frac{1}{2} exactly), g^{2} = 1: m_{A}^{2} = 2g^{2}Q_{0} = \frac{1}{2}, m_{H}^{2} = 2\beta Q_{0} = \frac{1}{2}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.g2: the gauge coupling g².
  print('g2 = ${HiggsExperiment.g2}');
  print('photon m² in the vacuum = ${2 * HiggsExperiment.g2 * 0.25}');
}
Output
g2 = 1.0
photon m² in the vacuum = 0.5
dtconstant
static const double dt = 0.25
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.dt: the Hamiltonian step size.
  print('dt = ${HiggsExperiment.dt}');
  print('step spread at the carrier: ${stepSpread(HiggsExperiment.dt, 0.5, HiggsExperiment.carrierU)} (stable below 1)');
}
Output
dt = 0.25
step spread at the carrier: 0.012973050458715597 (stable below 1)
carrierUconstant
static const double carrierU = 0.3

The wave packet's carrier: Cayley parameter u = \tan(\frac{k}{2}) (k \approx 0.6), and its width.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.carrierU: the wave carrier's Cayley parameter u = tan(k/2).
  print('carrierU = ${HiggsExperiment.carrierU}');
  print('lattice k̂² = 4u²/(1 + u²) = ${4 * latticeSpread(HiggsExperiment.carrierU)}');
}
Output
carrierU = 0.3
lattice k̂² = 4u²/(1 + u²) = 0.33027522935779813
static const int packetHalfWidth = 24
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.packetHalfWidth: the wave packet's half-width in sites.
  print('packetHalfWidth = ${HiggsExperiment.packetHalfWidth}');

}
Output
packetHalfWidth = 24
amplitudeconstant
static const double amplitude = 0.3

The wave packet's amplitude (A_{y}, radians of link phase at the crest).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // HiggsExperiment.amplitude: the wave packet's crest, radians of link phase.
  print('amplitude = ${HiggsExperiment.amplitude}');
  final h = HiggsExperiment(preset: HiggsPreset.lightInVacuum, length: 128);
  print('largest |A_y| (as Im U) on the strip: ${h.waveA.map((x) => x.abs()).reduce((p, q) => p > q ? p : q).toStringAsFixed(6)}');
}
Output
amplitude = 0.3
largest |A_y| (as Im U) on the strip: 0.293399

Properties

lengthfield
final int length
latticefield
late GaugeLattice lattice
presetfield
late HiggsPreset preset
mathsgetter
LinkMaths get maths
mathssetter
set maths(LinkMaths m)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // maths = …: switch the strip's link maths mid-run.
  final h = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 64)..advance(50);
  h.maths = LinkMaths.classic;
  h.advance(50);
  print('maths now ${h.maths.name}, t = ${h.t}, Q = ${h.q.toStringAsFixed(9)}');
}
Output
maths now classic, t = 100, Q = 0.250923934
double friction

Radial friction on \psi (gauge invariant), so the field settles on the rim.

tfield
int t
hatgetter
MexicanHat get hat
Ramp alphaRamp

The temperature: \alpha over time (the hat forms when \alpha turns negative).

coldgetter
bool get cold

Cold, or cooling (the temperature's target).

settledgetter
bool get settled

Whether the preset has played out (for a looping miniature).

psigetter
(double, double) get psi

\psi at the first site (the strip's field is uniform).

qgetter
double get q

Q = |\psi|^{2} now.

double get photonMass2

The photon's mass squared now, m_{A}^{2} = 2g^{2}Q.

q0getter
double get q0

The rim Q_{0} = -\frac{\alpha}{\beta} (0 above T_{c}).

waveEgetter
List<double> get waveE

E_{y} along the strip.

waveAgetter
List<double> get waveA

A_{y} along the strip, the link phase (Im U as the rational measure: \sin A \approx A).

Methods

startmethod
void start(HiggsPreset p)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // start(preset): restart the strip on another preset.
  final h = HiggsExperiment(length: 64)..advance(30);
  h.start(HiggsPreset.higgsMode);
  print('${h.preset.name}: t = ${h.t}, Q = ${h.q}, friction ${h.friction}');
}
Output
higgsMode: t = 0, Q = 0.36, friction 0.0
advancemethod
void advance(int n)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // advance(n): Hamiltonian steps. The Higgs mode: Q rings round the rim at the Higgs mass, both ways, 400 steps.
  final a = HiggsExperiment(preset: HiggsPreset.higgsMode, length: 32), b = a.twin(LinkMaths.classic);
  final pa = <List<double>>[], pb = <List<double>>[];
  for (var k = 0; k < 400; k += 4) {
    pa.add([k * HiggsExperiment.dt, a.q]);
    pb.add([k * HiggsExperiment.dt, b.q]);
    a.advance(4);
    b.advance(4);
  }
  print('Q after 400 steps: rational ${a.q.toStringAsFixed(9)}, classic ${b.q.toStringAsFixed(9)}');
}
Output
Q after 400 steps: rational 0.174314218, classic 0.174314218
twinmethod
HiggsExperiment twin(LinkMaths m)

The same strip the other way, from this one's state now.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // twin(maths): the strip the other way from this state; the same 300 steps each.
  final a = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 128);
  final b = a.twin(LinkMaths.classic);
  a.advance(300);
  b.advance(300);
  print('wave centre after 300 steps: rational ${a.waveCentre().toStringAsFixed(6)}, classic ${b.waveCentre().toStringAsFixed(6)}');
}
Output
wave centre after 300 steps: rational 77.450543, classic 77.457725
setColdmethod
void setCold(bool cold, {int steps = 40})

Hot (\alpha > 0: no hat, \psi settles to 0) or cold (the hat: \psi rolls to the rim), over steps from now.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // setCold(false): warm the strip; the hat flattens into a bowl and Q falls to 0.
  final h = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 64);
  h.setCold(false, steps: 20);
  final pts = <List<double>>[];
  for (var k = 0; k <= 400; k += 20) {
    pts.add([k.toDouble(), h.q]);
    h.advance(20);
  }
  print('cold: ${h.cold}, α = ${h.lattice.alpha}, Q after 400 steps ${h.q.toStringAsExponential(2)}');
}
Output
cold: false, α = 0.5, Q after 400 steps 2.35e-10
void launchWave()

Sends a new wave packet from a quarter of the way along (replacing the transverse field there).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // launchWave(): a new right-moving packet a quarter of the way along.
  final h = HiggsExperiment(preset: HiggsPreset.higgsMode, length: 128);
  print('E_y energy before: ${h.waveE.fold(0.0, (s, e) => s + e * e).toStringAsFixed(6)}');
  h.launchWave();
  print('after launchWave: ${h.waveE.fold(0.0, (s, e) => s + e * e).toStringAsFixed(6)}, centre ${h.waveCentre().toStringAsFixed(3)}');
}
Output
E_y energy before: 0.000000
after launchWave: 0.921845, centre 32.000
nudgemethod
void nudge()

Nudges \psi off the top of the hat (when it sits there) by a small rational step.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // nudge(): step ψ off the top of the hat by (0.004, 0.003).
  final h = HiggsExperiment(preset: HiggsPreset.lightInVacuum, length: 32);
  print('ψ before ${h.psi}');
  h.nudge();
  print('ψ after (${h.psi.$1}, ${h.psi.$2})');
}
Output
ψ before (0.0, 0.0)
ψ after (0.004, 0.003)
double groupVelocity()

The group velocity the wave should have in the vacuum, \frac{k}{\sqrt{k^{2} + m_{A}^{2}}} (continuum; Root).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // groupVelocity() = k/√(k² + m_A²): light speed with no condensate, slower in it.
  final v0 = HiggsExperiment(preset: HiggsPreset.lightInVacuum, length: 64).groupVelocity();
  final v1 = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 64).groupVelocity();
  print('no condensate: v = ${v0.toStringAsFixed(9)}; in the condensate (m_A² = 1/2): v = ${v1.toStringAsFixed(9)}');
}
Output
no condensate: v = 1.000000000; in the condensate (m_A² = 1/2): v = 0.636091046
double waveCentre()

The energy-weighted centre of the wave (sites), for measuring how fast it moves.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // waveCentre(): the E²-weighted centre; it moves faster with no condensate. Both presets, the same 200 steps.
  final a = HiggsExperiment(preset: HiggsPreset.lightInVacuum, length: 256);
  final b = HiggsExperiment(preset: HiggsPreset.lightInCondensate, length: 256);
  final pa = <List<double>>[], pb = <List<double>>[];
  for (var k = 0; k <= 200; k += 10) {
    pa.add([k * HiggsExperiment.dt, a.waveCentre()]);
    pb.add([k * HiggsExperiment.dt, b.waveCentre()]);
    a.advance(10);
    b.advance(10);
  }
  print('moved in 50 time units: vacuum ${(pa.last[1] - pa.first[1]).toStringAsFixed(3)} sites, condensate ${(pb.last[1] - pb.first[1]).toStringAsFixed(3)} sites');
}
Output
moved in 50 time units: vacuum 47.455 sites, condensate 29.983 sites
final class LatticeGeometry

The shape of a 2-D lattice: nx \times ny sites (site i = y \cdot nx + x), a link from each site in +x (\mu = 0) and +y (\mu = 1), link index l = 2i + \mu, open or periodic in each direction, and which sites are superconducting.

Sites that are not superconducting are vacuum (or an insulator): \psi = 0 there, but their links still carry the magnetic field. Hopping (the |D\psi|^{2} term) is only between two superconducting sites, which gives Ginzburg–Landau's natural boundary condition at an insulating surface (no current out of the sample).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // A 6 × 5 lattice with a superconducting disc: sites, links, plaquettes, and which links carry hopping.
  final g = LatticeGeometry(6, 5, superconducting: (x, y) => (x - 2.5) * (x - 2.5) + (y - 2) * (y - 2) <= 5);
  var hops = 0, plaq = 0, inSample = 0;
  for (var l = 0; l < g.links; l++) {
    if (g.hop[l] == 1) hops++;
  }
  for (var i = 0; i < g.sites; i++) {
    if (g.plaquette[i] == 1) plaq++;
    if (g.plaquetteInSample(i)) inSample++;
  }
  print('${g.sites} sites, ${g.links} link slots, ${[for (var l = 0; l < g.links; l++) if (g.linkOn(l)) l].length} links, $hops hopping links');
  print('$plaq plaquettes, $inSample inside the sample');
}
Output
30 sites, 60 link slots, 49 links, 23 hopping links
20 plaquettes, 8 inside the sample

Constructors

LatticeGeometryconstructor
LatticeGeometry(this.nx, this.ny, {this.periodicX = false, this.periodicY = false, bool Function(int x, int y)? superconducting})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // LatticeGeometry(nx, ny, periodicX:, periodicY:, superconducting:): open edges have no outgoing link.
  final open = LatticeGeometry(3, 3), torus = LatticeGeometry(3, 3, periodicX: true, periodicY: true);
  int count(LatticeGeometry g) => [for (var l = 0; l < g.links; l++) if (g.linkOn(l)) l].length;
  print('open 3 × 3: ${count(open)} links; torus 3 × 3: ${count(torus)} links');
  print('next of site 2 in +x: open ${open.next[4]}, torus ${torus.next[4]}');
}
Output
open 3 × 3: 12 links; torus 3 × 3: 18 links
next of site 2 in +x: open -1, torus 0

Properties

nxfield
final int nx
nyfield
final int ny
final bool periodicX
final bool periodicY
nextfield
final Int32List next

The site a link leads to, or -1 (no link: an open edge).

prevfield
final Int32List prev

The site whose \mu-link leads to i (\operatorname{prev}[2i + \mu]), or -1.

scfield
final Uint8List sc

1 where the site is superconducting.

hopfield
final Uint8List hop

1 where the link carries hopping (both ends superconducting).

final Uint8List plaquette

1 where site i is the lower-left corner of a plaquette.

sitesgetter
int get sites

Methods

indexmethod
int index(int x, int y)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // index(x, y) = y·nx + x.
  final g = LatticeGeometry(4, 3);
  print([for (var y = 0; y < 3; y++) [for (var x = 0; x < 4; x++) g.index(x, y)].join(' ')].join(' | '));
}
Output
0 1 2 3 | 4 5 6 7 | 8 9 10 11
xOfmethod
int xOf(int i)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // xOf(i) = i mod nx.
  final g = LatticeGeometry(4, 3);
  print([for (final i in [0, 3, 5, 11]) 'xOf($i) = ${g.xOf(i)}'].join(', '));
}
Output
xOf(0) = 0, xOf(3) = 3, xOf(5) = 1, xOf(11) = 3
yOfmethod
int yOf(int i)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // yOf(i) = i div nx.
  final g = LatticeGeometry(4, 3);
  print([for (final i in [0, 3, 5, 11]) 'yOf($i) = ${g.yOf(i)}'].join(', '));
}
Output
yOf(0) = 0, yOf(3) = 0, yOf(5) = 1, yOf(11) = 2
linkOnmethod
bool linkOn(int l)

Whether link l exists.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // linkOn(l): whether link l = 2i + μ exists (open edges have none outward).
  final g = LatticeGeometry(3, 2);
  for (var i = 0; i < g.sites; i++) print('site $i (${g.xOf(i)}, ${g.yOf(i)}): +x ${g.linkOn(2 * i)}, +y ${g.linkOn(2 * i + 1)}');
}
Output
site 0 (0, 0): +x true, +y true
site 1 (1, 0): +x true, +y true
site 2 (2, 0): +x false, +y true
site 3 (0, 1): +x true, +y false
site 4 (1, 1): +x true, +y false
site 5 (2, 1): +x false, +y false
bool plaquetteInSample(int i)

Whether all four corners of the plaquette at i are superconducting (a vortex can be counted there).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // plaquetteInSample(i): all four corners superconducting, so a vortex can be counted there.
  final g = LatticeGeometry(4, 4, superconducting: (x, y) => x >= 1);
  print([for (var y = 0; y < 3; y++) [for (var x = 0; x < 3; x++) g.plaquetteInSample(g.index(x, y)) ? 'in' : 'out'].join(' ')].join(' | '));
}
Output
out in in | out in in | out in in
discLoopmethod
(List<int>, List<int>) discLoop(double cx, double cy, double r2)

A closed counter-clockwise path of sites round the plaquettes whose centres lie within quadrance r2 of (cx, cy) (a digital disc: compared by quadrance, no root), and those plaquettes. The boundary edges are the plaquette edges with the disc on their left, chained head to tail.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // discLoop(cx, cy, r²): a counter-clockwise path of sites round a digital disc of plaquettes (compared by quadrance).
  final g = LatticeGeometry(10, 10);
  final (path, interior) = g.discLoop(4.5, 4.5, 6);
  print('${interior.length} plaquettes inside, path of ${path.length} sites: ${path.take(8).join(', ')}, …');
}
Output
21 plaquettes inside, path of 20 sites: 23, 24, 25, 26, 36, 37, 47, 57, …
enum LinkMaths

How the link variables are stored and turned.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // LinkMaths: how links are stored and turned. Same lattice, same 300 relaxation steps, both ways.
  final g = LatticeGeometry(12, 12);
  final e = <LinkMaths, List<List<double>>>{};
  for (final m in LinkMaths.values) {
    final l = GaugeLattice(g, maths: m, alpha: -0.25, beta: 1, g2: 0.5)..setFieldParameter(0.04);
    l.setPsi((x, y) => (0.5, 0.0));
    e[m] = [];
    for (var k = 0; k <= 300; k++) {
      if (k % 10 == 0) e[m]!.add([k.toDouble(), l.energy()]);
      if (k < 300) l.relax(0.1);
    }
    print('${m.name}: F after 300 steps = ${l.energy().toStringAsFixed(9)}, max ||U|² − 1| = ${l.unitDrift().toStringAsExponential(1)}');
  }
}
Output
classic: F after 300 steps = -4.079001746, max ||U|² − 1| = 2.2e-16
rational: F after 300 steps = -4.079001746, max ||U|² − 1| = 2.2e-16

Values

classicvalue
classic
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // LinkMaths.classic keeps angles θ and rebuilds U = (cos θ, sin θ) after every turn.
  final l = GaugeLattice(LatticeGeometry(4, 4), maths: LinkMaths.classic)..setFieldParameter(0.1);
  l.setPsi((x, y) => (1.0, 0.0));
  for (var k = 0; k < 20; k++) l.relax(0.1);
  print('θ of link 1 = ${l.th[1].toStringAsFixed(9)}, U = (${l.ur[1].toStringAsFixed(9)}, ${l.ui[1].toStringAsFixed(9)})');
}
Output
θ of link 1 = -0.054584829, U = (0.998510618, -0.054557727)
rational
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // LinkMaths.rational turns U by Cayley points; no angle is stored (th stays 0).
  final l = GaugeLattice(LatticeGeometry(4, 4))..setFieldParameter(0.1);
  l.setPsi((x, y) => (1.0, 0.0));
  for (var k = 0; k < 20; k++) l.relax(0.1);
  print('maths = ${l.maths.name}; θ array untouched: ${l.th[1]}; U = (${l.ur[1].toStringAsFixed(9)}, ${l.ui[1].toStringAsFixed(9)})');
}
Output
maths = rational; θ array untouched: 0.0; U = (0.998510617, -0.054557749)
final class GaugeLattice

The lattice model in doubles (the live labs run this).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // A superconducting square in a field, relaxed both ways for 400 steps: the field is pushed out of the middle.
  // The plot shows the link variables' Im U_p (the field) along the middle row, both ways.
  final g = LatticeGeometry(20, 20, superconducting: (x, y) => x >= 3 && x < 17 && y >= 3 && y < 17);
  final profiles = <String, List<List<double>>>{};
  for (final m in LinkMaths.values) {
    final l = GaugeLattice(g, maths: m, alpha: -0.25, beta: 1, g2: 0.5)..setFieldParameter(0.03);
    l.setPsi((x, y) => (0.5, 0.0));
    for (var k = 0; k < 400; k++) l.relax(0.1);
    profiles[m.name] = [for (var x = 0; x < 19; x++) [x + 0.5, l.plaquetteAt(g.index(x, 10)).$2]];
    print('${m.name}: F = ${l.energy().toStringAsFixed(8)}, Im U_p at the edge ${l.plaquetteAt(g.index(1, 10)).$2.toStringAsFixed(6)}, in the middle ${l.plaquetteAt(g.index(10, 10)).$2.toStringAsExponential(2)}');
  }
}
Output
classic: F = -5.76023021, Im U_p at the edge 0.059939, in the middle 7.47e-3
rational: F = -5.76023021, Im U_p at the edge 0.059939, in the middle 7.47e-3

Constructors

GaugeLatticeconstructor
GaugeLattice(this.geometry, {LinkMaths maths = LinkMaths.rational, this.alpha = -1, this.beta = 1, this.g2 = 1})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // GaugeLattice(geometry, maths:, alpha:, beta:, g2:): ψ = 0 and U = 1 to start.
  final l = GaugeLattice(LatticeGeometry(5, 5), alpha: -1, beta: 1, g2: 1);
  print('maths ${l.maths.name}, α ${l.alpha}, β ${l.beta}, g² ${l.g2}, F = ${l.energy()}');
  l.setPsi((x, y) => (1.0, 0.0));
  print('on the rim (Q = 1): F = ${l.energy()} = 25·(α + β/2)');
}
Output
maths rational, α -1.0, β 1.0, g² 1.0, F = 0.0
on the rim (Q = 1): F = -12.5 = 25·(α + β/2)

Properties

final LatticeGeometry geometry
prfield
final Float64List pr

\psi (real, imaginary).

pifield
final Float64List pi

\psi (real, imaginary).

qrfield
final Float64List qr

\pi, ψ's momentum (Hamiltonian evolution only).

qifield
final Float64List qi

\pi, ψ's momentum (Hamiltonian evolution only).

urfield
final Float64List ur

U per link (real, imaginary); the classic way keeps them equal to (\cos \theta, \sin \theta).

uifield
final Float64List ui

U per link (real, imaginary); the classic way keeps them equal to (\cos \theta, \sin \theta).

thfield
final Float64List th

The classic way's link angles \theta (unused by the rational way).

elfield
final Float64List el

The electric field per link (Hamiltonian evolution only).

grfield
final Float64List gr

The last forces: \frac{\partial F}{\partial\bar{\psi}} per site and \frac{\partial F}{\partial\theta} per link.

gifield
final Float64List gi

The last forces: \frac{\partial F}{\partial\bar{\psi}} per site and \frac{\partial F}{\partial\theta} per link.

flfield
final Float64List fl

The last forces: \frac{\partial F}{\partial\bar{\psi}} per site and \frac{\partial F}{\partial\theta} per link.

alphafield
double alpha

The potential \alpha Q + (\frac{\beta}{2})Q^{2} (\alpha < 0: below T_{c}, the Mexican hat).

betafield
double beta

The potential \alpha Q + (\frac{\beta}{2})Q^{2} (\alpha < 0: below T_{c}, the Mexican hat).

Float64List? alphaMap

\alpha per site, when the temperature isn't uniform (a cooling front); null: alpha everywhere.

hrfield
double hr

The applied field's phase per plaquette, h = (hr, hi) (1: no field).

hifield
double hi

The applied field's phase per plaquette, h = (hr, hi) (1: no field).

bool renormalize

In the rational way, hold |U| to rounding by the quadrance correction U \leftarrow \frac{U(3 - Q)}{2} after each turn.

g2field
double g2

The gauge coupling g^{2} (the charge squared): \frac{1}{g^{2}} weighs the magnetic energy.

mathsgetter
LinkMaths get maths
mathssetter
set maths(LinkMaths m)

Switches the way the links are kept. The state carries over: to classic, \theta = \operatorname{atan2}(im, re) (in classic.ray); to rational, U as it is.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Switching ways mid-run: to classic, θ = atan2(Im U, Re U); the state carries over.
  final l = GaugeLattice(LatticeGeometry(6, 6))..setFieldParameter(0.05);
  l.setPsi((x, y) => (1.0, 0.0));
  for (var k = 0; k < 50; k++) l.relax(0.1);
  final before = l.energy();
  l.maths = LinkMaths.classic;
  print('energy before and after switching: ${before.toStringAsFixed(12)}, ${l.energy().toStringAsFixed(12)}');
  print('θ of link 0 now ${l.th[0].toStringAsFixed(9)}');
}
Output
energy before and after switching: -17.907373592774, -17.907373592774
θ of link 0 now 0.028137748
stepsfield
int steps

Methods

void copyStateFrom(GaugeLattice o)

Copies o's state (same geometry): fields, parameters and the applied field; the classic angles from the links.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // copyStateFrom(o): run a classic twin from a rational lattice's state, then compare after 100 more steps each.
  final g = LatticeGeometry(8, 8);
  final a = GaugeLattice(g)..setFieldParameter(0.05);
  a.setPsi((x, y) => (0.8, 0.0));
  for (var k = 0; k < 50; k++) a.relax(0.1);
  final b = GaugeLattice(g, maths: LinkMaths.classic)..copyStateFrom(a);
  for (var k = 0; k < 100; k++) {
    a.relax(0.1);
    b.relax(0.1);
  }
  print('rational F = ${a.energy().toStringAsFixed(10)}, classic F = ${b.energy().toStringAsFixed(10)}');
}
Output
rational F = -31.8022885252, classic F = -31.8022885252
setPsimethod
void setPsi((double, double) Function(int x, int y) value)

Sets \psi everywhere superconducting from value (x, y) → (re, im), zero elsewhere; \pi cleared.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // setPsi((x, y) → ψ): a vortex-like start ψ = (x − c) + i(y − c), zero outside the sample.
  final g = LatticeGeometry(6, 6, superconducting: (x, y) => x > 0);
  final l = GaugeLattice(g)..setPsi((x, y) => ((x - 2.5) / 3, (y - 2.5) / 3));
  print('ψ(0, 0) = (${l.pr[0]}, ${l.pi[0]}) (vacuum), ψ(1, 0) = (${l.pr[1]}, ${l.pi[1]})');
  print('vortex at the centre plaquette: ${l.vortexAt(g.index(2, 2))}');
}
Output
ψ(0, 0) = (0.0, 0.0) (vacuum), ψ(1, 0) = (-0.5, -0.8333333333333334)
vortex at the centre plaquette: 1
void setFieldParameter(double t)

The applied field's phase per plaquette, by its Cayley parameter: h = e(t), a flux of 2 \cdot \operatorname{atan} t per plaquette.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // setFieldParameter(t): the applied field per plaquette as a Cayley point h = e(t) (flux 2·atan t).
  final l = GaugeLattice(LatticeGeometry(3, 3))..setFieldParameter(0.5);
  print('h = (${l.hr}, ${l.hi})');
}
Output
h = (0.6, 0.8)
void computeForces()

Fills gr, gi (\frac{\partial F}{\partial\bar{\psi}}) and fl (\frac{\partial F}{\partial\theta}).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // computeForces(): ∂F/∂ψ̄ per site and ∂F/∂θ per link (the supercurrent plus the curl of B).
  final g = LatticeGeometry(3, 1);
  final l = GaugeLattice(g, alpha: -1, beta: 1, g2: 1)..setPsi((x, y) => (1.0, 0.0));
  l.setLinks((x, y, mu) => mu == 0 ? cayley(0.5) : (1.0, 0.0));
  l.computeForces();
  print('∂F/∂ψ̄: ${[for (var i = 0; i < 3; i++) '(${l.gr[i].toStringAsFixed(4)}, ${l.gi[i].toStringAsFixed(4)})'].join(' ')}');
  print('∂F/∂θ on the x-links: ${l.fl[0].toStringAsFixed(4)}, ${l.fl[2].toStringAsFixed(4)} (2 Im(ψ̄_j U ψ_i) = 2·(4/5))');
}
Output
∂F/∂ψ̄: (0.4000, 0.8000) (0.8000, 0.0000) (0.4000, -0.8000)
∂F/∂θ on the x-links: 1.6000, 1.6000 (2 Im(ψ̄_j U ψ_i) = 2·(4/5))
(double, double) plaquetteAt(int i)

U_{p} at the plaquette whose lower-left corner is i (1 where there is none).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // plaquetteAt(i): U_p, the field through the plaquette as a unit complex number.
  final g = LatticeGeometry(3, 3);
  final l = GaugeLattice(g)..setLinks((x, y, mu) => mu == 1 && x == 1 ? cayley(0.25) : (1.0, 0.0));
  print('U_p at (0, 0) = ${l.plaquetteAt(g.index(0, 0))}');
  print('U_p at (1, 0) = ${l.plaquetteAt(g.index(1, 0))}');
  print('U_p at (2, 2) (no plaquette) = ${l.plaquetteAt(g.index(2, 2))}');
}
Output
U_p at (0, 0) = (0.8823529411764706, 0.47058823529411764)
U_p at (1, 0) = (0.8823529411764706, -0.47058823529411764)
U_p at (2, 2) (no plaquette) = (1.0, 0.0)
energymethod
double energy()

The free energy F.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // energy(): the Ginzburg–Landau free energy; it decreases step by step under relax.
  final l = GaugeLattice(LatticeGeometry(10, 10), alpha: -0.25, beta: 1, g2: 0.5)..setFieldParameter(0.05);
  l.setPsi((x, y) => (0.3, 0.1));
  final pts = <List<double>>[];
  for (var k = 0; k <= 100; k++) {
    if (k % 5 == 0) pts.add([k.toDouble(), l.energy()]);
    l.relax(0.1);
  }
  print('F at steps 0, 50, 100: ${pts[0][1].toStringAsFixed(6)}, ${pts[10][1].toStringAsFixed(6)}, ${pts[20][1].toStringAsFixed(6)}');
}
Output
F at steps 0, 50, 100: -1.192020, -2.707093, -2.741165
double hamiltonian()

The Hamiltonian (\frac{g^{2}}{2})\Sigma E^{2} + \Sigma|\pi|^{2} + F.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // hamiltonian() = (g²/2)ΣE² + Σ|π|² + F, under evolve, both ways, the same 400 steps.
  final g = LatticeGeometry(16, 1, periodicX: true, periodicY: true);
  final series = <Map<String, Object>>[];
  for (final m in LinkMaths.values) {
    final l = GaugeLattice(g, maths: m, alpha: -0.5, beta: 2, g2: 1)..setPsi((x, y) => (0.3, 0.4));
    l.setLinks((x, y, mu) => mu == 1 ? cayley(0.1 * (x < 8 ? 1 : -1)) : (1.0, 0.0));
    final h0 = l.hamiltonian(), pts = <List<double>>[];
    for (var k = 0; k <= 400; k++) {
      if (k % 20 == 0) pts.add([k.toDouble(), l.hamiltonian() - h0]);
      l.evolve(0.1);
    }
    series.add({'label': m.name, 'points': pts});
    print('${m.name}: H(0) = ${h0.toStringAsFixed(9)}, H(400) − H(0) = ${(l.hamiltonian() - h0).toStringAsExponential(2)}');
  }
}
Output
classic: H(0) = -0.684736791, H(400) − H(0) = 1.63e-3
rational: H(0) = -0.684736791, H(400) − H(0) = 1.63e-3
relaxmethod
void relax(double dt, {double? dtA})

One step of time-dependent Ginzburg–Landau (gradient flow): \psi \leftarrow \psi - dt \cdot \frac{\partial F}{\partial\bar{\psi}}, \theta \leftarrow \theta − dtA·\frac{\partial F}{\partial\theta}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // relax(dt, dtA:): one gradient-flow step; ψ settles on the rim Q₀ = −α/β.
  final l = GaugeLattice(LatticeGeometry(6, 6), alpha: -0.5, beta: 2)..setPsi((x, y) => (0.05, 0.0));
  final pts = <List<double>>[];
  for (var k = 0; k <= 60; k++) {
    pts.add([k.toDouble(), l.pr[14] * l.pr[14] + l.pi[14] * l.pi[14]]);
    l.relax(0.2);
  }
  print('Q at the middle after 60 steps = ${pts.last[1].toStringAsFixed(9)} (rim Q0 = 0.25)');
}
Output
Q at the middle after 60 steps = 0.249915567 (rim Q0 = 0.25)
evolvemethod
void evolve(double dt, {double radialFriction = 0})

One step of the Hamiltonian evolution (symplectic Euler): E \leftarrow E - dt \cdot \frac{\partial F}{\partial\theta}, \pi \leftarrow \pi - dt \cdot \frac{\partial F}{\partial\bar{\psi}}, then the links turn by dt \cdot g^{2}E and \psi \leftarrow \psi + dt \cdot \pi. radialFriction damps only π's component along \psi (gauge invariant: Gauss's law is untouched), so the field settles on the rim of the hat without damping the waves' charge.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // evolve(dt): Hamiltonian real-time step. Gauss's law, both ways, after the same 200 steps.
  final g = LatticeGeometry(6, 6, periodicX: true, periodicY: true);
  for (final m in LinkMaths.values) {
    final l = GaugeLattice(g, maths: m, alpha: -0.5, beta: 2, g2: 1)..setPsi((x, y) => (0.3 + 0.02 * x, 0.4 - 0.03 * y));
    final g0 = [for (var i = 0; i < g.sites; i++) l.gauss(i)];
    for (var k = 0; k < 200; k++) l.evolve(0.1);
    var worst = 0.0;
    for (var i = 0; i < g.sites; i++) {
      final d = (l.gauss(i) - g0[i]).abs();
      if (d > worst) worst = d;
    }
    print('${m.name}: max |Gauss(200) − Gauss(0)| = ${worst == 0 ? '0' : worst < 1e-14 ? 'nonzero, below 1e-14 (rounding)' : worst}');
  }
}
Output
classic: max |Gauss(200) − Gauss(0)| = nonzero, below 1e-14 (rounding)
rational: max |Gauss(200) − Gauss(0)| = nonzero, below 1e-14 (rounding)
gaussmethod
double gauss(int i)

Gauss's law at site i: \sum_{\mathrm{out}} E - \sum_{in} E + 2 \operatorname{Im}(\bar{\pi}_{i} \psi_{i}) (conserved by evolve).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // gauss(i) = Σ_out E − Σ_in E + 2 Im(π̄ψ): put a little E on one link and see the two ends.
  final g = LatticeGeometry(3, 3, periodicX: true, periodicY: true);
  final l = GaugeLattice(g);
  l.el[0] = 0.25; // the +x link from site 0 to site 1
  print([for (var i = 0; i < g.sites; i++) l.gauss(i)].join(', '));
}
Output
0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
vortexAtmethod
int vortexAt(int i)

The vortex number of the plaquette at i, counted exactly by signs (winding.ray): the winding of \psi carried round the plaquette by the links, closed by the plaquette's own phase. 0 outside the sample or where \psi = 0.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // vortexAt(i): the winding of ψ carried round a plaquette, counted exactly by signs.
  final g = LatticeGeometry(8, 8);
  final l = GaugeLattice(g)..setPsi((x, y) => (x - 3.5, y - 3.5));
  final v = [for (var i = 0; i < g.sites; i++) if (l.vortexAt(i) != 0) (g.xOf(i), g.yOf(i), l.vortexAt(i))];
  print('vortices (x, y, n): $v');
  final a = GaugeLattice(g)..setPsi((x, y) => (x - 3.5, -(y - 3.5)));
  print('conjugate field: ${[for (var i = 0; i < g.sites; i++) if (a.vortexAt(i) != 0) a.vortexAt(i)]}');
}
Output
vortices (x, y, n): [(3, 3, 1)]
conjugate field: [-1]
fluxoidmethod
int fluxoid(List<int> path, List<int> interior)

The fluxoid of a closed path of neighbouring sites (counter-clockwise round interior, the plaquettes it encloses): (\frac{1}{2\pi})[\sum_{\mathrm{links}} (\Delta\varphi - A) + \sum_{p} \theta_{p}], an integer, counted exactly by signs. The polygon: \psi carried back to the start link by link (each step turns by one gauge-invariant phase difference), then turned on by each enclosed plaquette's U_{p} in turn (each step one plaquette's flux), which by Stokes ends exactly where it began.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // fluxoid(path, interior): phase winding plus enclosed flux, an integer, counted by signs.
  final g = LatticeGeometry(12, 12);
  final (path, inside) = g.discLoop(5.5, 5.5, 12);
  final l = GaugeLattice(g)..setPsi((x, y) {
    // ψ winding twice round the centre: ((x − c) + i(y − c))².
    final a = x - 5.5, b = y - 5.5;
    return (a * a - b * b, 2 * a * b);
  });
  print('loop of ${path.length} sites round ${inside.length} plaquettes: fluxoid = ${l.fluxoid(path, inside)}');
}
Output
loop of 28 sites round 37 plaquettes: fluxoid = 2
(List<double>, List<double>) fluxoidPolygon(List<int> path, List<int> interior)

The polygon fluxoid winds (the classic count sums the same steps by atan2).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // fluxoidPolygon: the polygon whose winding is the fluxoid (ψ carried link by link, then turned by each U_p).
  final g = LatticeGeometry(8, 8);
  final (path, inside) = g.discLoop(3.5, 3.5, 5);
  final l = GaugeLattice(g)..setPsi((x, y) => (x - 3.5, y - 3.5));
  final (re, im) = l.fluxoidPolygon(path, inside);
  print('${re.length} vertices; winding by signs = ${windingOf(re, im)}');
}
Output
41 vertices; winding by signs = 1
holonomymethod
(double, double) holonomy(List<int> path)

The holonomy \prod U round a closed path (a unit complex number; e^{i\Phi} for the enclosed flux \Phi).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // holonomy(path) = ΠU round a loop = e^{iΦ}: in a uniform field h = e(t) it is h^(plaquettes inside).
  final g = LatticeGeometry(8, 8);
  final (hr, hi) = cayley(0.05);
  final l = GaugeLattice(g)..setLinks((x, y, mu) {
    if (mu == 0) return (1.0, 0.0);
    var r = 1.0, i = 0.0;
    for (var k = 0; k < x; k++) (r, i) = (r * hr - i * hi, r * hi + i * hr);
    return (r, i);
  });
  final (path, inside) = g.discLoop(3.5, 3.5, 5);
  final (wr, wi) = l.holonomy(path);
  var pr = 1.0, pi = 0.0;
  for (var k = 0; k < inside.length; k++) (pr, pi) = (pr * hr - pi * hi, pr * hi + pi * hr);
  print('W = (${wr.toStringAsFixed(12)}, ${wi.toStringAsFixed(12)})');
  print('h^${inside.length} = (${pr.toStringAsFixed(12)}, ${pi.toStringAsFixed(12)})');
  print('half-turn spread of W = ${halfTurnSpread(wr).toStringAsFixed(12)}');
}
Output
W = (-0.503336980130, 0.864090206190)
h^21 = (-0.503336980130, 0.864090206190)
half-turn spread of W = 0.751668490065
void applyGauge(List<double> gRe, List<double> gIm)

Applies the gauge transformation g_{i} = (gRei, gImi) (unit numbers): \psi \to g\psi, \pi \to g\pi, U_{l} \to g_{j} U_{l} \bar{g}_{i}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // applyGauge(gRe, gIm): ψ → gψ, U → g_j U ḡ_i; the energy is unchanged (to rounding in doubles).
  final g = LatticeGeometry(6, 6);
  final l = GaugeLattice(g)..setFieldParameter(0.07)..setPsi((x, y) => (0.5 + 0.1 * x, 0.2 * y));
  for (var k = 0; k < 30; k++) l.relax(0.1);
  final e0 = l.energy();
  final turns = [for (var i = 0; i < g.sites; i++) cayley((i % 7 - 3) / 4)];
  l.applyGauge([for (final t in turns) t.$1], [for (final t in turns) t.$2]);
  print('F before ${e0.toStringAsFixed(12)}, after ${l.energy().toStringAsFixed(12)}, |difference| ${(l.energy() - e0).abs() < 1e-12 ? 'below 1e-12' : (l.energy() - e0).abs()}');
}
Output
F before -17.818820525577, after -17.818820525577, |difference| below 1e-12
noisemethod
void noise(double amplitude, {int seed = 1})

Small random \psi on the superconducting sites (seeded): the fluctuations a cooling sample starts from.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // noise(amplitude, seed:): small seeded random ψ, what a cooling sample starts from.
  final l = GaugeLattice(LatticeGeometry(4, 4))..noise(0.01, seed: 3);
  print('ψ(0) = (${l.pr[0].toStringAsFixed(6)}, ${l.pi[0].toStringAsFixed(6)}), ψ(5) = (${l.pr[5].toStringAsFixed(6)}, ${l.pi[5].toStringAsFixed(6)})');
}
Output
ψ(0) = (-0.002736, -0.008795), ψ(5) = (-0.002685, 0.009043)
unitDriftmethod
double unitDrift()

Max ||U|{}^{2}- 1| over the links (0 for the classic way by construction, rounding for the rational way).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // unitDrift(): max ||U|² − 1|, both ways and the rational way without its quadrance correction; 500 steps each.
  final g = LatticeGeometry(10, 10);
  for (final (name, m, fix) in [('classic', LinkMaths.classic, true), ('rational', LinkMaths.rational, true), ('rational, no correction', LinkMaths.rational, false)]) {
    final l = GaugeLattice(g, maths: m)..setFieldParameter(0.05)..setPsi((x, y) => (0.7, 0.1));
    l.renormalize = fix;
    for (var k = 0; k < 500; k++) l.relax(0.1);
    print('$name: ${l.unitDrift().toStringAsExponential(1)}');
  }
}
Output
classic: 2.2e-16
rational: 2.2e-16
rational, no correction: 2.0e-15
final class MexicanHat

The Mexican hat V(Q) = \alpha Q + (\frac{\beta}{2})Q^{2} in the quadrance Q = |\psi|^{2} (the Ginzburg–Landau potential).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // The Mexican hat V(Q) = αQ + (β/2)Q² in the quadrance Q = |ψ|²: its rim Q₀ = −α/β and depth −α²/(2β) are rational.
  const h = MexicanHat(-0.5, 2);
  print('rim Q0 = ${h.q0}, depth V(Q0) = ${h.depth}, slope at the rim ${h.slope(h.q0)}');
  print('V(0) = ${h.v(0)}, V(Q0) = ${h.v(h.q0)}, V(1/2) = ${h.v(0.5)}');
}
Output
rim Q0 = 0.25, depth V(Q0) = -0.0625, slope at the rim 0.0
V(0) = 0.0, V(Q0) = -0.0625, V(1/2) = 0.0

Constructors

MexicanHatconstructor
const MexicanHat(this.alpha, this.beta)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // MexicanHat(α, β): α < 0 below T_c (a rim), α > 0 above (a bowl).
  const cold = MexicanHat(-1, 1), hot = MexicanHat(1, 1);
  print('cold: Q0 = ${cold.q0}, depth ${cold.depth}; hot: Q0 = ${hot.q0}, depth ${hot.depth}');
}
Output
cold: Q0 = 1.0, depth -0.5; hot: Q0 = 0.0, depth 0.0

Properties

alphafield
final double alpha
betafield
final double beta
q0getter
double get q0

The rim (the vacuum): Q_{0} = -\frac{\alpha}{\beta}, rational (|\psi_{0}| = \sqrt{Q_{0}} would be a root; the lab never needs it).

depthgetter
double get depth

The depth of the rim below the top: V(Q_{0}) = -\frac{\alpha^{2}}{2\beta}.

Methods

vmethod
double v(double q)
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // v(Q): the potential at quadrance Q.
  const h = MexicanHat(-1, 1);
  print([for (final q in [0.0, 0.5, 1.0, 1.5, 2.0]) 'V($q) = ${h.v(q)}'].join(', '));
}
Output
V(0.0) = 0.0, V(0.5) = -0.375, V(1.0) = -0.5, V(1.5) = -0.375, V(2.0) = 0.0
slopemethod
double slope(double q)

V'(Q) = \alpha + \beta Q: ψ's restoring force is -V'(Q)\psi.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // slope(Q) = V′(Q) = α + βQ: ψ is pushed by −V′(Q)ψ, zero on the rim.
  const h = MexicanHat(-0.5, 2);
  print([for (final q in [0.0, 0.25, 0.5]) "V'($q) = ${h.slope(q)}"].join(', '));
}
Output
V'(0.0) = -0.5, V'(0.25) = 0.0, V'(0.5) = 0.5
final class GLParameters

Lattice units (spacing 1) of the model in lattice.ray: hopping weight 1, potential \alpha Q + (\frac{\beta}{2})Q^{2}, magnetic weight \frac{1}{g^{2}}.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Ginzburg–Landau in lattice units: ξ², λ², κ² and the masses as squares; type II when κ² > 1/2.
  const p = GLParameters(alpha: -0.25, beta: 4, g2: 0.5);
  print('Q0 = ${p.q0}, ξ² = ${p.xi2}, λ² = ${p.lambda2}, κ² = ${p.kappa2}, type II: ${p.typeII}');
  print('photon m² = ${p.photonMass2}, Higgs m² = ${p.higgsMass2}, ratio = ${p.higgsMass2 / p.photonMass2} = 2κ²');
}
Output
Q0 = 0.0625, ξ² = 4.0, λ² = 16.0, κ² = 4.0, type II: true
photon m² = 0.0625, Higgs m² = 0.5, ratio = 8.0 = 2κ²

Constructors

GLParametersconstructor
const GLParameters({required this.alpha, required this.beta, required this.g2})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // GLParameters(alpha:, beta:, g2:): the type-I and type-II materials of the lab.
  for (final (name, p) in [('type I', const GLParameters(alpha: -1 / 36, beta: 1, g2: 2)), ('type II', const GLParameters(alpha: -0.25, beta: 4, g2: 0.5))]) {
    print('$name: κ² = ${p.kappa2}, type II: ${p.typeII}');
  }
}
Output
type I: κ² = 0.25, type II: false
type II: κ² = 4.0, type II: true

Properties

alphafield
final double alpha
betafield
final double beta
g2field
final double g2
q0getter
double get q0

Q_{0} = -\frac{\alpha}{\beta}.

xi2getter
double get xi2

\xi^{2} = \frac{1}{|\alpha|} (the coherence length squared).

lambda2getter
double get lambda2

\lambda^{2} = \frac{1}{2g^{2}Q_{0}} (the London penetration depth squared): no root.

kappa2getter
double get kappa2

\kappa^{2} = \frac{\lambda^{2}}{\xi^{2}} = \frac{\beta}{2g^{2}}; type II when \kappa^{2} > \frac{1}{2} (\kappa > \frac{1}{\sqrt{2}}), with no root.

typeIIgetter
bool get typeII
double get photonMass2

The photon's mass squared in the condensate, m_{A}^{2} = 2g^{2}Q_{0} = \frac{1}{\lambda^{2}}.

double get higgsMass2

The Higgs (amplitude) mode's mass squared, m_{H}^{2} = 2\beta Q_{0} = -2\alpha; \frac{m_{H}^{2}}{m_{A}^{2}} = 2\kappa^{2}.

final class Electroweak

The electroweak masses at tree level from g^{2}, g'^{2} and v^{2} (all squares: Rational).

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Tree-level electroweak masses from squares only; the weak mixing spread s_W = g′²/(g² + g′²).
  const e = Electroweak.standard;
  print('m_W² = ${e.mW2.toStringAsFixed(3)} GeV², m_Z² = ${e.mZ2.toStringAsFixed(3)} GeV²');
  print('s_W = ${e.sW.toStringAsFixed(6)}, c_W = ${e.cW.toStringAsFixed(6)}, m_W²/m_Z² = ${(e.mW2 / e.mZ2).toStringAsFixed(6)}');
  print('photon m² = ${e.photonMass2}');
}
Output
m_W² = 6431.398 GeV², m_Z² = 8359.574 GeV²
s_W = 0.230655, c_W = 0.769345, m_W²/m_Z² = 0.769345
photon m² = 0.0

Constructors

Electroweakconstructor
const Electroweak({required this.g2, required this.gp2, required this.v2})
Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Electroweak(g2:, gp2:, v2:): any couplings; equal g and g′ give s_W = 1/2.
  const e = Electroweak(g2: 0.25, gp2: 0.25, v2: 4);
  print('s_W = ${e.sW}, m_W² = ${e.mW2}, m_Z² = ${e.mZ2}');
}
Output
s_W = 0.5, m_W² = 0.25, m_Z² = 0.5

Static

standardconstant
static const standard = Electroweak(g2: 0.652 * 0.652, gp2: 0.357 * 0.357, v2: 246.0 * 246.0)

g = 0.652, g' = 0.357, v = 246 GeV.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // Electroweak.standard: g = 0.652, g′ = 0.357, v = 246 GeV.
  const e = Electroweak.standard;
  print('g² = ${e.g2.toStringAsFixed(6)}, g′² = ${e.gp2.toStringAsFixed(6)}, v² = ${e.v2}');
  print('s_W = ${e.sW.toStringAsFixed(4)}');
}
Output
g² = 0.425104, g′² = 0.127449, v² = 60516.0
s_W = 0.2307

Properties

g2field
final double g2
gp2field
final double gp2
v2field
final double v2
mW2getter
double get mW2

m_{W}^{2} = \frac{g^{2}v^{2}}{4}.

mZ2getter
double get mZ2

m_{Z}^{2} = \frac{(g^{2} + g'^{2})v^{2}}{4}.

sWgetter
double get sW

The weak mixing spread s_{W} = \frac{g'^{2}}{g^{2} + g'^{2}} (classically \sin^{2}\theta_{W}): the spread between (g, g') and the g axis.

cWgetter
double get cW

The cross c_{W} = 1 - s_{W} = \frac{m_{W}^{2}}{m_{Z}^{2}}.

double get photonMass2

The photon stays massless: the combination g'W³ + gB the vacuum doesn't charge.

Methods

double higgsMass2(double lambda)

m_{h}^{2} = 2\lambda v^{2} for the Higgs self-coupling \lambda.

Example
import 'package:riptide_kepler/riptide_kepler.ray' show ExactArith, F64Arith;
import 'package:riptide_precision/riptide_precision.ray' show Rational;
import 'package:riptide_rational_gauge/riptide_rational_gauge.ray';
import 'raya:convert';

void main() {
  // higgsMass2(λ) = 2λv²; λ ≈ 0.129 gives m_h² ≈ 125² GeV².
  const e = Electroweak.standard;
  final m2 = e.higgsMass2(0.129);
  print('m_h² = ${m2.toStringAsFixed(1)} GeV² (125² = ${125 * 125})');
}
Output
m_h² = 15613.1 GeV² (125² = 15625)