mailr17037 - /branches/interatomic/specific_fns/consistency_tests.py


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

Header


Content

Posted by edward on June 22, 2012 - 17:01:
Author: bugman
Date: Fri Jun 22 17:01:25 2012
New Revision: 17037

URL: http://svn.gna.org/viewcvs/relax?rev=17037&view=rev
Log:
Converted the consistency testing specific analysis code to the interatomic 
data design.


Modified:
    branches/interatomic/specific_fns/consistency_tests.py

Modified: branches/interatomic/specific_fns/consistency_tests.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/interatomic/specific_fns/consistency_tests.py?rev=17037&r1=17036&r2=17037&view=diff
==============================================================================
--- branches/interatomic/specific_fns/consistency_tests.py (original)
+++ branches/interatomic/specific_fns/consistency_tests.py Fri Jun 22 
17:01:25 2012
@@ -28,6 +28,7 @@
 # relax module imports.
 from api_base import API_base
 from api_common import API_common
+from generic_fns.interatomic import return_interatom
 from generic_fns.mol_res_spin import exists_mol_res_spin_data, return_spin, 
spin_loop
 from generic_fns import pipes
 from maths_fns.consistency_tests import Consistency
@@ -108,20 +109,20 @@
         if not exists_mol_res_spin_data():
             raise RelaxNoSequenceError
 
-        # Test if the CSA, bond length, angle Theta and correlation time 
values have been set.
-        for spin in spin_loop(spin_id):
+        # Test if the spin data has been set.
+        for spin, id in spin_loop(spin_id, return_id=True):
             # Skip deselected spins.
             if not spin.select:
                 continue
 
+            # Test if the nuclear isotope type has been set.
+            if not hasattr(spin, 'isotope'):
+                raise RelaxSpinTypeError
+
             # Test if the CSA value has been set.
             if not hasattr(spin, 'csa') or spin.csa == None:
                 raise RelaxNoValueError("CSA")
 
-            # Test if the bond length has been set.
-            if not hasattr(spin, 'r') or spin.r == None:
-                raise RelaxNoValueError("bond length")
-
             # Test if the angle Theta has been set.
             if not hasattr(spin, 'orientation') or spin.orientation == None:
                 raise RelaxNoValueError("angle Theta")
@@ -130,20 +131,34 @@
             if not hasattr(spin, 'tc') or spin.tc == None:
                 raise RelaxNoValueError("correlation time")
 
-            # Test if the spin type has been set.
-            if not hasattr(spin, 'heteronuc_type'):
-                raise RelaxSpinTypeError
-
-            # Test if the type attached proton has been set.
-            if not hasattr(spin, 'proton_type'):
-                raise RelaxProtonTypeError
+            # Test the interatomic data.
+            interatoms = return_interatom(id)
+            for interatom in interatoms:
+                # No relaxation mechanism.
+                if not interatom.dipole_pair:
+                    continue
+
+                # The interacting spin.
+                if id != interatom.spin_id1:
+                    spin_id2 = interatom.spin_id1
+                else:
+                    spin_id2 = interatom.spin_id2
+                spin2 = return_spin(spin_id2)
+
+                # Test if the nuclear isotope type has been set.
+                if not hasattr(spin2, 'isotope'):
+                    raise RelaxSpinTypeError
+
+                # Test if the interatomic distance has been set.
+                if not hasattr(interatom, 'r') or interatom.r == None:
+                    raise RelaxNoValueError("interatomic distance", 
spin_id=spin_id, spin_id2=spin_id2)
 
         # Frequency index.
         if cdp.ct_frq not in cdp.frq.values():
             raise RelaxError("No relaxation data corresponding to the 
frequency %s has been loaded." % cdp.ct_frq)
 
         # Consistency testing.
-        for spin in spin_loop(spin_id):
+        for spin, id in spin_loop(spin_id, return_id=True):
             # Skip deselected spins.
             if not spin.select:
                 continue
@@ -184,11 +199,32 @@
             if r1 == None or r2 == None or noe == None:
                 continue
 
+            # Loop over the interatomic data.
+            interatoms = return_interatom(id)
+            for i in range(len(interatoms)):
+                # No relaxation mechanism.
+                if not interatoms[i].dipole_pair:
+                    continue
+
+                # The surrounding spins.
+                if id != interatoms[i].spin_id1:
+                    spin_id2 = interatoms[i].spin_id1
+                else:
+                    spin_id2 = interatoms[i].spin_id2
+                spin2 = return_spin(spin_id2)
+
+                # Gyromagnetic ratios.
+                gx = return_gyromagnetic_ratio(spin.isotope)
+                gh = return_gyromagnetic_ratio(spin2.isotope)
+
+                # The interatomic distance.
+                r = interatoms[i].r
+
             # Initialise the function to calculate.
-            self.ct = Consistency(frq=cdp.ct_frq, 
gx=return_gyromagnetic_ratio(spin.heteronuc_type), 
gh=return_gyromagnetic_ratio(spin.proton_type), mu0=mu0, h_bar=h_bar)
+            self.ct = Consistency(frq=cdp.ct_frq, gx=gx, gh=gh, mu0=mu0, 
h_bar=h_bar)
 
             # Calculate the consistency tests values.
-            j0, f_eta, f_r2 = self.ct.func(orientation=spin.orientation, 
tc=spin.tc, r=spin.r, csa=spin.csa, r1=r1, r2=r2, noe=noe)
+            j0, f_eta, f_r2 = self.ct.func(orientation=spin.orientation, 
tc=spin.tc, r=r, csa=spin.csa, r1=r1, r2=r2, noe=noe)
 
             # Consistency tests values.
             if sim_index == None:
@@ -211,7 +247,6 @@
                 spin.f_r2_sim.append(f_r2)
 
 
-
     def data_init(self, data_cont, sim=False):
         """Initialise the data structures.
 




Related Messages


Powered by MHonArc, Updated Fri Jun 22 17:20:02 2012