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

Source Code for Module maths_fns.ri

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003, 2004 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   
 24  from ri_comps import r1_comps, dr1_comps, d2r1_comps 
 25  from ri_prime import func_ri_prime 
 26   
 27   
 28  # Calculate the NOE value. 
 29  ########################## 
 30   
31 -def calc_noe(data, i, frq_num, get_r1, params):
32 """Calculate the NOE value. 33 34 Half this code needs to be shifted into the function initialisation code. 35 """ 36 37 # Get the r1 value either from data.ri_prime or by calculation if the value is not in data.ri_prime 38 data.r1[i] = get_r1[i](data, i, frq_num, params) 39 40 # Calculate the NOE. 41 if data.r1[i] == 0.0 and data.ri_prime[i] == 0.0: 42 data.ri[i] = 1.0 43 elif data.r1[i] == 0.0: 44 data.ri[i] = 1e99 45 else: 46 data.ri[i] = 1.0 + data.g_ratio*(data.ri_prime[i] / data.r1[i])
47 48
49 -def calc_dnoe(data, i, frq_num, get_dr1, params, j):
50 """Calculate the derivative of the NOE value. 51 52 Half this code needs to be shifted into the function initialisation code. 53 """ 54 55 # Calculate the NOE derivative. 56 data.dr1[j, i] = get_dr1[i](data, i, frq_num, params, j) 57 if data.r1[i] == 0.0 and data.ri_prime[i] == 0.0: 58 data.dri[j, i] = 0.0 59 elif data.r1[i] == 0.0: 60 data.dri[j, i] = 1e99 61 else: 62 data.dri[j, i] = data.g_ratio * (1.0 / data.r1[i]**2) * (data.r1[i] * data.dri_prime[j, i] - data.ri_prime[i] * data.dr1[j, i])
63 64
65 -def calc_d2noe(data, i, frq_num, get_d2r1, params, j, k):
66 """Calculate the second partial derivative of the NOE value. 67 68 Half this code needs to be shifted into the function initialisation code. 69 """ 70 71 # Calculate the NOE second derivative. 72 data.d2r1[j, k, i] = get_d2r1[i](data, i, frq_num, params, j, k) 73 if data.r1[i] == 0.0 and data.ri_prime[i] == 0.0: 74 data.d2ri[j, k, i] = 0.0 75 elif data.r1[i] == 0.0: 76 data.d2ri[j, k, i] = 1e99 77 else: 78 a = data.ri_prime[i] * (2.0 * data.dr1[j, i] * data.dr1[k, i] - data.r1[i] * data.d2r1[j, k, i]) 79 b = data.r1[i] * (data.dri_prime[j, i] * data.dr1[k, i] + data.dr1[j, i] * data.dri_prime[k, i] - data.r1[i] * data.d2ri_prime[j, k, i]) 80 data.d2ri[j, k, i] = data.g_ratio * (1.0 / data.r1[i]**3) * (a - b)
81 82 83 84 # Calculate the R1 value. 85 ######################### 86
87 -def calc_r1(data, i, frq_num, params):
88 """Calculate the R1 value if there is no R1 data corresponding to the NOE data. 89 90 R1() = dip_const_func . dip_Jw_R1_func + csa_const_func . csa_Jw_R1_func 91 """ 92 93 # Place data in the R1 data class. 94 data.r1_data.remap_table = data.remap_table 95 data.r1_data.jw = data.jw 96 data.r1_data.dip_const_func = data.dip_const_func 97 data.r1_data.csa_const_func = data.csa_const_func 98 99 # Calculate the r1 components. 100 r1_comps(data.r1_data, i, params) 101 102 # Calculate the r1 value. 103 ri = func_ri_prime(data.r1_data) 104 return ri[i]
105 106
107 -def calc_dr1(data, i, frq_num, params, j):
108 """Calculate the R1 value if there is no R1 data corresponding to the NOE data. 109 110 dR1() 111 ----- = dip_const_func . dip_Jw_R1_grad + csa_const_func . csa_Jw_R1_grad 112 dJw 113 114 dR1() 115 ----- = 0 116 dRex 117 118 dR1() 119 ----- = dip_const_grad . dip_Jw_R1_func 120 dr 121 122 dR1() 123 ----- = csa_const_grad . csa_Jw_R1_func 124 dcsa 125 """ 126 127 # Place data in the R1 data class. 128 data.r1_data.remap_table = data.remap_table 129 data.r1_data.djw = data.djw 130 data.r1_data.dip_const_grad = data.dip_const_grad 131 data.r1_data.csa_const_grad = data.csa_const_grad 132 133 # Calculate the dr1 components. 134 dr1_comps(data.r1_data, i, params) 135 136 # Calculate the dr1 value. 137 dri = data.r1_data.create_dri_prime[j](data.r1_data) 138 139 return dri[i]
140 141
142 -def calc_d2r1(data, i, frq_num, params, j, k):
143 """Calculate the R1 value if there is no R1 data corresponding to the NOE data.""" 144 145 # Place data in the R1 data class. 146 data.r1_data.remap_table = data.remap_table 147 data.r1_data.d2jw = data.d2jw 148 data.r1_data.dip_const_hess = data.dip_const_hess 149 data.r1_data.csa_const_hess = data.csa_const_hess 150 151 # Calculate the dr1 components. 152 d2r1_comps(data.r1_data, i, params) 153 154 # Calculate the dr1 value. 155 if data.r1_data.create_d2ri_prime[j][k]: 156 d2ri = data.r1_data.create_d2ri_prime[j][k](data.r1_data) 157 return d2ri[i] 158 else: 159 return 0.0
160 161 162 163 # Extract the R1 value. 164 ####################### 165
166 -def extract_r1(data, i, frq_num, params):
167 """Get the R1 value from data.ri_prime""" 168 169 return data.ri_prime[data.noe_r1_table[i]]
170 171
172 -def extract_dr1(data, i, frq_num, params, j):
173 """Get the dR1 value from data.dri_prime""" 174 175 return data.dri_prime[j, data.noe_r1_table[i]]
176 177
178 -def extract_d2r1(data, i, frq_num, params, j, k):
179 """Get the d2R1 value from data.d2ri_prime""" 180 181 return data.d2ri_prime[j, k, data.noe_r1_table[i]]
182