Skip to content

Physical species tables in the input TOML: no hand-built Hermite coefficients - #62

Open
rogeriojorge wants to merge 4 commits into
mainfrom
feature/species-toml
Open

rogeriojorge wants to merge 4 commits into
mainfrom
feature/species-toml

Conversation

@rogeriojorge

Copy link
Copy Markdown
Member

Problem

Setting up a SPECTRAX case means building Hermite–Fourier coefficient arrays by hand in Python. The Landau-damping example spends 30 lines on Ck_0 and Fk_0 index arithmetic, and the field must be made consistent with Gauss's law by hand. JAX-in-Cell, by contrast, describes each species physically in its TOML file.

Change

load_parameters accepts one [species.<name>] table per species:

[input_parameters]
Lx = 1.2566        # box length in c/omega_pe
t_max = 20.0
nu = 2.0

[solver_parameters]
Nx = 9
Nn = 64

[species.electrons]
charge = -1
vth = 0.1414                  # sqrt(2T/m)/c, also the Hermite width
perturbation_amplitude = 0.01 # density * (1 + A cos(2 pi m x / L))

[species.protons]
charge = 1
mass = 1836
vth = 0.0033
  • The new species_initial_state builds the following from the species tables:
    • Ns, qs, ms, Omega_cs = Omega_ce / mass, alpha_s and u_s;
    • Ck_0, from each species' density in its own Maxwellian basis;
    • Fk_0, from Gauss's law i k·E = rho / Omega_ce, plus an optional uniform background field B0.
  • Each species takes charge, mass, density, vth, drift and a density perturbation. The perturbation fields use JAX-in-Cell's names: perturbation_amplitude, perturbation_mode and perturbation_axis.
  • The first species must have unit mass, because it sets the field units used by Ampère's law. Otherwise a clear ValueError is raised.
  • Files without species tables behave exactly as before. [input_parameters] and [solver_parameters] are now optional.

The change is 56 lines in one existing file, with no new modules.

Tests

  • Densities and Gauss's law: the species TOML gives the requested densities, and its initial field satisfies Gauss's law to 1e-14.
  • Landau damping at kλ_D = 0.5 is built only from the TOML. It damps at −0.1547 ω_pe, against the exact −0.1533 (1%). It oscillates at 1.410 ω_pe, against 1.416.
  • Units guard: making the first species non-unit mass raises.
  • The full suite passes, 10 tests in 7 s.

A [species.<name>] table with charge, mass, density, vth, drift and an optional density perturbation replaces hand-built Hermite-Fourier coefficients. The electric field solves Gauss's law, and Ns, qs, Omega_cs, alpha_s and u_s follow from the species. Old-style TOML files are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant