-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathan_utils.py
52 lines (36 loc) · 1.5 KB
/
an_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import numpy as np
def to_massweight_coor(movement_vector, atoms, indices=None):
"""Transform a movement_vector from xyz coordinates to mass
weighted coordinates.
Args:
movement_vector (numpy array): vector with coordinates of all
elements or specific elements.
atoms (ase object): ase atoms object
indices[optional] (list): list of atomic indices that
movement_vector describes.
Returns:
The mass weighted coordinates of the input
"""
if indices is None:
assert len(movement_vector) == 3*len(atoms), \
'Unexpected length of movement_vector'
indices = range(len(movement_vector)//3)
m = atoms.get_masses()[indices]
return movement_vector*np.repeat(m**0.5, 3)
def to_none_massweight_coor(movement_vector, atoms, indices=None):
"""Transform a mass weighted movement_vector to normal xyz coordinates.
Args:
movement_vector (numpy array): vector with coordinates of all
elements or specific elements.
atoms (ase object): ase atoms object
indices[optional] (list): list of atomic indices that
movement_vector describes.
Returns:
Movement_vector in normal xyz coordinates
"""
if indices is None:
assert len(movement_vector) == 3*len(atoms), \
'Unexpected length of movement_vector'
indices = range(len(movement_vector)//3)
m = atoms.get_masses()[indices]
return np.repeat(m**(-0.5), 3)*movement_vector