manipulate_adv
esta.general.manipulate_adv
¶
class for the mainipulation of atoms present in xyz file (or poscar type data, just convert it to xyz data and create manipulate object)
Author: sonukumar email: sonukumar.physics@gmail.com
Manipulate
¶
Bases: object
class to mainipulate atoms present in xyz file or poscar type file
.. information:: - delete atoms from poscar or xyzfile ... done - change types by another type/type of atoms ..done - shift atoms about origin ..done - shift atoms alogn a general direction .. done - other possiblities .....like bending ..done see other location - inverstion or reflection .. check? .. done - reflection etc .. see some other place (see mirror*py file in script_general) .. done - merge two xyz data files in a given order (> 2 to be done) - split a xyz file in two parts .. done - reshuffle xyz atomic position .. done - substitute .. to add .. done separately ../why?? add here - nn of atoms .. to add .. do .........why?? add here.. done somwhere .. externalBag
.. note:: - there is shift.py file ... add shift class in this file and then - use it as a superclass for the manipulate_structure class ...TODO sk!!
__init__(atomic_positions, atomic_labels=None)
¶
self
replace(atm_index, symbol_index, ofile=None)
¶
replace atomic types (indicated by the atomic indices) by different atomic types
Parameters:
-
atm_index
(list of integers
) –atm_index is list of atomic numbering starting from 1
-
symbol_index
(list of strings of atomic symbols
) –list of atomic symbols in the final xyz file/poscar file
-
ofile
–prefix for the outfile xyz file
change_type(atm_index, symbol_index, ofile=None)
¶
replace atom types.
replace atom types of atom ids by symbols present in symbol_index list
Parameters:
-
atm_index
(list of integers
) –atm_index is list of atomic numbering starting from 1
-
symbol_index
(list of strings of atomic symbols
) –list of atomic symbols in the final xyz file/poscar file
returns:
ofile: str prefix for the outfile xyz file
.. example:: atm_index = [1,9,10] # replace atom index 1, 9 ,10 by elements of type symbol_index = ['I', 'B', 'B']
delete_atoms(delete_list)
¶
delete atoms from atomic positions array
Parameters
atomic_positions : array of rank 2 or 3 atomic positions in xyz file or poscar file delete_list : list list of atoms with atomic numbering from 1
l_reverse: boolean¶
delete atom list except in delete_list¶
Returns:
-
new_atomic_positions
(array of rank 2 or 3 depending upton input array
) –new atomic positions after deletion of some atoms
-
new_atomic_labels
(list
) –list of atomic symbols
delete(delete_list=None, delete_type=None, lreverse=False)
¶
a more general method to delete atoms using atoms types and atomic indices
Parameters
atomic_positions : array atomic positions in xyz file or poscar file delete_list : list list of atom ids to be deleted; e.g. ['1-10', '12']. atoms numbering from 1 delete_type : list list of atom types; eg.['B', 'O'] lreverse: logical (optional) logical variable to delete the opposite set of selected atoms
Returns:
-
new_atomic_positions
(array of rank 2 or 3 depending upton input array
) –new atomic positions after deletion of some atoms
-
new_atomic_labels
(list
) –list of atomic symbols
delete_atomic_strs(step=None)
¶
delete atomic strs/points along an arrangement of pts in an array of shape(n, nat, 3) by a step/stride (default=2). n is no. of atomic-sts/points of shape(nat,3), nat is the no. of atoms in each set.
extract_atomic_strs_(id_strs=None)
¶
extract atomic strs/points along an arrangement of pts in an array of shape(n, nat, 3) by specifying the list of atomic strs to be extracted. Here n is no. of atomic-sts/points of shape(nat,3), nat is the no. of atoms in each set.
.. note:: id_atm_strs must be a list; for example: id_atm_strs = [1,2,3,4,7,810,100,123,1932] for last strs: id_strs=['-1']
invert_atoms(target_index, reference_index, misc=None)
¶
invert atom from atomic positions (target arraay) array or from set of atomic positions in xyz PAth file (might be useful for stereo-chemical reactions)
Parameters:
-
target_index
–array of ints for indexing atoms to be inverted ; numbering starts from 1
-
reference_index
–1D array of intergers of atoms wrt which invertion has to be done
-
misc
–tag to do some miscellaneous transformation ... under testing ... here I am inverting the array by double the distance a normal inversion is done also, reference pt is moved along the inversion direction as well.
Returns:
-
pos_with_inv
(array
) –array of positions containing inverted atoms references by target_index is misc is True, then reference atoms is also shifted by inversion operation
-
.. note::
–for doing inversion of t array wrt r point: new t = t' = r - (t-r) = 2* r - t
for misc tag: following inversion and shifting of reference pt done (using vector algebra) new t = t' = -(t-r) + [ -(t-r) ] + r = 3* r - 2 *t
or new t = t' = r + (r-t) + (r-t)/2 = (5*r-3*t)/2 # added (r-t)/2 more distance vecttaking for now following .. or new t = t' = r + (r-t) + 2(r-t)/3 = (8*r-5*t)/3 # added 2(r-t)/3 more distance vect new ref pt, r' = -(t-r) + r = 2*r - t ----- right!! here earliet this pt was r
freeze_atoms(frozen_atm_indx)
¶
collect atoms in freeze atoms list by placing them in Frozen block from the xyz file
Parameters
frozen_atm_indx: list list of integers specifying the atom numbers to be fixed, numbering starts from 1 ... max of the no. of atoms
Returns:
-
pos_frozen and pos_not_frozen: tuple
–tuple containing pos_frozen, an array containing fixed atoms and pos_not_frozen, an arrary containing atoms not fixed
-
frozen_atm_indx and not_frozen_atm_indx: tuple
–frozen_atm_indx: list of integers specifying the atom numbers to be fixed and not_frozen_atm_indx: list of integers specifying the atom numbers not to be fixed.
-
.. note::
–Works only for rank 2 array of atomic position only. For rank 3 .. easy to implement!!
get_atm_indices_constraint(frozen_atm_indices=None, not_frozen_atm_indices=None)
¶
Parameters:
-
frozen_atm_indices
–a list of integers specifying the atom numbers to be fixed; Numbering from 0 ..
natoms: total number of atoms in the xyz file or poscar type file¶
-
not_frozen_atm_indices
–a list of integers for not fixed atoms
Returns:
-
frozen_atm_indices
(list of integers
) –integers for fixed atoms
-
not_frozen_atm_indices
(list of intergers
) –integers specifying the atoms numbers NOT to be fixed; Numbering from 0 ..
-
.. note::
–numbering of atoms must be from 1. And only frozen or not frozen atoms list must be given. Similary output is only integers for not frozen or frozen atoms and vice-versa. One at a time for parameters/returns.
centroid(array)
¶
find centroid from the shift.py
shift_to_origin(filename)
¶
shift to orgin from the shift.py
shift(filename, xshift, yshift, zshift)
¶
shift in general from the shift.py
substitute(iatoms_list, ilinkatom_id, flinkatom_id, xyzfile)
¶
substiture atoms present in iatom_list by atoms presnt in the xyzfile.
The initial str has a atom link id given by ilinkatom_id and this atom should be replaced by the atom given in the flinkatom_id along with atoms present in the xyzfile.
merge(pos2, atm_label2)
¶
merge two xyz files first file read after class initialization second xyz's pos2 and atmlabel2 are input to this method!!
On output, new pos and label are returned
split_xyz(filename, atom_list, l_alternate=None)
¶
split xyz file into two parts
Parameters:
-
filename
(str
) –name of the xyz file
-
atom_list
(array of strings () of atom indices)
) –atoms which are there in the new xyz file (order of atom indices can be any order) ; e.g: ["1-2", "30-49", "59-123"]
-
l_alternate
(logical
, default:None
) –whether to get alternate split file containing remaining atoms (not mentioned in the atom_list)
Returns:
-
xyz file/s containing part of the original xyz file data
–
reshuffle_xyz(filename, atom_list)
¶
reshuffle xyz file data and get a new xyz file data
Parameters:
-
filename
(str
) –name of the xyz file
-
atom_list
(strings of atom indices
) –atoms which are to be placed first in the xyz. The order of atom indices can be any order) ; e.g: ["1-2", "30-49", "59-123"]
return
xyz file with reshuffled atomic indices