1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from lib.auto_relaxation.ri_comps import r1_comps, dr1_comps, d2r1_comps
25 from lib.auto_relaxation.ri_prime import func_ri_prime
26
27
28
29
30
31 -def calc_noe(data, i, frq_num, get_r1, params):
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
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
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
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
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
100 r1_comps(data.r1_data, i, params)
101
102
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 The equations are::
111
112 dR1()
113 ----- = dip_const_func . dip_Jw_R1_grad + csa_const_func . csa_Jw_R1_grad
114 dJw
115
116 dR1()
117 ----- = 0
118 dRex
119
120 dR1()
121 ----- = dip_const_grad . dip_Jw_R1_func
122 dr
123
124 dR1()
125 ----- = csa_const_grad . csa_Jw_R1_func
126 dcsa
127 """
128
129
130 data.r1_data.remap_table = data.remap_table
131 data.r1_data.djw = data.djw
132 data.r1_data.dip_const_grad = data.dip_const_grad
133 data.r1_data.csa_const_grad = data.csa_const_grad
134
135
136 dr1_comps(data.r1_data, i, params)
137
138
139 dri = data.r1_data.create_dri_prime[j](data.r1_data)
140
141 return dri[i]
142
143
144 -def calc_d2r1(data, i, frq_num, params, j, k):
145 """Calculate the R1 value if there is no R1 data corresponding to the NOE data."""
146
147
148 data.r1_data.remap_table = data.remap_table
149 data.r1_data.d2jw = data.d2jw
150 data.r1_data.dip_const_hess = data.dip_const_hess
151 data.r1_data.csa_const_hess = data.csa_const_hess
152
153
154 d2r1_comps(data.r1_data, i, params)
155
156
157 if data.r1_data.create_d2ri_prime[j][k]:
158 d2ri = data.r1_data.create_d2ri_prime[j][k](data.r1_data)
159 return d2ri[i]
160 else:
161 return 0.0
162
163
164
165
166
167
169 """Get the R1 value from data.ri_prime"""
170
171 return data.ri_prime[data.noe_r1_table[i]]
172
173
175 """Get the dR1 value from data.dri_prime"""
176
177 return data.dri_prime[j, data.noe_r1_table[i]]
178
179
181 """Get the d2R1 value from data.d2ri_prime"""
182
183 return data.d2ri_prime[j, k, data.noe_r1_table[i]]
184