amep.continuum.hde#
- amep.continuum.hde(coords: ndarray, box_boundary: ndarray, weights: ndarray | None = None, delta: float = 1.0, shift: float = 0.5, pbc: bool = False) tuple[ndarray, ndarray, ndarray] #
Histogram Density Estimation (HDE).
Calculates the density estimate for a given set of particle coordinates in a simulation box based on a 2D histogram of the particle positions.
Notes
This method is only applicable to 2D systems. For a 3D system, only the x-y plane is considered.
- Parameters:
coords (np.ndarray) – Coordinate frame of shape (N,3), which gives the positions of the particles. The third component is disregarded.
box_boundary (np.ndarray of shape (3,2)) – Boundary of the simulation box in the form of np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]]).
weights (np.ndarray|None, optional) – Weighting factors for each particle as array of shape (N,). The default is None.
delta (float, optional) – Bin width for the histogram bins (same for each spatial direction). The default is 1.0.
shift (float, optional) – Fraction of delta by which the most left bin edges are shifted. The default is 0.5.
pbc (bool, optional) – If True, periodic images are considered. The default is False.
- Returns:
hist (np.ndarray) – Coarse-grained density field as a two-dimensional array.
X (np.ndarray) – X-components of the grid points as two-dimensional meshgrid.
Y (np.ndarray) – Y-components of the grid points as two-dimensional meshgrid.
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> frame = traj[-1] >>> ld = amep.order.local_number_density( ... frame.coords(), frame.box, frame.radius() ... ) >>> dfield, X, Y = amep.continuum.hde( ... frame.coords(), frame.box, ... weights=ld, delta=2.0, pbc=True ... ) >>> fig, axs = amep.plot.new(figsize=(3.6,3)) >>> mp = amep.plot.field( ... axs, dfield, X, Y ... ) >>> cax = amep.plot.add_colorbar( ... fig, axs, mp, label=r"$\rho_{\rm loc}$" ... ) >>> axs.set_xlabel(r'$x$') >>> axs.set_ylabel(r'$y$') >>> fig.savefig('./figures/continuum/continuum-hde.png')