Package maths_fns :: Module paramag_centre
[hide private]
[frames] | no frames]

Source Code for Module maths_fns.paramag_centre

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2010-2011 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax.                                     # 
 6  #                                                                             # 
 7  # relax 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 2 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # relax 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 relax; if not, write to the Free Software                        # 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Module docstring. 
24  """Module for functions relating to the paramagnetic centre.""" 
25   
26  # Python imports. 
27  from numpy.linalg import norm 
28   
29   
30 -def vectors_centre_per_state(atomic_pos, paramag_centre, unit_vector, r):
31 """Calculate the electron spin to nuclear spin unit vectors and distances. 32 33 This assumes that there is one paramagnetic centre per state of the system. 34 35 36 @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. 37 @type atomic_pos: numpy rank-3 array 38 @param paramag_centre: The paramagnetic centre position in Angstrom. 39 @type paramag_centre: numpy rank-2, Nx3 array 40 @param unit_vector: The structure to fill with the electron spin to nuclear spin unit vectors. 41 @type unit_vector: numpy rank-3 array 42 @param r: The structure to fill with the electron spin to nuclear spin distances. 43 @type r: numpy rank-2 array 44 """ 45 46 # Loop over the spins. 47 for i in range(len(atomic_pos)): 48 # Loop over the states. 49 for c in range(len(atomic_pos[i])): 50 # The vector. 51 vect = atomic_pos[i, c] - paramag_centre[c] 52 53 # The length. 54 r[i, c] = norm(vect) 55 56 # The unit vector. 57 unit_vector[i, c] = vect / r[i, c] 58 59 # Convert the distances from Angstrom to meters. 60 r[i, c] = r[i, c] * 1e-10
61 62
63 -def vectors_single_centre(atomic_pos, paramag_centre, unit_vector, r):
64 """Calculate the electron spin to nuclear spin unit vectors and distances. 65 66 This assumes that there is only one paramagnetic centre for all states of the system. 67 68 69 @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. 70 @type atomic_pos: numpy rank-3 array 71 @param paramag_centre: The paramagnetic centre position in Angstrom. 72 @type paramag_centre: numpy rank-1, 3D array 73 @param unit_vector: The structure to fill with the electron spin to nuclear spin unit vectors. 74 @type unit_vector: numpy rank-3 array 75 @param r: The structure to fill with the electron spin to nuclear spin distances. 76 @type r: numpy rank-2 array 77 """ 78 79 # Loop over the spins. 80 for i in range(len(atomic_pos)): 81 # Loop over the states. 82 for c in range(len(atomic_pos[i])): 83 # The vector. 84 vect = atomic_pos[i, c] - paramag_centre 85 86 # The length. 87 r[i, c] = norm(vect) 88 89 # The unit vector. 90 unit_vector[i, c] = vect / r[i, c] 91 92 # Convert the distances from Angstrom to meters. 93 r[i, c] = r[i, c] * 1e-10
94