Skip to content

API Reference ​

Package Overview ​

IonosphereElectrodynamics Module
julia
IonosphereElectrodynamics

Standalone, zero-allocation 2D spherical magnetosphere–ionosphere (M–I) coupling solver. Solves the height-integrated ionospheric potential equation     on both hemispheres in dipole SMG coordinates and maps potentials, electric fields, and   convection velocities along dipole field lines.

source

Conductance & Mobility Models ​

IonosphereElectrodynamics.AbstractConductanceModel Type
julia
AbstractConductanceModel

Abstract supertype for height-integrated ionospheric Pedersen and Hall conductance models evaluated on a 2D spherical thin-shell ionosphere.

source
IonosphereElectrodynamics.UniformConductance Type
julia
UniformConductance(sigma_P, sigma_H = zero(sigma_P); FT = nothing) <: AbstractConductanceModel

Spatially uniform height-integrated Pedersen conductance sigma_P > 0 and Hall conductance sigma_H. Element type FT is inferred from arguments when not specified (defaulting to Float64 for integer inputs).

source
IonosphereElectrodynamics.SolarEUVConductance Type
julia
SolarEUVConductance(;
    sigma_P_day = 10.0,
    sigma_H_day = 15.0,
    sigma_P_night = 1.0,
    sigma_H_night = 0.5,
    sun_dir = (1.0, 0.0, 0.0),
    exponent = 0.5,
    twilight_deg = 0.0,
    FT = nothing,
) <: AbstractConductanceModel

Dayside solar-EUV conductance model parameterized by solar zenith angle (  ):

When twilight_deg > 0 (e.g., 15.0 corresponding to terminator twilight up to ),    provides a smooth, AD-differentiable transition across the terminator  .

source
IonosphereElectrodynamics.MoenBrekkeEUVConductance Type
julia
MoenBrekkeEUVConductance(;
    f107 = 150.0,
    sigma_P_night = 1.0,
    sigma_H_night = 0.5,
    sun_dir = (1.0, 0.0, 0.0),
    twilight_deg = 0.0,
    FT = nothing,
) <: AbstractConductanceModel

Moen & Brekke (1993) solar-EUV ionospheric conductance model driven by the radio flux index in SI units (Siemens), combined in quadrature with nightside floors and an optional smooth twilight terminator width twilight_deg.

source
IonosphereElectrodynamics.AuroralConductance Type
julia
AuroralConductance(
    base::AbstractConductanceModel;
    sigma_P_max = 15.0,
    hall_ratio = 1.5,
    fac_scale = 1.0e-6,
    mode = :tanh_sqrt,
    FT = nothing,
) <: AbstractConductanceModel

Dynamic upward-FAC auroral precipitation conductance wrapper around any base AbstractConductanceModel. Enhances in quadrature where outward radial FAC   :

  • mode = :tanh_sqrt (FLEKS/RIM):  .

  • mode = :saturating:   .

source
IonosphereElectrodynamics.RobinsonConductance Type
julia
RobinsonConductance(
    base::AbstractConductanceModel;
    E0_bg = 0.5,
    dE_scale = 5.0,
    fac_scale = 1.0e-6,
    flux_scale = 1.0,
    FT = nothing,
) <: AbstractConductanceModel

Dynamic upward-FAC auroral conductance wrapper using Knight (1973) electron precipitation and the empirical Robinson et al. (1987) Pedersen and Hall formulas combined in quadrature with base:

source
IonosphereElectrodynamics.HardyConductance Type
julia
HardyConductance(
    base::AbstractConductanceModel;
    kp = 3.0,
    sun_dir = (1.0, 0.0, 0.0),
    scale = 1.0,
    FT = nothing,
) <: AbstractConductanceModel

Kp-driven Hardy et al. (1987) statistical auroral oval conductance model superimposed in quadrature onto base.

source
IonosphereElectrodynamics.OvationConductance Type
julia
OvationConductance(
    base::AbstractConductanceModel;
    coupling = 4421.0,
    coupling_ref = 4421.0,
    sun_dir = (1.0, 0.0, 0.0),
    scale = 1.0,
    FT = nothing,
) <: AbstractConductanceModel

Newell / OVATION-Prime auroral conductance model driven by the solar-wind magnetospheric coupling function , superimposed in quadrature onto base.

