Repository navigation
Sync Discontinuous-Galerkin with main - #54
Open
rogeriojorge wants to merge 55 commits into
Open
rogeriojorge wants to merge 55 commits into
rogeriojorge wants to merge 55 commits into
Conversation
Switch to RFFT for Fourier transforms
* Fix periodic Orszag-Tang grid * Simplify periodic Orszag-Tang grid fix
Expose solver statistics
The solver stores Ck with irfftn(..., norm="forward") (Ck at k = 0 is the spatial mean), but inverse_HF_transform used the default backward norm, so every reconstructed f(x, v) was Nx*Ny*Nz times too small.
Random real C_nmp on odd and even grids go through the solver's rfftn(norm="forward") and back; the density and first velocity moments of f, integrated by Gauss-Hermite quadrature, must return C_000 and C_100/sqrt(2), C_010/sqrt(2), C_001/sqrt(2).
Use the solver's Fourier normalization in inverse_HF_transform
Landau damping example: pass its initial field to the solver
Build the default initial state on the requested grid, so 2D TOMLs without Ck_0 run
Keep the DG solver core (_model, _simulation, _initialization) and DG examples; take main's cleaned midpoint_solver, diagnostics, inverse transform, docs and tests; expose solver_stats from the DG simulation.
…ling An under-resolved run (too few Hermite modes or too weak hypercollisions for the filamentation reaching the cutoff, or a species whose Hermite width is narrower than it becomes) makes the adaptive step collapse; the solve then crawls for hours towards the hard-coded 1e6 steps. dtmin (off by default) stops it with an error at the collapse; max_steps is now a parameter.
simulation(throw=False) returns and puts diffrax's sol.result in output['solver_result'].
spectrax imports diffrax (time integration) and orthax (inverse Hermite transform), but pyproject.toml did not list them, so pip install left the package unimportable in a clean environment.
diffrax 0.7, matplotlib 3.10+ and current jax need at least 3.11, tomllib is in the standard library from 3.11, and CI tests 3.11 and 3.12. The old >=3.5 could not resolve.
The logo was a 4.7 MB 1576x1476 screenshot with embedded metadata; the README shows it at 30% width. It is now 800 px wide with a 256-colour palette and no metadata (193 KB). Tracked __pycache__ files are removed; __pycache__/ is already ignored.
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.
Three species with unequal (Nn, Nm, Np) check that flat Hermite index s*Nn*Nm*Np + p*Nn*Nm + m*Nn + n maps to state[s, p, m, n], and a fixed-step run restarted from a saved (Ck, Fk) snapshot matches the uninterrupted run.
|
This sync is with an older version of DG branch. Should be rechecked against newer commits. Growth/decay rate scans can be omitted from the sync. |
Compress the logo and stop tracking bytecode
Declare diffrax and orthax as dependencies
…ions Fix multispecies perturbation bookkeeping
Keep solver state axes structured
Expose dtmin, max_steps and throw so a collapsing step stops, or is reported, instead of crawling
Take the newer DG solver, examples and utilities (DG_project, inverse_HDG_transform, DG diagnostics and plots). Drop the Fourier growth/decay rate scans and their data. Keep solver_stats in the output and size the default Ck_0 by Nn*Nm*Np.
Take main's deps, logo, bytecode removal and dtmin/max_steps/throw solver options. Carry them onto the DG simulation: keep (Ck, Fk) as a structured solver state, let ImplicitMidpoint take a pytree state, and adapt main's tests to the DG layout. Update the README DG note and add the new solver options to the parameter table.
Member
Author
Member
Author
|
Handed over to @Benjamin-Herfray together with the DG parallel chain; see the handoff comment on #74 for the order (refresh this sync, then rebase the chain) and the jax 0.12 test fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem.
Discontinuous-Galerkinwas 96 commits behindmain(merge base bcd41c4).Change. A merge of current
main(ab87385, includes #49/#52/#53) into the branch, so the DG history and the open PRs #45/#39 stay valid.Conflicts and how they were resolved:
spectrax/_model.py,_simulation.py,_initialization.py: kept the DG solver. Main's rFFT layout,_twothirds_maskand Fourier default state do not apply to a DG discretization. From main, keptsolver_statsin the simulation output.spectrax/midpoint_solver.py: took main's cleaned version. It removes the broken_preconditioning/jaxoptimports that DG had commented out.1D_Landau_damping,1D_two_stream,1D_Weibel,2D_Orszag_Tangand their TOMLs): kept the DG versions. The Weibel files are kept even though main deleted them. Main'sadaptive_time_stepTOML key is not taken, because the DGsimulationdoes not accept it._initialize_maxwellian, the old_src/crank_nicolson removals, docs, README and tests.Follow-up commit: main's #52 test (a 2D multi-Hermite TOML with no initial state) failed on DG.
legTwas only given the x grid, and the defaultCk_0ignoredNm/Np. Both are fixed. The test asserts the DG shape(t, Ns*Nn*Nm*Np, Ny, Nx, Nz, Nl).Tests.
pytest tests: 9 passed, with and withoutJAX_ENABLE_X64=1.legTold-signature call is fixed (3 lines). It runs in 105 s. The E-field growth rate fitted over t in [5,15] is 0.221, and kinetic linear theory gives 0.218 for k=5.0, u=+-0.1, alpha=0.0707. The fit depends on the window (0.21-0.38) because the 1% seed saturates by t of about 12.Known issues (already on DG before this merge).
1D_Landau_damping_dr_curve.py,1D_two_stream_gr_curve.py,orszag_tang_data_analysis.py) do not run on the DG solver. They are kept so a later DG to main merge does not delete them.Merge order: this PR, then #45, then #39.
Update 2026-10-03 (head 2f4ee44)
git rev-list origin/main ^HEADis empty.simulationon this branch is Legendre DG in space, lists the four DG examples, and says that1D_Landau_damping_dr_curve.py,1D_two_stream_gr_curve.py,orszag_tang_data_analysis.pyand thediagnostics/plot/inverse_HF_transformutilities come from main, assume the Fourier layout and do not run on DG output. No code change.pytest tests9 passed (also withJAX_ENABLE_X64=1), Python 3.12, JAX 0.11.2, CPU.diagnosticsis exported here but is commented out in the DGsimulation; a DG energy diagnostic would need Legendre mass weights, not rFFT weights.Stack: this PR -> #45 (base now
sync/dg-with-main) -> #39 (base nowagent/dg-autodiff).Update 2026-10-23 (head a5998a8)
DG_project,inverse_HDG_transform, DG diagnostics and plots). The growth/decay rate scans (*_dr_curve,*_gr_curveand their toml/csv files) are not on the branch.dtmin/max_steps/throw(plussolver_resultandvalid_times), and Keep solver state axes structured #13's structured(Ck, Fk)solver state. Their tests are adapted to the DG layout.ImplicitMidpointnow accepts a pytree state.dCkbookkeeping), because DG droppeddCkfrom the output.pytest tests17 passed (also withJAX_ENABLE_X64=1). Reduced DG Landau, two-stream, OT and Weibel runs stay finite. Landau E-field damping rate is -0.1036 at Nx=33, Nn=40.