Package lib :: Package alignment :: Module paramag_centre
[hide private]
[frames] | no frames]

Source Code for Module lib.alignment.paramag_centre

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2010-2011 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Module for functions relating to the paramagnetic centre.""" 
24   
25  # Python imports. 
26  from numpy.linalg import norm 
27   
28   
29 -def vectors_centre_per_state(atomic_pos, paramag_centre, unit_vector, r):
30 """Calculate the electron spin to nuclear spin unit vectors and distances. 31 32 This assumes that there is one paramagnetic centre per state of the system. 33 34 35 @param atomic_pos: The atomic positions in Angstrom. The first index is the spins, the second is the structures, and the third is the atomic coordinates. 36 @type atomic_pos: numpy rank-3 array 37 @param paramag_centre: The paramagnetic centre position in Angstrom. 38 @type paramag_centre: numpy rank-2, Nx3 array 39 @param unit_vector: The structure to fill with the electron spin to nuclear spin unit vectors. 40 @type unit_vector: numpy rank-3 array 41 @param r: The structure to fill with the electron spin to nuclear spin distances. 42 @type r: numpy rank-2 array 43 """ 44 45 # Loop over the spins. 46 for i in range(len(atomic_pos)): 47 # Loop over the states. 48 for c in range(len(atomic_pos[i])): 49 # The vector. 50 vect = atomic_pos[i, c] - paramag_centre[c] 51 52 # The length. 53 r[i, c] = norm(vect) 54 55 # The unit vector. 56 unit_vector[i, c] = vect / r[i, c] 57 58 # Convert the distances from Angstrom to meters. 59 r[i, c] = r[i, c] * 1e-10
60 61
62 -def vectors_single_centre(atomic_pos, paramag_centre, unit_vector, r):
63 """Calculate the electron spin to nuclear spin unit vectors and distances. 64 65 This assumes that there is only one paramagnetic centre for all states of the system. 66 67 68 @param atomic_pos: The atomic positions in Angstrom. The first index is the spins, the second is the structures, and the third is the atomic coordinates. 69 @type atomic_pos: numpy rank-3 array 70 @param paramag_centre: The paramagnetic centre position in Angstrom. 71 @type paramag_centre: numpy rank-1, 3D array 72 @param unit_vector: The structure to fill with the electron spin to nuclear spin unit vectors. 73 @type unit_vector: numpy rank-3 array 74 @param r: The structure to fill with the electron spin to nuclear spin distances. 75 @type r: numpy rank-2 array 76 """ 77 78 # Loop over the spins. 79 for i in range(len(atomic_pos)): 80 # Loop over the states. 81 for c in range(len(atomic_pos[i])): 82 # The vector. 83 vect = atomic_pos[i, c] - paramag_centre 84 85 # The length. 86 r[i, c] = norm(vect) 87 88 # The unit vector. 89 unit_vector[i, c] = vect / r[i, c] 90 91 # Convert the distances from Angstrom to meters. 92 r[i, c] = r[i, c] * 1e-10
93