Skip to content

Add Plasma Histogram Diagnostic#1357

Open
AlexanderSinn wants to merge 23 commits into
Hi-PACE:developmentfrom
AlexanderSinn:Add_Plasma_Histogram_Diagnostic
Open

Add Plasma Histogram Diagnostic#1357
AlexanderSinn wants to merge 23 commits into
Hi-PACE:developmentfrom
AlexanderSinn:Add_Plasma_Histogram_Diagnostic

Conversation

@AlexanderSinn
Copy link
Copy Markdown
Member

@AlexanderSinn AlexanderSinn commented Feb 10, 2026

This PR adds a histogram diagnostic type that allows the creation of arbitrary 1D and 2D histograms of beam and plasma species.

Documentation:

This diagnostic allows the direct computation of histograms of arbitrary particle
quantities during the simulation runtime. It supports both plasma and beam particles.
It is part of the standard field diagnostic and is enabled by setting
<diag name>.base_geometry = histogram. Histograms may have one or two user-defined axes.
Optionally, the simulation z-axis can be included as an additional axis or integrated over.
All field diagnostic parameters apply, except field_data and diag_type.
For example, patch_lo and patch_hi can be used to restrict the particles included in
the histogram in coordinate space, but do not modify the histogram axes.
Each particle species produces a separate histogram that is output as
<species name>_<diag name>. No unit conversion or normalization by cell volume is applied.
Particles outside the histogram bounds are discarded.

  • <diag name>.hist_species_names (string)
    List of species to include. Can be beam and/or plasma species.

  • <diag name>.hist_num_bins (int or 2 int)
    Number of bins per histogram axis.

  • <diag name>.hist_bins_lo (flaot or 2 flaot)
    Lower bound of each histogram axis.

  • <diag name>.hist_bins_hi (flaot or 2 flaot)
    Upper bound of each histogram axis.

  • <diag name>.hist_function (string)
    Parser expression defining the first histogram axis as a function of particle properties:
    x, y, z, ux, uy, uz, ga_psi, w, ion_lev.
    Here, ga_psi is the quasi-static weighting factor for plasma particles,
    ion_lev is the ionization level (for ionizable species), and w is the
    macro-particle weight.

  • <diag name>.hist_function2 (string) optional
    Parser expression defining the second histogram axis. Uses the same variables as
    <diag name>.hist_function.

  • <diag name>.hist_weight (string) optional (default w)
    Parser expression defining the weight contributed by each particle to the histogram.
    For plasma particles, this weight is automatically multiplied by ga_psi
    to obtain the physical particle weight. Uses the same variables as
    <diag name>.hist_function. This can also be used to filter particles.

  • <diag name>.hist_add_z_axis (bool) optional (default false)
    Add the zeta axis from the simulation to the histogram output.
    This is more efficient than adding z as a custom histogram axis using
    hist_function or hist_function2. If disabled the histogram contains data from
    all z slices in the range given by patch_lo and patch_hi.

Example:

diagnostic.names = lev0 hist_uz hist_x_ux

hist_uz.base_geometry = histogram
hist_uz.hist_species_names = beam
hist_uz.hist_num_bins = 500
hist_uz.hist_bins_lo = 1980
hist_uz.hist_bins_hi = 2020
hist_uz.hist_function = "uz"
hist_uz.hist_add_z_axis= true

hist_x_ux.base_geometry = histogram
hist_x_ux.hist_species_names = beam
hist_x_ux.hist_num_bins = 500 500
hist_x_ux.hist_bins_lo = -2 -10
hist_x_ux.hist_bins_hi =  2  10
hist_x_ux.hist_function = "x"
hist_x_ux.hist_function2 = "ux"
image
  • Small enough (< few 100s of lines), otherwise it should probably be split into smaller PRs
  • Tested (describe the tests in the PR description)
  • Runs on GPU (basic: the code compiles and run well with the new module)
  • Contains an automated test (checksum and/or comparison with theory)
  • Documented: all elements (classes and their members, functions, namespaces, etc.) are documented
  • Constified (All that can be const is const)
  • Code is clean (no unwanted comments, )
  • Style and code conventions are respected at the bottom of https://github.com/Hi-PACE/hipace
  • Proper label and GitHub project, if applicable

@AlexanderSinn AlexanderSinn changed the title [WIP] Add Plasma Histogram Diagnostic Add Plasma Histogram Diagnostic Apr 27, 2026
@AlexanderSinn AlexanderSinn added component: plasma About the plasma species component: beam About the beam species component: diagnostics About any types of diagnostics labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: beam About the beam species component: diagnostics About any types of diagnostics component: plasma About the plasma species

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant