Skip to content

Numerical methods

JoSIM solves the transient circuit equations using voltage or phase as the nodal unknown. It uses the second-order backward difference formula (BDF2):

\[ \left.\frac{dx}{dt}\right|_n\approx \frac{3x_n-4x_{n-1}+x_{n-2}}{2h}, \]

where h is the internal timestep. Nonlinear junction terms are predicted from previous samples. Without nonlinear inductors, each step uses one sparse linear solve. Quadratic inductors add the correction described below. JoSIM does not provide general SPICE RELTOL/ABSTOL controls or a fully implicit junction solve.

Nonlinear inductors

For the quadratic inductor model, voltage mode differentiates total flux linkage with BDF2. Phase mode imposes SIGMA*(phi_positive-phi_negative)=Phi_total. The solver corrects the inductor rows using damped Newton iteration, retaining KLU's symbolic analysis and refactorizing the numerical coefficients together for each iteration.

The flux residual must be below 1e-26 Wb + 1e-12*S, where S is the sum of the absolute node-derived flux, self flux, mutual flux terms and BDF2 history contribution in that row. Sources, noise samples, junction predictions and histories are evaluated once per attempted step and held fixed during correction. Junction terms retain their existing explicit predictor.

Each step permits at most 40 Newton corrections and 16 damping halvings per correction. Failure restarts the complete run at half the timestep, restoring the initial state and random streams. Circuits with nonlinear inductors permit at most eight such timestep reductions, including junction phase-advance retries; failure then reports an error. These residual and iteration limits are not a local integration-error estimate. Check timestep refinement for the quantities of interest, especially large excursions and long ladders.

Timestep and startup

Each attempt uses a fixed timestep. Transmission-line delays can require a smaller step when the matrix is built. During a run, a predicted junction phase increment above 0.2 cycles after the first 1% of samples causes the whole run to restart at half the timestep. The step is never increased automatically.

This phase-advance check is not an estimate of integration error. Repeat the simulation with a smaller requested step and compare the quantities that matter for the circuit. Use -V 1 to see the final step and sample count. Settling time, noise bandwidth and output sampling need their own checks.

Default startup advances the circuit through a finite negative-time interval from zero stored histories. It does not calculate a DC operating point. DST disables this interval. With explicit capacitor IC=, a coupled initial solve supplies the voltages, currents and voltage derivatives at t=0. These give linear voltage and quadratic phase histories for starting BDF2; the actual initial state is output before the first advance to h. Each timestep restart reconstructs that state. See the initial-state guide for supported circuits and the alternative of a physical charging interval.

Junction phase

The Josephson voltage relation is

\[ V=\sigma\frac{d\phi}{dt},\qquad \sigma=\frac{\Phi_0}{2\pi}. \]

Under constant voltage, phase should therefore increase linearly:

\[ \phi(t)-\phi(t_a)=\frac{V}{\sigma}(t-t_a). \]

This provides a simple check for long simulations. Earlier versions used slightly different constants in the junction matrix and history terms, which caused an accumulating phase error in voltage mode. Version 3.0 uses the same constant in both places. Phase is not wrapped, so accumulated cycles remain available in the output.

Buffer example

The circuit in issue #101 has two junctions and two inductors. Its reverse response contains positive and negative voltage pulses, even though their net area is almost zero. B02 makes a negative phase excursion while B01 returns; the two voltage peaks need not coincide.

A separate integration of the Kirchhoff and RCSJ equations gives the same response. For the supplied parameters, the reverse net pulse area is about -1.38e-6 Phi0, while the forward area is about 0.999998 Phi0. The triangular input pulse is approximately 4.3 ppm below one flux quantum.

The reference circuits and data include both directions. They use the subgap resistance because the junction voltages stay below the model's transition region. Tests compare both JoSIM analysis modes with the reference and repeat them at smaller timesteps.

Noise and output sampling

A resolved integration step does not by itself prevent output aliasing. Check the print interval and filtering against the frequencies present in the circuit. The noise guide describes the interpolation and bandwidth conventions; the SQUID example shows how to compare bandwidth, timestep and sample spacing.