def test_compile_2nd_matrix_free_rotor_point2(self): """Check the operation of the compile_2nd_matrix_free_rotor() function.""" # The simulated free rotor 2nd degree frame order matrix (1e6 ensembles, axis=[2,1,3]). real = array( [[ 0.3367, -0.0100, -0.0307, -0.0100, 0.3521, -0.0152, -0.0307, -0.0152, 0.3112], [ -0.0104, 0.3520, -0.0152, -0.2908, -0.0559, 0.2602, 0.1989, -0.1685, 0.0664], [ -0.0306, -0.0155, 0.3112, 0.1991, -0.1683, 0.0666, 0.2399, 0.2092, 0.1989], [ -0.0104, -0.2908, 0.1989, 0.3520, -0.0559, -0.1685, -0.0152, 0.2602, 0.0664], [ 0.3520, -0.0563, -0.1684, -0.0563, 0.4362, -0.0841, -0.1684, -0.0841, 0.2118], [ -0.0153, 0.2602, 0.0661, -0.1684, -0.0844, 0.2117, 0.2093, -0.0740, 0.0997], [ -0.0306, 0.1991, 0.2399, -0.0155, -0.1683, 0.2092, 0.3112, 0.0666, 0.1989], [ -0.0153, -0.1684, 0.2093, 0.2602, -0.0844, -0.0740, 0.0661, 0.2117, 0.0997], [ 0.3113, 0.0663, 0.1991, 0.0663, 0.2117, 0.0993, 0.1991, 0.0993, 0.4770]]) # The cone axis. r, theta, phi = cartesian_to_spherical([2, 1, 3]) # The Kronecker product of the eigenframe rotation. Rx2_eigen = self.calc_Rx2_eigen_axis(theta, phi) # Calculate the matrix. f2 = compile_2nd_matrix_free_rotor(self.f2_temp, Rx2_eigen) # Print out. print_frame_order_2nd_degree(real, "real") print_frame_order_2nd_degree(f2, "calculated") print_frame_order_2nd_degree(real-f2, "difference") # Check the values. for i in range(9): for j in range(9): print("Element %s, %s; diff %s." % (i, j, f2[i, j] - real[i, j])) self.assert_(abs(f2[i, j] - real[i, j]) < 1e-3)
def test_compile_2nd_matrix_free_rotor_point1(self): """Check the operation of the compile_2nd_matrix_free_rotor() function.""" # The simulated in frame free rotor 2nd degree frame order matrix (1e6 ensembles). real = array( [[ 0.5001, 0.0001, 0, 0.0001, 0.4999, 0, 0, 0, 0], [ -0.0001, 0.5001, 0, -0.4999, 0.0001, 0, 0, 0, 0], [ 0, 0, 0.0006, 0, 0, -0.0005, 0, 0, 0], [ -0.0001, -0.4999, 0, 0.5001, 0.0001, 0, 0, 0, 0], [ 0.4999, -0.0001, 0, -0.0001, 0.5001, 0, 0, 0, 0], [ 0, 0, 0.0005, 0, 0, 0.0006, 0, 0, 0], [ 0, 0, 0, 0, 0, 0, 0.0006, -0.0005, 0], [ 0, 0, 0, 0, 0, 0, 0.0005, 0.0006, 0], [ 0, 0, 0, 0, 0, 0, 0, 0, 1.0000]]) # The Kronecker product of the eigenframe rotation. Rx2_eigen = self.calc_Rx2_eigen_axis(0.0, 0.0) # Calculate the matrix. f2 = compile_2nd_matrix_free_rotor(self.f2_temp, Rx2_eigen) # Print out. print_frame_order_2nd_degree(real, "real") print_frame_order_2nd_degree(f2, "calculated") print_frame_order_2nd_degree(real-f2, "difference") # Check the values. for i in range(9): for j in range(9): print("Element %s, %s; diff %s." % (i, j, f2[i, j] - real[i, j])) self.assert_(abs(f2[i, j] - real[i, j]) < 1e-3)
def __init__(self): """Calculate the frame order at infinity. This is when the starting positions are random. """ # Loop over the models. for model_index in range(len(MODELS)): # Aliases. model = MODELS[model_index] model_text = MODEL_TEXT[model_index] # Loop over the tags. for tag in TAGS: # Set up the variables to loop over. if model in ['rotor', 'free_rotor']: vars = ['Z'] elif model in ['iso_cone_free_rotor', 'iso_cone_torsionless']: vars = ['X'] elif model in ['iso_cone']: vars = ['X', 'Z'] elif model in ['double_rotor', 'pseudo-ellipse_free_rotor', 'pseudo-ellipse_torsionless']: vars = ['X', 'Y'] elif model in ['pseudo-ellipse']: vars = ['X', 'Y', 'Z'] else: raise RelaxError("Unknown model '%s'." % model) # Loop over the variables. for var in vars: # The file name. file_name = '_%s_%s_theta_%s_calc.agr' % (model, tag, lower(var)) print("Creating the '*%s' files." % file_name) # Set up the eigenframe. self.setup_eigenframe(tag=tag) # The Kronecker product of the eigenframe rotation. Rx2_eigen = kron_prod(self.eigenframe, self.eigenframe) # Set the initial storage structures. self.init_storage() # Loop over the angle incs. for i in range(INC+1): # Get the angle for the increment. theta = self.get_angle(i-1, model=model, var=var) # Vary X. if var == 'X': theta_x = theta theta_y = THETA_Y theta_z = THETA_Z # Vary Y. elif var == 'Y': theta_x = THETA_X theta_y = theta theta_z = THETA_Z # Vary Z. elif var == 'Z': theta_x = THETA_X theta_y = THETA_Y theta_z = theta # Calculate the frame order matrices. if model == 'rotor': self.first_frame_order[i] = rotor.compile_1st_matrix_rotor(self.first_frame_order[i], self.eigenframe, theta_z) self.second_frame_order[i] = rotor.compile_2nd_matrix_rotor(self.second_frame_order[i], Rx2_eigen, theta_z) elif model == 'free_rotor': self.first_frame_order[i] = free_rotor.compile_1st_matrix_free_rotor(self.first_frame_order[i], self.eigenframe) self.second_frame_order[i] = free_rotor.compile_2nd_matrix_free_rotor(self.second_frame_order[i], Rx2_eigen) elif model == 'iso_cone': self.first_frame_order[i] = iso_cone.compile_1st_matrix_iso_cone(self.first_frame_order[i], self.eigenframe, theta_x, theta_z) self.second_frame_order[i] = iso_cone.compile_2nd_matrix_iso_cone(self.second_frame_order[i], Rx2_eigen, theta_x, theta_z) elif model == 'iso_cone_free_rotor': self.first_frame_order[i] = iso_cone_free_rotor.compile_1st_matrix_iso_cone_free_rotor(self.first_frame_order[i], self.eigenframe, theta_x) self.second_frame_order[i] = iso_cone_free_rotor.compile_2nd_matrix_iso_cone_free_rotor(self.second_frame_order[i], Rx2_eigen, theta_x) elif model == 'iso_cone_torsionless': self.first_frame_order[i] = iso_cone_torsionless.compile_1st_matrix_iso_cone_torsionless(self.first_frame_order[i], self.eigenframe, theta_x) self.second_frame_order[i] = iso_cone_torsionless.compile_2nd_matrix_iso_cone_torsionless(self.second_frame_order[i], Rx2_eigen, theta_x) elif model == 'pseudo-ellipse': self.first_frame_order[i] = pseudo_ellipse.compile_1st_matrix_pseudo_ellipse(self.first_frame_order[i], self.eigenframe, theta_x, theta_y, theta_z) self.second_frame_order[i] = pseudo_ellipse.compile_2nd_matrix_pseudo_ellipse(self.second_frame_order[i], Rx2_eigen, theta_x, theta_y, theta_z) elif model == 'pseudo-ellipse_free_rotor': self.first_frame_order[i] = pseudo_ellipse_free_rotor.compile_1st_matrix_pseudo_ellipse_free_rotor(self.first_frame_order[i], self.eigenframe, theta_x, theta_y) self.second_frame_order[i] = pseudo_ellipse_free_rotor.compile_2nd_matrix_pseudo_ellipse_free_rotor(self.second_frame_order[i], Rx2_eigen, theta_x, theta_y) elif model == 'pseudo-ellipse_torsionless': self.first_frame_order[i] = pseudo_ellipse_torsionless.compile_1st_matrix_pseudo_ellipse_torsionless(self.first_frame_order[i], self.eigenframe, theta_x, theta_y) self.second_frame_order[i] = pseudo_ellipse_torsionless.compile_2nd_matrix_pseudo_ellipse_torsionless(self.second_frame_order[i], Rx2_eigen, theta_x, theta_y) elif model == 'double_rotor': self.first_frame_order[i] = double_rotor.compile_1st_matrix_double_rotor(self.first_frame_order[i], self.eigenframe, theta_y, theta_x) self.second_frame_order[i] = double_rotor.compile_2nd_matrix_double_rotor(self.second_frame_order[i], Rx2_eigen, theta_y, theta_x) else: raise RelaxError("Unknown model '%s'." % model) # Write the data. self.write_data(file_name=file_name, model=model, model_text=model_text, var=var)
def __init__(self): """Calculate the frame order at infinity. This is when the starting positions are random. """ # Loop over the models. for model_index in range(len(MODELS)): # Aliases. model = MODELS[model_index] model_text = MODEL_TEXT[model_index] # Loop over the tags. for tag in TAGS: # Set up the variables to loop over. if model in ['rotor', 'free_rotor']: vars = ['Z'] elif model in ['iso_cone_free_rotor', 'iso_cone_torsionless']: vars = ['X'] elif model in ['iso_cone']: vars = ['X', 'Z'] elif model in [ 'double_rotor', 'pseudo-ellipse_free_rotor', 'pseudo-ellipse_torsionless' ]: vars = ['X', 'Y'] elif model in ['pseudo-ellipse']: vars = ['X', 'Y', 'Z'] else: raise RelaxError("Unknown model '%s'." % model) # Loop over the variables. for var in vars: # The file name. file_name = '_%s_%s_theta_%s_calc.agr' % (model, tag, lower(var)) print("Creating the '*%s' files." % file_name) # Set up the eigenframe. self.setup_eigenframe(tag=tag) # The Kronecker product of the eigenframe rotation. Rx2_eigen = kron_prod(self.eigenframe, self.eigenframe) # Set the initial storage structures. self.init_storage() # Loop over the angle incs. for i in range(INC + 1): # Get the angle for the increment. theta = self.get_angle(i - 1, model=model, var=var) # Vary X. if var == 'X': theta_x = theta theta_y = THETA_Y theta_z = THETA_Z # Vary Y. elif var == 'Y': theta_x = THETA_X theta_y = theta theta_z = THETA_Z # Vary Z. elif var == 'Z': theta_x = THETA_X theta_y = THETA_Y theta_z = theta # Calculate the frame order matrices. if model == 'rotor': self.first_frame_order[ i] = rotor.compile_1st_matrix_rotor( self.first_frame_order[i], self.eigenframe, theta_z) self.second_frame_order[ i] = rotor.compile_2nd_matrix_rotor( self.second_frame_order[i], Rx2_eigen, theta_z) elif model == 'free_rotor': self.first_frame_order[ i] = free_rotor.compile_1st_matrix_free_rotor( self.first_frame_order[i], self.eigenframe) self.second_frame_order[ i] = free_rotor.compile_2nd_matrix_free_rotor( self.second_frame_order[i], Rx2_eigen) elif model == 'iso_cone': self.first_frame_order[ i] = iso_cone.compile_1st_matrix_iso_cone( self.first_frame_order[i], self.eigenframe, theta_x, theta_z) self.second_frame_order[ i] = iso_cone.compile_2nd_matrix_iso_cone( self.second_frame_order[i], Rx2_eigen, theta_x, theta_z) elif model == 'iso_cone_free_rotor': self.first_frame_order[ i] = iso_cone_free_rotor.compile_1st_matrix_iso_cone_free_rotor( self.first_frame_order[i], self.eigenframe, theta_x) self.second_frame_order[ i] = iso_cone_free_rotor.compile_2nd_matrix_iso_cone_free_rotor( self.second_frame_order[i], Rx2_eigen, theta_x) elif model == 'iso_cone_torsionless': self.first_frame_order[ i] = iso_cone_torsionless.compile_1st_matrix_iso_cone_torsionless( self.first_frame_order[i], self.eigenframe, theta_x) self.second_frame_order[ i] = iso_cone_torsionless.compile_2nd_matrix_iso_cone_torsionless( self.second_frame_order[i], Rx2_eigen, theta_x) elif model == 'pseudo-ellipse': self.first_frame_order[ i] = pseudo_ellipse.compile_1st_matrix_pseudo_ellipse( self.first_frame_order[i], self.eigenframe, theta_x, theta_y, theta_z) self.second_frame_order[ i] = pseudo_ellipse.compile_2nd_matrix_pseudo_ellipse( self.second_frame_order[i], Rx2_eigen, theta_x, theta_y, theta_z) elif model == 'pseudo-ellipse_free_rotor': self.first_frame_order[ i] = pseudo_ellipse_free_rotor.compile_1st_matrix_pseudo_ellipse_free_rotor( self.first_frame_order[i], self.eigenframe, theta_x, theta_y) self.second_frame_order[ i] = pseudo_ellipse_free_rotor.compile_2nd_matrix_pseudo_ellipse_free_rotor( self.second_frame_order[i], Rx2_eigen, theta_x, theta_y) elif model == 'pseudo-ellipse_torsionless': self.first_frame_order[ i] = pseudo_ellipse_torsionless.compile_1st_matrix_pseudo_ellipse_torsionless( self.first_frame_order[i], self.eigenframe, theta_x, theta_y) self.second_frame_order[ i] = pseudo_ellipse_torsionless.compile_2nd_matrix_pseudo_ellipse_torsionless( self.second_frame_order[i], Rx2_eigen, theta_x, theta_y) elif model == 'double_rotor': self.first_frame_order[ i] = double_rotor.compile_1st_matrix_double_rotor( self.first_frame_order[i], self.eigenframe, theta_y, theta_x) self.second_frame_order[ i] = double_rotor.compile_2nd_matrix_double_rotor( self.second_frame_order[i], Rx2_eigen, theta_y, theta_x) else: raise RelaxError("Unknown model '%s'." % model) # Write the data. self.write_data(file_name=file_name, model=model, model_text=model_text, var=var)