crystal_lattice_stable19072026
esta.vaspBag.inout.crystal_lattice_stable19072026
¶
CrystalLattice
¶
Crystal lattice class to define lattice parameters and basis; crystal = lattice + basis (atoms or molecules )
Author: Sonu Kumar Email: sonukumar.physics@gmail.com
to_cartesian
property
¶
get atomic position in cartesin cooridnates
to_crystal
property
¶
get atomic position in crystal cooridnates
is_crystal
property
¶
check if atom positions in crytal coordinates
is_cartesian
property
¶
check if atom positions in cartesian coordinates
get_rVolume
property
¶
get real space lattice volume
get_volume
property
¶
get real space lattice volume
get_cell_vectors
property
¶
geta tuple of set of three cell/lattice vectors lv1, lv2, and lv3 in c-style format
get_cell_matrix
property
¶
get lattice matrix of three cell/lattice vectors lv1, lv2, and lv3 in c-style format or fortran stype format default is c style format.
cell_matrixx
property
¶
get lattice matrix of three cell/lattice vectors lv1, lv2, and lv3 in c-style format or fortran stype format default is c style format.
get_atm_type
property
¶
get symbolic representation of atoms of each type in the form of list
get_natm_type
property
¶
get no. of atoms of each type in a list format
get_each_atm_type
property
¶
get same integer for atoms of same type
is_selective_dynamics
property
¶
check whether selective dynamics True or False
get_cell_angle
property
¶
Calculates the alpha, beta, and gamma angles (in degrees) of a cell matrix. Assumes rows are the lattice vectors a, b, and c.
get_atm_symbol
property
¶
by reading POSCAR, find the atomic labels of the atoms
read_poscar_adv(verbosity=None)
¶
read poscar file present in the current dir or in the location specified.
parameters crysatal lattice object
return if l_SelectDynamics: return self.tau_cartesian, self.real_volume, self.LV1, self.LV2, self.LV3,self.atm_type, self.natm_type, self.natm, self.atomFix, self.atomMove, self.atomFixDir else: return self.tau_cartesian, self.real_volume, self.LV1, self.LV2, self.LV3,self.atm_type, self.natm_type, self.natm
read_poscar(verbosity=None)
¶
read poscar file present in the current dir or in the location specified.
parameters crysatal lattice object
return if l_SelectDynamics: return self.tau_cartesian, self.real_volume, self.LV1, self.LV2, self.LV3,self.atm_type, self.natm_type, self.natoms, self.atomFix, self.atomMove else: return self.tau_cartesian, self.real_volume, self.LV1, self.LV2, self.LV3,self.atm_type, self.natm_type, self.natoms
set_atm_position(new_positions)
¶
Safely updates the atomic positions array.
set_cell_matrix(new_matrix)
¶
Safely updates the 3x3 lattice/cell matrix.
set_atm_symbol(new_symbol)
¶
Safely updates the list of atomic chemical symbols.
set_atm_fix_dir(indices, direction=None)
¶
Parametes
indices: integers with numbering from 0 ==> atm_fix, atom_move have numbering from 0 direction: list of boolen. set atom indices as fixed (T T T vs F F F in the POSCAR file). direction is list of boolen each of len3, e.g. [[False, False, True], [..]]
Returns:
-
resetted values of self.atm_fix, self.atm_move, and self.atm_fix_dir for selective dynamics–
apply_basis_rotation_(M)
¶
Apply any 3x3 transformation matrix to the cell and atomic positions. Apply any 3x3 transformation matrix to the cell and atomic positions.
Generally the M is given row wise* in python world
_note::
M's transpose in general for passive transformation of pand p column vectors: p = M.t * p
M transpose bcz M = [[vector a ..], [vector b ..], [vector c .. as row]] ---> so M.t is needed
as needed by the Linear Alzebra transformation
from spglib: \mathbf{x} = (\mathbf{a}, \mathbf{b}, \mathbf{c}) oldsymbol{x}.
( \mathbf{a}_\mathrm{p} \; \mathbf{b}_\mathrm{p} \; \mathbf{c}_\mathrm{p} )
= ( \mathbf{a}_\mathrm{s} \; \mathbf{b}_\mathrm{s} \;
\mathbf{c}_\mathrm{s} ) oldsymbol{P}_\mathrm{c},
Below is from AI: may be wrong!!
if M and cell_matrix are column major
Transform Cell Vectors(Swap \(a,b,c o c,a,b\)) np.dot(M, cell_matrix) \(M\) acts on the columns of cell_matrix from the left, shuffling the vectors.
Transform Fractional Atoms np.dot(np.linalg.inv(M), atom_coord) Coordinates change by the inverse (If single atom is a column [3, 1]) transformation to keep the physical position invariant.
If both row major:
np.dot(cell_matrix, M.T) Multiplying by $M^T$ on the right acts on the rows of
cell_matrix, swapping vector positions
(Array of atoms [N, 3]) np.dot(direct_coords, M) ..
apply_basis_rotation(M)
¶
Apply any 3x3 transformation matrix to the cell and atomic positions. Assumes M and cell_matrix are in Row-Major format, and atm_position is a numpy array of shape (N, 3).
get_poscar()
¶
XXXXXXXXXXXXXXXXXXXXXXXXXX---DEPRECATED-------DEPRECATED ------------------XXXXXXXXXXXXXXXXXXXXXX ** get_poscar is deprecated; use read_poscar instead!! ** read poscar file present in the current dir or in the location specified.
get_reciprocal_lattice()
¶
return the reciprocal lattice vectors
input: real space lattice vectors: LV1, LV2, LV3
output: reciprocal space lattice vectors: b1, b2, b3
- note: a factor of 2pi is included in b1, b2, and b3
reciprocal_lattice()
¶
deprecated: method to calculate the reciprocal lattice vectors
get_all_atoms_labels()
¶
by reading POSCAR, find the atomic labels of the atoms and total no of atoms
Parameters:
string: POSCAR file in current dir.
Return:
list : strings of atomic lebels of all atoms according to the numbering of atoms in POSCAR file
scalar: total number of atoms in the POSCAR file
list: integer numbers starting from 1 to ntotal for all atoms(e.g. 1 1 1 2 3 4 4 ..)
author: sk email: sonukumar.physics@gmail.com
__each_atm_type()
¶
by reading POSCAR, label each atoms of same type with same integer
parameters
input: POSCAR file in current dir. poscar file
Returns:
-
list(list of integer numbers starting from 1 to ntotal for all atoms(e.g. 1 1 1 2 3 4 4 ..)) –
get_unique_list(inp)
¶
get unique elements of list
return: string for each type of atoms
get_grouped_list(llist)
¶
get same string elements of list grouped together
get_neach_type(inp)
¶
get number of list entries of each type
return:
list of integers for each type of atoms specifying their number
write_poscar_(latt_obj, name_outfile: str = None, extension: str = None, ldirect=False)
¶
create POSCAR file given the cell_parameters, atomic postions, and atom labels. Optionally the name of output POSCAR can be provided. When dealing with mutliple POSCAR file, better to provide the name of the output POSCAR file.
Parameters:
-
latt_obj– -
name_outfile(str, default:None) –name of the output POSCAR file
-
extension(str, default:None) –
Returns:
-
generates POSCAR file with name = name_outfile.extension–
write_poscar(latt_obj, name_outfile: str = None, extension: str = None, ldirect=False)
¶
create POSCAR file given the cell_parameters, atomic postions, and atom labels. Optionally the name of output POSCAR can be provided. When dealing with mutliple POSCAR file, better to provide the name of the output POSCAR file.
Parameters:
-
latt_obj– -
name_outfile(str, default:None) –name of the output POSCAR file
-
extension(str, default:None) –
Returns:
-
writes POSCAR file with name = name_outfile.extension–
get_selectivePOSCAR(ldisp=True, disp_atoms_num=None, outfile=None)
¶
get displaced poscar with selective tag and atomic positions tagged by T T T or F F F
Parameters:
-
ldisp–whether fix atoms or not
-
disp_atoms_num–list of atoms indices as strings; e.g: ["1-2", '3']
-
outfile–output file name
Returns:
-
POSCAR file with selective dynamics tags–
get_selectivePOSCAR_adv(ldisp=True, disp_atoms_num=None, fix_direction=None, coord='cartesian', outfile=None)
¶
get displaced poscar with selective tag and atomic positions tagged by T T T or F F F
Parameters:
-
ldisp–whether fix atoms or not
-
disp_atoms_num–list of atoms indices as strings to be fixed during DFT relaxation; e.g: ["1-2", '3']
-
fix_direction–x, y, or z direciton; by default atoms are fixed in all directions
-
coord–cartesian or direct coordinates; default: cartesian
-
outfile–output file name
Returns:
-
POSCAR file with selective dynamics tags–
get_dispPOSCAR(ldisp=None, disp_atoms_num=None)
¶
deprecated: use get_selectivePOSCAR