[−][src]Function bader::methods::ongrid
pub fn ongrid(
p: usize,
density: &Density<'_>,
weight_map: WeightMap
) -> (isize, Vec<(usize, f64)>)
Finds the maxima associated with the current point, p.
p
: The point from which to step.density
: The referenceDensity
.weight_map
: AnArc
wrappedVoxelMap
for tracking the maxima.
Returns:
(isize, Vec::with_capacity(0))
: The point current point's maxima and it's
weights. As this is not the weight method there are no weights.
Examples
use bader::density::Density; use bader::atoms::Lattice; use bader::voxel_map::VoxelMap; use bader::methods::ongrid; use std::sync::Arc; // Intialise the reference density. let data = (0..64).map(|rho| rho as f64).collect::<Vec<f64>>(); let lattice = Lattice::new([[3., 0., 0.], [0., 3., 0.], [0., 0., 3.]]); let density = Density::new(&data, [4, 4, 4], lattice.to_cartesian, 1E-8, None, [0., 0., 0.]); let voxel_map = VoxelMap::new(64); let voxel_map = Arc::new(voxel_map); // The highest gradient between point, p = 33, and it's neighbours, with // periodic boundary conditions, is with point p = 61 however as this hasn't // been stored so this would block. // assert_eq!(ongrid(33, &density, Arc::clone(&voxel_map)).0, -1); // after stroing the maxima for the point, p = 61, ongrid will now return // this value. voxel_map.maxima_store(61, 63); assert_eq!(ongrid(33, &density, Arc::clone(&voxel_map)).0, 63)