|
| 1 | +"""Localized steady states of the LLE: solitons, soliton crystals, |
| 2 | +and parameter continuation. |
| 3 | +
|
| 4 | +`newton_state` solves the stationary Lugiato-Lefever equation |
| 5 | +
|
| 6 | + 0 = -(1 + i alpha) psi + i |psi|^2 psi + i D psi + F |
| 7 | +
|
| 8 | +by Newton's method in Fourier space -- and its Jacobian is the same |
| 9 | +linearization the package's `fluctuation_matrix` builds around a |
| 10 | +steady state, evaluated at the current iterate: the operator that |
| 11 | +damps a perturbation of a steady state and the operator Newton inverts |
| 12 | +to find that steady state are one and the same. (The solver keeps the |
| 13 | +grid's wrapped convolution entries that the physically mode-truncated |
| 14 | +`fluctuation_matrix` sets to zero -- the exact Jacobian of the |
| 15 | +*discrete* equations, needed for machine-precision convergence. The |
| 16 | +wrapped entries only transfer amplitude across the band edge, so on |
| 17 | +the resolved soliton's own modes the two operators act identically: |
| 18 | +the test suite asserts that both annihilate the translation mode to |
| 19 | +1e-9.) |
| 20 | +
|
| 21 | +Exact facts the test suite asserts, rather than states: |
| 22 | +
|
| 23 | +* the converged residual is below the requested tolerance (the solver |
| 24 | + refuses to return otherwise), and the converged state, handed to the |
| 25 | + independent split-step evolver `lle_evolve`, stays put; |
| 26 | +* from a flat seed, Newton lands on the exact root of the homogeneous |
| 27 | + cubic; |
| 28 | +* an N-fold soliton crystal on the 2 pi ring equals, to machine |
| 29 | + precision, the single soliton of the same equation with dispersion |
| 30 | + d_m scaled by N^m, resampled onto the crystal grid -- the exact |
| 31 | + rescaling theta -> N theta of the periodic domain; |
| 32 | +* the linearization around any localized steady state carries an |
| 33 | + *exact* zero eigenvalue whose eigenvector is the translation mode |
| 34 | + d psi / d theta (Goldstone mode of the broken translation symmetry); |
| 35 | + the drift matrix is therefore marginally, not asymptotically, stable, |
| 36 | + and the spectra machinery refuses it unless told that the marginal |
| 37 | + direction is understood (`allow_marginal`, see `spectra`). |
| 38 | +
|
| 39 | +The sech seed uses the standard soliton asymptotics of the anomalous |
| 40 | +LLE (amplitude ~ sqrt(2 alpha), width ~ sqrt(|d2| / alpha), pump phase |
| 41 | +cos phi_0 = sqrt(8 alpha) / (pi F); T. Herr et al., Nature Photonics 8, |
| 42 | +145 (2014)); the *converged* answers never depend on the seed quality, |
| 43 | +only Newton's basin does. |
| 44 | +""" |
| 45 | +from __future__ import annotations |
| 46 | + |
| 47 | +import numpy as np |
| 48 | + |
| 49 | +from .lle import _linear_symbol, homogeneous_steady_states |
| 50 | + |
| 51 | +__all__ = ["newton_state", "soliton_seed", "continuation"] |
| 52 | + |
| 53 | + |
| 54 | +def _residual_k(psi, F, alpha, dispersion): |
| 55 | + """Stationary-LLE residual in Fourier space (FFT convention).""" |
| 56 | + n = psi.size |
| 57 | + k = np.fft.fftfreq(n, d=1.0 / n) |
| 58 | + L = _linear_symbol(alpha, dispersion, k) |
| 59 | + Rk = L * np.fft.fft(psi) + np.fft.fft(1j * np.abs(psi) ** 2 * psi) |
| 60 | + Rk[0] += F * n |
| 61 | + return Rk |
| 62 | + |
| 63 | + |
| 64 | +def _jacobian(psi, alpha, dispersion): |
| 65 | + """Exact Jacobian of the discrete (pseudospectral) residual, in the |
| 66 | + doubled Fourier basis. |
| 67 | +
|
| 68 | + Identical to `fluctuation_matrix` except that the products |
| 69 | + 2 |psi|^2 delta and psi^2 conj(delta) are the *grid's* circular |
| 70 | + convolutions (mode transfers taken modulo n): the exact Jacobian |
| 71 | + of the discrete pseudospectral residual, which Newton needs to |
| 72 | + converge to machine precision. The entries where the two differ |
| 73 | + are exactly the wrapped transfers across the band edge; on |
| 74 | + perturbations resolved inside the band the two operators act |
| 75 | + identically, which the test suite asserts on the soliton's |
| 76 | + translation mode. |
| 77 | + """ |
| 78 | + psi = np.asarray(psi, dtype=complex) |
| 79 | + n = psi.size |
| 80 | + kgrid = np.fft.fftfreq(n, d=1.0 / n).astype(int) |
| 81 | + f_abs2 = np.fft.fft(np.abs(psi) ** 2) / n |
| 82 | + f_sq = np.fft.fft(psi ** 2) / n |
| 83 | + L = _linear_symbol(alpha, dispersion, kgrid.astype(float)) |
| 84 | + # FFT layout: the component of mode value v sits at slot v mod n |
| 85 | + A = 2j * f_abs2[(kgrid[:, None] - kgrid[None, :]) % n] |
| 86 | + B = 1j * f_sq[(kgrid[:, None] + kgrid[None, :]) % n] |
| 87 | + A[np.arange(n), np.arange(n)] += L |
| 88 | + return np.block([[A, B], [np.conj(B), np.conj(A)]]) |
| 89 | + |
| 90 | + |
| 91 | +def newton_state(psi0, F, alpha, dispersion=(0.0,), tol=1e-12, |
| 92 | + maxiter=60): |
| 93 | + """Newton solution of the stationary LLE from the seed psi0. |
| 94 | +
|
| 95 | + Returns (psi, info) with info = {"residual", "iterations"}; the |
| 96 | + residual is the max-norm of the stationary equation on the theta |
| 97 | + grid. Raises RuntimeError if the tolerance is not reached -- a |
| 98 | + state is never returned unverified. The Jacobian at each iterate |
| 99 | + is the exact discrete form of `fluctuation_matrix(psi, alpha, |
| 100 | + dispersion)` (see `_jacobian`). |
| 101 | + """ |
| 102 | + psi = np.asarray(psi0, dtype=complex).copy() |
| 103 | + n = psi.size |
| 104 | + res = np.inf |
| 105 | + for it in range(int(maxiter)): |
| 106 | + Rk = _residual_k(psi, F, alpha, dispersion) |
| 107 | + res = float(np.abs(np.fft.ifft(Rk)).max()) |
| 108 | + if res < tol: |
| 109 | + return psi, {"residual": res, "iterations": it} |
| 110 | + J = _jacobian(psi, alpha, dispersion) |
| 111 | + rhs = np.concatenate([Rk / n, np.conj(Rk) / n]) |
| 112 | + # minimal-norm least-squares step: at a localized state the |
| 113 | + # Jacobian is exactly singular along the translation (Goldstone) |
| 114 | + # mode, and the minimal-norm solution is the Newton step that |
| 115 | + # does not slide along the soliton position |
| 116 | + delta = np.linalg.lstsq(J, -rhs, rcond=1e-9)[0] |
| 117 | + psi = psi + np.fft.ifft(delta[:n] * n) |
| 118 | + raise RuntimeError( |
| 119 | + f"Newton did not reach tol = {tol:g} in {maxiter} iterations " |
| 120 | + f"(residual {res:.3e}); refusing to return an unconverged " |
| 121 | + "state") |
| 122 | + |
| 123 | + |
| 124 | +def soliton_seed(n, F, alpha, dispersion, n_pulses=1): |
| 125 | + """Sech ansatz seed for `newton_state`: the lower flat state plus |
| 126 | + ``n_pulses`` equally spaced sech pulses with the standard |
| 127 | + asymptotic amplitude sqrt(2 alpha), width sqrt(|d2| / (2 alpha)) |
| 128 | + and pump phase cos phi_0 = sqrt(8 alpha) / (pi F) (Herr et al., |
| 129 | + Nature Photonics 8, 145 (2014)). Anomalous dispersion (d2 < 0 in |
| 130 | + this package's sign convention) required. |
| 131 | + """ |
| 132 | + d2 = float(dispersion[0]) |
| 133 | + if d2 >= 0.0: |
| 134 | + raise ValueError("bright-soliton seeds need anomalous " |
| 135 | + "dispersion (d2 < 0 in this convention)") |
| 136 | + roots = homogeneous_steady_states(F, alpha) |
| 137 | + rho_low = float(roots[0]) |
| 138 | + psi_low = F / (1.0 + 1j * (alpha - rho_low)) |
| 139 | + arg = np.sqrt(8.0 * alpha) / (np.pi * F) |
| 140 | + phi0 = np.arccos(min(arg, 1.0)) |
| 141 | + theta = 2.0 * np.pi * np.arange(n) / n |
| 142 | + width = np.sqrt(abs(d2) / (2.0 * alpha)) |
| 143 | + psi = np.full(n, psi_low, dtype=complex) |
| 144 | + for p in range(int(n_pulses)): |
| 145 | + center = 2.0 * np.pi * (p + 0.5) / n_pulses |
| 146 | + d = np.angle(np.exp(1j * (theta - center))) # wrapped distance |
| 147 | + psi += np.sqrt(2.0 * alpha) * np.exp(1j * phi0) / np.cosh(d / width) |
| 148 | + return psi |
| 149 | + |
| 150 | + |
| 151 | +def continuation(psi0, F, alphas, dispersion=(0.0,), tol=1e-12, |
| 152 | + maxiter=60): |
| 153 | + """Sweep the detuning: Newton-solve at each alpha in ``alphas``, |
| 154 | + seeding each step with the previous converged state. |
| 155 | +
|
| 156 | + Returns (states, infos) as lists. Every step is verified to the |
| 157 | + tolerance or the sweep raises (naming the failing alpha), so a |
| 158 | + returned branch contains no unconverged member. Sweeping F at |
| 159 | + fixed alpha works by transposing the roles: call in a loop, this |
| 160 | + function stays deliberately simple. |
| 161 | + """ |
| 162 | + psi = np.asarray(psi0, dtype=complex).copy() |
| 163 | + states, infos = [], [] |
| 164 | + for a in alphas: |
| 165 | + try: |
| 166 | + psi, info = newton_state(psi, F, float(a), dispersion, |
| 167 | + tol=tol, maxiter=maxiter) |
| 168 | + except RuntimeError as exc: |
| 169 | + raise RuntimeError( |
| 170 | + f"continuation failed at alpha = {a}: {exc}") from exc |
| 171 | + states.append(psi.copy()) |
| 172 | + infos.append(info) |
| 173 | + return states, infos |
0 commit comments