PHARE

Installation and first run

PHARE is built from source. Simulations are set up and analysed in Python and run in parallel with MPI. Every option is described in the documentation.

Build and run

to validate
  1. Requirements

    Git, CMake, make or ninja, C++20 and Fortran compilers, MPI, parallel HDF5, and Python 3.11 or later with its development headers. SAMRAI is downloaded and built unless CMake is given an existing installation.

  2. Build

    git clone https://github.com/PHAREHUB/PHARE
    cd PHARE
    python3 -m pip install -r requirements.txt
    mkdir build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release     # -DSAMRAI_ROOT=/path/to/samrai to reuse an installation
    make -j

    By default one Python module is compiled for every supported combination of dimension, interpolation order and number of split particles, plus the MHD variants. This takes a long time and a lot of memory. To build a subset, pass -DPHARE_PERMUTATIONS=<file> with lines in the format of res/sim/all.txt. Details: building PHARE.

  3. Run a test case

    cd ..    # PHARE root
    export PYTHONPATH=$PWD/build:$PWD/pyphare:$PWD
    mpirun -n 4 python3 tests/functional/harris/harris_2d.py

    Two Harris current sheets in a periodic 2D box, with automatic refinement on two levels (200 × 100 cells, 10,000 time steps; the test suite runs it on 10 MPI ranks). At the end the script writes plots of B, J, density and pressure to phare_outputs/harris_2d_plots/4/. Being a test, it deletes its raw outputs when it finishes. For a shorter run, reduce final_time in the script.

  4. Writing a run script and reading the outputs

    Copy into your own script the imports, the module-level constants (cells, time_step, final_time, timestamps, diag_dir) and the config() function of harris_2d.py, and end it with Simulator(config()).run(). The outputs then remain in phare_outputs/harris_2d:

    from pyphare.pharesee.run import Run
    
    run = Run("phare_outputs/harris_2d")
    run.GetB(25.0).plot(qty="z", plot_patches=True, filename="bz.png")

    Run reads all levels and patches of the AMR hierarchy. See running from Python, simulation inputs and reading outputs.

Capabilities and limitations

checked against the code, October 2026
FeatureStatusDetails
Dimensions available 1D, 2D and 3D. 3D hybrid runs were added in April 2026; there is no 3D functional test in the test suite yet.
Particle shape available Interpolation orders 1, 2 and 3.
Ion populations available Any number of populations, each initialised as a drifting Maxwellian whose density, bulk velocity and thermal speeds are Python functions.
Electrons limited Massless fluid with an isothermal closure (uniform Te). Ohm's law includes resistivity and hyper-resistivity, the latter on by default (1e-4, constant or spatially varying).
Mesh refinement available Refinement ratio 2. Levels defined by fixed boxes, or by automatic tagging on magnetic field variations. Each finer level takes four sub-steps per parent step.
Coarse-fine interpolation limited Low order at level boundaries; higher-order field refinement is in review. #1278
Boundary conditions limited Periodic only. Physical boundaries are in review. #1318
MHD limited A standalone finite-volume MHD solver (ideal or Hall) with constrained transport and adaptive time stepping. The default build mostly uses the Rusanov flux; other Riemann solvers need a custom build. MHD and hybrid levels in one run: in development. #1309 to validate
Parallelism available MPI. Optional dynamic load balancing by particle count or by cell count. Multithreading is in development. #1324
Output available HDF5 diagnostics (phareh5) or VTK-HDF (pharevtkhdf, readable by ParaView); checkpoint and restart.
Installation limited Build from source: CMake, MPI, parallel HDF5, Python 3.11 or later; SAMRAI is fetched or reused. No binary package.

Help