Author: bugman Date: Wed Mar 4 11:39:09 2009 New Revision: 8899 URL: http://svn.gna.org/viewcvs/relax?rev=8899&view=rev Log: Merged revisions 8893-8898 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r8893 | bugman | 2009-02-27 18:58:24 +0100 (Fri, 27 Feb 2009) | 3 lines The diagonalised alignment tensor is now being created (and is being done correctly). ........ r8894 | bugman | 2009-03-02 17:26:48 +0100 (Mon, 02 Mar 2009) | 5 lines Fix for the calc_tensor_diag() function. The algorithm for finding Ayy was broken. ........ r8895 | bugman | 2009-03-02 17:34:06 +0100 (Mon, 02 Mar 2009) | 5 lines Fix for the test_name_argfail_mol_id() unit test. The mol_id can be None, i.e. for naming unnamed molecules. ........ r8896 | bugman | 2009-03-02 17:35:33 +0100 (Mon, 02 Mar 2009) | 3 lines Fixed the check for None in molecule.name(). ........ r8897 | bugman | 2009-03-02 17:42:04 +0100 (Mon, 02 Mar 2009) | 5 lines Allowed the spin_num arg of spin.create() to be None. This is useful for polymers where the name is important rather than number. ........ r8898 | bugman | 2009-03-04 10:32:28 +0100 (Wed, 04 Mar 2009) | 3 lines Fix for the test_create_argfail_spin_num() unit test. ........ Modified: branches/bmrb/ (props changed) branches/bmrb/data/align_tensor.py branches/bmrb/prompt/molecule.py branches/bmrb/prompt/spin.py branches/bmrb/test_suite/unit_tests/_prompt/test_molecule.py branches/bmrb/test_suite/unit_tests/_prompt/test_spin.py Propchange: branches/bmrb/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Wed Mar 4 11:39:09 2009 @@ -1,1 +1,1 @@ -/1.3:1-8881 +/1.3:1-8898 Modified: branches/bmrb/data/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/data/align_tensor.py?rev=8899&r1=8898&r2=8899&view=diff ============================================================================== --- branches/bmrb/data/align_tensor.py (original) +++ branches/bmrb/data/align_tensor.py Wed Mar 4 11:39:09 2009 @@ -24,6 +24,7 @@ from re import search from math import cos, sin from numpy import dot, float64, identity, transpose, zeros +from numpy.linalg import eigvals from types import ListType # relax module imports. @@ -505,8 +506,8 @@ return tensor -def calc_tensor_diag(rotation, tensor): - """Function for calculating the diagonalised alignment tensor. +def calc_tensor_diag(tensor): + """Calculate the diagonalised alignment tensor. The diagonalised alignment tensor is defined as:: @@ -514,10 +515,8 @@ tensor = | 0 Ayy' 0 |. | 0 0 Azz'| - The diagonalised alignment tensor is calculated using the tensor and the rotation matrix - through the equation:: - - R^T . tensor_diag . R. + The diagonalised alignment tensor is calculated by eigenvalue decomposition. + @param rotation: The rotation matrix. @type rotation: numpy array ((3, 3), float64) @@ -527,8 +526,28 @@ @rtype: numpy array ((3, 3), float64) """ - # Rotation (R^T . tensor_diag . R). - return dot(transpose(rotation), dot(tensor_diag, rotation)) + # The eigenvalues. + vals = eigvals(tensor) + + # Find the |x| < |y| < |z| indices. + abs_vals = abs(vals).tolist() + Axx_index = abs_vals.index(min(abs_vals)) + Azz_index = abs_vals.index(max(abs_vals)) + last_index = range(3) + last_index.pop(max(Axx_index, Azz_index)) + last_index.pop(min(Axx_index, Azz_index)) + Ayy_index = last_index[0] + + # Empty tensor. + tensor_diag = zeros((3, 3), float64) + + # Fill the elements. + tensor_diag[0, 0] = vals[Axx_index] + tensor_diag[1, 1] = vals[Ayy_index] + tensor_diag[2, 2] = vals[Azz_index] + + # Return the tensor. + return tensor_diag def dependency_generator(): @@ -561,10 +580,10 @@ yield ('Axx_unit', ['alpha', 'beta', 'gamma'], ['alpha', 'beta', 'gamma']) yield ('Ayy_unit', ['alpha', 'beta', 'gamma'], ['alpha', 'beta', 'gamma']) yield ('Azz_unit', ['alpha', 'beta'], ['alpha', 'beta']) - yield ('tensor_diag', ['Axx', 'Ayy', 'Axy', 'Axz', 'Ayz'], ['tensor', 'rotation']) yield ('rotation', ['alpha', 'beta', 'gamma'], ['Axx_unit', 'Ayy_unit', 'Azz_unit']) yield ('tensor', ['Axx', 'Ayy', 'Axy', 'Axz', 'Ayz'], ['Axx', 'Ayy', 'Azz', 'Axy', 'Axz', 'Ayz']) yield ('tensor_5D', ['Axx', 'Ayy', 'Axy', 'Axz', 'Ayz'], ['Axx', 'Ayy', 'Azz', 'Axy', 'Axz', 'Ayz']) + yield ('tensor_diag', ['Axx', 'Ayy', 'Axy', 'Axz', 'Ayz'], ['tensor']) Modified: branches/bmrb/prompt/molecule.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/prompt/molecule.py?rev=8899&r1=8898&r2=8899&view=diff ============================================================================== --- branches/bmrb/prompt/molecule.py (original) +++ branches/bmrb/prompt/molecule.py Wed Mar 4 11:39:09 2009 @@ -242,7 +242,7 @@ print text # Residue identification string. - if mol_id and type(mol_id) != str: + if mol_id != None and type(mol_id) != str: raise RelaxNoneStrError, ('molecule identification string', mol_id) # New molecule name. Modified: branches/bmrb/prompt/spin.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/prompt/spin.py?rev=8899&r1=8898&r2=8899&view=diff ============================================================================== --- branches/bmrb/prompt/spin.py (original) +++ branches/bmrb/prompt/spin.py Wed Mar 4 11:39:09 2009 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2007-2008 Edward d'Auvergne # +# Copyright (C) 2007-2009 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -30,7 +30,7 @@ # relax module imports. import help from generic_fns.mol_res_spin import copy_spin, create_spin, delete_spin, display_spin, id_string_doc, name_spin, number_spin -from relax_errors import RelaxIntError, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError +from relax_errors import RelaxNoneIntError, RelaxNoneStrError, RelaxStrError class Spin: @@ -157,8 +157,8 @@ print text # Spin number. - if type(spin_num) != int: - raise RelaxIntError, ('spin number', spin_num) + if spin_num != None and type(spin_num) != int: + raise RelaxNoneIntError, ('spin number', spin_num) # Spin name. if spin_name != None and type(spin_name) != str: Modified: branches/bmrb/test_suite/unit_tests/_prompt/test_molecule.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/test_suite/unit_tests/_prompt/test_molecule.py?rev=8899&r1=8898&r2=8899&view=diff ============================================================================== --- branches/bmrb/test_suite/unit_tests/_prompt/test_molecule.py (original) +++ branches/bmrb/test_suite/unit_tests/_prompt/test_molecule.py Wed Mar 4 11:39:09 2009 @@ -139,12 +139,12 @@ # Loop over the data types. for data in DATA_TYPES: - # Catch the str arguments, and skip them. - if data[0] == 'str': + # Catch the None and str arguments, and skip them. + if data[0] == 'None' or data[0] == 'str': continue # The argument test. - self.assertRaises(RelaxStrError, self.molecule_fns.name, mol_id=data[1]) + self.assertRaises(RelaxNoneStrError, self.molecule_fns.name, mol_id=data[1]) def test_name_argfail_name(self): Modified: branches/bmrb/test_suite/unit_tests/_prompt/test_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/test_suite/unit_tests/_prompt/test_spin.py?rev=8899&r1=8898&r2=8899&view=diff ============================================================================== --- branches/bmrb/test_suite/unit_tests/_prompt/test_spin.py (original) +++ branches/bmrb/test_suite/unit_tests/_prompt/test_spin.py Wed Mar 4 11:39:09 2009 @@ -98,11 +98,11 @@ # Loop over the data types. for data in DATA_TYPES: # Catch the int and bin arguments, and skip them. - if data[0] == 'int' or data[0] == 'bin': - continue - - # The argument test. - self.assertRaises(RelaxIntError, self.spin_fns.create, spin_num=data[1], spin_name='NH') + if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': + continue + + # The argument test. + self.assertRaises(RelaxNoneIntError, self.spin_fns.create, spin_num=data[1], spin_name='NH') def test_create_argfail_spin_name(self):