PyPIC3D uses TOML configuration files to define the simulation parameters.
PyPIC3D --config path/to/config.tomlThe output directory is simulation_parameters.output_dir (the current
working directory by default). PyPIC3D creates a data subdirectory there.
[simulation_parameters] is the input section for solver,
geometry, runtime, and physical-constant values.
[plotting] contains write parameters used during simulations
to write output data. Particle and external-field entries use numbered
sections such as [particle1] and [field1].
All sections contain built-in defaults. A particle section is needed for a PIC run, but field-only electrodynamic configurations are also supported.
This example uses one tile covering the complete grid and therefore needs only one JAX device:
[simulation_parameters]
name = "minimal"
output_dir = "./outputs"
solver = "electrodynamic_yee"
particle_pusher = "boris"
relativistic = true
Nx = 64
Ny = 1
Nz = 1
x_wind = 1.0
y_wind = 1.0
z_wind = 1.0
t_wind = 1.0e-8
cfl = 0.9
particle_tile_nx = 64
particle_tile_ny = 1
particle_tile_nz = 1
guard_cells = 2
particle_tile_capacity_factor = 1.25
particle_batch_size = 1250
shape_factor = 1
current_calculation = "j_from_rhov"
filter_j = "bilinear"
alpha = 1.0
x_bc = "periodic"
y_bc = "periodic"
z_bc = "periodic"
particle_x_bc = "periodic"
particle_y_bc = "periodic"
particle_z_bc = "periodic"
eps = 8.85418782e-12
mu = 1.25663706e-6
C = 2.99792458e8
kb = 1.380649e-23
[plotting]
plotting_interval = 10
plot_openpmd_particles = false
plot_openpmd_fields = false
plotvelocities = false
plotchargedensity = false
openpmd_field_queue_size = 2
openpmd_particle_queue_size = 2
dump_particles = false
dump_fields = false
[particle1]
name = "electrons"
N_particles = 5000
charge = -1.602e-19
mass = 9.1093837e-31
temperature = 1.0Nx,Ny, andNzare the physical cell counts.x_wind,y_wind, andz_windare the physical domain widths. The domain is centered on zero unless explicit bounds are given.x_min/x_max(and theyandzpairs) place the domain explicitly instead of centering it. The GR demos use this form.- If
dtis omitted, it is computed fromcfland the active grid spacing. - If
Ntis omitted, it is computed asint(t_wind / dt). - If
Ntis provided, it controls the number of iterations directly. - Tile widths default to the full physical grid, giving one tile. Multi-tile configuration and device requirements are described in :doc:`tiling`.
solveriselectrodynamic_yee,electrostatic,static_metric,dynamic_metric, ordark_matter_yee. See :doc:`solvers` for the update sequences, :doc:`dark_photon` for the dark sector, and :doc:`dynamical_relativity` for evolving geometry.metricselects the spacetime chart for the GR solvers:flat_cartesian(default),flat_cylindrical,flat_spherical,kerr_schild_cartesian,kerr_schild_spherical, ornumerical. The Kerr-Schild charts also readmetric_mass(default1.0) andmetric_spin(default0.0). See :doc:`dynamical_relativity`.particle_pusherisborisorhiguera_cary. Therelativisticswitch selects relativistic or non-relativistic Boris; Higuera-Cary uses its relativistic update.static_metricuseshybrid_boris_geodesicand the shared Hermite particle-metric reconstruction described in :doc:`solvers`. Its particle sampler requiresguard_cells >= 3(the default for this configuration).particle_batch_sizeis the positive, static number of active particles processed at once inside each tile. An explicit value is reduced to the tile slot capacity when necessary. If omitted, initialization uses every active particle for a one-tile run. For a multi-tile CPU run it targets 128 particles per scheduler-visible logical CPU thread assigned to each local mesh device, capped by the largest active tile population. Other accelerator backends use a conservative target of 1024 particles. The resolved value is printed before JIT compilation.shape_factoris1or2for particle shapes and electromagnetic field gathering. It does not select the particle-metric reconstruction.current_calculationisj_from_rhovoresirkepovfor the Yee solvers, orGR_direct_depositionoresirkepovforstatic_metric.esirkepovis charge conserving and preserves Gauss's law to round-off; see :doc:`chargeconservation`.filter_jisnone,digital, orbilinearfor direct current. The selected filter is applied to deposited current and to an evolved electric copy used for particle interpolation, including the initial backward half-kick. External fields and the magnetic gather are unfiltered. On the Yee solvers Esirkepov requiresfilter_j = "none". Thestatic_metricanddynamic_metricsolvers instead support a matched filter that is applied to the deposited current, the charge density, the gathered physical D/B and the particle metric with one common periodic stencil, so Esirkepov continuity is preserved; it requires a Cartesian metric and periodic field and particle boundaries. Because of those constraints both GR solvers defaultfilter_jtononerather than inheriting the Yee default, so matched filtering is opt-in.alphais the digital filter coefficient and belongs in a recognized simulation or dynamic parameter section.electrostatic_schwarz_tolis the maximum absolute Poisson residual in the interface-adjacent owned cells (default1e-6).electrostatic_schwarz_max_iterationscaps nearest-neighbor Schwarz iterations per electrostatic timestep (default500).electrostatic_local_cg_tolis the tile-local CG residual-norm tolerance (default1e-6).electrostatic_local_cg_max_iterationscaps CG iterations within each local tile solve (default500).
Field boundaries use x_bc, y_bc, and z_bc with values periodic
or conducting. Particle boundaries are global settings shared by all
species:
particle_x_bcparticle_y_bcparticle_z_bc
Their supported values are periodic, reflecting, and absorbing.
Coordinate-stretched PML is available only with electrodynamic_yee. Add one
entry for each absorbing wall:
[[pml]]
wall = "-x"
thickness = 8
order = 3.0
target_reflection = 1.0e-8
[[pml]]
wall = "+x"
thickness = 8
order = 3.0
sigma_max = 60.0wall is one of -x, +x, -y, +y, -z, or +z.
sigma_max can be supplied directly; otherwise it is derived from
target_reflection. A periodic field boundary on a PML-active axis is
changed to a non-wrapping conducting halo contract during initialization.
Use [fieldX] entries to load .npy arrays into field components:
[field1]
name = "prescribed_Bz"
type = 5
path = "inputs/Bz.npy"
evolve = falseThe component mapping is:
0,1,2:Ex,Ey,Ez3,4,5:Bx,By,Bz6,7,8:Jx,Jy,Jz
Arrays must have physical-interior shape (Nx, Ny, Nz). evolve = true
is the default and adds the array to the self-consistent field state.
evolve = false is available for electric and magnetic components only; it
keeps the prescribed field outside Maxwell evolution while including it in
particle pushes and energy diagnostics.
At plotting_interval cadence, the driver appends:
total_energy.txtenergy_error.txtelectric_field_energy.txtmagnetic_field_energy.txtkinetic_energy.txttotal_momentum.txt
dark_matter_yee additionally appends dark_field_energy.txt and prints a
Dark Field Energy line. dynamic_metric instead writes the constraint
norms hamiltonian_l2.txt and momentum_l2.txt; flat-space energy
conservation reports do not apply to a dynamical spacetime.
Set plot_openpmd_fields = true to write data/fields.h5 and
plot_openpmd_particles = true to write data/particles.h5. Writers copy
only addressable device shards and store their chunks at global offsets,
without assembling full field or particle arrays. Every run uses bounded
asynchronous queues, including when it spans several devices or processes.
openpmd_field_queue_size and openpmd_particle_queue_size limit pending
host snapshots, not the number of output files. A full queue waits for disk
writes; larger queues retain more host memory.
Field output contains E, B, and J. plotchargedensity = true
deposits the scalar charge-density mesh rho from the current particle
positions, and plotvelocities = true adds the particle-weighted vector mesh
fluid_velocity. dump_fields writes
data/initial_fields/initial_fields.h5, and dump_particles writes
data/initial_particles/<species>_initial_particles.h5 during initialization,
including runs with Nt = 0. Initial particle dumps retain the configured
positions and velocities before leapfrog seeding, with no diagnostic half-step
position shift. Initial histogram plots in single-process runs accumulate
50-bin counts from local shards and retain the existing image names and limits.
Final run parameters, species metadata, and timing statistics are written to
data/output.toml. These diagnostics are not complete restart checkpoints.
dark_matter_yee adds [dark_fieldN] blocks for the dark sector and the
sin_chi / dark_mu static parameters. It also overrides the ordinary
Courant condition with the Proca stability limit. See :doc:`dark_photon`.
dynamic_metric adds a [metric] table carrying the initial BSSN
geometry, the gauge controls and the six gravitational boundary codes, and it
forces C = eps = mu = 1 with double precision. See
:doc:`dynamical_relativity`.