Skip to content

Fix multispecies perturbation bookkeeping - #12

Open
rogeriojorge wants to merge 3 commits into
mainfrom
agent/fix-multispecies-perturbations
Open

rogeriojorge wants to merge 3 commits into
mainfrom
agent/fix-multispecies-perturbations

Conversation

@rogeriojorge

@rogeriojorge rogeriojorge commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Problem

simulation builds the perturbation dCk by zeroing the uniform density coefficient (n=m=p=0, k=0) of species 0 and 1 only. With three or more populations the other backgrounds stay in dCk.

Change (1 production line)

dCk = Ck.at[:, jnp.arange(Ns) * Nn * Nm * Np, 0, 0, 0].set(0).

Tests

test_perturbation_removes_every_background_density_and_keeps_mean_current[Ns=1,2,3,4]: each species has a background density, a uniform drift (k=0 first Hermite moment, i.e. a physical mean current) and a kx=1 density perturbation. dCk must equal Ck everywhere except the Ns density slots; the mean-current coefficients survive in dCk, and the net mean current still drives the uniform Ex. On main, Ns=3 and Ns=4 fail; Ns=1 and 2 pass.

Evidence (tested SHA 3f89a09, rebased on main ab87385; local, Python 3.12.9, JAX 0.11.2)

python -m pytest -n 2 -q tests: 12 passed.

Other two-species assumptions on main, not changed here: default qs, Omega_cs ([1, 1/mi_me]) and initial state are two-species; diagnostics uses mi_me masses and the legacy Debye length only for Ns=2, otherwise unit masses unless ms/masses is given; EM_energy and the Ampere source are normalised by Omega_cs[0].

No dependencies. Touches the same _simulation.py block as #13 (trivial conflict).

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
spectrax/_simulation.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rogeriojorge
rogeriojorge marked this pull request as ready for review July 13, 2026 03:09
rogeriojorge added a commit that referenced this pull request Sep 23, 2026
The study scripts now live in a separate repository pinned to a7ca601. This branch keeps only the unchanged merges of #44, #24, #12 and #17 (with #9).
@rogeriojorge
rogeriojorge force-pushed the agent/fix-multispecies-perturbations branch from e428bb3 to 94960e3 Compare September 26, 2026 21:11
dCk must differ from Ck only in each species' uniform density slot; the k=0
first Hermite moment (mean current) and all k != 0 coefficients are kept, and
the net mean current still drives the uniform field.
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