Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

""" 

This module contains various support/utility functions. 

""" 

import numpy as np 

from ase.geometry import find_mic 

 

 

def get_wrapped_displacements(positions, ideal_positions, cell): 

"""Compute the smallest possible displacements from positions and 

ideal_positions given cell. 

 

Notes 

----- 

* uses `find_mic` from ASE 

* assumes `pbc=[True, True, True]`. 

 

Parameters 

---------- 

positions : array 

positions array 

ideal_positions : array 

ideal positions from which displacements are computed 

cell : array 

cell with shape (3,3) 

 

Returns 

------- 

array 

array with wrapped displacements 

""" 

 

displacements = [] 

for pos, ideal_pos in zip(positions, ideal_positions): 

v_ij = np.array([pos - ideal_pos]) 

displacements.append(find_mic(v_ij, cell, pbc=True)[0][0]) 

return np.array(displacements)