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

Source Code for Module user_functions.align_tensor

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """The align_tensor user function definitions.""" 
 24   
 25  # relax module imports. 
 26  from graphics import WIZARD_IMAGE_PATH 
 27  from generic_fns import align_tensor, pipes 
 28  from user_functions.data import Uf_info; uf_info = Uf_info() 
 29  from user_functions.objects import Desc_container 
 30   
 31   
 32  # The user function class. 
 33  uf_class = uf_info.add_class('align_tensor') 
 34  uf_class.title = "Class for manipulating the alignment tensor." 
 35  uf_class.menu_text = "&align_tensor" 
 36  uf_class.gui_icon = "relax.align_tensor" 
 37   
 38   
 39  # The align_tensor.copy user function. 
 40  uf = uf_info.add_uf('align_tensor.copy') 
 41  uf.title = "Copy alignment tensor data." 
 42  uf.title_short = "Alignment tensor copying." 
 43  uf.add_keyarg( 
 44      name = "tensor_from", 
 45      default = None, 
 46      py_type = "str", 
 47      desc_short = "source tensor ID", 
 48      desc = "The identification string of the alignment tensor to copy the data from." 
 49  ) 
 50  uf.add_keyarg( 
 51      name = "pipe_from", 
 52      default = None, 
 53      py_type = "str", 
 54      desc_short = "source data pipe", 
 55      desc = "The name of the data pipe to copy the alignment tensor data from.", 
 56      wiz_element_type = 'combo', 
 57      wiz_combo_iter = pipes.pipe_names, 
 58      can_be_none = True 
 59  ) 
 60  uf.add_keyarg( 
 61      name = "tensor_to", 
 62      default = None, 
 63      py_type = "str", 
 64      desc_short = "destination tensor ID", 
 65      desc = "The identification string of the alignment tensor to copy the data to.", 
 66      can_be_none = True 
 67  ) 
 68  uf.add_keyarg( 
 69      name = "pipe_to", 
 70      default = None, 
 71      py_type = "str", 
 72      desc_short = "destination data pipe", 
 73      desc = "The name of the data pipe to copy the alignment tensor data to.", 
 74      wiz_element_type = 'combo', 
 75      wiz_combo_iter = pipes.pipe_names, 
 76      can_be_none = True 
 77  ) 
 78  # Description. 
 79  uf.desc.append(Desc_container()) 
 80  uf.desc[-1].add_paragraph("This will copy the alignment tensor data to a new tensor or a new data pipe.  The destination data pipe must not contain any alignment tensor data corresponding to the tensor_to label.  If the source or destination data pipes are not supplied, then both will default to the current data pipe.  Both the source and destination tensor IDs must be supplied.") 
 81  # Prompt examples. 
 82  uf.desc.append(Desc_container("Prompt examples")) 
 83  uf.desc[-1].add_paragraph("To copy the alignment tensor data corresponding to 'Pf1' from the data pipe 'old' to the current data pipe, type one of:") 
 84  uf.desc[-1].add_prompt("relax> align_tensor.copy('Pf1', 'old')") 
 85  uf.desc[-1].add_prompt("relax> align_tensor.copy(tensor_from='Pf1', pipe_from='old')") 
 86  uf.desc[-1].add_paragraph("To copy the alignment tensor data corresponding to 'Otting' from the current data pipe to the data pipe new, type one of:") 
 87  uf.desc[-1].add_prompt("relax> align_tensor.copy('Otting', pipe_to='new')") 
 88  uf.desc[-1].add_prompt("relax> align_tensor.copy(tensor_from='Otting', pipe_to='new')") 
 89  uf.desc[-1].add_paragraph("To copy the alignment tensor data of 'Otting' to that of 'Otting new', type one of:") 
 90  uf.desc[-1].add_prompt("relax> align_tensor.copy('Otting', tensor_to='Otting new')") 
 91  uf.desc[-1].add_prompt("relax> align_tensor.copy(tensor_from='Pf1', tensor_to='Otting new')") 
 92  uf.backend = align_tensor.copy 
 93  uf.menu_text = "&copy" 
 94  uf.gui_icon = "oxygen.actions.list-add" 
 95  uf.wizard_size = (800, 600) 
 96  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
 97   
 98   
 99  # The align_tensor.delete user function. 