source
IonosphereElectrodynamics.CustomConductance Type
julia
CustomConductance(fn; uses_jr = false) <: AbstractConductanceModel

User-supplied conductance callback. When uses_jr = false (default), fn(theta, phi, t) returns (sigma_P, sigma_H). When uses_jr = true, fn(theta, phi, t, jr_outward) receives outward radial FAC jr_outward as well. sigma_P must be finite and strictly positive everywhere.

source
IonosphereElectrodynamics.knight_precipitation Function
julia
knight_precipitation(
    jr_up::Real;
    E0_bg = 0.5,
    dE_scale = 5.0,
    fac_scale = 1.0e-6,
    flux_scale = 1.0,
) -> Tuple{T, T}

Compute auroral electron mean precipitating energy E0_keV [keV] and downward energy flux flux_mWm2 [mW/m²] from upward field-aligned current jr_up using a smooth Knight (1973) current–voltage relation:

source
IonosphereElectrodynamics.evaluate_conductance Function
julia
evaluate_conductance(
    model::AbstractConductanceModel,
    theta::Real,
    phi::Real,
    r_hat,
    t::Real;
    jr_outward::Real = 0,
) -> Tuple{T, T}

Evaluate height-integrated Pedersen and Hall conductances (sigma_P, sigma_H) for model at dipole colatitude theta, longitude phi, simulation-frame unit radial vector r_hat (SVector{3}, AbstractVector, or NTuple{3}), simulation time t, and optional outward FAC jr_outward.

source
IonosphereElectrodynamics.electron_mobility_tensor Function
julia
electron_mobility_tensor(sigma_p::Real, sigma_h::Real, b_hat; sigma_0::Real = sigma_p) -> SMatrix{3,3}

Construct the anisotropic 3D conductance/mobility tensor sigma_0 b bᵀ + sigma_p (I - b bᵀ) + sigma_h (b ×). Accepts any length-3 SVector, AbstractVector, or NTuple for b_hat and promotes across generic Real types.

source

Dipole Frame & Field-Line Mapping ​

IonosphereElectrodynamics.DipoleFrame Type
julia
DipoleFrame{FT <: Real}

Immutable, isbits-compatible orthonormal Solar Magnetic (SMG) coordinate frame built from a 3D planetary dipole moment vector.

  • center: Body / dipole center in simulation coordinates.

  • rot: Orthonormal rotation matrix whose rows (e1, e2, e3) map simulation vectors to SMG coordinates (x_smg = rot * (x_sim - center)), with e3[3] >= 0 pointing toward geographic/simulation North.

  • dipole_moment, M0: 3D dipole moment vector and magnitude norm(dipole_moment).

  • dipole_sign: -1 for Earth-like polarity (m ⋅ e3 < 0), +1 for reversed polarity.

  • r_iono: Ionospheric shell radius in simulation length units.

source
IonosphereElectrodynamics.build_dipole_frame Function
julia
build_dipole_frame(
    dipole_moment;
    center = (0.0, 0.0, 0.0),
    r_iono = 1.0,
    FT = nothing,
) -> DipoleFrame

Construct a DipoleFrame from dipole_moment, matching FLEKS's SMG convention: e3 always points toward northern simulation hemisphere (e3[3] >= 0), dipole_sign records the polarity along e3 (-1 Earth-like, +1 reversed), and e1 is the projection of simulation +x (falling back to +y when |e3[1]| > 0.99) orthogonal to e3. Element type FT is inferred from inputs when omitted.

source
IonosphereElectrodynamics.dipole_B0 Function
julia
dipole_B0(frame::DipoleFrame, x_sim; r_min = eps(...)) -> SVector{3}

Evaluate the analytic dipole magnetic field at simulation position x_sim (SVector{3}, AbstractVector, or NTuple{3}) using frame.center and frame.dipole_moment (softened at r_min).

source
IonosphereElectrodynamics.map_dipole_smg Function
julia
map_dipole_smg(x_smg, r_map::Real) -> (i_hem, x_map, theta_map, phi_map)

Map SMG position x_smg (SVector{3}, AbstractVector, or NTuple{3}) along the dipole field line   to radius r_map. Returns (i_hem, x_map, theta_map, phi_map) where i_hem is +1 (north), -1 (south), or 0 (closed equatorial field line with  ).

