WarpX Documentation

repository·development·Indexed 19 days ago

https://github.com/blast-warpx/warpx

WarpX is a highly-parallel, optimized electromagnetic and electrostatic Particle-In-Cell (PIC) code designed for extreme-scale simulations on GPUs and multi-core CPUs. It features Perfectly-Matched Layers (PML), mesh refinement, and the boosted-frame technique. The code integrates with HPC standards and tools including AMReX, openPMD, PICMI, yt, ADIOS, and HDF5, and supports in-situ visualization via Ascent.

Tokens
125.4K
Snippets
344
Records
580
Agent score
66%

What's inside WarpX

  1. Overview of WarpX capabilities

    development

    WarpX is an advanced Particle-In-Cell (PIC) code designed for high-performance plasma physics simulations. It is highly parallel and optimized for multi-core CPUs as well as NVIDIA, AMD, or Intel GPUs, scaling to exascale supercomputers.

    Key Features:

    • Field Solvers: Supports Maxwell's equations, Poisson's equation, and Ampere's law coupled with Ohm's law.
    • Geometries: Supports 1D, 2D, and 3D Cartesian, cylindrical, and spherical grids.
    • Multi-physics: Includes ionization, atomic, fusion, collisional physics, and quantum electrodynamics (QED).
    • Numerical Methods: Supports explicit and implicit time advancement, mesh refinement, boosted-frame simulations, embedded boundaries, and pseudo-spectral solvers.
    • Extensibility: Can be extended via a Python interface to couple with other codes or AI/ML frameworks.
    • Platforms: Runs on Linux, macOS, and Windows.
  2. Overview of WarpX

    development

    WarpX is an advanced electromagnetic and electrostatic Particle-In-Cell (PIC) code. It is designed for high performance and scalability, capable of running on GPUs and multi-core CPUs with built-in load balancing. It is suitable for large-scale simulations on supercomputers.

    Key features include:

    • Perfectly-Matched Layers (PML)
    • Mesh refinement
    • Boosted-frame technique
    • Support for various high-performance computing (HPC) backends and data formats.
  3. Use in situ visualization capabilities in WarpX

    development

    WarpX supports in situ visualization, which allows you to visualize simulation data directly from the running simulation without the overhead of dumping large data files to disk. This is achieved through integration with external visualization frameworks. Supported frameworks include:

    • Ascent: For in situ visualization.
    • Catalyst: For in situ visualization.
    • Sensei: For in situ visualization.

    Refer to the specific documentation for Ascent, Catalyst, or Sensei to learn how to configure and use these capabilities within your WarpX simulation.

  4. Scientific applications of WarpX

    development

    WarpX is used across several scientific domains for high-fidelity plasma modeling and particle-in-cell (PIC) simulations. Key application areas include:

    • Astrophysical Plasma Physics: Modeling multispecies ion acceleration, magnetic reconnection, and ion-acoustic solitons.
    • Microelectronics: Powering solvers like ARTEMIS (Adaptive mesh Refinement Time-domain ElectrodynaMIcs Solver), which couples WarpX's Maxwell equations implementation with quantum material equations (e.g., LLG for micromagnetics and London equations for superconductors).
    • Nuclear Fusion and Plasma Confinement: Simulating FRC stability, magnetic mirror configurations, Penning discharges, and high-beta fusion reactors.
    • Plasma Thrusters and Spacecraft Physics: Conducting 2D/3D PIC simulations of Hall thrusters, including studies on azimuthal instabilities and Monte Carlo collisions.
    • High-Performance Computing (HPC): Advancing numerical studies on wave attenuation and electromagnetic PIC simulations.
  5. Supported Output Formats in WarpX

    development

    WarpX generates several types of output data depending on the simulation requirements:

    • Field and Particle Data:
      • openPMD: Supported via community formats like ADIOS and HDF5.
      • AMReX Plotfiles: The native AMReX data format.
    • Reduced Diagnostics: On-the-fly observables (e.g., energy histograms, particle beam statistics) typically stored as tabular text (CSV) files.
  6. Understand the WarpX repository structure

    development

    WarpX source code is organized within the Source/ directory. Key components of the PIC (Particle-In-Cell) loop are located as follows:

    • Main PIC loop: Implemented in WarpX::Evolve within Source/WarpXEvolve.cpp.
    • Core PIC loop logic:
      • When subcycling is OFF: WarpX::OneStep_nosub.
      • When subcycling is ON (method 1): WarpX::OneStep_sub1.
    • Main WarpX class: Implemented in Source/WarpX.cpp.
  7. Use Pinned Memory for optimized data transfers

    development

    Pinned (or "page locked") host memory is required for:

    • Performing asynchronous copies between the host (CPU) and the device (GPU).
    • Writing to CPU memory directly from a GPU kernel.

    In WarpX/AMReX, pinned memory is typically provided via the amrex::PinnedArenaAllocator. This allocator is passed as the last argument to the constructors of ParticleContainer and MultiFab to enable optimized data transfer routines, such as output initialization.

  8. Use Background Monte Carlo Collisions (MCC)

    development

    The MCC module simulates collisions between simulation particles and a neutral background gas. It supports several processes:

    • Elastic scattering
    • Back scattering
    • Charge exchange
    • Excitation collisions
    • Impact ionization

    Implementation Details

    • Null Collision Strategy: To minimize computational overhead, WarpX uses a null collision strategy. It pre-selects a subset of macroparticles based on maximum collision probability over a range of energies, only performing detailed cross-section calculations for those particles.
    • Background Assumptions: The background neutral particles are assumed to be thermal and moving at non-relativistic velocities in the lab frame. Users specify a neutral temperature, and a velocity vector for a neutral particle is randomly chosen for each collision consideration.
    • Energy Calculation: Collision energy is calculated using ParticleUtils::getCollisionEnergy(), which accounts for relativistic effects. This is critical for high-energy ions where classical approximations fail.
  9. Interact with HPC Batch Systems

    development

    HPC systems utilize batch (scheduling) systems to manage compute jobs asynchronously. WarpX documentation provides quick reference guides (cheat sheets) for interacting with the following common batch systems:

    • Slurm: Used at NERSC, OLCF Frontier, etc.
    • Flux: A modern resource manager framework used at LLNL LC, etc.
    • LSF (Load Sharing Facility): An IBM batch system used at OLCF Summit, LLNL Lassen, etc.
    • PBS (Portable Batch System): Includes OpenPBS, PBS Pro, and TORQUE.
    • PJM (Parallel Job Manager): A Fujitsu batch system used at RIKEN Fugaku, etc.

    Individual HPC machine guides typically include job submission example scripts that can be used as templates for your own compute jobs.

  10. How SENSEI in situ architecture works

    development

    SENSEI is a framework for in situ data analysis that provides uniform access to various visualization and analysis back ends (e.g., VisIt Libsim, ParaView Catalyst, VTK-m, Ascent, ADIOS, Yt, and Python) via a runtime XML configuration.

    Its architecture consists of three main components:

    1. Data Adaptors: Present simulation data in the SENSEI data model.
    2. Analysis Adaptors: Present back-end data consumers to the simulation.
    3. Bridge Code: Manages adaptors and periodically pushes data through the system.

    Users can switch between different back ends (like Catalyst or Libsim) by simply changing the XML configuration file without modifying the simulation source code.

  11. How Electrostatic AMR works in WarpX

    development

    WarpX uses a recursive approach for mesh refinement in electrostatic solvers to ensure that the field solution at a given level $L_n$ is not affected by solutions at finer levels $L_{n+1}$ and up. This design prevents long-range errors that violate Gauss' Law.

    Implementation Workflow

    1. Charge Deposition: Macroparticle charges are deposited onto the highest level patch that contains them.
    2. Recursive Deposition: The charge density of each patch is then added recursively to lower (coarser) levels, down to the base level $L_0$.
    3. Potential Calculation:
      • The electric potential is first calculated at the coarsest level $L_0$.
      • The solution is interpolated onto the boundaries of the refined patch at the next level $L_1$.
      • The potential is then computed at $L_1$ by solving the Poisson equation.
      • This process repeats iteratively for each subsequent refinement level.

    This hierarchical approach ensures that the coarse grid solution remains independent of the fine grid details, which is key to minimizing spurious effects at the interface.