100  uf = uf_info.add_uf('align_tensor.delete') 
101  uf.title = "Delete alignment tensor data from the relax data store." 
102  uf.title_short = "Alignment tensor pipe deletion." 
103  uf.add_keyarg( 
104      name = "tensor", 
105      py_type = "str", 
106      desc_short = "tensor", 
107      desc = "The alignment tensor identification string.", 
108      wiz_element_type = 'combo', 
109      wiz_combo_iter = align_tensor.get_ids, 
110      wiz_read_only = True, 
111      can_be_none = True 
112  ) 
113  # Description. 
114  uf.desc.append(Desc_container()) 
115  uf.desc[-1].add_paragraph("This will delete the specified alignment tensor data from the current data pipe.  If no tensor is specified, all tensors will be deleted.") 
116  uf.backend = align_tensor.delete 
117  uf.menu_text = "&delete" 
118  uf.gui_icon = "oxygen.actions.list-remove" 
119  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
120   
121   
122  # The align_tensor.display user function. 
123  uf = uf_info.add_uf('align_tensor.display') 
124  uf.title = "Display the alignment tensor information in full detail." 
125  uf.title_short = "Align tensor display." 
126  uf.display = True 
127  uf.add_keyarg( 
128      name = "tensor", 
129      py_type = "str", 
130      desc_short = "tensor", 
131      desc = "The alignment tensor identification string.", 
132      wiz_element_type = 'combo', 
133      wiz_combo_iter = align_tensor.get_ids, 
134      wiz_read_only = True, 
135      can_be_none = True 
136  ) 
137  uf.desc.append(Desc_container()) 
138  uf.desc[-1].add_paragraph("This will show all information relating to the alignment tensor, including the different tensor forms:") 
139  uf.desc[-1].add_list_element("Probability tensor.") 
140  uf.desc[-1].add_list_element("Saupe order matrix.") 
141  uf.desc[-1].add_list_element("Alignment tensor.") 
142  uf.desc[-1].add_list_element("Magnetic susceptibility tensor.") 
143  uf.desc[-1].add_paragraph("All possible tensor parameters and information will also be shown (Eigensystem, GDO, Aa, Ar, R, eta, chi_ax, chi_rh, etc).  The printout will be extensive.") 
144  uf.desc[-1].add_paragraph("If no tensor is specified, all tensors will be displayed.") 
145  uf.backend = align_tensor.display 
146  uf.menu_text = "dis&play" 
147  uf.gui_icon = "oxygen.actions.document-preview" 
148  uf.wizard_height_desc = 400 
149  uf.wizard_size = (800, 600) 
150  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
151   
152   
153  # The align_tensor.fix user function. 
154  uf = uf_info.add_uf('align_tensor.fix') 
155  uf.title = "Fix all alignment tensors so that they do not change during optimisation." 
156  uf.title_short = "Fix alignment tensors." 
157  uf.add_keyarg( 
158      name = "id", 
159      py_type = "str", 
160      desc_short = "tensor ID", 
161      desc = "The alignment tensor identification string.", 
162      wiz_element_type = 'combo', 
163      wiz_combo_iter = align_tensor.get_ids, 
164      wiz_read_only = True, 
165      can_be_none = True 
166  ) 
167  uf.add_keyarg( 
168      name = "fixed", 
169      default = True, 
170      py_type = "bool", 
171      desc_short = "fixed flag", 
172      desc = "The flag specifying if the tensors should be fixed or variable." 
173  ) 
174  uf.desc.append(Desc_container()) 
175  uf.desc[-1].add_paragraph("If the ID string is left unset, then all alignment tensors will be fixed.") 
176  uf.backend = align_tensor.fix 
177  uf.menu_text = "&fix" 
178  uf.gui_icon = "oxygen.status.object-locked" 
179  uf.wizard_size = (800, 500) 
180  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
181   
182   
183  # The align_tensor.init user function. 
184  uf = uf_info.add_uf('align_tensor.init') 
185  uf.title = "Initialise an alignment tensor." 
186  uf.title_short = "Alignment tensor initialisation." 
187  uf.add_keyarg( 
188      name = "tensor", 
189      py_type = "str", 
190      desc_short = "tensor ID", 
191      desc = "The alignment tensor identification string." 
192  ) 
193  uf.add_keyarg( 
194      name = "params", 
195      py_type = "num_tuple", 
196      desc_short = "alignment tensor parameters", 
197      dim = 5, 
198      desc = "The alignment tensor data.", 
199      wiz_read_only = False 
200  ) 
201  uf.add_keyarg( 
202      name = "scale", 
203      default = 1.0, 
204      py_type = "float", 
205      desc_short = "scale", 
206      desc = "The alignment tensor eigenvalue scaling value." 
207  ) 
208  uf.add_keyarg( 
209      name = "angle_units", 
210      default = "deg", 
211      py_type = "str", 
212      desc_short = "angle units", 
213      desc = "The units for the angle parameters." 
214  ) 
215  uf.add_keyarg( 
216      name = "param_types", 
217      default = 2, 
218      py_type = "int", 
219      desc_short = "parameter types", 
220      desc = "A flag to select different parameter combinations.", 
221      wiz_element_type = "combo", 
222      wiz_combo_choices = [ 
223          "{Sxx, Syy, Sxy, Sxz, Syz}", 
224          "{Szz, Sxx-yy, Sxy, Sxz, Syz}", 
225          "{Axx, Ayy, Axy, Axz, Ayz}", 
226          "{Azz, Axx-yy, Axy, Axz, Ayz}", 
227          "{Axx, Ayy, Axy, Axz, Ayz}", 
228          "{Azz, Axx-yy, Axy, Axz, Ayz}", 
229          "{Pxx, Pyy, Pxy, Pxz, Pyz}", 
230          "{Pzz, Pxx-yy, Pxy, Pxz, Pyz}" 
231      ], 
232      wiz_combo_data = [ 
233          0, 
234          1, 
235          2, 
236          3, 
237          4, 
238          5, 
239          6, 
240          7 
241      ], 
242      wiz_read_only = True 
243  ) 
244  uf.add_keyarg( 
245      name = "errors", 
246      default = False, 
247      py_type = "bool", 
248      desc_short = "errors flag", 
249      desc = "A flag which determines if the alignment tensor data or its errors are being input." 
250  ) 
251  uf.desc.append(Desc_container()) 
252  uf.desc[-1].add_paragraph("Using this function, the alignment tensor data can be set up.  The alignment tensor parameters should be a tuple of floating point numbers (a list surrounded by round brakets).  These correspond to the parameters of the tensor which can be specified by the parameter types whereby the values correspond to:") 
253  uf.desc[-1].add_item_list_element("0", "{Sxx, Syy, Sxy, Sxz, Syz}  (unitless),") 
254  uf.desc[-1].add_item_list_element("1", "{Szz, Sxx-yy, Sxy, Sxz, Syz}  (Pales default format),") 
255  uf.desc[-1].add_item_list_element("2", "{Axx, Ayy, Axy, Axz, Ayz}  (unitless),") 
256  uf.desc[-1].add_item_list_element("3", "{Azz, Axx-yy, Axy, Axz, Ayz}  (unitless),") 
257  uf.desc[-1].add_item_list_element("4", "{Axx, Ayy, Axy, Axz, Ayz}  (units of Hertz),") 
258  uf.desc[-1].add_item_list_element("5", "{Azz, Axx-yy, Axy, Axz, Ayz}  (units of Hertz),") 
259  uf.desc[-1].add_item_list_element("6", "{Pxx, Pyy, Pxy, Pxz, Pyz}  (unitless),") 
260  uf.desc[-1].add_item_list_element("7", "{Pzz, Pxx-yy, Pxy, Pxz, Pyz}  (unitless).") 
261  uf.desc[-1].add_paragraph("Other formats may be added later.  The relationship between the Saupe order matrix S and the alignment tensor A is") 
262  uf.desc[-1].add_item_list_element(None, "S = 3/2 A.") 
263  uf.desc[-1].add_paragraph("The probability matrix P is related to the alignment tensor A by") 
264  uf.desc[-1].add_item_list_element(None, "A = P - 1/3 I,") 
265  uf.desc[-1].add_paragraph("where I is the identity matrix.  For the alignment tensor to be supplied in Hertz, the bond vectors must all be of equal length.") 
266  # Prompt examples. 
267  uf.desc.append(Desc_container("Prompt examples")) 
268  uf.desc[-1].add_paragraph("To set a rhombic tensor to the run 'CaM', type one of:") 
269  uf.desc[-1].add_prompt("relax> align_tensor.init('super media', (-8.6322e-05, -5.5786e-04, -3.1732e-05, 2.2927e-05, 2.8599e-04), param_types=1)") 
270  uf.desc[-1].add_prompt("relax> align_tensor.init(tensor='super media', params=(-8.6322e-05, -5.5786e-04, -3.1732e-05, 2.2927e-05, 2.8599e-04), param_types=1)") 
271  uf.backend = align_tensor.init 
272  uf.menu_text = "&init" 
273  uf.wizard_height_desc = 420 
274  uf.wizard_size = (1000, 750) 
275  uf.gui_icon = "relax.align_tensor" 
276  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
277   
278   
279  # The align_tensor.matrix_angles user function. 
280  uf = uf_info.add_uf('align_tensor.matrix_angles') 
281  uf.title = "Calculate the 5D angles between all alignment tensors." 
282  uf.title_short = "Alignment tensor angle calculation." 
283  uf.display = True 
284  uf.add_keyarg( 
285      name = "basis_set", 
286      default = 0, 
287      py_type = "int", 
288      desc_short = "basis set", 
289      desc = "The basis set to operate with.", 
290      wiz_element_type = "combo", 
291      wiz_combo_choices = ["{Sxx, Syy, Sxy, Sxz, Syz}", "{Szz, Sxxyy, Sxy, Sxz, Syz}"], 
292      wiz_combo_data = [0, 1] 
293  ) 
294  uf.add_keyarg( 
295      name = "tensors", 
296      py_type = "str_list", 
297      desc_short = "alignment tensor IDs", 
298      desc = "A list of the tensors to apply the calculation to.  If None, all tensors are used.", 
299      wiz_element_type = "combo_list", 
300      wiz_combo_iter = align_tensor.get_ids, 
301      wiz_read_only = True, 
302      can_be_none = True 
303  ) 
304  # Description. 
305  uf.desc.append(Desc_container()) 
306  uf.desc[-1].add_paragraph("This will calculate the angles between all loaded alignment tensors for the current data pipe.  The matrices are first converted to a 5D vector form and then then angles are calculated.  The angles are dependent on the basis set.  If the basis set is set to the default of 0, the vectors {Sxx, Syy, Sxy, Sxz, Syz} are used.  If the basis set is set to 1, the vectors {Szz, Sxxyy, Sxy, Sxz, Syz} are used instead.") 
307  uf.backend = align_tensor.matrix_angles 
308  uf.menu_text = "&matrix_angles" 
309  uf.gui_icon = "oxygen.categories.applications-education" 
310  uf.wizard_size = (800, 600) 
311  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
312   
313   
314  # The align_tensor.reduction user function. 
315  uf = uf_info.add_uf('align_tensor.reduction') 
316  uf.title = "Specify that one tensor is a reduction of another." 
317  uf.title_short = "Specify tensor reductions." 
318  uf.add_keyarg( 
319      name = "full_tensor", 
320      py_type = "str", 
321      desc_short = "full tensor", 
322      desc = "The full alignment tensor.", 
323      wiz_element_type = 'combo', 
324      wiz_combo_iter = align_tensor.get_ids, 
325      wiz_read_only = True 
326  ) 
327  uf.add_keyarg( 
328      name = "red_tensor", 
329      py_type = "str", 
330      desc_short = "reduced tensor", 
331      desc = "The reduced alignment tensor.", 
332      wiz_element_type = 'combo', 
333      wiz_combo_iter = align_tensor.get_ids, 
334      wiz_read_only = True 
335  ) 
336  # Description. 
337  uf.desc.append(Desc_container()) 
338  uf.desc[-1].add_paragraph("Prior to optimisation of the N-state model and Frame Order theories using alignment tensors, which tensor is a reduction of which other tensor must be specified through this user function.") 
339  # Prompt examples. 
340  uf.desc.append(Desc_container("Prompt examples")) 
341  uf.desc[-1].add_paragraph("To state that the alignment tensor loaded as 'chi3 C-dom' is a reduction of 'chi3 N-dom', type:") 
342  uf.desc[-1].add_prompt("relax> align_tensor.reduction(full_tensor='chi3 N-dom', red_tensor='chi3 C-dom')") 
343  uf.backend = align_tensor.reduction 
344  uf.menu_text = "&reduction" 
345  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
346   
347   
348  # The align_tensor.set_domain user function. 
349  uf = uf_info.add_uf('align_tensor.set_domain') 
350  uf.title = "Set the domain label for the alignment tensor." 
351  uf.title_short = "Tensor domain labelling." 
352  uf.add_keyarg( 
353      name = "tensor", 
354      py_type = "str", 
355      desc_short = "tensor ID", 
356      desc = "The alignment tensor to assign the domain label to.", 
357      wiz_element_type = 'combo', 
358      wiz_combo_iter = align_tensor.get_ids, 
359      wiz_read_only = True, 
360  ) 
361  uf.add_keyarg( 
362      name = "domain", 
363      py_type = "str", 
364      desc_short = "domain", 
365      desc = "The domain label." 
366  ) 
367  # Description. 
368  uf.desc.append(Desc_container()) 
369  uf.desc[-1].add_paragraph("Prior to optimisation of the N-state model or Frame Order theories, the domain to which each alignment tensor belongs must be specified.") 
370  # Prompt examples. 
371  uf.desc.append(Desc_container("Prompt examples")) 
372  uf.desc[-1].add_paragraph("To link the alignment tensor loaded as 'chi3 C-dom' to the C-terminal domain 'C', type:") 
373  uf.desc[-1].add_prompt("relax> align_tensor.set_domain(tensor='chi3 C-dom', domain='C')") 
374  uf.backend = align_tensor.set_domain 
375  uf.menu_text = "&set_domain" 
376  uf.gui_icon = "oxygen.actions.edit-select" 
377  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
378   
379   
380  # The align_tensor.svd user function. 
381  uf = uf_info.add_uf('align_tensor.svd') 
382  uf.title = "Calculate the singular values and condition number for all alignment tensors." 
383  uf.title_short = "Alignment tensor SVD calculation." 
384  uf.display = True 
385  uf.add_keyarg( 
386      name = "basis_set", 
387      default = 0, 
388      py_type = "int", 
389      desc_short = "basis set", 
390      desc = "The basis set to operate with.", 
391      wiz_element_type = "combo", 
392      wiz_combo_choices = ["{Sxx, Syy, Sxy, Sxz, Syz}", "{Szz, Sxxyy, Sxy, Sxz, Syz}"], 
393      wiz_combo_data = [0, 1] 
394  ) 
395  uf.add_keyarg( 
396      name = "tensors", 
397      py_type = "str_list", 
398      desc_short = "alignment tensor IDs", 
399      desc = "A list of the tensors to apply the calculation to.  If None, all tensors are used.", 
400      wiz_element_type = "combo_list", 
401      wiz_combo_iter = align_tensor.get_ids, 
402      wiz_read_only = True, 
403      can_be_none = True 
404  ) 
405  # Description. 
406  uf.desc.append(Desc_container()) 
407  uf.desc[-1].add_paragraph("This will perform a singular value decomposition of all tensors loaded for the current data pipe.  If the basis set is set to the default of 0, the matrix on which SVD will be performed is composed of the unitary basis set {Sxx, Syy, Sxy, Sxz, Syz} layed out as:") 
408  uf.desc[-1].add_verbatim(""" 
409      | Sxx1 Syy1 Sxy1 Sxz1 Syz1 | 
410      | Sxx2 Syy2 Sxy2 Sxz2 Syz2 | 
411      | Sxx3 Syy3 Sxy3 Sxz3 Syz3 | 
412      |  .    .    .    .    .   | 
413      |  .    .    .    .    .   | 
414      |  .    .    .    .    .   | 
415      | SxxN SyyN SxyN SxzN SyzN | 
416  """) 
417  uf.desc[-1].add_paragraph("If basis_set is set to 1, the geometric basis set consisting of the stretching and skewing parameters Szz and Sxx-yy respectively {Szz, Sxxyy, Sxy, Sxz, Syz} will be used instead.  The matrix is:") 
418  uf.desc[-1].add_verbatim(""" 
419      | Szz1 Sxxyy1 Sxy1 Sxz1 Syz1 | 
420      | Szz2 Sxxyy2 Sxy2 Sxz2 Syz2 | 
421      | Szz3 Sxxyy3 Sxy3 Sxz3 Syz3 | 
422      |  .     .     .    .    .   | 
423      |  .     .     .    .    .   | 
424      |  .     .     .    .    .   | 
425      | SzzN SxxyyN SxyN SxzN SyzN | 
426  """) 
427  uf.desc[-1].add_paragraph("The relationships between the geometric and unitary basis sets are:") 
428  uf.desc[-1].add_verbatim(""" 
429      Szz = - Sxx - Syy, 
430      Sxxyy = Sxx - Syy, 
431  """) 
432  uf.desc[-1].add_paragraph("The SVD values and condition number are dependent upon the basis set chosen.") 
433  uf.backend = align_tensor.svd 
434  uf.menu_text = "s&vd" 
435  uf.gui_icon = "oxygen.categories.applications-education" 
436  uf.wizard_height_desc = 500 
437  uf.wizard_size = (1000, 750) 
438  uf.wizard_image = WIZARD_IMAGE_PATH + 'align_tensor.png' 
439