Author: bugman Date: Tue Mar 5 11:33:43 2013 New Revision: 18631 URL: http://svn.gna.org/viewcvs/relax?rev=18631&view=rev Log: The frame order optimisation can now handle both types of pivot for the average position rotation. This allows the frame_order.average_position user function to be fully active. Modified: branches/frame_order_testing/maths_fns/frame_order/__init__.py branches/frame_order_testing/specific_fns/frame_order.py Modified: branches/frame_order_testing/maths_fns/frame_order/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/maths_fns/frame_order/__init__.py?rev=18631&r1=18630&r2=18631&view=diff ============================================================================== --- branches/frame_order_testing/maths_fns/frame_order/__init__.py (original) +++ branches/frame_order_testing/maths_fns/frame_order/__init__.py Tue Mar 5 11:33:43 2013 @@ -61,7 +61,7 @@ class Frame_order: """Class containing the target function of the optimisation of Frame Order matrix components.""" - def __init__(self, model=None, init_params=None, full_tensors=None, full_in_ref_frame=None, rdcs=None, rdc_errors=None, rdc_weights=None, rdc_vect=None, dip_const=None, pcs=None, pcs_errors=None, pcs_weights=None, atomic_pos=None, temp=None, frq=None, paramag_centre=zeros(3), scaling_matrix=None, num_int_pts=500, centroid=zeros(3), translation_opt=False, pivot=zeros(3), pivot_opt=False, quad_int=True): + def __init__(self, model=None, init_params=None, full_tensors=None, full_in_ref_frame=None, rdcs=None, rdc_errors=None, rdc_weights=None, rdc_vect=None, dip_const=None, pcs=None, pcs_errors=None, pcs_weights=None, atomic_pos=None, temp=None, frq=None, paramag_centre=zeros(3), scaling_matrix=None, num_int_pts=500, ave_pos_pivot=zeros(3), ave_pos_piv_sync=True, translation_opt=False, pivot=zeros(3), pivot_opt=False, quad_int=True): """Set up the target functions for the Frame Order theories. @keyword model: The name of the Frame Order model. @@ -100,8 +100,10 @@ @type scaling_matrix: numpy rank-2 array @keyword num_int_pts: The number of points to use for the numerical integration technique. @type num_int_pts: int - @keyword centroid: The central position to rotate all atoms about. For example this can be the centre of mass of the moving domain. - @type centroid: numpy 3D rank-1 array + @keyword ave_pos_pivot: The pivot point to rotate all atoms about to the average domain position. For example this can be the centre of mass of the moving domain. + @type ave_pos_pivot: numpy 3D rank-1 array + @keyword ave_pos_piv_sync: A flag which if True will cause pivot point to rotate to the average domain position to be synchronised with the motional pivot. This will cause ave_pos_pivot argument to be ignored. + @type ave_pos_piv_sync: bool @keyword translation_opt: A flag which if True will allow the pivot point of the motion to be optimised. @type translation_opt: bool @keyword pivot: The pivot point for the ball-and-socket joint motion. This is needed if PCS or PRE values are used. @@ -135,7 +137,8 @@ self.paramag_centre = paramag_centre self.total_num_params = len(init_params) self.num_int_pts = num_int_pts - self.centroid = centroid + self.ave_pos_pivot = ave_pos_pivot + self.ave_pos_piv_sync = ave_pos_piv_sync self.translation_opt = translation_opt self._param_pivot = pivot self.pivot_opt = pivot_opt @@ -1891,6 +1894,12 @@ @type RT_ave: numpy rank-2, 3D array """ + # The rotational pivot. + if self.ave_pos_piv_sync: + ave_pos_pivot = self._param_pivot + else: + ave_pos_pivot = self.ave_pos_pivot + # The pivot to atom vectors. for j in range(self.num_spins): # The lanthanide to pivot vector. @@ -1898,10 +1907,10 @@ self.r_ln_pivot[:, j] = pivot - self.paramag_centre # Rotate then translate the atomic positions, then calculate the pivot to atom vector. - self.r_pivot_atom[:, j] = dot(R_ave, self.atomic_pos[j] - self.centroid) + self.centroid + self.r_pivot_atom[:, j] = dot(R_ave, self.atomic_pos[j] - ave_pos_pivot) + ave_pos_pivot self.r_pivot_atom[:, j] += self._translation_vector self.r_pivot_atom[:, j] -= pivot - self.r_pivot_atom_rev[:, j] = dot(RT_ave, self.atomic_pos[j] - self.centroid) + self.centroid + self.r_pivot_atom_rev[:, j] = dot(RT_ave, self.atomic_pos[j] - ave_pos_pivot) + ave_pos_pivot self.r_pivot_atom_rev[:, j] += self._translation_vector self.r_pivot_atom_rev[:, j] -= pivot Modified: branches/frame_order_testing/specific_fns/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/specific_fns/frame_order.py?rev=18631&r1=18630&r2=18631&view=diff ============================================================================== --- branches/frame_order_testing/specific_fns/frame_order.py (original) +++ branches/frame_order_testing/specific_fns/frame_order.py Tue Mar 5 11:33:43 2013 @@ -1372,6 +1372,10 @@ @type scaling: bool """ + # Check for the average domain displacement information. + if not hasattr(cdp, 'ave_pos_pivot') or not hasattr(cdp, 'ave_pos_translation'): + raise RelaxError("The mechanics of the displacement to the average domain position have not been set up.") + # Assemble the parameter vector. param_vector = self._assemble_param_vector(sim_index=sim_index) @@ -1408,9 +1412,6 @@ if 'pcs' in data_types or 'pre' in data_types: atomic_pos, paramag_centre = self._minimise_setup_atomic_pos(sim_index=sim_index) - # The centre of mass of the moving domain - to use as the centroid for the average domain position rotation. - com = centre_of_mass(atom_id=self._domain_moving(), verbosity=0) - # Average domain translation. translation_opt = False if not self._translation_fixed(): @@ -1429,6 +1430,16 @@ # The number of integration points. if not hasattr(cdp, 'num_int_pts'): cdp.num_int_pts = 200000 + + # The centre of mass of the moving domain - to use as the centroid for the average domain position rotation. + if cdp.ave_pos_pivot == 'com': + com = centre_of_mass(atom_id=self._domain_moving(), verbosity=0) + ave_pos_piv_sync = False + + # The centre of mass of the moving domain - to use as the centroid for the average domain position rotation. + if cdp.ave_pos_pivot == 'motional': + com = pivot + ave_pos_piv_sync = True # Print outs. if sim_index == None: @@ -1445,7 +1456,7 @@ sys.stdout.write("Base data: %s\n" % repr(base_data)) # Set up the optimisation function. - target = frame_order.Frame_order(model=cdp.model, init_params=param_vector, full_tensors=full_tensors, full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_errors=rdc_err, rdc_weights=rdc_weight, rdc_vect=rdc_vect, dip_const=rdc_const, pcs=pcs, pcs_errors=pcs_err, pcs_weights=pcs_weight, atomic_pos=atomic_pos, temp=temp, frq=frq, paramag_centre=paramag_centre, scaling_matrix=scaling_matrix, centroid=com, translation_opt=translation_opt, pivot=pivot, pivot_opt=pivot_opt, num_int_pts=cdp.num_int_pts, quad_int=cdp.quad_int) + target = frame_order.Frame_order(model=cdp.model, init_params=param_vector, full_tensors=full_tensors, full_in_ref_frame=full_in_ref_frame, rdcs=rdcs, rdc_errors=rdc_err, rdc_weights=rdc_weight, rdc_vect=rdc_vect, dip_const=rdc_const, pcs=pcs, pcs_errors=pcs_err, pcs_weights=pcs_weight, atomic_pos=atomic_pos, temp=temp, frq=frq, paramag_centre=paramag_centre, scaling_matrix=scaling_matrix, ave_pos_pivot=com, ave_pos_piv_sync=ave_pos_piv_sync, translation_opt=translation_opt, pivot=pivot, pivot_opt=pivot_opt, num_int_pts=cdp.num_int_pts, quad_int=cdp.quad_int) # Return the data. return target, param_vector, data_types, scaling_matrix