Skip to content

Automatic diagnostic figure for any species count and dimension; spectrax input.toml saves it - #63

Open
rogeriojorge wants to merge 4 commits into
feature/species-tomlfrom
feature/auto-plots
Open

rogeriojorge wants to merge 4 commits into
feature/species-tomlfrom
feature/auto-plots

Conversation

@rogeriojorge

Copy link
Copy Markdown
Member

Stacked on #62. Review #62 first.

Problem

plot assumed exactly two species, a 1D run along y, and input keys (dn1, nx, k_norm) that only the default two-stream case defines. It failed or showed the wrong panels for any other case, so every example carried its own plotting code.

Change

plot(output, save=None, show=True) now works for any number of species and any dimension, in the spirit of JAX-in-Cell's single automatic figure. It draws these panels:

Panel Content
Energy exchange Electric and magnetic field energy, and the change in kinetic energy of each species
Energy conservation |W(t)/W(0) − 1|
Strongest modes The four strongest electric-field modes, labelled by their wavevector
Hermite spectrum Per species: Σ_k |δC_n|² against Hermite order and time, which shows phase mixing, recurrence and the reach of the closure
Phase space Per species: the perturbation f − ⟨f⟩_x at the last saved time, along the longest direction
Field map In 2D or 3D only: the strongest field component in the plane

Other changes:

  • phase_space(output, species, time_index) is exposed for custom figures.
  • diagnostics also returns electric_energy and magnetic_energy.
  • Command line: spectrax input.toml runs the case, saves input.png next to the file, and shows it. --no-show is for batch runs.

_plot.py shrinks from 127 to 121 lines while covering every case.

Tests

  • The CLI runs a three-species 2D TOML and writes the figure.
  • The full suite passes, 11 tests in 9 s.
  • The figure was checked visually on Landau damping and on a 2D two-species case.

plot(output) shows the field and kinetic energy exchange, energy conservation, the strongest field modes, the Hermite spectrum of each species over time, the phase-space perturbation of each species and, in 2D, the field in the plane. The CLI saves input.png next to the TOML. diagnostics now also returns electric_energy and magnetic_energy.
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