def test_compile_2nd_matrix_pseudo_ellipse_free_rotor_point1(self): """Check the operation of the compile_2nd_matrix_pseudo_ellipse_free_rotor() function.""" # The simulated out of frame free rotor pseudo-ellipse 2nd degree frame order matrix (1e6 ensembles). real = array( [[ 0.3428, -0.0193, 0.0389, -0.0193, 0.3137, -0.0194, 0.0389, -0.0194, 0.3435], [ -0.0225, 0.2313, 0.0034, -0.1413, 0.0449, 0.2309, -0.1830, -0.1412, -0.0224], [ 0.0417, 0.0091, 0.2142, -0.1767, -0.0838, 0.0092, 0.1211, -0.1770, 0.0421], [ -0.0225, -0.1413, -0.1830, 0.2313, 0.0449, -0.1412, 0.0034, 0.2309, -0.0224], [ 0.3124, 0.0418, -0.0840, 0.0418, 0.3758, 0.0418, -0.0840, 0.0418, 0.3118], [ -0.0193, 0.2251, 0.0151, -0.1476, 0.0389, 0.2251, -0.1706, -0.1468, -0.0196], [ 0.0417, -0.1767, 0.1211, 0.0091, -0.0838, -0.1770, 0.2142, 0.0092, 0.0421], [ -0.0193, -0.1476, -0.1706, 0.2251, 0.0389, -0.1468, 0.0151, 0.2251, -0.0196], [ 0.3448, -0.0225, 0.0450, -0.0225, 0.3104, -0.0224, 0.0450, -0.0224, 0.3447]], float64) # Init. x = pi/4.0 y = 50.0 / 360.0 * 2.0 * pi # The Kronecker product of the eigenframe rotation. Rx2_eigen = self.calc_Rx2_eigen_full(self.out_of_frame_alpha, self.out_of_frame_beta, self.out_of_frame_gamma) # Calculate the matrix. f2 = compile_2nd_matrix_pseudo_ellipse_free_rotor(self.f2_temp, Rx2_eigen, x, y) # 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." % (i, j)) self.assert_(abs(f2[i, j] - real[i, j]) < 1e-3)
def test_compile_2nd_matrix_pseudo_ellipse_free_rotor_point2(self): """Check the operation of the compile_2nd_matrix_pseudo_ellipse_free_rotor() function.""" # The simulated out of frame free rotor pseudo-ellipse 2nd degree frame order matrix (1e6 ensembles). real = array( [[ 0.3251, 0.0163, -0.0324, 0.0163, 0.3493, 0.0164, -0.0324, 0.0164, 0.3256], [ -0.0248, 0.1481, -0.0480, -0.0500, 0.0492, 0.1475, -0.1472, -0.0500, -0.0244], [ 0.0079, 0.0328, 0.0572, -0.0661, -0.0163, 0.0331, 0.0074, -0.0662, 0.0084], [ -0.0248, -0.0500, -0.1472, 0.1481, 0.0492, -0.0500, -0.0480, 0.1475, -0.0244], [ 0.3289, 0.0081, -0.0167, 0.0081, 0.3426, 0.0080, -0.0167, 0.0080, 0.3285], [ 0.0163, 0.0669, 0.1139, -0.1322, -0.0324, 0.0662, 0.0157, -0.1307, 0.0161], [ 0.0079, -0.0661, 0.0074, 0.0328, -0.0163, -0.0662, 0.0572, 0.0331, 0.0084], [ 0.0163, -0.1322, 0.0157, 0.0669, -0.0324, -0.1307, 0.1139, 0.0662, 0.0161], [ 0.3459, -0.0245, 0.0491, -0.0245, 0.3081, -0.0244, 0.0491, -0.0244, 0.3460]], float64) # Init. x = pi / 4.0 y = 150.0 / 360.0 * 2.0 * pi # The Kronecker product of the eigenframe rotation. Rx2_eigen = self.calc_Rx2_eigen_full(self.out_of_frame_alpha, self.out_of_frame_beta, self.out_of_frame_gamma) # Calculate the matrix. f2 = compile_2nd_matrix_pseudo_ellipse_free_rotor(self.f2_temp, Rx2_eigen, x, y) # 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." % (i, j)) self.assert_(abs(f2[i, j] - real[i, j]) < 1e-2)
def fixme_test_compile_2nd_matrix_pseudo_ellipse_free_rotor_order(self): """Check if compile_2nd_matrix_pseudo_ellipse_free_rotor() can return the identity matrix for order.""" # The Kronecker product of the eigenframe rotation. Rx2_eigen = self.calc_Rx2_eigen_full(0.0, 0.0, 0.0) # Calculate the frame order matrix. f2 = compile_2nd_matrix_pseudo_ellipse_free_rotor(self.f2_temp, Rx2_eigen, 1e-10, 1e-10) # Print outs. print_frame_order_2nd_degree(self.I_order_free_rotor, "Free rotor identity for order") print_frame_order_2nd_degree(f2, "Compiled frame order") # Check the values. for i in range(9): for j in range(9): print("Element %s, %s." % (i, j)) self.assertAlmostEqual(f2[i, j], self.I_order_free_rotor[i, j])
def test_compile_2nd_matrix_pseudo_ellipse_free_rotor_half_cone_90_y(self): """Check if compile_2nd_matrix_pseudo_ellipse() can return the matrix for a half cone rotated 90 degrees about y.""" # The Kronecker product of the eigenframe rotation. Rx2_eigen = self.calc_Rx2_eigen_full(pi, pi/2.0, pi) # Calculate the frame order matrix (rotated about z by 2pi). f2 = compile_2nd_matrix_pseudo_ellipse_free_rotor(self.f2_temp, Rx2_eigen, pi/2.0, pi/2.0) # Print outs. print_frame_order_2nd_degree(self.f2_half_cone_90_y, "The half cone frame order matrix") print_frame_order_2nd_degree(f2, "Compiled frame order") # Check the values. for i in range(9): for j in range(9): print("Element %s, %s." % (i, j)) self.assertAlmostEqual(f2[i, j], self.f2_half_cone_90_y[i, j])
def test_compile_2nd_matrix_pseudo_ellipse_free_rotor_restriction_test(self): """Check if compile_2nd_matrix_pseudo_ellipse_free_rotor() can approximate compile_2nd_matrix_iso_cone_free_rotor().""" # The Kronecker product of the eigenframe rotation. Rx2_eigen_a = self.calc_Rx2_eigen_full(0.0, 0.0, 0.0) Rx2_eigen_b = self.calc_Rx2_eigen_axis(0.0, 1.0) # Calculate the frame order matrix. f2a = compile_2nd_matrix_pseudo_ellipse_free_rotor(self.f2_temp, Rx2_eigen_a, pi/4.6, pi/4.6) f2b = compile_2nd_matrix_iso_cone_free_rotor(self.f2_temp, Rx2_eigen_b, pi/4.6) # Print outs. print_frame_order_2nd_degree(f2a, "Free rotor pseudo-ellipse frame order") print_frame_order_2nd_degree(f2b, "Free rotor isotropic cone frame order") print_frame_order_2nd_degree(f2b-f2a, "difference") # Check the values. for i in range(9): for j in range(9): print("Element %s, %s." % (i, j)) self.assertAlmostEqual(f2a[i, j], f2b[i, j])
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)