def get_stabilized_reciprocal_mesh(mesh, rotations, is_shift=np.zeros(3, dtype='intc'), is_time_reversal=True, qpoints=np.array([], dtype='double')): """ Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. is_shift=[0, 0, 0] gives Gamma center mesh and the values 1 give half mesh distance shifts. """ mapping = np.zeros(np.prod(mesh), dtype='intc') mesh_points = np.zeros((np.prod(mesh), 3), dtype='intc') qpoints = np.array(qpoints, dtype='double', order='C') if qpoints.shape == (3, ): qpoints = np.array([qpoints], dtype='double', order='C') if qpoints.shape == (0, ): qpoints = np.array([[0, 0, 0]], dtype='double', order='C') spg.stabilized_reciprocal_mesh( mesh_points, mapping, np.array(mesh, dtype='intc'), np.array(is_shift, dtype='intc'), is_time_reversal * 1, np.array(rotations, dtype='intc', order='C'), qpoints) return mapping, mesh_points
def get_stabilized_reciprocal_mesh(mesh, rotations, is_shift=np.zeros(3, dtype='intc'), is_time_reversal=True, qpoints=np.array([], dtype='double')): """ Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. is_shift=[0, 0, 0] gives Gamma center mesh and the values 1 give half mesh distance shifts. """ mapping = np.zeros(np.prod(mesh), dtype='intc') mesh_points = np.zeros((np.prod(mesh), 3), dtype='intc') qpoints = np.array(qpoints, dtype='double', order='C') if qpoints.shape == (3,): qpoints = np.array([qpoints], dtype='double', order='C') if qpoints.shape == (0,): qpoints = np.array([[0, 0, 0]], dtype='double', order='C') spg.stabilized_reciprocal_mesh( mesh_points, mapping, np.array(mesh, dtype='intc'), np.array(is_shift, dtype='intc'), is_time_reversal * 1, np.array(rotations, dtype='intc', order='C'), qpoints) return mapping, mesh_points
def get_mappings(mesh, rotations, is_shift=np.zeros(3, dtype='intc'), is_time_reversal=True, qpoints=np.double([])): """ Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. is_shift=[0, 0, 0] gives Gamma center mesh and the values 1 give half mesh distance shifts. """ mapping = np.zeros(np.prod(mesh), dtype='intc') rot_mapping = np.zeros(np.prod(mesh), dtype="intc") mesh_points = np.zeros((np.prod(mesh), 3), dtype='intc') qpoints = np.double(qpoints).copy() if qpoints.shape == (3,): qpoints = np.double([qpoints]) spg.stabilized_reciprocal_mesh(mesh_points, mapping, rot_mapping, np.intc(mesh).copy(), np.intc(is_shift), is_time_reversal * 1, np.intc(rotations).copy(), np.double(qpoints)) return mapping, rot_mapping
def get_mappings(mesh, rotations, is_shift=np.zeros(3, dtype='intc'), is_time_reversal=True, qpoints=np.double([])): """ Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. is_shift=[0, 0, 0] gives Gamma center mesh and the values 1 give half mesh distance shifts. """ mapping = np.zeros(np.prod(mesh), dtype='intc') rot_mapping = np.zeros(np.prod(mesh), dtype="intc") mesh_points = np.zeros((np.prod(mesh), 3), dtype='intc') qpoints = np.double(qpoints).copy() if qpoints.shape == (3, ): qpoints = np.double([qpoints]) spg.stabilized_reciprocal_mesh(mesh_points, mapping, rot_mapping, np.intc(mesh).copy(), np.intc(is_shift), is_time_reversal * 1, np.intc(rotations).copy(), np.double(qpoints)) return mapping, rot_mapping
def get_stabilized_reciprocal_mesh( mesh, lattice, rotations, is_shift=np.zeros(3, dtype=int), is_time_reversal=True, qpoints=np.array([], dtype=float), symprec=1e-5 ): """ Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. The convention of 'lattice' is: [[ a_x, a_y, a_z ], [ b_x, b_y, b_z ], [ c_x, c_y, c_z ]] (ASE convention) Since it has to be passed to the C extention in the following format: [[ a_x, b_x, c_x ], [ a_y, b_y, c_y ], [ a_z, b_z, c_z ]] (spglib convention) Therefore in this method, lattice is transposed. is_shift=[ 0, 0, 0 ] gives Gamma center mesh and the values 1 give half mesh distance shifts. """ mapping = np.zeros(np.prod(mesh), dtype=int) mesh_points = np.zeros((np.prod(mesh), 3), dtype=int) qpoints = np.array(qpoints, dtype=float) if qpoints.shape == (3,): qpoints = np.array([qpoints]) spg.stabilized_reciprocal_mesh( mesh_points, mapping, np.array( mesh, dtype=int ), np.array( is_shift, dtype=int ), is_time_reversal * 1, lattice.T.copy(), rotations.copy(), np.array( qpoints, dtype=float), symprec ) return mapping, mesh_points
def get_stabilized_reciprocal_mesh(mesh, rotations, is_shift=None, is_time_reversal=True, qpoints=None): """Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. Args: mesh: int array (3,): Uniform sampling mesh numbers is_shift: int array (3,): [0, 0, 0] gives Gamma center mesh and value 1 gives half mesh shift. is_time_reversal: bool: Time reversal symmetry is included or not. qpoints: float array (N ,3) or (3,): Stabilizer(s) in the fractional coordinates. Return: mapping_table: int array (N,): Grid point mapping table to ir-gird-points grid_address: int array (N, 3): Address of all grid points """ _set_no_error() mapping_table = np.zeros(np.prod(mesh), dtype='intc') grid_address = np.zeros((np.prod(mesh), 3), dtype='intc') if is_shift is None: is_shift = [0, 0, 0] if qpoints is None: qpoints = np.array([[0, 0, 0]], dtype='double', order='C') else: qpoints = np.array(qpoints, dtype='double', order='C') if qpoints.shape == (3,): qpoints = np.array([qpoints], dtype='double', order='C') if spg.stabilized_reciprocal_mesh( grid_address, mapping_table, np.array(mesh, dtype='intc'), np.array(is_shift, dtype='intc'), is_time_reversal * 1, np.array(rotations, dtype='intc', order='C'), qpoints) > 0: return mapping_table, grid_address else: return None
def get_stabilized_reciprocal_mesh(mesh, rotations, is_shift=None, is_time_reversal=True, qpoints=None): """Return k-point map to the irreducible k-points and k-point grid points . The symmetry is searched from the input rotation matrices in real space. Args: mesh: int array (3,): Uniform sampling mesh numbers is_shift: int array (3,): [0, 0, 0] gives Gamma center mesh and value 1 gives half mesh shift. is_time_reversal: bool: Time reversal symmetry is included or not. qpoints: float array (N ,3) or (3,): Stabilizer(s) in the fractional coordinates. Returns: mapping_table: int array (N,): Grid point mapping table to ir-gird-points grid_address: int array (N, 3): Address of all grid points """ _set_no_error() mapping_table = np.zeros(np.prod(mesh), dtype='intc') grid_address = np.zeros((np.prod(mesh), 3), dtype='intc') if is_shift is None: is_shift = [0, 0, 0] if qpoints is None: qpoints = np.array([[0, 0, 0]], dtype='double', order='C') else: qpoints = np.array(qpoints, dtype='double', order='C') if qpoints.shape == (3,): qpoints = np.array([qpoints], dtype='double', order='C') if spg.stabilized_reciprocal_mesh( grid_address, mapping_table, np.array(mesh, dtype='intc'), np.array(is_shift, dtype='intc'), is_time_reversal * 1, np.array(rotations, dtype='intc', order='C'), qpoints) > 0: return mapping_table, grid_address else: return None
def get_stabilized_reciprocal_mesh(mesh, rotations, is_shift=None, is_time_reversal=True, qpoints=None, is_dense=False): """Return k-point map to the irreducible k-points and k-point grid points. The symmetry is searched from the input rotation matrices in real space. Parameters ---------- mesh : array_like Uniform sampling mesh numbers. dtype='intc', shape=(3,) rotations : array_like Rotation matrices with respect to real space basis vectors. dtype='intc', shape=(rotations, 3) is_shift : array_like [0, 0, 0] gives Gamma center mesh and value 1 gives half mesh shift. dtype='intc', shape=(3,) is_time_reversal : bool Time reversal symmetry is included or not. qpoints : array_like q-points used as stabilizer(s) given in reciprocal space with respect to reciprocal basis vectors. dtype='double', shape=(qpoints ,3) or (3,) is_dense : bool, optional grid_mapping_table is returned with dtype='uintp' if True. Otherwise its dtype='intc'. Default is False. Returns ------- grid_mapping_table : ndarray Grid point mapping table to ir-gird-points. dtype='intc', shape=(prod(mesh),) grid_address : ndarray Address of all grid points. Each address is given by three unsigned integers. dtype='intc', shape=(prod(mesh), 3) """ _set_no_error() if is_dense: dtype = 'uintp' else: dtype = 'intc' mapping_table = np.zeros(np.prod(mesh), dtype=dtype) grid_address = np.zeros((np.prod(mesh), 3), dtype='intc') if is_shift is None: is_shift = [0, 0, 0] if qpoints is None: qpoints = np.array([[0, 0, 0]], dtype='double', order='C') else: qpoints = np.array(qpoints, dtype='double', order='C') if qpoints.shape == (3, ): qpoints = np.array([qpoints], dtype='double', order='C') if spg.stabilized_reciprocal_mesh( grid_address, mapping_table, np.array(mesh, dtype='intc'), np.array(is_shift, dtype='intc'), is_time_reversal * 1, np.array(rotations, dtype='intc', order='C'), qpoints) > 0: return mapping_table, grid_address else: return None