mailr3006 - /1.3/test_suite/unit_tests/data/test_diff_tensor.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 13, 2007 - 13:21:
Author: bugman
Date: Sat Jan 13 13:20:29 2007
New Revision: 3006

URL: http://svn.gna.org/viewcvs/relax?rev=3006&view=rev
Log:
Added the diffusion tensor data structure unit test 'test_set_prolate_params'.

This test checks that all the parameters, vectors, and matrices associated 
with the prolate
spheroidal diffusion tensor are set up correctly.


Modified:
    1.3/test_suite/unit_tests/data/test_diff_tensor.py

Modified: 1.3/test_suite/unit_tests/data/test_diff_tensor.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/data/test_diff_tensor.py?rev=3006&r1=3005&r2=3006&view=diff
==============================================================================
--- 1.3/test_suite/unit_tests/data/test_diff_tensor.py (original)
+++ 1.3/test_suite/unit_tests/data/test_diff_tensor.py Sat Jan 13 13:20:29 
2007
@@ -22,6 +22,8 @@
 #                                                                            
 #
 
###############################################################################
 
+from math import cos, pi, sin
+from Numeric import array, dot, transpose
 from os.path import join, sep
 from string import split
 from sys import path
@@ -43,6 +45,70 @@
         self.diff_data = DiffTensorElement()
 
 
+    def test_set_prolate_params(self):
+        """Test the setting of prolate diffusion tensor parameters.
+        
+        The following parameters will be set:
+            tm: 20 ns
+            Da: 2e6
+            theta: 60 degrees
+            phi: 290 degrees
+        """
+
+        # The parameter values.
+        tm = 2e-8
+        Da = 2e6
+        theta = (60 / 360.0) * 2.0 * pi
+        phi = (290 / 360.0) * 2.0 * pi
+        Diso = 1/(6*tm)
+        Dpar = Diso + 2.0/3.0 * Da
+        Dper = Diso - 1.0/3.0 * Da
+        Dratio = Dpar / Dper
+
+        # Vectors.
+        Dpar_unit = array([sin(theta) * cos(phi), sin(theta) * sin(phi), 
cos(theta)])
+
+        # Matrices.
+        tensor_diag = array([[ Dper,  0.0,  0.0],
+                             [  0.0, Dper,  0.0],
+                             [  0.0,  0.0, Dpar]])
+        rotation = array([[ cos(theta) * cos(phi), -sin(phi), sin(theta) * 
cos(phi) ],
+                          [ cos(theta) * sin(phi),  cos(phi), sin(theta) * 
sin(phi) ],
+                          [           -sin(theta),       0.0,            
cos(theta) ]])
+        tensor = dot(rotation, dot(tensor_diag, transpose(rotation)))
+
+
+        # Set the diffusion type.
+        self.diff_data.type = 'spheroid'
+
+        # Set the diffusion parameters.
+        self.diff_data.tm = tm
+        self.diff_data.Da = Da
+        self.diff_data.theta = theta
+        self.diff_data.phi = phi
+
+        # Test the set values.
+        self.assertEqual(self.diff_data.type, 'spheroid')
+        self.assertEqual(self.diff_data.tm, tm)
+        self.assertEqual(self.diff_data.Da, Da)
+        self.assertEqual(self.diff_data.theta, theta)
+        self.assertEqual(self.diff_data.phi, phi)
+
+        # Test the automatically created values.
+        self.assertEqual(self.diff_data.Diso, Diso)
+        self.assertEqual(self.diff_data.Dpar, Dpar)
+        self.assertEqual(self.diff_data.Dper, Dper)
+        self.assertEqual(self.diff_data.Dratio, Dratio)
+
+        # Test the vectors.
+        self.assertEqual(self.diff_data.Dpar_unit.tostring(), 
Dpar_unit.tostring())
+
+        # Test the matrices.
+        self.assertEqual(self.diff_data.tensor_diag.tostring(), 
tensor_diag.tostring())
+        self.assertEqual(self.diff_data.rotation.tostring(), 
rotation.tostring())
+        self.assertEqual(self.diff_data.tensor.tostring(), tensor.tostring())
+
+
     def test_set_Diso(self):
         """Test that the Diso parameter cannot be set."""
 
@@ -56,7 +122,8 @@
     def test_set_tm(self):
         """Test the setting of the tm parameter.
         
-        The setting of the tm parameter should automatically create the Diso 
parameter.
+        The tm parameter will be set to 10 ns.  The setting of tm should 
automatically create the
+        Diso parameter.
         """
 
         # Set the tm value to 10 ns.




Related Messages


Powered by MHonArc, Updated Sat Jan 13 13:40:05 2007