Do you know of a way to integrate density within a particular Miller (HKL) plane?
For an arbitrary crystal structure and an arbitrary Miller plane (e.g. 110), integrate the density across the polygon that's bounded within the unit cell.
Hi, @sgbaird I think will have to define a grid and a set of inequalities to create a mask for that grid then apply the mask and get the integrated charge.
I'm actually interested in this or similar functionality too. I'm wondering what a convenience method might look like:
def get_density_orientated_by_plane(self, hkl: Tuple[float, float, float]) -> np.ndarray:
"""
Converts charge density to conventional setting, rotates charge density to
align with chosen plane defined by its Miller indices, and returns a 3D
array that can be sliced and integrated as necessary.
"""
...
def get_density_through_sites(self, sites: Tuple[PeriodicSite, ...]) -> np.ndarray:
"""
Same as above, but calculates plane automatically based on provided sites.
Perhaps could return the slice (eg 2D array) automatically?
"""
I'm looking at this StackOverflow answer, does this seem reasonable?
Does pyrho already allow arbitrary rotations @jmmshn? I guess it could be done with the right supercell matrix?
Does
pyrhoalready allow arbitrary rotations @jmmshn? I guess it could be done with the right supercell matrix?
Correct.
I'm looking at this StackOverflow answer, does this seem reasonable?
I think it will be easier to get the reorientation information and boundaries in the transformed cell (without any consideration for the numpy volumetric data) then just use the internal machinery we already have for the interpolation.
I should probably mention that I implemented something similar in Mathematica using some nice analytical and numerical integration functions for 3D objects. See https://github.com/sgbaird/LatticePlane and https://doi.org/10.1107/S1600576722001492. I had explored doing this in Python with some geometry packages (scikit-geom or something like that), but had some trouble.
Cool, so this looks like you had an analytic form for your density so calculating it for a set of points directly is going to be much more accurate.
@jmmshn thanks! For the LatticePlane study, I approximated atoms as hard spheres, points, or isotropic Gaussian distributions based on CIF input data. While I mentioned applicability to DFT data, I never used DFT data directly. If I were to use LatticePlane, I'd consider doing a 3D (e.g. spline) interpolation of the points prior to numerical integration across the plane. Interpolation probably isn't necessary if densities are probeable at arbitrary locations without expensive, additional calculations.
On a separate note, @mkhorton what got you interested in density integration within a bounded plane?