source
IonosphereElectrodynamics.map_dipole_smg_with_jacobian Function
julia
map_dipole_smg_with_jacobian(
    x_smg, r_map::Real
) -> (i_hem, x_map, theta_map, phi_map, jac_smg)

Map SMG position x_smg (SVector{3}, AbstractVector, or NTuple{3}) along the dipole field line   to radius r_map, returning (i_hem, x_map, theta_map, phi_map, jac_smg) where jac_smg::SMatrix{2, 3, T, 6} is the exact closed-form Jacobian in SMG coordinates.

source
IonosphereElectrodynamics.dipole_conductance_tensor Function
julia
dipole_conductance_tensor(
    sigma_P::Real,
    sigma_H::Real,
    cos_theta::Real,
    sin_theta::Real,
    dipole_sign::Real;
    sigma_0_ratio = 1000,
    sigma_parallel = nothing,
    use_dip_angle = true,
) -> (sigma_tt, sigma_tp, sigma_pp)

Compute the height-integrated spherical conductance tensor components at dipole colatitude matching Goodman (1995) / Ridley et al. (2004) / FLEKS, including finite parallel conductance , equatorial Cowling enhancement in , and exact dipole-polarity Hall sign (-dipole_sign).

source
IonosphereElectrodynamics.dipole_fac_sample_point Function
julia
dipole_fac_sample_point(
    frame::DipoleFrame,
    theta_i::Real,
    phi::Real,
    r_fac::Real,
) -> (valid, x_fac_sim, x_iono_sim, r_hat_iono, b_iono_mag, br_over_b_iono)

Map an ionospheric shell point (theta_i, phi) outward along the dipole field line   to the magnetospheric FAC extraction shell r_fac.

Returns valid = false if the field line closes below r_fac. Otherwise returns the 3D simulation coordinates x_fac_sim and x_iono_sim, unit outward radial vector r_hat_iono, dipole field magnitude b_iono_mag at r_iono, and outward dipole radial projection br_over_b_iono = (B0_iono ⋅ r_hat_iono) / |B0_iono|.

source

Magnetic Field Models & Field-Line Mapping ​

IonosphereElectrodynamics.AbstractIonosphereFieldModel Type
julia
AbstractIonosphereFieldModel{FT <: Real}

Abstract supertype for 3D internal planetary magnetic field models used to map potentials and convection velocities between the magnetosphere and ionospheric shell (DipoleFieldModel, MultipoleFieldModel / IGRFFieldModel).

source
IonosphereElectrodynamics.DipoleFieldModel Type
julia
DipoleFieldModel(frame::DipoleFrame) <: AbstractIonosphereFieldModel

Wrapper around DipoleFrame implementing eval_B0, map_to_ionosphere, map_with_jacobian, and map_fac_sample_point analytically.

source
IonosphereElectrodynamics.MultipoleFieldModel Type
julia
MultipoleFieldModel(; r_ref = 1.0, r_iono = r_ref, center = (0, 0, 0), lmax, g, h, rot = ..., FT = nothing)
MultipoleFieldModel(dipole_moment; r_ref = 1.0, r_iono = 1.0, center = (0, 0, 0), ...)

Internal spherical-harmonic multipole magnetic field model (alias IGRFFieldModel) with Gauss coefficients in Schmidt quasi-normalization up to degree lmax:

Triangular coefficient indexing for      uses k = div(l * (l + 1), 2) + m (so length  , starting with (1, 0) => 1, (1, 1) => 2, (2, 0) => 3, ...). Alternatively g and h may be length (lmax+1)*(lmax+2)÷2 - 1 or (lmax, lmax+1) matrices indexed by [l, m + 1].

source
IonosphereElectrodynamics.IGRFFieldModel Type
julia
IGRFFieldModel

Alias for MultipoleFieldModel representing Earth's International Geomagnetic Reference Field or any planetary internal spherical-harmonic expansion.

source
IonosphereElectrodynamics.eval_B0 Function
julia
eval_B0(model::AbstractIonosphereFieldModel, x_sim; r_min = eps(...)) -> SVector{3}

Evaluate the 3D background magnetic field at simulation position x_sim in simulation coordinates.

source
IonosphereElectrodynamics.trace_field_line_to_radius Function
julia
trace_field_line_to_radius(
    model::AbstractIonosphereFieldModel,
    x_sim,
    r_target;
    step_size = nothing,
    max_steps = 2000,
) -> (hit::Bool, x_target_sim::SVector{3}, arc_length)

