From e8cd20d7606813e2cc17de9c18ac60e9b7de9256 Mon Sep 17 00:00:00 2001 From: robinzyb <38876805+robinzyb@users.noreply.github.com> Date: Thu, 11 Jan 2024 15:37:59 +0100 Subject: [PATCH] change constrain for pav in cp2kcube --- cp2kdata/cube/cube.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/cp2kdata/cube/cube.py b/cp2kdata/cube/cube.py index 67ab46e..d165f64 100644 --- a/cp2kdata/cube/cube.py +++ b/cp2kdata/cube/cube.py @@ -235,11 +235,7 @@ def copy(self): return deepcopy(self) def get_pav(self, axis='z', interpolate=False): - np.testing.assert_array_equal( - self.cell.get_cell_angles(), - np.array([90.0, 90.0, 90.0]), - err_msg="The cell is not orthorhombic, the pav can not be used!" - ) + # do the planar average along specific axis lengths = self.cell.get_cell_lengths() @@ -249,14 +245,35 @@ def get_pav(self, axis='z', interpolate=False): vals = self.cube_vals.mean(axis=(1, 2)) points = np.arange(0, grid_point[0])*gs_matrix[0][0] length = lengths[0] + + np.testing.assert_array_equal( + self.cell.get_cell_angles()[[1,2]], + np.array([90.0, 90.0]), + err_msg=f"The axis x is not perpendicular to yz plane, the pav can not be used!" + ) + elif axis == 'y': vals = self.cube_vals.mean(axis=(0, 2)) points = np.arange(0, grid_point[1])*gs_matrix[1][1] length = lengths[1] + + np.testing.assert_array_equal( + self.cell.get_cell_angles()[[0, 2]], + np.array([90.0, 90.0]), + err_msg=f"The axis y is not perpendicular to xz plane, the pav can not be used!" + ) + elif axis == 'z': vals = self.cube_vals.mean(axis=(0, 1)) points = np.arange(0, grid_point[2])*gs_matrix[2][2] length = lengths[2] + + np.testing.assert_array_equal( + self.cell.get_cell_angles()[[0,1]], + np.array([90.0, 90.0]), + err_msg=f"The axis z is not perpendicular to xy plane, the pav can not be used!" + ) + else: print("not such plane average style, the avaialble options are 'x', 'y', 'z'")