APSLF Bridge Reference

Public API

Sparlectra.ApslfSolver — Type
ApslfSolver <: AbstractExternalSolver

Adapter that runs a PFModel through AnalyticLoadFlow.jl's solve_pf_apslf.

Fields:

  • order::Int = 24: highest power-series coefficient to compute.
  • nr_polish::Bool = false: run a Newton-Raphson polishing step on the series result. Off since 0.13.0 (AnalyticLoadFlow 0.9.15): the series alone is a load-flow solution, the polish is a debugging aid.
  • mode::Symbol = :direct: :direct (native PV handling) or :outer (PQ-only series plus an outer secant loop for PV enforcement); forwarded to solve_pf_apslf.
  • convergence_radius::Bool = true: evaluate AnalyticLoadFlow's Padé-pole margin (stability_from_Vcoeff: the distance dmin of the nearest Padé pole to the evaluation point s = 1, with the bus that owns it and the GRN/YEL/RED level). Reported as the Padé margin next to the Jacobian condition; costs about as much as the solve itself, so it can be switched off for large networks. The margin is not the convergence radius of the series (a Froissart doublet can sit next to s = 1 on a convergent series), so the result carries the coefficient-growth radius of the series as well; that one is a root test on the coefficients and always evaluated (see _apslf_series_radius).
  • precision::Symbol = :float64: arithmetic of the series and the Padé evaluation, :float64 or :double_double (AnalyticLoadFlow 0.11, direct mode only); forwarded to solve_pf_apslf.

apslf_solver is the keyword constructor for it and checks precision against mode.

source
Sparlectra.solvePf — Method
solvePf(solver::ApslfSolver, model::PFModel; kwargs...) -> PFSolution

Solve model with AnalyticLoadFlow.jl's analytic power-series solver.

Maps the canonical PFModel fields onto the AnalyticLoadFlow spec via _apslf_spec_from_model. The returned voltage vector is in the same PF ordering as model.busIdx_net.

model.V0 is not used as a start: AnalyticLoadFlow always starts from its own analytic germ and does not accept an external start voltage. Only the angle of V0[slack_idx] is read, as the slack angle (see _apslf_spec_from_model).

meta carries solver-specific diagnostics: the series/Padé order, the Padé margin (stability: dmin/pole/bus/level, derived from the distance of Padé poles to the physical evaluation point s = 1), the coefficient-growth radius of the series (series_radius: radius/bus, see _apslf_series_radius), and NR-polish bookkeeping (enabled/success/improved/rejected/reject_reason), and for a non-converged run the diagnosis of AnalyticLoadFlow (reason, message, pole_min_abs, pole_bus, pole_pair, pade_change, order; nothing when the run converged). The bus fields are in the numbering of the net the model was built from (busIdx_net).

Without a finite reactive limit in model the direct kernel runs one outer pass instead of up to 30 identical ones (see _apslf_solve).

Extra kwargs (e.g. tol forwarded by runpf_external!) are accepted and ignored; convergence/polish behavior is controlled entirely via the ApslfSolver fields.

source

Internals

Sparlectra.APSLF_MIN_VERSION — Constant
APSLF_MIN_VERSION

Lowest AnalyticLoadFlow.jl version the adapter is verified against (0.10.2: a non-converged result carries the diagnosis that solvePf passes on; since 0.10.0 the series is evaluated with Padé only, so the adapter passes no use_pade, and an older version would fall back to direct Taylor summation). The Project.toml compat carries the same bound, but Julia does not check a Manifest against the compat at load time: an environment whose Manifest predates the bump loads the older version without a message, and an older version can return a wrong series result flagged as converged. check_apslf_version closes that gap at load time.

source
Sparlectra._apslf_series_radius — Method
_apslf_series_radius(Vcoeff, slack) -> (radius, idx)

Coefficient-growth (root test) estimate of the radius of convergence of the APSLF voltage series in the embedding parameter s: for every non-slack row i of Vcoeff (PF ordering, column k + 1 holds the coefficient of s^k), the smallest |c_k|^(-1/k) over the last four orders, then the smallest over the rows; idx is the row that sets it. A radius below 1 means the plain series does not reach the physical point s = 1 (the Padé evaluation may still continue past it); this is the number that predicted the outcome on the grid-bench data sets where the Padé margin did not. Inf when every coefficient beyond order 0 vanishes, NaN (with idx = 0) for a series of order 0.

source
Sparlectra._apslf_spec_from_model — Method
_apslf_spec_from_model(model::PFModel) -> NamedTuple

Pure mapping from the canonical PFModel fields onto the AnalyticLoadFlow spec expected by solve_pf_apslf: Ybus → Y, busType → bustype, real/imag(Sspec) → Pspec/Qspec, Vset → Vm, qmin_pu/qmax_pu → Qmin/Qmax (the band of the bus injection, see PFModel; defaulting to -Inf/Inf when model carries no Q-limits), slack_idx → slack, and Vslack, the complex slack voltage: magnitude Vset[slack_idx], angle of V0[slack_idx] (the slack angle of the net, which getBusData keeps under a flat start as well). _apslf_solve passes Vslack as the keyword of the same name; without it AnalyticLoadFlow fixes the slack at angle 0 and the whole solution comes back rotated by the slack angle. Split out from solvePf so the mapping itself is independently testable.

source
Sparlectra.check_apslf_version — Function
check_apslf_version(loaded = pkgversion(AnalyticLoadFlow)) -> VersionNumber

Return loaded when it satisfies APSLF_MIN_VERSION, otherwise throw an ErrorException that names both versions and the Pkg command that fixes the environment. Called from the module __init__, so an outdated environment fails using Sparlectra with the cause in one line instead of producing wrong voltages later. Tests call it with an explicit version.

source