Skip to content

Developer API Coverage ​

This page makes exported developer-facing helpers canonical for Documenter. Most users should start from the Library, task pages, or module overview pages instead.

Package Modules ​

vSmartMOM Module
julia
vSmartMOM

Top-level package module for configuring and running vector adding-doubling radiative-transfer simulations.

source
vSmartMOM.CoreRT Module
julia
CoreRT

Core radiative-transfer implementation: model types, layer optical-property construction, adding-doubling kernels, surface coupling, and solver entry points.

source
vSmartMOM.IO Module
julia
IO

Input/output helpers for loading YAML, dictionary, atmospheric-profile, and NetCDF/GEOS-Chem configuration sources into vSmartMOM parameter objects.

source
vSmartMOM.InelasticScattering Module
julia
InelasticScattering

Molecular Raman and Cabannes/Rayleigh helper types and precomputations used by CoreRT inelastic-scattering modes.

source
vSmartMOM.Aerosols Module
julia
Aerosols Module

Flexible aerosol framework supporting multiple schemes:

  • TOMAS-15: Size-resolved aerosol microphysics (15 bins)

  • Two-Moment: Bulk aerosol properties (AOD + effective radius)

  • Future: MAAM, custom schemes, etc.

Includes a wavelength-dependent refractive-index database and data readers. Scheme-to-optics conversion is not implemented; compute_optical_properties throws an explicit error. Production Mie optics live in Scattering.

source
vSmartMOM.StandaloneSS Module
julia
StandaloneSS

Standalone exact single-scattering tools. Phase 1 implements scalar, plane-parallel exact paths with vector-Stokes support for atmospheric Rayleigh single scatter and direct-beam surface reflection.

source

Absorption Internals ​

vSmartMOM.Absorption.AbstractCrossSectionModel Type
julia
type AbstractCrossSectionModel

Abstract Cross Section Model type for generic cross section calculations Currently either a HitranModel or an InterpolationModel

source
vSmartMOM.Absorption.AbstractComplexErrorFunction Type
julia
type AbstractComplexErrorFunction

Abstract Complex Error Function type for generic complex error functions

source
vSmartMOM.Absorption.save_interpolation_model Function

Convenience function to save an InterpolationModel at a specified filepath (Using JLD2)

source
vSmartMOM.Absorption.load_interpolation_model Function

Convenience function to load an InterpolationModel from a specified filepath (Using JLD2)

source
vSmartMOM.Absorption.CIATable Type
julia
CIATable

Pre-interpolated CIA cross-section table keyed by (ν_model_grid, T_block). Stored in Float64 because σ values are ~1e-44 to 1e-46 cm⁵/molec² — well below Float32's smallest normal (~1.18e-38). Built once per band at model construction time; cheap T-interpolation per layer at runtime.

source
vSmartMOM.Absorption.MTCKDTable Type
julia
MTCKDTable

Water-vapor continuum reference table from MT_CKD's absco-ref_wv-mt-ckd.nc. Stored at the file's native ν grid (uniform 10 cm⁻¹); per-band tables are built on demand bybuild_mtckd_band_table.

source
vSmartMOM.Absorption.MTCKDBand Type
julia
MTCKDBand

Per-band cache of MT_CKD coefficients pre-interpolated onto a model ν grid. Filling values outside the file's ν range with zeros.

source
vSmartMOM.Absorption.parse_cia_file Function
julia
parse_cia_file(path) -> Vector{CIABlock{Float64}}

Read a HITRAN .cia file. Each block is a single header line followed by n_pts lines of (ν σ) pairs. Header layout (fixed-width, 100 cols): cols 1–20 formula (e.g. "O2-O2") cols 21–30 ν_min (f10.3) cols 31–40 ν_max (f10.3) cols 41–47 n_pts (i7) cols 48–54 T (f7.1, K) cols 55–64 σ_max (e10.3) cols 98–100 HITRAN CIA reference code

source
vSmartMOM.Absorption.build_cia_table Function
julia
build_cia_table(blocks, ν_grid) -> CIATable

Project all blocks onto ν_grid, grouping by block temperature. Missing spectral coverage is stored as NaN, not as a physical zero, so subsequent temperature interpolation can use only panels that actually tabulate a given wavenumber. Overlapping blocks at the same temperature use the finer native spectral sampling. Negative interpolated values are rejected by default; :clamp_zero must be requested explicitly. Always Float64 internally (see CIATable docstring).

source
vSmartMOM.Absorption.load_cia_table Function
julia
load_cia_table(path, ν_grid; reference_codes=nothing,
               negative_policy=:error) -> CIATable

Convenience: parse a .cia file and build the model-grid table in one call. reference_codes can select one documented HITRAN source family rather than implicitly stitching overlapping experiments. negative_policy is forwarded to build_cia_table. The FT keyword is accepted for back-compat but ignored — the table is always Float64 (see CIATable docstring).

source
vSmartMOM.Absorption.compute_τ_cia! Function
julia
compute_τ_cia!(τ_abs, table, profile, vmr_dict)

Add the symmetric midpoint-column CIA contribution σ(ν,T) · [n_A(mid)N_B + n_B(mid)N_A] / 2 to τ_abs[ν,layer] for every layer of profile. vmr_dict provides per-layer (or scalar) mixing ratios; O2/N2 fall back to USS defaults if absent.

All intermediate arithmetic is Float64 to avoid Float32 underflow on σ (~1e-45) and overflow on n²·Δz (~1e41); the result is converted to eltype(τ_abs) only at accumulation.

source
vSmartMOM.Absorption.cia_σ_at_T! Function
julia
cia_σ_at_T!(σ_out, table, T_layer)

Fill σ_out[k] = σ(ν_grid[k], T_layer) by linear interpolation in T using only measured panels that cover that wavenumber. Constant extrapolation uses the nearest covering temperature. A wavenumber absent from every selected panel is returned as zero, but this means outside tabulated support, not a demonstrated physical zero; callers can inspect table.coverage. σ_out must be a Float64 vector matching the table's ν grid.

source
vSmartMOM.Absorption.load_mtckd Function
julia
load_mtckd(path) -> MTCKDTable

Read the AER-distributed absco-ref_wv-mt-ckd.nc file.

source
vSmartMOM.Absorption.build_mtckd_band Function
julia
build_mtckd_band(table, ν_grid) -> MTCKDBand

Interpolate the table's coefficients onto ν_grid. Outside the table's ν range (typically [-20, 20000] cm⁻¹), all coefficients are set to 0 so τ_continuum vanishes there (UV/Vis above 500 nm has no MT_CKD contribution).

source
vSmartMOM.Absorption.compute_τ_h2o_continuum! Function
julia
compute_τ_h2o_continuum!(τ_abs, band, ν_grid, profile, vmr_h2o)

Add the MT_CKD H₂O self+foreign continuum optical depth to τ_abs[ν, layer].

