API Reference
Package Overview
IonosphereElectrodynamics Module
IonosphereElectrodynamicsStandalone, zero-allocation 2D spherical magnetosphere–ionosphere (M–I) coupling solver. Solves the height-integrated ionospheric potential equation
Conductance & Mobility Models
IonosphereElectrodynamics.AbstractConductanceModel Type
AbstractConductanceModelAbstract supertype for height-integrated ionospheric Pedersen and Hall conductance models
IonosphereElectrodynamics.UniformConductance Type
UniformConductance(sigma_P, sigma_H = zero(sigma_P); FT = nothing) <: AbstractConductanceModelSpatially 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).
IonosphereElectrodynamics.SolarEUVConductance Type
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,
) <: AbstractConductanceModelDayside solar-EUV conductance model parameterized by solar zenith angle
When twilight_deg > 0 (e.g., 15.0 corresponding to terminator twilight up to
IonosphereElectrodynamics.MoenBrekkeEUVConductance Type
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,
) <: AbstractConductanceModelMoen & Brekke (1993) solar-EUV ionospheric conductance model driven by the twilight_deg.
IonosphereElectrodynamics.AuroralConductance Type
AuroralConductance(
base::AbstractConductanceModel;
sigma_P_max = 15.0,
hall_ratio = 1.5,
fac_scale = 1.0e-6,
mode = :tanh_sqrt,
FT = nothing,
) <: AbstractConductanceModelDynamic upward-FAC auroral precipitation conductance wrapper around any base AbstractConductanceModel. Enhances
mode = :tanh_sqrt(FLEKS/RIM): .mode = :saturating: .
IonosphereElectrodynamics.RobinsonConductance Type
RobinsonConductance(
base::AbstractConductanceModel;
E0_bg = 0.5,
dE_scale = 5.0,
fac_scale = 1.0e-6,
flux_scale = 1.0,
FT = nothing,
) <: AbstractConductanceModelDynamic 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:
IonosphereElectrodynamics.HardyConductance Type
HardyConductance(
base::AbstractConductanceModel;
kp = 3.0,
sun_dir = (1.0, 0.0, 0.0),
scale = 1.0,
FT = nothing,
) <: AbstractConductanceModelKp-driven Hardy et al. (1987) statistical auroral oval conductance model superimposed in quadrature onto base.
IonosphereElectrodynamics.OvationConductance Type
OvationConductance(
base::AbstractConductanceModel;
coupling = 4421.0,
coupling_ref = 4421.0,
sun_dir = (1.0, 0.0, 0.0),
scale = 1.0,
FT = nothing,
) <: AbstractConductanceModelNewell / OVATION-Prime auroral conductance model driven by the solar-wind magnetospheric coupling function base.
IonosphereElectrodynamics.CustomConductance Type
CustomConductance(fn; uses_jr = false) <: AbstractConductanceModelUser-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.
IonosphereElectrodynamics.knight_precipitation Function
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:
IonosphereElectrodynamics.evaluate_conductance Function
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.
IonosphereElectrodynamics.electron_mobility_tensor Function
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.
Dipole Frame & Field-Line Mapping
IonosphereElectrodynamics.DipoleFrame Type
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)), withe3[3] >= 0pointing toward geographic/simulation North.dipole_moment,M0: 3D dipole moment vector and magnitudenorm(dipole_moment).dipole_sign:-1for Earth-like polarity (m ⋅ e3 < 0),+1for reversed polarity.r_iono: Ionospheric shell radius in simulation length units.
IonosphereElectrodynamics.build_dipole_frame Function
build_dipole_frame(
dipole_moment;
center = (0.0, 0.0, 0.0),
r_iono = 1.0,
FT = nothing,
) -> DipoleFrameConstruct 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.
IonosphereElectrodynamics.dipole_B0 Function
dipole_B0(frame::DipoleFrame, x_sim; r_min = eps(...)) -> SVector{3}Evaluate the analytic dipole magnetic field x_sim (SVector{3}, AbstractVector, or NTuple{3}) using frame.center and frame.dipole_moment (softened at r_min).
IonosphereElectrodynamics.map_dipole_smg Function
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 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
IonosphereElectrodynamics.map_dipole_smg_with_jacobian Function
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 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
IonosphereElectrodynamics.dipole_conductance_tensor Function
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 (-dipole_sign).
IonosphereElectrodynamics.dipole_fac_sample_point Function
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 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|.
Magnetic Field Models & Field-Line Mapping
IonosphereElectrodynamics.AbstractIonosphereFieldModel Type
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).
IonosphereElectrodynamics.DipoleFieldModel Type
DipoleFieldModel(frame::DipoleFrame) <: AbstractIonosphereFieldModelWrapper around DipoleFrame implementing eval_B0, map_to_ionosphere, map_with_jacobian, and map_fac_sample_point analytically.
IonosphereElectrodynamics.MultipoleFieldModel Type
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 lmax:
Triangular coefficient indexing for k = div(l * (l + 1), 2) + m (so length (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].
IonosphereElectrodynamics.IGRFFieldModel Type
IGRFFieldModelAlias for MultipoleFieldModel representing Earth's International Geomagnetic Reference Field or any planetary internal spherical-harmonic expansion.
IonosphereElectrodynamics.eval_B0 Function
eval_B0(model::AbstractIonosphereFieldModel, x_sim; r_min = eps(...)) -> SVector{3}Evaluate the 3D background magnetic field x_sim in simulation coordinates.
IonosphereElectrodynamics.trace_field_line_to_radius Function
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 x_sim until the magnetic field line intersects sphere r = r_target around the model center, returning the shorter-arc footpoint.
IonosphereElectrodynamics.map_to_ionosphere Function
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).
IonosphereElectrodynamics.map_with_jacobian Function
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
IonosphereElectrodynamics.map_fac_sample_point Function
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.
Solver, Configuration & Diagnostics
IonosphereElectrodynamics.IonosphereConfig Type
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).
IonosphereElectrodynamics.IonosphereSolver Type
IonosphereSolver{FT <: Real, C <: AbstractConductanceModel}Pre-allocated runtime solver for the 2D spherical ionospheric Ohm's law 0 B steady-state heap allocations for Float64/Float32).
IonosphereElectrodynamics.solve_ionosphere! Function
solve_ionosphere!(
solver::IonosphereSolver,
jr_outward::AbstractMatrix{<:Real} = solver.jr_outward;
t::Real = 0.0,
neutral_wind = nothing,
) -> BoolSolve the 2D spherical ionospheric potential equation 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.
IonosphereElectrodynamics.solve_ionosphere Function
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,
) -> MatrixStateless, 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).
IonosphereElectrodynamics.reset_ionosphere! Function
reset_ionosphere!(solver::IonosphereSolver)Reset solved ionospheric FAC, potentials, gradients, and solver diagnostics to zero.
sourceIonosphereElectrodynamics.cross_polar_cap_potential Function
cross_polar_cap_potential(solver::IonosphereSolver) -> NamedTuple{(:north, :south)}Return the northern and southern cross-polar-cap convection potential drops
IonosphereElectrodynamics.write_ionosphere_diagnostics Function
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.
IonosphereElectrodynamics.compute_horizontal_current Function
compute_horizontal_current(solver::IonosphereSolver; neutral_wind = nothing, t = 0.0) -> (J_theta, J_phi)Compute the height-integrated horizontal ionospheric sheet current components (n_theta, n_phi) grid.
IonosphereElectrodynamics.compute_joule_heating Function
compute_joule_heating(solver::IonosphereSolver; neutral_wind = nothing, t = 0.0) -> MatrixCompute the height-integrated local Joule heating rate (n_theta, n_phi) ionospheric grid (non-negative everywhere).
IonosphereElectrodynamics.integrated_joule_heating Function
integrated_joule_heating(solver::IonosphereSolver; neutral_wind = nothing, t = 0.0)
-> NamedTuple{(:north, :south, :total)}Compute hemispheric and total integrated Joule heating power
IonosphereElectrodynamics.compute_ionosphere_ground_dB Function
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
3D Field & Convection Evaluation
IonosphereElectrodynamics.IonosphereFieldView Type
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.
IonosphereElectrodynamics.ionosphere_field_view Function
ionosphere_field_view(solver::IonosphereSolver) -> IonosphereFieldView
ionosphere_field_view(solver::IonosphereSolver, phi_pot::AbstractMatrix{<:Real}) -> IonosphereFieldViewCreate 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.
IonosphereElectrodynamics.eval_ionosphere_E Function
eval_ionosphere_E(
view::IonosphereFieldView,
x_sim;
B0 = nothing,
field_model = nothing,
) -> SVector{3}Evaluate the mapped 3D electric field x_sim (SVector{3}, AbstractVector, or NTuple{3}), satisfying AbstractIonosphereFieldModel field_model.
IonosphereElectrodynamics.eval_ionosphere_u_exb Function
eval_ionosphere_u_exb(
view::IonosphereFieldView,
x_sim,
B0;
u_max = Inf,
field_model = nothing,
) -> SVector{3}Evaluate the mapped magnetospheric convection velocity x_sim, optionally capped at |u| <= u_max and mapped along an optional AbstractIonosphereFieldModel field_model.