Trace along both directions from simulation position x_sim until the magnetic field line intersects sphere r = r_target around the model center, returning the shorter-arc footpoint.

source
IonosphereElectrodynamics.map_to_ionosphere Function
julia
map_to_ionosphere(model::AbstractIonosphereFieldModel, x_sim) -> (i_hem, x_map_loc, theta_map, phi_map)

Map 3D simulation position x_sim along model's magnetic field line to its ionospheric shell (i_hem = +1 north, -1 south, 0 closed/unmapped).

source
IonosphereElectrodynamics.map_with_jacobian Function
julia
map_with_jacobian(model::AbstractIonosphereFieldModel, x_sim) -> (i_hem, x_map_loc, theta_map, phi_map, jac_sim)

Map simulation position x_sim along model's field line to its ionospheric shell and return the Jacobian (projected orthogonal to in multipole models).

source
IonosphereElectrodynamics.map_fac_sample_point Function
julia
map_fac_sample_point(model::AbstractIonosphereFieldModel, theta_i, phi, r_fac)
    -> (valid, x_fac_sim, x_iono_sim, r_hat_iono, b_iono_mag, br_over_b_iono)

Map ionospheric footpoint (theta_i, phi) outward along model's field line to radius r_fac.

source

Solver, Configuration & Diagnostics ​

IonosphereElectrodynamics.IonosphereConfig Type
julia
IonosphereConfig(;
    r_iono = nothing,
    r_fac = nothing,
    r_ib = nothing,
    r_core = nothing,
    center = (0.0, 0.0, 0.0),
    dipole_moment = nothing,
    n_theta_hem = 33,
    n_phi = 64,
    lat_boundary_deg = nothing,
    low_lat_bc = :dirichlet,
    conductance = UniformConductance(5.0, 0.0),
    use_dip_angle = true,
    sigma_0_ratio = 1000.0,
    sigma_parallel = nothing,
    sigma_P_floor = 0.0,
    neutralize_fac = true,
    n_smooth_fac = 0,
    relax_alpha = 1.0,
    omega_corot = (0.0, 0.0, 0.0),
    couple_every = 1,
    u_max = 1.5,
    tol = 1.0e-8,
    max_iter = 500,
    damp_radial_B1 = true,
    particle_bc = :ionosphere,
    n_ib = 1.0,
    T_ib = 0.2,
    update_per_stage = false,
    FT = nothing,
)

Configuration for the 2D spherical magnetosphere–ionosphere (M–I) electrostatic coupling solver, including optional geometry and boundary metadata for coupling to 3D magnetospheric host simulations. Element type FT is inferred from inputs and conductance when omitted (defaulting to Float64).

source
IonosphereElectrodynamics.IonosphereSolver Type
julia
IonosphereSolver{FT <: Real, C <: AbstractConductanceModel}

Pre-allocated runtime solver for the 2D spherical ionospheric Ohm's law     on both hemispheres using FLEKS's 5-point spherical finite-difference stencil and ILU(0)-preconditioned BiCGSTAB (0 B steady-state heap allocations for Float64/Float32).

source
IonosphereElectrodynamics.solve_ionosphere! Function
julia
solve_ionosphere!(
    solver::IonosphereSolver,
    jr_outward::AbstractMatrix{<:Real} = solver.jr_outward;
    t::Real = 0.0,
    neutral_wind = nothing,
) -> Bool

Solve the 2D spherical ionospheric potential equation         on both hemispheres in 0 B steady-state heap allocations when neutral_wind === nothing and conjugate_coupling == false. Returns true if both hemispheric solves converged within solver.config.tol.

source
IonosphereElectrodynamics.solve_ionosphere Function
julia
solve_ionosphere(
    solver::IonosphereSolver,
    jr_outward::AbstractMatrix{<:Real};
    t::Real = 0.0,
    neutral_wind = nothing,
) -> Matrix
solve_ionosphere(
    cfg::IonosphereConfig,
    jr_outward::AbstractMatrix{<:Real};
    r_iono = nothing,
    dipole_moment = nothing,
    center = nothing,
    lat_boundary_deg = nothing,
    t::Real = 0.0,
    neutral_wind = nothing,
) -> Matrix

