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