Package prompt :: Module align_tensor
[hide private]
[frames] | no frames]

Source Code for Module prompt.align_tensor

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-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 containing the 'align_tensor' user function class.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # Python module imports. 
 28   
 29  # relax module imports. 
 30  from base_class import User_fn_class 
 31  import arg_check 
 32  from generic_fns import align_tensor 
 33   
 34   
35 -class Align_tensor(User_fn_class):
36 """Class for manipulating the alignment tensor.""" 37
38 - def copy(self, tensor_from=None, pipe_from=None, tensor_to=None, pipe_to=None):
39 """Function for copying alignment tensor data. 40 41 Keyword Arguments 42 ~~~~~~~~~~~~~~~~~ 43 44 tensor_from: The identification string of the alignment tensor to copy the data from. 45 46 pipe_from: The name of the data pipe to copy the alignment tensor data from. 47 48 tensor_to: The identification string of the alignment tensor to copy the data to. 49 50 pipe_to: The name of the data pipe to copy the alignment tensor data to. 51 52 53 Description 54 ~~~~~~~~~~~ 55 56 This function will copy the alignment tensor data to a new tensor or a new data pipe. The 57 destination data pipe must not contain any alignment tensor data corresponding to the 58 tensor_to label. If the pipe_from or pipe_to arguments are not supplied, then both will 59 default to the current data pipe. Both the tensor_from and tensor_to arguments must be 60 supplied. 61 62 63 Examples 64 ~~~~~~~~ 65 66 To copy the alignment tensor data corresponding to 'Pf1' from the data pipe 'old' to the 67 current data pipe, type one of: 68 69 relax> align_tensor.copy('Pf1', 'old') 70 relax> align_tensor.copy(tensor_from='Pf1', pipe_from='old') 71 72 73 To copy the alignment tensor data corresponding to 'Otting' from the current data pipe to 74 the data pipe new, type one of: 75 76 relax> align_tensor.copy('Otting', pipe_to='new') 77 relax> align_tensor.copy(tensor_from='Otting', pipe_to='new') 78 79 80 To copy the alignment tensor data of 'Otting' to that of 'Otting new', type one of: 81 82 relax> align_tensor.copy('Otting', tensor_to='Otting new') 83 relax> align_tensor.copy(tensor_from='Pf1', tensor_to='Otting new') 84 """ 85 86 # Function intro text. 87 if self._exec_info.intro: 88 text = self._exec_info.ps3 + "align_tensor.copy(" 89 text = text + "tensor_from=" + repr(tensor_from) 90 text = text + ", pipe_from=" + repr(pipe_from) 91 text = text + ", tensor_to=" + repr(tensor_to) 92 text = text + ", pipe_to=" + repr(pipe_to) + ")" 93 print(text) 94 95 # The argument checks. 96 arg_check.is_str(tensor_from, 'tensor from') 97 arg_check.is_str(pipe_from, 'pipe from', can_be_none=True) 98 arg_check.is_str(tensor_to, 'tensor to', can_be_none=True) 99 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True) 100 101 # Execute the functional code. 102 align_tensor.copy(tensor_from=tensor_from, pipe_from=pipe_from, tensor_to=tensor_to, pipe_to=pipe_to)
103 104
105 - def delete(self, tensor=None):
106 """Function for deleting alignment tensor data. 107 108 109 Keyword Arguments 110 ~~~~~~~~~~~~~~~~~ 111 112 tensor: The alignment tensor identification string. 113 114 115 Description 116 ~~~~~~~~~~~ 117 118 This function will delete the specified alignment tensor data from the current data pipe. 119 """ 120 121 # Function intro text. 122 if self._exec_info.intro: 123 text = self._exec_info.ps3 + "align_tensor.delete(" 124 text = text + "tensor=" + repr(tensor) + ")" 125 print(text) 126 127 # The argument checks. 128 arg_check.is_str(tensor, 'tensor', can_be_none=True) 129 130 # Execute the functional code. 131 align_tensor.delete(tensor=tensor)
132 133
134 - def display(self, tensor=None):
135 """Function for displaying the alignment tensor information. 136 137 Keyword Arguments 138 ~~~~~~~~~~~~~~~~~ 139 140 tensor: The alignment tensor identification string. 141 """ 142 143 # Function intro text. 144 if self._exec_info.intro: 145 text = self._exec_info.ps3 + "align_tensor.display(" 146 text = text + "tensor=" + repr(tensor) + ")" 147 print(text) 148 149 # The argument checks. 150 arg_check.is_str(tensor, 'tensor', can_be_none=True) 151 152 # Execute the functional code. 153 align_tensor.display(tensor=tensor)
154 155
156 - def fix(self, id=None, fixed=True):
157 """Fix all alignment tensors so that they do not change during optimisation. 158 159 Keyword Arguments 160 ~~~~~~~~~~~~~~~~~ 161 162 id: The alignment tensor identification string. 163 164 fixed: The flag specifying if the tensors should be fixed or variable. 165 166 167 Description 168 ~~~~~~~~~~~ 169 170 If the ID string is left unset, then all alignment tensors will be fixed. 171 """ 172 173 # Function intro text. 174 if self._exec_info.intro: 175 text = self._exec_info.ps3 + "align_tensor.fix(" 176 text = text + "id=" + repr(id) 177 text = text + ", fixed=" + repr(fixed) + ")" 178 print(text) 179 180 # The argument checks. 181 arg_check.is_str(id, 'tensor ID', can_be_none=True) 182 arg_check.is_bool(fixed, 'fixed') 183 184 # Execute the functional code. 185 align_tensor.fix(id=id, fixed=fixed)
186 187
188 - def init(self, tensor=None, params=None, scale=1.0, angle_units='deg', param_types=0, errors=False):
189 """Function for initialising the alignment tensor. 190 191 Keyword Arguments 192 ~~~~~~~~~~~~~~~~~ 193 194 tensor: The alignment tensor identification string. 195 196 params: The alignment tensor data. 197 198 scale: The alignment tensor eigenvalue scaling value. 199 200 angle_units: The units for the angle parameters. 201 202 param_types: A flag to select different parameter combinations. 203 204 errors: A flag which determines if the alignment tensor data or its errors are being input. 205 206 207 Description 208 ~~~~~~~~~~~ 209 210 Using this function, the alignment tensor data can be set up. The params argument should be 211 a tuple of floating point numbers (a list surrounded by round brakets). These correspond to 212 the parameters of the tensor, which can be specified by the param_types argument, where the 213 values correspond to 214 215 0: {Sxx, Syy, Sxy, Sxz, Syz} (unitless), 216 1: {Szz, Sxx-yy, Sxy, Sxz, Syz} (Pales default format), 217 2: {Axx, Ayy, Axy, Axz, Ayz} (unitless), 218 3: {Azz, Axx-yy, Axy, Axz, Ayz} (unitless), 219 4: {Axx, Ayy, Axy, Axz, Ayz} (units of Hertz), 220 5: {Azz, Axx-yy, Axy, Axz, Ayz} (units of Hertz), 221 6: {Pxx, Pyy, Pxy, Pxz, Pyz} (unitless), 222 7: {Pzz, Pxx-yy, Pxy, Pxz, Pyz} (unitless), 223 224 Other formats may be added later. The relationship between the Saupe order matrix S and the 225 alignment tensor A is 226 227 S = 3/2 A. 228 229 The probability matrix P is related to the alignment tensor A by 230 231 A = P - 1/3 I, 232 233 where I is the identity matrix. For the alignment tensor to be supplied in Hertz, the bond 234 vectors must all be of equal length. 235 236 237 Examples 238 ~~~~~~~~ 239 240 To set a rhombic tensor to the run 'CaM', type one of: 241 242 relax> align_tensor.init('super media', (-8.6322e-05, -5.5786e-04, -3.1732e-05, 2.2927e-05, 243 2.8599e-04), param_types=1) 244 relax> align_tensor.init(tensor='super media', params=(-8.6322e-05, -5.5786e-04, 245 -3.1732e-05, 2.2927e-05, 2.8599e-04), param_types=1) 246 """ 247 248 # Function intro text. 249 if self._exec_info.intro: 250 text = self._exec_info.ps3 + "align_tensor.init(" 251 text = text + "tensor=" + repr(tensor) 252 text = text + ", params=" + repr(params) 253 text = text + ", scale=" + repr(scale) 254 text = text + ", angle_units=" + repr(angle_units) 255 text = text + ", param_types=" + repr(param_types) 256 text = text + ", errors=" + repr(errors) + ")" 257 print(text) 258 259 # The argument checks. 260 arg_check.is_str(tensor, 'tensor') 261 arg_check.is_num_tuple(params, 'alignment tensor parameters', size=5) 262 arg_check.is_float(scale, 'scale') 263 arg_check.is_str(angle_units, 'angle units') 264 arg_check.is_int(param_types, 'parameter types') 265 arg_check.is_bool(errors, 'errors flag') 266 267 # Execute the functional code. 268 align_tensor.init(tensor=tensor, params=params, scale=scale, angle_units=angle_units, param_types=param_types, errors=errors)
269 270
271 - def matrix_angles(self, basis_set=0, tensors=None):
272 """Function for calculating the 5D angles between all alignment tensors. 273 274 Keyword Arguments 275 ~~~~~~~~~~~~~~~~~ 276 277 basis_set: The basis set to operate with. 278 279 tensors: A list of the tensors to apply the calculation to. If None, all tensors are used. 280 281 282 Description 283 ~~~~~~~~~~~ 284 285 This function will calculate the angles between all loaded alignment tensors for the current 286 data pipe. The matrices are first converted to a 5D vector form and then then angles are 287 calculated. The angles are dependent on the basis set. If the basis_set argument is set to 288 the default of 0, the vectors {Sxx, Syy, Sxy, Sxz, Syz} are used. If the basis_set argument 289 is set to 1, the vectors {Szz, Sxxyy, Sxy, Sxz, Syz} are used instead. 290 """ 291 292 # Function intro text. 293 if self._exec_info.intro: 294 text = self._exec_info.ps3 + "align_tensor.matrix_angles(" 295 text = text + "basis_set=" + repr(basis_set) 296 text = text + ", tensors=" + repr(tensors) + ")" 297 print(text) 298 299 # The argument checks. 300 arg_check.is_int(basis_set, 'basis set') 301 arg_check.is_str_list(tensors, 'alignment tensors', can_be_none=True) 302 303 # Execute the functional code. 304 align_tensor.matrix_angles(basis_set, tensors)
305 306
307 - def reduction(self, full_tensor=None, red_tensor=None):
308 """Specify that one tensor is a reduction of another. 309 310 Keyword Arguments 311 ~~~~~~~~~~~~~~~~~ 312 313 full_tensor: The full alignment tensor. 314 315 red_tensor: The reduce alignment tensor. 316 317 318 Description 319 ~~~~~~~~~~~ 320 321 Prior to optimisation of the N-state model and Frame Order theories using alignment tensors, 322 which tensor is a reduction of which other tensor must be specified through this user 323 function. 324 325 326 Examples 327 ~~~~~~~~ 328 329 To state that the alignment tensor loaded as 'chi3 C-dom' is a reduction of 'chi3 N-dom', type: 330 331 relax> align_tensor.reduction(full_tensor='chi3 N-dom', red_tensor='chi3 C-dom') 332 """ 333 334 # Function intro text. 335 if self._exec_info.intro: 336 text = self._exec_info.ps3 + "align_tensor.reduction(" 337 text = text + "full_tensor=" + repr(full_tensor) 338 text = text + ", red_tensor=" + repr(red_tensor) + ")" 339 print(text) 340 341 # The argument checks. 342 arg_check.is_str(full_tensor, 'full tensor') 343 arg_check.is_str(red_tensor, 'reduced tensor') 344 345 # Execute the functional code. 346 align_tensor.reduction(full_tensor=full_tensor, red_tensor=red_tensor)
347 348
349 - def set_domain(self, tensor=None, domain=None):
350 """Set the domain label for the alignment tensor. 351 352 Keyword Arguments 353 ~~~~~~~~~~~~~~~~~ 354 355 tensor: The alignment tensor to assign the domain label to. 356 357 domain: The domain label. 358 359 360 Description 361 ~~~~~~~~~~~ 362 363 Prior to optimisation of the N-state model or Frame Order theories, the domain to which each 364 alignment tensor belongs must be specified. 365 366 367 Examples 368 ~~~~~~~~ 369 370 To link the alignment tensor loaded as 'chi3 C-dom' to the C-terminal domain 'C', type: 371 372 relax> align_tensor.set_domain(tensor='chi3 C-dom', domain='C') 373 """ 374 375 # Function intro text. 376 if self._exec_info.intro: 377 text = self._exec_info.ps3 + "align_tensor.set_domain(" 378 text = text + "tensor=" + repr(tensor) 379 text = text + ", domain=" + repr(domain) + ")" 380 print(text) 381 382 # The argument checks. 383 arg_check.is_str(tensor, 'tensor') 384 arg_check.is_str(domain, 'domain') 385 386 # Execute the functional code. 387 align_tensor.set_domain(tensor=tensor, domain=domain)
388 389
390 - def svd(self, basis_set=0, tensors=None):
391 """Function for calculating the singular values for all tensors and the condition number. 392 393 Keyword Arguments 394 ~~~~~~~~~~~~~~~~~ 395 396 basis_set: The basis set to operate with. 397 398 tensors: A list of the tensors to apply the calculation to. If None, all tensors are used. 399 400 401 Description 402 ~~~~~~~~~~~ 403 404 This function will, using SVD, calculate the singular values of all tensors loaded for the 405 current data pipe. If the basis_set argument is set to the default of 0, the matrix on 406 which SVD will be performed is composed of the unitary basis set {Sxx, Syy, Sxy, Sxz, Syz} 407 layed out as: 408 409 ----- 410 411 | Sxx1 Syy1 Sxy1 Sxz1 Syz1 | 412 | Sxx2 Syy2 Sxy2 Sxz2 Syz2 | 413 | Sxx3 Syy3 Sxy3 Sxz3 Syz3 | 414 | . . . . . | 415 | . . . . . | 416 | . . . . . | 417 | SxxN SyyN SxyN SxzN SyzN | 418 419 ----- 420 421 If basis_set is set to 1, the geometric basis set consisting of the stretching and skewing 422 parameters Szz and Sxx-yy respectively {Szz, Sxxyy, Sxy, Sxz, Syz} will be used instead. 423 The matrix is: 424 425 ----- 426 427 | Szz1 Sxxyy1 Sxy1 Sxz1 Syz1 | 428 | Szz2 Sxxyy2 Sxy2 Sxz2 Syz2 | 429 | Szz3 Sxxyy3 Sxy3 Sxz3 Syz3 | 430 | . . . . . | 431 | . . . . . | 432 | . . . . . | 433 | SzzN SxxyyN SxyN SxzN SyzN | 434 435 ----- 436 437 The relationships between the geometric and unitary basis sets are: 438 439 ----- 440 441 Szz = - Sxx - Syy, 442 Sxxyy = Sxx - Syy, 443 444 ----- 445 446 The SVD values and condition number are dependendent upon the basis set chosen. 447 """ 448 449 # Function intro text. 450 if self._exec_info.intro: 451 text = self._exec_info.ps3 + "align_tensor.svd(" 452 text = text + "basis_set=" + repr(basis_set) 453 text = text + ", tensors=" + repr(tensors) + ")" 454 print(text) 455 456 # The argument checks. 457 arg_check.is_int(basis_set, 'basis set') 458 arg_check.is_str_list(tensors, 'alignment tensors', can_be_none=True) 459 460 # Execute the functional code. 461 align_tensor.svd(basis_set, tensors)
462