Stateless, functional 2D spherical potential solve returning a fresh potential matrix phi_pot of size (n_theta, n_phi). Directly differentiable in forward-mode (ForwardDiff.jl) and reverse-mode (ChainRulesCore.jl).

source
IonosphereElectrodynamics.reset_ionosphere! Function
julia
reset_ionosphere!(solver::IonosphereSolver)

Reset solved ionospheric FAC, potentials, gradients, and solver diagnostics to zero.

source
IonosphereElectrodynamics.cross_polar_cap_potential Function
julia
cross_polar_cap_potential(solver::IonosphereSolver) -> NamedTuple{(:north, :south)}

Return the northern and southern cross-polar-cap convection potential drops   across active nodes in each hemisphere.

source
IonosphereElectrodynamics.write_ionosphere_diagnostics Function
julia
write_ionosphere_diagnostics(filename::AbstractString, solver::IonosphereSolver; time = 0.0, cycle = 0)

Write 2D spherical ionosphere diagnostics (theta_deg phi_deg Jr SigmaP SigmaH Phi E_theta E_phi) in a FLEKS-compatible ASCII table.

source
IonosphereElectrodynamics.compute_horizontal_current Function
julia
compute_horizontal_current(solver::IonosphereSolver; neutral_wind = nothing, t = 0.0) -> (J_theta, J_phi)

Compute the height-integrated horizontal ionospheric sheet current components       over the spherical (n_theta, n_phi) grid.

source
IonosphereElectrodynamics.compute_joule_heating Function
julia
compute_joule_heating(solver::IonosphereSolver; neutral_wind = nothing, t = 0.0) -> Matrix

Compute the height-integrated local Joule heating rate    [W/m² in SI] over the (n_theta, n_phi) ionospheric grid (non-negative everywhere).

source
IonosphereElectrodynamics.integrated_joule_heating Function
julia
integrated_joule_heating(solver::IonosphereSolver; neutral_wind = nothing, t = 0.0)
    -> NamedTuple{(:north, :south, :total)}

Compute hemispheric and total integrated Joule heating power     over active nodes.

source
IonosphereElectrodynamics.compute_ionosphere_ground_dB Function
julia
compute_ionosphere_ground_dB(
    solver::IonosphereSolver,
    station_xyz;
    mu0 = 4π * 1.0e-7,
    neutral_wind = nothing,
    t = 0.0,
) -> SVector{3}

Compute the ground magnetic perturbation produced by horizontal ionospheric sheet currents via Biot–Savart integration over active ionospheric shell cells:

source

3D Field & Convection Evaluation ​

IonosphereElectrodynamics.IonosphereFieldView Type
julia
IonosphereFieldView{FT <: Real, Mat <: AbstractMatrix{FT}}

Lightweight, Adapt.adapt-friendly view of solved ionospheric potential gradients, pole gradients, dipole frame, and planetary corotation angular velocity for 3D CPU/GPU boundary evaluation kernels.

source
IonosphereElectrodynamics.ionosphere_field_view Function
julia
ionosphere_field_view(solver::IonosphereSolver) -> IonosphereFieldView
ionosphere_field_view(solver::IonosphereSolver, phi_pot::AbstractMatrix{<:Real}) -> IonosphereFieldView

Create an IonosphereFieldView referencing solver's solved gradient arrays, or purely compute gradients from an explicit potential matrix phi_pot (e.g., returned by solve_ionosphere) without mutating solver.

source
IonosphereElectrodynamics.eval_ionosphere_E Function
julia
eval_ionosphere_E(
    view::IonosphereFieldView,
    x_sim;
    B0 = nothing,
    field_model = nothing,
) -> SVector{3}

Evaluate the mapped 3D electric field     at simulation position x_sim (SVector{3}, AbstractVector, or NTuple{3}), satisfying    along either the analytic dipole or an optional AbstractIonosphereFieldModel field_model.

source
IonosphereElectrodynamics.eval_ionosphere_u_exb Function
julia
eval_ionosphere_u_exb(
    view::IonosphereFieldView,
    x_sim,
    B0;
    u_max = Inf,
    field_model = nothing,
) -> SVector{3}

Evaluate the mapped magnetospheric convection velocity      at simulation position x_sim, optionally capped at |u| <= u_max and mapped along an optional AbstractIonosphereFieldModel field_model.

source