vmr_h2o is the H2O/dry-air molar ratio, per-layer or scalar. profile.p_full is total moist pressure in hPa and profile.T is in K. profile.vcd_h2o supplies the hydrostatically integrated H2O column, making the result invariant to layer subdivision for constant coefficients. All intermediate arithmetic is Float64; the result is converted to eltype(τ_abs) only at accumulation.

source
julia
compute_τ_h2o_continuum!(τ_abs, table::MTCKDTable, ν_grid, profile, vmr_h2o)

Convenience overload that builds the per-band cache on the fly.

source

Scattering Internals ​

vSmartMOM.Scattering.greek_coefficients_from_scattering_matrix Function
julia
greek_coefficients_from_scattering_matrix(μ, w, matrix)

Convert angle-space scattering-matrix elements sampled at quadrature nodes μ with weights w into Sanghavi Greek coefficients. This is the same coefficient projection used by the Mie/NAI2 path, factored for analytic phase functions.

source
vSmartMOM.Scattering.compute_aerosol_optical_properties_gpu Function
julia
compute_aerosol_optical_properties_gpu(model::MieModel{<:NAI2,FT}, backend;
                                       precision_policy=NativeFloat64(),
                                       FT2=Float64)

GPU-accelerated version of compute_aerosol_optical_properties for the NAI2 method.

Arguments

  • model: MieModel configured for NAI2 computation

  • backend: KernelAbstractions backend (e.g., CPU(), CUDABackend())

  • precision_policy: NativeFloat64() for A100/V100, DSEmulated() for Float32 double-single Dₙ, or NativeFloat32() for a native-Float32 Dₙ kernel (same kernel-1 dispatch as the caller-node GPU path, via _mie_kernel1) — all three share the SAME Float64-widened host-side reduction/Greek quadrature regardless of policy (see the RA comment in the function body for why that is Metal-safe and NOT policy-dependent, unlike the caller-node path). On MetalGPU(), NativeFloat64() (any FT === Float64 model, in fact) throws a clear ArgumentError rather than attempting an unsupported Float64 device array.

  • FT2: output float type. Defaults to Float64, NOT the model's FT type parameter — this low-level, direct-backend entry point does not read model.architecture/model.FT for this default (unlike the single-verb compute_aerosol_optical_properties(model) router in phase_function_autodiff.jl's _dispatch_aerosol_optics, which always supplies FT2 = _mie_output_type(model) explicitly, so a Float32 model produces Float32 greek coefficients through THAT entry point without any explicit override). Calling this function directly (bypassing the router, e.g. in tests) for a Float32 model REQUIRES passing FT2 = Float32 explicitly, or the output silently comes back in Float64.

Returns

  • AerosolOptics with greek_coefs, SSA, extinction, truncation factor
source
vSmartMOM.Scattering.compute_aerosol_optical_properties_nodes_gpu Function
julia
compute_aerosol_optical_properties_nodes_gpu(radii, weights, n_real, n_imag,
    wavelength, backend; precision_policy = NativeFloat64(), l_max = nothing)
    -> AerosolOptics

GPU/KernelAbstractions implementation backing compute_aerosol_optical_properties_nodes — takes an explicit KA backend (e.g. KernelAbstractions.CPU() or CUDA.CUDABackend()), mirroring compute_aerosol_optical_properties_gpu's calling convention so it can be exercised directly in tests on a CPU backend without a real GPU device.

