def find_primitive(cell, symprec=1e-5, angle_tolerance=-1.0): """Primitive cell is searched in the input cell. The primitive cell is returned by a tuple of (lattice, positions, numbers). If it fails, None is returned. """ _set_no_error() lattice, positions, numbers, _ = _expand_cell(cell) if lattice is None: return None num_atom_prim = spg.primitive(lattice, positions, numbers, symprec, angle_tolerance) _set_error_message() if num_atom_prim > 0: return (np.array(lattice.T, dtype='double', order='C'), np.array(positions[:num_atom_prim], dtype='double', order='C'), np.array(numbers[:num_atom_prim], dtype='intc')) else: return None
def find_primitive(cell, symprec=1e-5, angle_tolerance=-1.0): """ A primitive cell in the input cell is searched and returned as an object of Atoms class. If no primitive cell is found, (None, None, None) is returned. """ lattice, positions, numbers, _ = _expand_cell(cell) num_atom_prim = spg.primitive(lattice, positions, numbers, symprec, angle_tolerance) if num_atom_prim > 0: return (np.array(lattice.T, dtype='double', order='C'), np.array(positions[:num_atom_prim], dtype='double', order='C'), np.array(numbers[:num_atom_prim], dtype='intc')) else: return None, None, None
def find_primitive(bulk, symprec=1e-5): """ A primitive cell in the input cell is searched and returned as an object of Atoms class. If no primitive cell is found, ( None, None, None ) is returned. """ # Atomic positions have to be specified by scaled positions for spglib. positions = bulk.get_scaled_positions().copy() lattice = bulk.get_cell().T.copy() numbers = bulk.get_atomic_numbers() # lattice is transposed with respect to the definition of Atoms class num_atom_prim = spg.primitive(lattice, positions, numbers, symprec) if num_atom_prim > 0: return lattice.T, positions[:num_atom_prim], numbers[:num_atom_prim] else: return None, None, None
def find_primitive(bulk, symprec=1e-5, angle_tolerance=-1.0): """ A primitive cell in the input cell is searched and returned as an object of Atoms class. If no primitive cell is found, (None, None, None) is returned. """ # Atomic positions have to be specified by scaled positions for spglib. positions = bulk.get_scaled_positions().copy() lattice = bulk.get_cell().T.copy() numbers = np.intc(bulk.get_atomic_numbers()).copy() # lattice is transposed with respect to the definition of Atoms class num_atom_prim = spg.primitive(lattice, positions, numbers, symprec, angle_tolerance) if num_atom_prim > 0: return (lattice.T.copy(), positions[:num_atom_prim].copy(), numbers[:num_atom_prim].copy()) else: return None, None, None
def find_primitive(bulk, symprec=1e-5, angle_tolerance=-1.0): """ A primitive cell in the input cell is searched and returned as an object of Atoms class. If no primitive cell is found, (None, None, None) is returned. """ # Atomic positions have to be specified by scaled positions for spglib. positions = np.array(bulk.get_scaled_positions(), dtype='double', order='C') lattice = np.array(bulk.get_cell().T, dtype='double', order='C') numbers = np.array(bulk.get_atomic_numbers(), dtype='intc') # lattice is transposed with respect to the definition of Atoms class num_atom_prim = spg.primitive(lattice, positions, numbers, symprec, angle_tolerance) if num_atom_prim > 0: return (np.array(lattice.T, dtype='double', order='C'), np.array(positions[:num_atom_prim], dtype='double', order='C'), np.array(numbers[:num_atom_prim], dtype='intc')) else: return None, None, None