Density sampling¶
“Density” here covers how many of a given atom structure or bond structure are present, either over time or as a function of position in the box. add_density_sampling counts atoms; its sibling add_bond_density_sampling counts bonds using the same dimensions, direction options, and output layout - this page documents the shared machinery once, and the bond variant page only calls out what’s different.
sampler.add_density_sampling(
name_out="density_water_z",
atoms=[{"atom": "O", "bonds": ["H", "H"]}],
dimension="Cartesian1D",
region="Box",
num_bins=200,
direction="z",
)
sampler.add_bond_density_sampling(
name_out="density_OH_z",
bonds=[{"bond": "O-H", "bonds_A": ["H"]}],
dimension="Time",
)
Dimensions¶
dimension selects what is being histogrammed:
|
What it does |
|---|---|
|
Number of matching atoms per frame - a time series, not a histogram. |
|
1D positional histogram along one Cartesian axis of the simulation box. |
|
2D positional histogram over one Cartesian plane of the simulation box. |
|
Same as |
|
Same as |
direction then picks the axis/plane, depending on dimension (unused for "Time"):
|
|
|---|---|
|
|
|
|
|
|
|
|
num_bins sets the number of histogram bins (for both axis, in the 2D case); it is ignored for "Time".
Conditions¶
conditions further filters which atoms or bonds count, evaluated per frame in addition to region and the bonding-environment match:
"Charge":(min, max)tuple - only count atoms whose ReaxFF charge falls in this range."Angle":(min, max)tuple - only count atoms that have at least one angle (formed with any two of their bonded neighbours) falling in this range."Bond Length":(min, max)tuple in Ångstrom, filtering by the length of the bond
sampler.add_density_sampling(
name_out="density_protonated_O",
atoms=[{"atom": "O", "bonds": ["H"]}],
dimension="Time",
conditions={"Charge": (-0.9, -0.5)},
)
Output¶
For "Time", each identifier stores num_frames and densities (count per sampled frame). For the histogram dimensions, each identifier stores num_frames, hist (counts per frame, averaged), hist_std, and bin_edges (x_edges/y_edges for the 2D case) plus direction. Position histograms are not normalized to a physical density by the sampler itself - plot_data(..., density=True) converts a "Cartesian1D"/"Pore1D"/"Cartesian2D"/"Pore2D" histogram to particles per nm³.