Shares its preamble (validation, FT/RA derivation, per-node arrays, Kernel

  1. with compute_aerosol_extinction_nodes_gpu via the internal

_prepare_node_mie_gpu helper. Reuses the existing per-node kernels from gpu_mie_kernels.jl (mie_coefficients_kernel_f64!/_ds!, amplitude_phase_kernel!, cross_sections_kernel!) UNCHANGED. The weighted bulk reduction across nodes and the Greek-coefficient angular projection additionally launch the previously-unused device-resident kernels weighted_sum_kernel!, size_reduction_kernel!, and greek_coefficients_kernel! — so, unlike compute_aerosol_optical_properties_gpu (which copies the per-node phase-matrix/cross-section arrays back to the host and reduces there), this path keeps the reduction device-resident and copies back only the six bulk Greek arrays plus the two bulk scalars (ω̃, k).

Precision: the per-node kernels (1-3) run in the kernel's native float type FT = eltype(radii) (Float32 under DSEmulated/NativeFloat32, matching the existing GPU path's speed rationale). The reduction/Greek kernels (4-5) accumulate in RA = _mie_reduction_type(precision_policy, FT) — Float64 for NativeFloat64 always, Float64 for DSEmulated when FT === Float32 (Float64-widened + Neumaier-compensated, exactly like compute_aerosol_optical_properties_gpu's host-side reduction — except here the widened reduction runs as device arrays/kernels rather than after an Array() copy-back), and — new — Float32 (never widened) for NativeFloat32, so the entire pipeline allocates zero Float64 device arrays under that policy. See MiePrecisionPolicy for the full table.

source
vSmartMOM.Scattering.compute_aerosol_extinction_nodes_gpu Function
julia
compute_aerosol_extinction_nodes_gpu(radii, weights, n_real, n_imag,
    wavelength, backend; precision_policy = NativeFloat64()) -> k

GPU/KernelAbstractions implementation backing compute_aerosol_extinction_nodes — takes an explicit KA backend (e.g. KernelAbstractions.CPU() or CUDA.CUDABackend()), mirroring compute_aerosol_optical_properties_nodes_gpu's calling convention so it can be exercised directly in tests on a CPU backend without a real GPU device.

Shares its preamble (validation, FT/RA derivation, per-node arrays, Kernel

  1. with compute_aerosol_optical_properties_nodes_gpu via the

internal _prepare_node_mie_gpu helper. Launches ONLY the per-node cross_sections_kernel! on top of that shared preamble (which computes C_ext AND C_sca together in one fused pass — cheaper to keep fused than to add a C_ext-only kernel variant; the unused C_sca output is simply not reduced), then the device-resident weighted_sum_kernel! reduction across nodes. UNLIKE compute_aerosol_optical_properties_nodes_gpu, this path launches no amplitude_phase_kernel!, size_reduction_kernel!, or greek_coefficients_kernel!, and needs no angular grid at all (no gausslegendre, compute_mie_π_τ, or compute_legendre_poly calls), since none of them affect k. Only the single scalar bulk_C_ext is copied back to the host.

Precision: identical convention to compute_aerosol_optical_properties_nodes_gpu — the per-node kernels run in the kernel's native float type FT = eltype(radii) (Float32 under DSEmulated/NativeFloat32); the reduction accumulates in RA = _mie_reduction_type(precision_policy, FT), narrowed back to FT only for the returned scalar. Under NativeFloat32, RA === FT === Float32, so this function allocates ZERO Float64 device arrays end to end.

source
vSmartMOM.Scattering.compute_aerosol_optical_properties_nodes_batched_gpu Function
julia
compute_aerosol_optical_properties_nodes_batched_gpu(geometry::MieNodeGeometry,
    wavelength, n_real::AbstractVector, n_imag::AbstractVector,
    polarization, truncation, backend;
    l_max = nothing,
    precision_policy = NativeFloat64(),
    workspace = nothing) -> Vector{AerosolOptics}

GPU/KernelAbstractions implementation backing compute_aerosol_optical_properties_nodes_batched — takes an EXPLICIT KA backend (e.g. KernelAbstractions.CPU() or CUDA.CUDABackend()), mirroring compute_aerosol_optical_properties_nodes_gpu's directly-callable convention so it can be exercised on a CPU-backed KA backend in tests without a real GPU device, INDEPENDENTLY of geometry.architecture (which only determines what the top-level compute_aerosol_optical_properties_nodes_batched dispatcher picks automatically). This is the entry point the acceptance-gate tests use to compare, e.g., the KA-CPU-backed batched path against the KA-CPU-backed single-ensemble path bit-for-bit.

source
vSmartMOM.Scattering.compute_aerosol_extinction_nodes_batched_gpu Function
julia
compute_aerosol_extinction_nodes_batched_gpu(geometry::MieNodeGeometry,
    wavelength, n_real::AbstractVector, n_imag::AbstractVector, backend;
    precision_policy = NativeFloat64(), workspace = nothing) -> Vector

GPU/KernelAbstractions implementation backing compute_aerosol_extinction_nodes_batched — explicit-backend directly-callable counterpart, mirroring compute_aerosol_extinction_nodes_gpu's convention, independent of geometry.architecture (see compute_aerosol_optical_properties_nodes_batched_gpu for why this entry point exists — it is what the acceptance-gate tests use for same-backend batched-vs-single comparisons).

source
vSmartMOM.Scattering.MiePrecisionPolicy Type
julia
MiePrecisionPolicy

Abstract precision policy for the Mie GPU kernels (both the log-normal MieModel GPU path in compute_NAI2_gpu.jl and the caller-node GPU path in compute_NAI2_nodes.jl). Three concrete policies:

PolicyDₙ recursionSize-distribution reduction / Greek projectionTarget hardware
NativeFloat64native Float64Float64 (RA = Float64)A100/V100 (full FP64 throughput)
DSEmulatedFloat32 double-singleFloat64-widened + Neumaier (RA = Float64 when the kernel runs in Float32)consumer CUDA (L40S etc.) — FP32-only Dₙ, but reduction can still afford Float64
NativeFloat32native Float32Float32 + Neumaier (RA = Float32, never widened)Apple Metal (NO Float64 hardware at all) and F32-only-throughput consumer CUDA

The caller-node GPU path (compute_aerosol_optical_properties_nodes_gpu / compute_aerosol_extinction_nodes_gpu) keeps its size-distribution reduction and Greek-coefficient projection device-resident (see _prepare_node_mie_gpu), so the reduction accumulator type RA is not just an accuracy knob but determines whether Float64 DEVICE ARRAYS get allocated at all. NativeFloat32 is the ONLY policy under which the node GPU pipeline allocates zero Float64 device arrays end to end — required for backends with no Float64 hardware support (Metal) or crippled FP64 throughput (consumer CUDA). NativeFloat64/DSEmulated semantics and tolerances are UNCHANGED by NativeFloat32's introduction.

Backend-dependent reduction discipline (Metal note): on MetalGPU(), default_mie_precision_policy resolves ONLY to NativeFloat32 for Float32 inputs (Float64 throws ArgumentError — Metal has no Float64 hardware at all). DSEmulated's Dₙ-recursion kernel is pure Float32 arithmetic and IS Metal-compatible, but DSEmulated's historical reduction discipline widens to RA = Float64, which is illegal on Metal device arrays. Making DSEmulated-on-Metal correct would require a Float32-COMPENSATED (not widened) reduction variant, which is NOT implemented this round — the node GPU preamble (_prepare_node_mie_gpu) detects a Metal-shaped backend and throws a clear ArgumentError if the resolved policy/element-type combination would need a Float64 device array, so DSEmulated on Metal fails loudly rather than crashing inside KernelAbstractions.allocate. Use NativeFloat32 on Metal.

source
vSmartMOM.Scattering.NativeFloat64 Type

Use native Float64 for the Dn recursion (A100, V100 – full FP64 throughput).

source
vSmartMOM.Scattering.DSEmulated Type

Use DoubleSingle emulation for the Dn recursion (L40S, consumer GPUs – FP32 only).

source
vSmartMOM.Scattering.NativeFloat32 Type

Use native Float32 END TO END: the Dₙ recursion AND the size-distribution reduction AND the Greek-coefficient projection all run in plain Float32 (Neumaier-compensated, never Float64-widened). The only policy that allocates ZERO Float64 device arrays anywhere in the caller-node GPU pipeline – for Apple Metal (no Float64 hardware support at all) and F32-only-throughput consumer CUDA. Strictly less accurate than DSEmulated (no double-single emulation for Dₙ, no Float64-widened reduction) – see the caller-node GPU functions' docstrings and test/test_mie_nodes.jl for measured error bands.

source
vSmartMOM.Scattering.DoubleSingle Type
julia
DoubleSingle{T}

Unevaluated sum of two floating-point numbers hi + lo where |lo| <= ulp(hi)/2. Provides ~2p mantissa bits (48 bits for T=Float32).

All operations are branchless and use only +, -, *, fma.

source
vSmartMOM.Scattering.ComplexDS Type
julia
ComplexDS{T}

Complex number with DoubleSingle real and imaginary parts (4 floats of type T). Used for the Dn recursion where complex division has catastrophic cancellation.

source
vSmartMOM.Scattering.NeumaierAccum Type
julia
NeumaierAccum{T}

Neumaier's improved Kahan summation. Maintains a running sum s and a compensation variable c. Unlike plain Kahan, this handles the case where |addend| > |s| correctly.

Cost: ~7 FLOPs per addition (vs 1 for naive sum).

source
vSmartMOM.Scattering.neumaier_add Function

Add a value to the Neumaier accumulator.

source
vSmartMOM.Scattering.neumaier_sum Function

Extract the compensated sum.

source
vSmartMOM.Scattering.compute_Sl Function
julia
compute_Sl(l, ν₁, ν₂, ν₂_positive_flag, k, N_max, ab_pairs, an_m_bn, an_p_bn, wigner_A, wigner_B)

Evaluate for the Domke PCW Greek-coefficient formulation (Sanghavi 2014, Eq. 22).

Sums over Mie indices with Wigner d-matrix elements. Valid  ₁ ₂ pairs: (0,0), (2,2), (2,-2), (0,2). Used to compute α, β, γ, δ, ϵ, ζ via Eq. 24.

Arguments

  • l: expansion index (1-based, corresponds to   in Eq. 22)

  • ν₁, ν₂: Fourier indices; ν₂_positive_flag selects sign convention for  ₂  

  • k: wavenumber

  • N_max: maximum Mie expansion order

  • ab_pairs: precomputed etc. from compute_avg_anbns!

  • an_m_bn, an_p_bn:   and   weighted by size distribution

  • wigner_A, wigner_B: Wigner d-matrix tables for   and  

Returns

  • Complex value
source
vSmartMOM.Scattering.compute_mie_π_τ Function

compute_mie_π_τ(μ, nmax, π, τ) Computes the associated Legendre functions amplitude functions π and τ in Mie theory (stored internally). See eq 6 in Sanghavi 2014

  • μ cosine of the scattering angle

  • nmax max number of legendre terms (depends on size parameter; see get_n_max)

Functions returns π and τ (of size [nmax,length(μ)])

source

Core RT Internals ​

vSmartMOM.CoreRT.RTModelLin Type
julia
struct RTModelLin{A,B,C}

Holds linearized (Jacobian) model parameters: derivatives of optical depths and aerosol properties w.r.t. physical state-vector elements.

Fields

  • τ̇_abs: ∂τ_abs/∂VMR(gas,z) per band: [NGas*Nz × nSpec × Nz], species-major

  • τ̇_aer: ∂τ_aer/∂x per band: Vector of arrays [NAer × 7 × nSpec × nLayers]

  • lin_aerosol_optics: Linearized aerosol optics per band per aerosol: Vector{Vector{linAerosolOptics}}

  • τ̇_rayl_psurf: ∂τ_rayl/∂p_surf per band: [nSpec × nLayers]; nothing when pressure is disabled

  • τ̇_aer_psurf: ∂τ_aer/∂p_surf per band: [NAer × nSpec × nLayers]; nothing when disabled

  • τ̇_abs_psurf: ∂τ_abs/∂p_surf per band: [nSpec × nLayers]; nothing when pressure is disabled

  • abundance_contract: Terms omitted by the gas-abundance tangents; nothing when the caller supplied τ̇_abs

source
vSmartMOM.CoreRT.AbundanceTangentContract Type
julia
AbundanceTangentContract

Records what the native gas-abundance tangents τ̇_abs omit. Each native gas column is the partial ∂τ/∂VMR = σ·N_dry: it differentiates the explicit abundance factor of line/LUT absorption with every cross section, CIA and MT_CKD optical depth held fixed. The q-driven H₂O columns also include the exact response of ABSCO H₂O-broadener axes, which is therefore never listed as omitted. omitted[i_band][igas]lists the forward terms of bandi_bandthat nevertheless respond to native gas slotigas(slot 1 is q-driven H₂O, slot1+iisvariable_molecules[i_band][i]).

With abundance_jacobians == :complete (the default), a solve or Jacobian plan that requests a slot with omitted terms is rejected. :frozen_cross_section accepts those omissions explicitly; the tangent values are identical in both settings. When q ≡ 0, H₂O absorption is not evaluated and the q-driven H₂O columns are structural zeros rather than derivatives; Jacobian plans may not select them.

Fields

  • abundance_jacobians: Accepted abundance-derivative definition: :complete or :frozen_cross_section

  • species: Species label of each native gas slot, per band

  • omitted: Forward terms responding to each native gas slot but absent from τ̇_abs, per band

source
vSmartMOM.CoreRT.OpticalPropertyJacobian Type
julia
OpticalPropertyJacobian

Type alias for CoreScatteringOpticalPropertiesLin. Use this name in new code to emphasise the physical meaning: the Jacobian of the four core optical properties (τ, ϖ, Z⁺⁺, Z⁻⁺) w.r.t. the state vector.

source
vSmartMOM.CoreRT.RawAerosolJacobian Type
julia
RawAerosolJacobian{T}

Holds the un-truncated derivatives of single-aerosol optical properties with respect to the aerosol sub-parameters [τ_ref, nᵣ, nᵢ, rₘ, σ_g, p₀, σ_p].

This struct is the AD boundary for aerosols: everything upstream (Mie code, aerosol profile code, or ForwardDiff) produces these raw derivatives. The delta_m_truncation_lin function then maps them through the δ-M truncation chain rule to produce the CoreScatteringOpticalPropertiesLin that the RT kernel expects.

Fields

  • τ̇_aer: ∂τ_aer/∂x [Nparams_aer × nSpec] — optical depth derivatives

  • ω̃̇: ∂ω̃/∂x [Nparams_mie × nSpec] — SSA derivatives (Mie params only)

  • ḟᵗ: ∂fᵗ/∂x [Nparams_mie × nSpec] — truncation factor derivatives (Mie params only)

  • Ż⁺⁺: ∂Z⁺⁺/∂x [Nparams_mie × nμ × nμ] — phase matrix derivatives (Mie params only)

  • Ż⁻⁺: ∂Z⁻⁺/∂x [Nparams_mie × nμ × nμ] — phase matrix derivatives (Mie params only)

source
vSmartMOM.CoreRT.rt_run_ss Function
julia
rt_run_ss(model::RTModel; i_band=1) -> (R_SFI, T_SFI, ieR_SFI, ieT_SFI, hem_R, hem_T)

Run the single-scatter approximation forward RT solver for one or more bands.

Computes only the single-scattering component of the TOA reflectance / BOA transmittance by replacing the layer-doubling kernel with rt_kernel_ss! and using interaction_ss! for the final surface coupling. Useful as a fast/debug reference path; not a physically complete RT solution (multiple scattering is dropped).

Equivalent to rt_run_ss(noRS(), model, i_band).

Ported from sanghavi-branch rt_run_ss (see docs/dev_notes/plans/IMPLEMENTATION_PLAN_v2.md Phase 1c).

Arguments

  • model::RTModel: Pre-built model from model_from_parameters.

  • i_band::Integer=1: Spectral band index (or vector of indices).

Returns

6-tuple (R_SFI, T_SFI, ieR_SFI, ieT_SFI, hem_R, hem_T):

  • R_SFI, T_SFI, ieR_SFI, ieT_SFI: shape (nVza, nStokes, nSpec) — same per-direction outputs as rt_run.

  • hem_R, hem_T: hemispherically integrated single-scatter Stokes-I fluxes (diffuse only), shape (nSpec,): the diffuse upwelling flux at TOA and the diffuse downwelling flux at BOA, in the units of F₀ (they are not normalized by the incident flux μ₀F₀, so they are not reflectances or transmittances). Computed from the m=0 Fourier coefficient of the Stokes-I source function over the hemisphere (Σⱼ J₀[j, 1, λ] · μⱼ · wⱼ). The unscattered direct beam is excluded from hem_T for every quadrature scheme; add μ₀ F₀ exp(−τ/μ₀) for the total downwelling flux.

source
julia
rt_run_ss(RS_type, model::RTModel, iBand; sources=nothing)

Single-scatter approximation driver with explicit Raman type. See rt_run_ss for the user-facing entry point and the outputs (hem_T is the diffuse downwelling flux only). Solar F₀ precedence and the call-only effect of sources= are as for rt_run(RS_type, model, iBand).

source
vSmartMOM.CoreRT.delta_m_forward Function
julia
delta_m_forward(τ_aer, ω̃, fᵗ, Z⁺⁺, Z⁻⁺)

Apply δ-M truncation (Nakajima & Tanaka 1988) to raw aerosol optical properties.

Phase matrices Z⁺⁺, Z⁻⁺ pass through unchanged (truncation is already applied to the Greek coefficients during Mie computation).

Returns

CoreScatteringOpticalProperties with δ-M scaled (τ_mod, ϖ_mod, Z⁺⁺, Z⁻⁺).

source
vSmartMOM.CoreRT.delta_m_truncation_lin Function
julia
delta_m_truncation_lin(τ_aer, fᵗ, ω̃, τ̇_aer, ω̃̇, ḟᵗ, Ż⁺⁺, Ż⁻⁺, Z⁺⁺, Z⁻⁺,
                       n_aer_params, mie_range, profile_range, arr_type)

Apply the δ-M truncation chain rule analytically to map raw (un-truncated) aerosol derivatives to δ-M modified derivatives.

The 4 raw variables (τ_aer, ω̃, fᵗ, Z) are mapped to 3 modified variables (τ_mod, ϖ_mod, Z) via:

For profile-only parameters (p₀, σ_p), ω̃̇ = ḟᵗ = Ż = 0, so only the τ chain contributes.

Arguments

  • n_aer_params::Int: Total aerosol sub-parameters (currently 7).

  • mie_range: Indices within the 7-param block that have Mie sensitivity (currently 2:5).

  • profile_range: Indices that only affect τ via the vertical profile (currently [1, 6, 7]).

  • arr_type: Array constructor (Array or CuArray).

Returns

  • CoreScatteringOpticalProperties: Forward δ-M scaled properties.

  • CoreScatteringOpticalPropertiesLin: Linearized properties [n_aer_params × nSpec].

source

StandaloneSS Internals ​

vSmartMOM.StandaloneSS.ExactSSConfig Type
julia
ExactSSConfig(; geometry, surface, contributors, I0, n_stokes=1,
                polarization_type=nothing, architecture=CPU())

Configuration for the Phase 1 standalone exact single-scatter solver. Outputs have shape (nGeom, nStokes, nSpec). polarization_type, when provided, determines the Stokes count for the currently supported vector paths: Rayleigh or Greek-coefficient atmospheric single scatter and direct-beam surface reflection.

source
vSmartMOM.StandaloneSS.SSGeometry Type
julia
SSGeometry(μ₀, μv, Δϕ)

Solar and viewing geometry for the standalone single-scatter solver. μ₀ is the positive solar cosine, μv are positive upward viewing cosines, and Δϕ is the view-sun relative azimuth in radians for each view.

source
vSmartMOM.StandaloneSS.LambertianSSSurface Type
julia
LambertianSSSurface(albedo)

Lambertian surface used by Phase 1 path 2. albedo may be a scalar or a per-spectral vector.

source
vSmartMOM.StandaloneSS.CoxMunkSSSurface Type
julia
CoxMunkSSSurface(; wind_speed, n_water=nothing, whitecap_albedo=0.22,
                   include_whitecaps=true, shadowing=true)

Scalar Cox-Munk ocean surface for standalone exact path 2. wind_speed is the 10-m wind speed in m/s. n_water may be nothing, a scalar complex refractive index, or a per-spectral vector of complex refractive indices. The nothing fallback uses a fixed visible-water refractive index for this standalone path.

source
vSmartMOM.StandaloneSS.GreekCoefsSSContributor Type
julia
GreekCoefsSSContributor(; greek_coefs, ϖ, τ)

Standalone exact-angle scattering contributor backed by the same Scattering.GreekCoefs used by the full MOM solver. This is the preferred bridge for vector aerosol single scattering in StandaloneSS.

source
vSmartMOM.StandaloneSS.TruncatedAndExactScatteringOpticalProperties Type
julia
TruncatedAndExactScatteringOpticalProperties(truncated, exact, truncfac)

Dual-form optical-property container used by the broader exact-SFI design. Phase 1 defines the type for API alignment but does not wire it into rt_run.

source
vSmartMOM.StandaloneSS.SSMeasurementSelector Type
julia
SSMeasurementSelector(; paths=(:total,), geometry_indices=:,
                        spectral_indices=:, stokes_indices=:)

Select and flatten StandaloneSS radiance outputs into a retrieval measurement vector. Multiple paths are concatenated in the order provided. All Stokes components are selected by default so future polarized outputs are not silently reduced to Stokes I; pass stokes_indices=1 for I-only retrieval vectors.

source
vSmartMOM.StandaloneSS.run_exact_ss Function
julia
run_exact_ss(model::RTModel; i_band=1, paths=:paths_1_2, I0=nothing)

Convenience wrapper that builds an ExactSSConfig from model via exact_ss_config_from_model and runs the standalone exact single-scattering solver.

source
julia
run_exact_ss(config::ExactSSConfig; paths=:paths_1_2)

Run standalone exact single-scattering for selected paths. Stokes-vector path 1 currently supports Rayleigh and Greek-coefficient scattering; path 2 supports Lambertian and Cox-Munk direct-beam reflection. Paths 3 and 4 currently support scalar Lambertian surfaces. Radiance arrays have shape (nGeom, nStokes, nSpec).

source
vSmartMOM.StandaloneSS.run_exact_ss_with_jacobians Function
julia
run_exact_ss_with_jacobians(config; paths=:paths_1_2,
                            selector=SSMeasurementSelector())

Run the standalone solver and return handcoded f₂ Jacobians for paths 1 and 2. The Jacobians are with respect to the solver seam variables τ_layer, ϖ_eff, P_eff, and surface_brdf, holding the other seam variables fixed. The returned NamedTuple also includes measurements, the selected retrieval measurement vector from selected_measurements(result, selector). This Phase 5a prototype is CPU-only.

source
vSmartMOM.StandaloneSS.exact_ss_config_from_model Function
julia
exact_ss_config_from_model(model::RTModel; i_band=1, I0=nothing)

Build a standalone exact single-scattering configuration from a precomputed CoreRT model. The adapter is intentionally conservative: it reuses the model's Rayleigh Greek coefficients, absorption optical depths, supported surface types, and any aerosol optics whose truncation factor is zero.

If aerosol optics have already been δ-M/δ-BGE truncated (fᵗ != 0), the adapter throws instead of silently mixing truncated phase matrices with unmodified optical-depth state.

A CoxMunkSurface with n_water = nothing is passed on with the Segelstein (1981) index at every spectral point of the band, as the RT solvers use it.

source
vSmartMOM.StandaloneSS.selected_measurements Function
julia
selected_measurements(result, selector=SSMeasurementSelector())

Return the selected StandaloneSS radiances as a one-dimensional measurement vector. The vector order is geometry, then Stokes, then spectral point within each selected path, with geometry varying fastest; multiple paths are concatenated in selector order.

source
vSmartMOM.StandaloneSS.selected_measurement_jacobian Function
julia
selected_measurement_jacobian(dL_dp, selector=SSMeasurementSelector())

Flatten a StandaloneSS Jacobian array with shape (nGeom, nStokes, nSpec, nParam) into a retrieval Jacobian matrix with shape (nMeasurement, nParam), using the same measurement ordering as selected_measurements.

source
vSmartMOM.StandaloneSS.surface_brdf_wind_jacobian Function
julia
surface_brdf_wind_jacobian(config)
surface_brdf_wind_jacobian(surface, geometry, n_spec; polarization_type=nothing)

Return the StandaloneSS seam derivative of Cox-Munk direct-beam surface BRDF with respect to wind speed. For scalar Stokes it returns an array with shape (nGeom, nSpec, 1). For vector Stokes it returns (nGeom, nStokes, nSpec, 1), matching chain_rule_combine_surface_brdf's dρ_dp input.

source
vSmartMOM.StandaloneSS.truncated_ss_path1 Function
julia
truncated_ss_path1(config, l_trunc)

Run standalone atmospheric single-scatter path 1 with scattering phase functions reconstructed from only the first l_trunc Greek/Legendre moments. Optical depths and single-scattering albedos are unchanged. This is the post-hoc first-order analogue of the MOM angular truncation, not a full δ-M or δ-BGE optical-depth rescaling.

source
vSmartMOM.StandaloneSS.truncated_ss_path2 Function
julia
truncated_ss_path2(config, max_m)

Run standalone direct-beam surface path 2 with the surface BRDF reconstructed from Fourier moments m = 0:max_m-1. Lambertian surfaces are exactly represented by m = 0; Cox-Munk surfaces use the same direct-beam Fourier coefficient convention as the CoreRT surface correction.

source
vSmartMOM.StandaloneSS.apply_back_correction! Function
julia
apply_back_correction!(R_SFI, config; l_trunc, max_m)
apply_back_correction!(R_SFI, model; i_band=1, l_trunc=nothing, max_m=nothing, I0=nothing)

Apply the standalone first-order back-correction in place: exact(path1+path2) - truncated(path1+path2). This is a diagnostic/post-hoc single-scattering correction and does not propagate a corrected source through the multiple-scattering operator.

source
vSmartMOM.StandaloneSS.determine_required_l_aerosol Function
julia
determine_required_l_aerosol(contributor; target_relative_error=1e-4)

Return the required phase-function moment order for a Phase 1 contributor. Rayleigh is exact through l=2; pure absorption contributes no phase series. For the Henyey-Greenstein contributor, the estimate uses the closed-form asymptotic g^l decay.

source
vSmartMOM.StandaloneSS.determine_required_l_from_moments Function
julia
determine_required_l_from_moments(β; target_relative_error=1e-4)

Estimate the highest Greek/Legendre moment needed from a supplied coefficient series by comparing the squared tail energy to the requested relative error. The input is indexed as Julia arrays are: β[1] is the l=0 coefficient.

source
vSmartMOM.StandaloneSS.determine_required_nbrdf Function
julia
determine_required_nbrdf(surface; target_relative_error=1e-4)

Return the required BRDF Fourier moment count for a surface. Lambertian surfaces only need m=0, represented as a count of 1.

source
vSmartMOM.StandaloneSS.determine_required_nbrdf_coxmunk Function
julia
determine_required_nbrdf_coxmunk(wind_speed_ms; target_relative_error=1e-4)

Heuristic Cox-Munk BRDF Fourier moment count from the capillary-slope width. This helper is standalone and does not depend on the CoreRT CoxMunk type.

source
vSmartMOM.StandaloneSS.determine_required_nquad Function
julia
determine_required_nquad(config; target_relative_error=1e-4)

Combined Phase 2 diagnostic for the standalone solver: stream count, surface Fourier count, and later paths-3+4 inner quadrature estimate.

source
vSmartMOM.StandaloneSS.determine_required_nquad_inner Function
julia
determine_required_nquad_inner(τ_total, contributors; target_relative_error=1e-4)

Estimate the smooth inner quadrature order needed by later paths 3+4. Phase 1 does not use inner quadrature, but this diagnostic is part of the standalone solver API for the next path slice.

source
vSmartMOM.StandaloneSS.determine_required_nstreams Function
julia
determine_required_nstreams(contributors, surface; target_relative_error=1e-4)

Return a diagnostic record for the discrete-ordinate stream count implied by Phase 1 contributors and the surface BRDF.

source
vSmartMOM.StandaloneSS.chain_rule_combine_dτ Function
julia
chain_rule_combine_dτ(dL_dτ, dτ_dp)

Contract f₂ Jacobians with parameter derivatives of layer optical depth. dL_dτ has shape (nGeom, nStokes, nSpec, nLayers) and dτ_dp has shape (nLayers, nSpec, nParam). The returned array has shape (nGeom, nStokes, nSpec, nParam).

source
vSmartMOM.StandaloneSS.chain_rule_combine_dϖ Function
julia
chain_rule_combine_dϖ(dL_dϖ, dϖ_dp)

Contract f₂ Jacobians with parameter derivatives of effective single-scattering albedo. dL_dϖ has shape (nGeom, nStokes, nSpec, nLayers) and dϖ_dp has shape (nLayers, nSpec, nParam). The returned array has shape (nGeom, nStokes, nSpec, nParam).

source
vSmartMOM.StandaloneSS.chain_rule_combine_dP Function
julia
chain_rule_combine_dP(dL_dP, dP_dp)

Contract f₂ Jacobians with parameter derivatives of geometry-dependent effective phase values. dL_dP has shape (nGeom, nStokes, nSpec, nLayers). For scalar phase derivatives, dP_dp has shape (nGeom, nLayers, nSpec, nParam). For vector-Stokes phase derivatives, dP_dp has shape (nGeom, nStokes, nLayers, nSpec, nParam). The returned array has shape (nGeom, nStokes, nSpec, nParam).

source
vSmartMOM.StandaloneSS.chain_rule_combine_surface_brdf Function
julia
chain_rule_combine_surface_brdf(dL_dρ, dρ_dp)

Contract f₂ Jacobians with parameter derivatives of surface BRDF. dL_dρ has shape (nGeom, nStokes, nSpec). For scalar BRDF derivatives, dρ_dp has shape (nGeom, nSpec, nParam). For vector-Stokes BRDF derivatives, dρ_dp has shape (nGeom, nStokes, nSpec, nParam). The returned array has shape (nGeom, nStokes, nSpec, nParam).

source

Inelastic Internals ​

vSmartMOM.InelasticScattering.get_greek_raman_VS Function
julia
get_greek_raman_VS(rs, molecule)

Return the Greek coefficients of the vibrational Q-branch (ΔJ = 0) phase matrix of one molecular species. The Q branch is the sum of the per-J lines of compute_σ_Rayl_VibRaman_coeff_hires!, each a Rayleigh-type line with isotropic part α′²/3 and anisotropic part (2/27) b_JJ γ′². Their sum is a single Rayleigh-type line with the population-weighted ⟨b_JJ⟩ (q_branch_mean_b, same temperature as the lines), so the phase matrix uses

γ_C = 3⟨b_JJ⟩γ′² / (45α′² + 4⟨b_JJ⟩γ′²),   ρ = 2γ_C / (1 + γ_C).

(The O and S branches are separate RVRS lines with the RRS phase matrix.)

source
vSmartMOM.InelasticScattering.q_branch_mean_b Function
julia
q_branch_mean_b(mol, v)

Population-weighted Placzek–Teller coefficient of the Q-branch (ΔJ = 0) lines that start in vibrational level v,

⟨b_JJ⟩ = Σ_J w_J b_JJ / Σ_J w_J,   w_J = g_J (2J+1) exp(−hc E(v,J)/(k T)),

with b_JJ = J(J+1)/((2J−1)(2J+3)) (Sanghavi 2022, Eq. 31) and g_J the nuclear spin weight. The sum runs over the levels J = 0…Jmax of the per-J lines of compute_σ_Rayl_VibRaman_coeff_hires!, at the temperature T they were computed for (mol.effCoeff.T). Each of those lines carries the anisotropy b_JJ γ², so their sum carries ⟨b_JJ⟩ γ².

source
vSmartMOM.InelasticScattering.has_inelastic Function
julia
has_inelastic(rs::AbstractRamanType) -> Bool

Return whether rs represents a Raman-aware mode that carries inelastic source/scattering state. This is the public trait used by CoreRT boundary code instead of spelling out isa noRS checks at each call site.

source
vSmartMOM.InelasticScattering.uses_cabannes_phase Function
julia
uses_cabannes_phase(rs::AbstractRamanType) -> Bool

Return whether the elastic Rayleigh path should use Cabannes phase coefficients because Raman redistribution is handled explicitly by rs.

source
vSmartMOM.InelasticScattering.needs_interaction_workspace Function
julia
needs_interaction_workspace(rs::AbstractRamanType) -> Bool

Return whether CoreRT should allocate the staged inelastic interaction workspace for this Raman mode.

source
vSmartMOM.InelasticScattering.needs_rayleigh_expansion Function
julia
needs_rayleigh_expansion(rs::AbstractRamanType) -> Bool

Return whether per-layer Rayleigh scattering fractions must be expanded onto the active Raman spectral grid before entering the core kernel.

source
vSmartMOM.InelasticScattering.normalize_raman_weights! Function
julia
normalize_raman_weights!(rs, model, iBand)

Normalize Raman redistribution weights for modes whose ϖ_λ₁λ₀ represents a rotational Raman fraction. Modes that do not require this normalization are left unchanged. For RRS, throws an ArgumentError when the weights sum to zero (never filled by getRamanSSProp!), since the Raman fraction 1 − ϖ_Cabannes would otherwise be lost.

source
vSmartMOM.InelasticScattering.compute_effective_coefficents! Function
julia
compute_effective_coefficents!(ν_eff, T, mol)
compute_effective_coefficents!(ν_eff, T, mol, molecule, anisotropy)

Update molecular effective polarizability, anisotropy, depolarization, and Greek-coefficient factors at effective wavenumber ν_eff and temperature T.

The three-argument form (and anisotropy = ConstantAnisotropy) uses the Raman-module tensor: the Buldakov et al. mean polarizability and the wavelength-independent anisotropy . These are the constants of the published Raman tables. With anisotropy = DispersiveAnisotropy, molecule ∈ (N₂(), O₂()) takes and from the UsingRefInd refractivity and King factor (see Scattering._dispersive_polarizability_tensor); H₂ has no such data and keeps the Raman-module tensor. The derivative terms α_prime and γ_prime (vibrational Raman) are the Raman-module constants in both cases.

source
vSmartMOM.InelasticScattering.compute_σ_RoVibRaman_coeff! Function
julia
compute_σ_RoVibRaman_coeff!(T, mol; vmax=2, Jmax=30)

Update rotational and rovibrational Raman transition prefactors for mol at temperature T.

source
vSmartMOM.InelasticScattering.get_n₀_n₁ Function
julia
get_n₀_n₁(arr, Δ)

Return destination and source spectral index ranges for a Raman offset Δ against the third dimension of arr.

source
vSmartMOM.InelasticScattering.getRamanSSProp! Function
julia
getRamanSSProp!(rs::RRS, λ, grid_in)

Fill the rotational Raman state of rs for the band grid grid_in (cm⁻¹) and the reference wavelength λ (nm; normally the band centre, 1e7 / mean(grid_in)): the Raman phase coefficients, the Cabannes fraction and the line weights ϖ_λ₁λ₀ with their source offsets i_λ₁λ₀. Throws an ArgumentError when the band holds no rotational line or λ lies outside it.

source
vSmartMOM.InelasticScattering.sol_RRS Type
julia
sol_RRS{FT}

Stellar/solar rotational Raman-scattering mode for H₂-dominated atmospheres.

source
vSmartMOM.InelasticScattering.sol_VS_0to1 Type
julia
sol_VS_0to1{FT<:AbstractFloat}

Stellar/solar vibrational Raman mode for H₂-dominated atmospheres, ground to first excited state.

Fields

  • h2: Molecular Constant for H2

  • greek_raman: Greek coefs in Raman calculations

  • fscattRayl: Pre-computed optical properties

  • ϖ_Cabannes

  • ϖ_λ₁λ₀

  • i_λ₁λ₀

  • Z⁻⁺_λ₁λ₀

  • Z⁺⁺_λ₁λ₀

  • dτ₀

  • dτ₀_λ

  • k_Rayl_scatt

  • n_Raman

  • F₀

source
vSmartMOM.InelasticScattering.sol_VS_1to0 Type
julia
sol_VS_1to0{FT<:AbstractFloat}

Stellar/solar vibrational Raman mode for H₂-dominated atmospheres, first excited to ground state.

Fields

  • h2: Molecular Constant for H2

  • greek_raman: Greek coefs in Raman calculations

  • fscattRayl: Pre-computed optical properties

  • ϖ_Cabannes

  • ϖ_λ₁λ₀

  • i_λ₁λ₀

  • Z⁻⁺_λ₁λ₀

  • Z⁺⁺_λ₁λ₀

  • dτ₀

  • dτ₀_λ

  • k_Rayl_scatt

  • n_Raman

  • F₀

source
vSmartMOM.InelasticScattering.sol_VS_0to1_plus Type
julia
sol_VS_0to1_plus{FT<:AbstractFloat}

Stellar/solar vibrational Raman mode for H₂-dominated atmospheres, ground to first excited state, over concatenated spectral bands.

Fields

  • bandSpecLim: Concatenated indices of band limits

  • iBand

  • grid_in

  • h2: Molecular Constant for H2

  • greek_raman: Greek coefs in Raman calculations

  • greek_raman_VS

  • fscattRayl: Pre-computed optical properties

  • ϖ_Cabannes

  • ϖ_λ₁λ₀

  • i_λ₁λ₀

  • Z⁻⁺_λ₁λ₀

  • Z⁺⁺_λ₁λ₀

  • ϖ_λ₁λ₀_VS

  • i_λ₁λ₀_VS

  • Z⁻⁺_λ₁λ₀_VS

  • Z⁺⁺_λ₁λ₀_VS

  • i_λ₁λ₀_all

  • i_ref

  • n_Raman

  • F₀

source
vSmartMOM.InelasticScattering.sol_VS_1to0_plus Type
julia
sol_VS_1to0_plus{FT<:AbstractFloat}

Stellar/solar vibrational Raman mode for H₂-dominated atmospheres, first excited to ground state, over concatenated spectral bands.

Fields

  • bandSpecLim: Concatenated indices of band limits

  • iBand

  • grid_in

  • h2: Molecular Constant for H2

  • greek_raman: Greek coefs in Raman calculations

  • greek_raman_VS

  • fscattRayl: Pre-computed optical properties

  • ϖ_Cabannes

  • ϖ_λ₁λ₀

  • i_λ₁λ₀

  • Z⁻⁺_λ₁λ₀

  • Z⁺⁺_λ₁λ₀

  • ϖ_λ₁λ₀_VS

  • i_λ₁λ₀_VS

  • Z⁻⁺_λ₁λ₀_VS

  • Z⁺⁺_λ₁λ₀_VS

  • i_λ₁λ₀_all

  • i_ref

  • n_Raman

  • F₀

source

Aerosol Internals ​

vSmartMOM.Aerosols.compute_optical_properties Function
julia
compute_optical_properties(data::AerosolData, wavelengths::AbstractVector,
                           ri_database::RefractiveIndexDatabase)

Reserved entry point for converting ingested aerosol schemes to physical optics. Currently throws ArgumentError: the TOMAS and two-moment ingestion framework has no validated conversion from its concentration units and vertical geometry to extinction, single-scattering albedo, and phase coefficients.

Earlier versions returned placeholder efficiencies, number densities, and a constant asymmetry parameter. Those values were not suitable for scientific use and are no longer returned. Use the production Scattering Mie APIs and CoreRT aerosol configuration for radiative-transfer calculations. A future scheme adapter must supply explicit units, meteorology, size distributions, and a validated Mie/phase calculation before implementing this interface.

source

Architecture Internals ​

vSmartMOM.Architectures.AbstractArchitecture Type
julia
AbstractArchitecture

Abstract supertype for compute architectures supported by vSmartMOM.

source
vSmartMOM.Architectures.@hascuda Macro
julia
@hascuda expr

A macro to compile and execute expr only if CUDA is installed and available. Generally used to wrap expressions that can only be compiled if CuArrays and CUDAnative can be loaded.

source
vSmartMOM.Architectures.ka_backend Function
julia
ka_backend(arch::AbstractArchitecture)

Return the KernelAbstractions backend object for arch, suitable for launching KA kernels (@kernel/ndrange=) and KernelAbstractions.allocate.

  • CPU() → KernelAbstractions.CPU() (always available).

  • GPU() → CUDA.CUDABackend(), but only when the vSmartMOMCUDAExt extension is loaded (i.e. using CUDA). Without it, the default method below throws an informative error rather than failing cryptically inside a kernel launch. This mirrors the weak-dependency pattern used for devi/array_type.

This is the architecture→backend mapping consumed by the GPU Mie pipeline (compute_aerosol_optical_properties on a GPU()-architecture MieModel).

source
vSmartMOM.Architectures.has_gpu_mie Function
julia
has_gpu_mie(arch::AbstractArchitecture) -> Bool

Capability trait: does arch have a GPU Mie pipeline (ka_backend + default_mie_precision_policy + the KernelAbstractions Mie kernels)?

  • Defaults to false for every architecture, including GPU() and MetalGPU(). A backend extension opts in by adding a more-specific method once it actually wires up the GPU Mie path. vSmartMOMCUDAExt sets has_gpu_mie(::GPU) = true; the Metal extension defines no Mie path, so MetalGPU() keeps the default false and Mie is computed on the CPU (RT arrays still run on Metal, exactly as before this trait existed).

The default lives on the abstract supertype and the CUDA ext adds the concrete ::GPU refinement — the same precompile-safe pattern as ka_backend (a more specific method is a refinement, not a method overwrite).

Consumed by the aerosol-optics router: true → GPU Mie pipeline; false → CPU Mie compute (with a one-time @warn when arch is not CPU()).

source
vSmartMOM.Architectures.default_mie_precision_policy Function
julia
default_mie_precision_policy(arch::AbstractArchitecture, ::Type{FT})
default_mie_precision_policy(arch::AbstractArchitecture)            # forwarding shim → Float64

Return the default GPU Mie Dₙ-recursion precision policy for arch and output float type FT, used when a MieModel's precision_policy is nothing (auto). The concrete policy types (NativeFloat64, DSEmulated) live in the Scattering module, so the returned value is supplied by the loaded GPU backend extension:

  • CPU() → nothing (the CPU path ignores the precision policy entirely).

  • GPU() (set by vSmartMOMCUDAExt) is FT-aware:

    • Float64 → Scattering.NativeFloat64(), the full-FP64 Dₙ recursion appropriate for A100/V100-class hardware.

    • Float32 → Scattering.DSEmulated(), the Float32-native path. Float32 models cannot use NativeFloat64 (its kernel asserts FT === Float64), so auto-selecting it would break the several existing GPU YAMLs built with float_type: Float32. DSEmulated runs the device Dₙ recursion in Float32 double-single pairs and the host-side bulk reduction is already Float64-widened + Neumaier-compensated, so accuracy lands at the Float32 representational floor — the best a Float32 model can do.

Calling this on a GPU() without CUDA.jl loaded throws, matching ka_backend. The 1-arg method is a back-compat forwarding shim that defaults FT = Float64.

source

IO Internals ​

vSmartMOM.IO.Formats.load_config Function

Load a configuration Dict from a source

source