Skip to content

Remove MPI from openPMD output, extract the driver’s diagnostics, refactor the collapse demos - #98

Merged
cwoolfo1 merged 7 commits into
uwplasma:mainfrom
cwoolfo1:main
Nov 17, 2026
Merged

cwoolfo1 merged 7 commits into
uwplasma:mainfrom
cwoolfo1:main

Conversation

@cwoolfo1

Copy link
Copy Markdown
Member

Per-process openPMD output + offline merge (replaces MPI collective I/O)

Multiprocess runs no longer need MPI-enabled openPMD or parallel HDF5. Each JAX process writes its own data/fields_pNNN.h5 / particles_pNNN.h5 through the same bounded async queues a single-process run uses, exchanging nothing. A single-process run keeps the unsuffixed names and needs no merge.

New PyPIC3D/diagnostics/merge_openpmd.py joins a _pNNN group back into the unsuffixed file every analysis path already reads. Exposed as python -m PyPIC3D.diagnostics.merge_openpmd outputs/data and the console script PyPIC3D-merge-openpmd (--output, --iterations, --overwrite, --no-pmd). It validates that process indices are exactly 0..N-1 and that tile coverage is complete, and rewrites the .pmd pointer beside the merged series.
Because the HDF5 backend reports every dataset as one whole chunk, a reader can’t discover which regions a file wrote. The writer now records ownership explicitly as iteration attributes (pypic3dOwnedTiles, pypic3dTileCounts, pypic3dTileShape, pypic3dGlobalShape, pypic3dProcessIndex/Count), and the merge reads them back.
Mesh records use tile-shaped HDF5 chunks so a per-process file allocates only the cells that process owns, while each file stays a valid whole-domain mesh.
mpi_communicator() and every comm plumbing path are gone. initialize_distributed() now relies on JAX’s own Slurm/Open-MPI detection, with PYPIC_COORDINATOR_ADDRESS / PYPIC_PROCESS_ID / PYPIC_NUM_PROCESSES for launches it can’t detect. The [distributed] extra (mpi4py) is dropped from pyproject.toml.
PyPIC3D/distributed.py → PyPIC3D/utilities/distributed.py.
parallel_openpmd.py deleted; multihost_io_worker.py and sharded_openpmd_worker.py tests deleted, replaced by tests/distributed_tests/merge_openpmd_test.py (312 lines) which runs the whole naming/ownership/merge round trip on one process with no launcher.
docs/distributed_cartesian.md loses the parallel-HDF5/openPMD-from-source build instructions; docs/usage.rst documents the merge step.
Driver loop extraction

main.py drops from ~400 to ~210 lines. The energy/constraint/openPMD blocks move into a new PyPIC3D/diagnostics/simulation_output.py (open_simulation_output context manager, write_simulation_output, write_scalar_diagnostics, write_work_energy_tracker, simulation_energy_components, print_energy). Writer cleanup is now a finally block that closes both writers and preserves the original exception.

Supporting moves: compute_energy_components (diagnostic_quantities.py) folds the external-field add and the optional Proca term into one call; print_bssn_constraints (static_metric.py); _dark_timestep → dark_photon_courant_condition in simulation_helpers.py. Unused benchmark static parameter removed. New tests/code_tests/simulation_output_test.py.

Collapse demo refactors
Charged stellar collapse: the separate 1D radial metric solve is gone. initial_metric.py (484 lines changed, mostly deletions) is now a Cartesian time-symmetric Hamiltonian solve on the BSSN grid — JAX_BSSN’s discrete Hamiltonian, Newton with autodiff JVPs and GMRES (so memory scales with the grid rather than a dense 3D Jacobian), Robin outer boundary, backtracking line search. It is called from initial_data.py after particles and the spherical E field are loaded, so the demo is now a single python initial_data.py step.
The star is specified as a uniform coordinate sphere (rest mass 1, coordinate radius 10, Q = 0.2) with ADM mass and areal radius as measured outputs instead of prescribed inputs. charged_star.toml species values updated accordingly.
Neutral OS collapse: initial_metric.py simplified to the analytic solution, with the Wu & Most (2026) reference cited.
Readability pass

Single-call-site private helpers inlined across supergaussian.py, openPMD.py, initialization.py, particle_initialization.py, particle_tile_communication.py, grids.py, parameters.py. Notably _tile_grid_axis loses a nested lax.cond ladder that was selecting dx/dy/dz by traced axis index. Behavior-preserving; test coverage added in initialization_test.py, parameters_test.py, sharded_openpmd_test.py, distributed_particle_refresh_test.py.

@cwoolfo1
cwoolfo1 merged commit 2a2d8b7 into uwplasma:main Nov 17, 2026
1 check failed
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