def compile_1st_matrix_pseudo_ellipse(matrix, R_eigen, theta_x, theta_y, sigma_max): """Generate the 1st degree Frame Order matrix for the pseudo-ellipse. @param matrix: The Frame Order matrix, 1st degree to be populated. @type matrix: numpy 3D, rank-2 array @param R_eigen: The eigenframe rotation matrix. @type R_eigen: numpy 3D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float @param sigma_max: The maximum torsion angle. @type sigma_max: float """ # The surface area normalisation factor. fact = 2.0 * pec(theta_x, theta_y) # Invert. if fact == 0.0: fact = 1e100 else: fact = 1.0 / fact # Sinc value. sinc_smax = sinc(sigma_max/pi) # Numerical integration of phi of each element. matrix[0, 0] = fact * sinc_smax * (2.0*pi + quad(part_int_daeg1_pseudo_ellipse_00, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[1, 1] = fact * sinc_smax * (2.0*pi + quad(part_int_daeg1_pseudo_ellipse_11, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[2, 2] = fact * quad(part_int_daeg1_pseudo_ellipse_22, -pi, pi, args=(theta_x, theta_y), full_output=1)[0] # Rotate and return the frame order matrix. return rotate_daeg(matrix, R_eigen)
def compile_2nd_matrix_pseudo_ellipse_free_rotor(matrix, Rx2_eigen, theta_x, theta_y): """Generate the 2nd degree Frame Order matrix for the free rotor pseudo-ellipse. @param matrix: The Frame Order matrix, 2nd degree to be populated. @type matrix: numpy 9D, rank-2 array @param Rx2_eigen: The Kronecker product of the eigenframe rotation matrix with itself. @type Rx2_eigen: numpy 9D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float """ # The surface area normalisation factor. fact = 1.0 / (6.0 * pec(theta_x, theta_y)) # Diagonal. matrix[0, 0] = fact * (4.0*pi - quad(part_int_daeg2_pseudo_ellipse_free_rotor_00, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[1, 1] = matrix[3, 3] = fact * 3.0/2.0 * quad(part_int_daeg2_pseudo_ellipse_free_rotor_11, -pi, pi, args=(theta_x, theta_y), full_output=1)[0] matrix[4, 4] = fact * (4.0*pi - quad(part_int_daeg2_pseudo_ellipse_free_rotor_44, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 8] = fact * (4.0*pi - 2.0*quad(part_int_daeg2_pseudo_ellipse_free_rotor_88, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 1. matrix[0, 4] = matrix[0, 0] matrix[4, 0] = matrix[4, 4] matrix[0, 8] = fact * (4.0*pi + quad(part_int_daeg2_pseudo_ellipse_free_rotor_08, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 0] = fact * (4.0*pi + quad(part_int_daeg2_pseudo_ellipse_free_rotor_80, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[4, 8] = fact * (4.0*pi + quad(part_int_daeg2_pseudo_ellipse_free_rotor_48, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 4] = matrix[8, 0] # Off diagonal set 2. matrix[1, 3] = matrix[3, 1] = -matrix[1, 1] # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen)
def compile_1st_matrix_pseudo_ellipse_free_rotor(matrix, R_eigen, theta_x, theta_y): """Generate the 1st degree Frame Order matrix for the free rotor pseudo-ellipse. @param matrix: The Frame Order matrix, 1st degree to be populated. @type matrix: numpy 3D, rank-2 array @param R_eigen: The eigenframe rotation matrix. @type R_eigen: numpy 3D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float """ # The surface area normalisation factor. fact = 2.0 * pec(theta_x, theta_y) # Invert. if fact == 0.0: fact = 1e100 else: fact = 1.0 / fact # Numerical integration of phi of each element. matrix[2, 2] = fact * quad(part_int_daeg1_pseudo_ellipse_free_rotor_22, -pi, pi, args=(theta_x, theta_y), full_output=1)[0] # Rotate and return the frame order matrix. return rotate_daeg(matrix, R_eigen)
def compile_2nd_matrix_pseudo_ellipse_free_rotor(matrix, Rx2_eigen, theta_x, theta_y): """Generate the 2nd degree Frame Order matrix for the free rotor pseudo-ellipse. @param matrix: The Frame Order matrix, 2nd degree to be populated. @type matrix: numpy 9D, rank-2 array @param Rx2_eigen: The Kronecker product of the eigenframe rotation matrix with itself. @type Rx2_eigen: numpy 9D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float """ # The surface area normalisation factor. fact3 = 3.0 * pec(theta_x, theta_y) fact4 = 4.0 * pec(theta_x, theta_y) fact6 = 6.0 * pec(theta_x, theta_y) # Invert. if fact3 == 0.0: fact3 = 1e100 fact4 = 1e100 fact6 = 1e100 else: fact3 = 1.0 / fact3 fact4 = 1.0 / fact4 fact6 = 1.0 / fact6 # Diagonal. matrix[0, 0] = fact6 * (4.0*pi - quad(part_int_daeg2_pseudo_ellipse_free_rotor_00, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[1, 1] = matrix[3, 3] = fact4 * quad(part_int_daeg2_pseudo_ellipse_free_rotor_11, -pi, pi, args=(theta_x, theta_y), full_output=1)[0] matrix[4, 4] = fact6 * (4.0*pi - quad(part_int_daeg2_pseudo_ellipse_free_rotor_44, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 8] = fact3 * (2.0*pi - quad(part_int_daeg2_pseudo_ellipse_free_rotor_88, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 1. matrix[0, 4] = matrix[0, 0] matrix[4, 0] = matrix[4, 4] matrix[0, 8] = fact3 * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_free_rotor_08, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 0] = fact6 * (4.0*pi + quad(part_int_daeg2_pseudo_ellipse_free_rotor_80, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[4, 8] = fact3 * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_free_rotor_48, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 4] = matrix[8, 0] # Off diagonal set 2. matrix[1, 3] = matrix[3, 1] = -matrix[1, 1] # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen)
def compile_2nd_matrix_pseudo_ellipse_torsionless(matrix, Rx2_eigen, theta_x, theta_y): """Generate the 2nd degree Frame Order matrix for the torsionless pseudo-ellipse. @param matrix: The Frame Order matrix, 2nd degree to be populated. @type matrix: numpy 9D, rank-2 array @param Rx2_eigen: The Kronecker product of the eigenframe rotation matrix with itself. @type Rx2_eigen: numpy 9D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float """ # The rigid case. if theta_x == 0.0: # Set up the matrix as the identity. matrix[:] = 0.0 for i in range(len(matrix)): matrix[i, i] = 1.0 # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen) # The surface area normalisation factor. fact = 6.0 * pec(theta_x, theta_y) fact2 = 0.5 * fact # Invert. if fact == 0.0: fact = 1e100 fact2 = 1e100 else: fact = 1.0 / fact fact2 = 1.0 / fact2 # Diagonal. matrix[0, 0] = fact2 * (3.0*pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_00, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[1, 1] = fact * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_11, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[2, 2] = fact * (5.0*pi - quad(part_int_daeg2_pseudo_ellipse_torsionless_22, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[3, 3] = matrix[1, 1] matrix[4, 4] = fact2 * (3.0*pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_44, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[5, 5] = fact * (5.0*pi - quad(part_int_daeg2_pseudo_ellipse_torsionless_55, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[6, 6] = matrix[2, 2] matrix[7, 7] = matrix[5, 5] matrix[8, 8] = fact2 * (2.0*pi - quad(part_int_daeg2_pseudo_ellipse_torsionless_88, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 1. matrix[0, 4] = matrix[4, 0] = fact2 * (pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_04, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[0, 8] = matrix[8, 0] = fact2 * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_08, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[4, 8] = matrix[8, 4] = fact2 * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_48, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 2. matrix[1, 3] = matrix[3, 1] = matrix[0, 4] matrix[2, 6] = matrix[6, 2] = -matrix[0, 8] matrix[5, 7] = matrix[7, 5] = -matrix[4, 8] # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen)
def compile_2nd_matrix_pseudo_ellipse(matrix, Rx2_eigen, theta_x, theta_y, sigma_max): """Generate the 2nd degree Frame Order matrix for the pseudo-ellipse. @param matrix: The Frame Order matrix, 2nd degree to be populated. @type matrix: numpy 9D, rank-2 array @param Rx2_eigen: The Kronecker product of the eigenframe rotation matrix with itself. @type Rx2_eigen: numpy 9D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float @param sigma_max: The maximum torsion angle. @type sigma_max: float """ # The surface area normalisation factor. fact = 12.0 * pec(theta_x, theta_y) # Invert. if fact == 0.0: fact = 1e100 else: fact = 1.0 / fact # Sigma_max part. if sigma_max == 0.0: fact2 = 1e100 else: fact2 = fact / (2.0 * sigma_max) # Diagonal. matrix[0, 0] = fact * (4.0*pi*(sinc(2.0*sigma_max/pi) + 2.0) + quad(part_int_daeg2_pseudo_ellipse_00, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[1, 1] = fact * (4.0*pi*sinc(2.0*sigma_max/pi) + quad(part_int_daeg2_pseudo_ellipse_11, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[2, 2] = fact * 2.0*sinc(sigma_max/pi) * (5.0*pi - quad(part_int_daeg2_pseudo_ellipse_22, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[3, 3] = matrix[1, 1] matrix[4, 4] = fact * (4.0*pi*(sinc(2.0*sigma_max/pi) + 2.0) + quad(part_int_daeg2_pseudo_ellipse_44, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[5, 5] = fact * 2.0*sinc(sigma_max/pi) * (5.0*pi - quad(part_int_daeg2_pseudo_ellipse_55, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[6, 6] = matrix[2, 2] matrix[7, 7] = matrix[5, 5] matrix[8, 8] = 4.0 * fact * (2.0*pi - quad(part_int_daeg2_pseudo_ellipse_88, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) # Off diagonal set 1. matrix[0, 4] = fact * (4.0*pi*(2.0 - sinc(2.0*sigma_max/pi)) + quad(part_int_daeg2_pseudo_ellipse_04, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[4, 0] = fact * (4.0*pi*(2.0 - sinc(2.0*sigma_max/pi)) + quad(part_int_daeg2_pseudo_ellipse_40, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[0, 8] = 4.0 * fact * (2.0*pi - quad(part_int_daeg2_pseudo_ellipse_08, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[8, 0] = fact * (8.0*pi + quad(part_int_daeg2_pseudo_ellipse_80, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[4, 8] = 4.0 * fact * (2.0*pi - quad(part_int_daeg2_pseudo_ellipse_48, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[8, 4] = fact * (8.0*pi - quad(part_int_daeg2_pseudo_ellipse_84, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) # Off diagonal set 2. matrix[1, 3] = matrix[3, 1] = fact * (4.0*pi*sinc(2.0*sigma_max/pi) + quad(part_int_daeg2_pseudo_ellipse_13, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[2, 6] = matrix[6, 2] = -fact * 4.0 * sinc(sigma_max/pi) * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_26, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) matrix[5, 7] = matrix[7, 5] = -fact * 4.0 * sinc(sigma_max/pi) * (2.0*pi + quad(part_int_daeg2_pseudo_ellipse_57, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]) # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen)
def pcs_numeric_quad_int_pseudo_ellipse(theta_x=None, theta_y=None, sigma_max=None, c=None, r_pivot_atom=None, r_ln_pivot=None, A=None, R_eigen=None, RT_eigen=None, Ri_prime=None): """Determine the averaged PCS value via numerical integration. @keyword theta_x: The x-axis half cone angle. @type theta_x: float @keyword theta_y: The y-axis half cone angle. @type theta_y: float @keyword sigma_max: The maximum torsion angle. @type sigma_max: float @keyword c: The PCS constant (without the interatomic distance and in Angstrom units). @type c: float @keyword r_pivot_atom: The pivot point to atom vector. @type r_pivot_atom: numpy rank-1, 3D array @keyword r_ln_pivot: The lanthanide position to pivot point vector. @type r_ln_pivot: numpy rank-1, 3D array @keyword A: The full alignment tensor of the non-moving domain. @type A: numpy rank-2, 3D array @keyword R_eigen: The eigenframe rotation matrix. @type R_eigen: numpy rank-2, 3D array @keyword RT_eigen: The transpose of the eigenframe rotation matrix (for faster calculations). @type RT_eigen: numpy rank-2, 3D array @keyword Ri_prime: The empty rotation matrix for the in-frame isotropic cone motion, used to calculate the PCS for each state i in the numerical integration. @type Ri_prime: numpy rank-2, 3D array @return: The averaged PCS value. @rtype: float """ def pseudo_ellipse(theta, phi): """The pseudo-ellipse wrapper formula.""" return tmax_pseudo_ellipse(phi, theta_x, theta_y) # Perform numerical integration. result = tplquad(pcs_pivot_motion_full_quad_int, -sigma_max, sigma_max, lambda phi: -pi, lambda phi: pi, lambda theta, phi: 0.0, pseudo_ellipse, args=(r_pivot_atom, r_ln_pivot, A, R_eigen, RT_eigen, Ri_prime)) # The surface area normalisation factor. SA = 2.0 * sigma_max * pec(theta_x, theta_y) # Return the value. return c * result[0] / SA
def compile_1st_matrix_pseudo_ellipse(matrix, R_eigen, theta_x, theta_y, sigma_max): """Generate the 1st degree Frame Order matrix for the pseudo-ellipse. @param matrix: The Frame Order matrix, 1st degree to be populated. @type matrix: numpy 3D, rank-2 array @param R_eigen: The eigenframe rotation matrix. @type R_eigen: numpy 3D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float @param sigma_max: The maximum torsion angle. @type sigma_max: float """ # The surface area normalisation factor. fact = 2.0 * pec(theta_x, theta_y) # Invert. if fact == 0.0: fact = 1e100 else: fact = 1.0 / fact # Sinc value. sinc_smax = sinc(sigma_max / pi) # Numerical integration of phi of each element. matrix[0, 0] = fact * sinc_smax * (2.0 * pi + quad(part_int_daeg1_pseudo_ellipse_00, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[1, 1] = fact * sinc_smax * (2.0 * pi + quad(part_int_daeg1_pseudo_ellipse_11, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[2, 2] = fact * quad(part_int_daeg1_pseudo_ellipse_22, -pi, pi, args=(theta_x, theta_y), full_output=1)[0] # Rotate and return the frame order matrix. return rotate_daeg(matrix, R_eigen)
def compile_1st_matrix_pseudo_ellipse(matrix, theta_x, theta_y, sigma_max): """Generate the 1st degree Frame Order matrix for the pseudo-ellipse. @param matrix: The Frame Order matrix, 1st degree to be populated. @type matrix: numpy 3D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float @param sigma_max: The maximum torsion angle. @type sigma_max: float """ # The surface area normalisation factor. fact = 1.0 / (2.0 * sigma_max * pec(theta_x, theta_y)) # Numerical integration of phi of each element. matrix[0, 0] = fact * quad(part_int_daeg1_pseudo_ellipse_xx, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0] matrix[1, 1] = fact * quad(part_int_daeg1_pseudo_ellipse_yy, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0] matrix[2, 2] = fact * quad(part_int_daeg1_pseudo_ellipse_zz, -pi, pi, args=(theta_x, theta_y, sigma_max), full_output=1)[0]
def pcs_numeric_int_pseudo_ellipse(theta_x=None, theta_y=None, sigma_max=None, c=None, r_pivot_atom=None, r_ln_pivot=None, A=None, R_eigen=None, RT_eigen=None, Ri_prime=None): """Determine the averaged PCS value via numerical integration. @keyword theta_x: The x-axis half cone angle. @type theta_x: float @keyword theta_y: The y-axis half cone angle. @type theta_y: float @keyword sigma_max: The maximum torsion angle. @type sigma_max: float @keyword c: The PCS constant (without the interatomic distance and in Angstrom units). @type c: float @keyword r_pivot_atom: The pivot point to atom vector. @type r_pivot_atom: numpy rank-1, 3D array @keyword r_ln_pivot: The lanthanide position to pivot point vector. @type r_ln_pivot: numpy rank-1, 3D array @keyword A: The full alignment tensor of the non-moving domain. @type A: numpy rank-2, 3D array @keyword R_eigen: The eigenframe rotation matrix. @type R_eigen: numpy rank-2, 3D array @keyword RT_eigen: The transpose of the eigenframe rotation matrix (for faster calculations). @type RT_eigen: numpy rank-2, 3D array @keyword Ri_prime: The empty rotation matrix for the in-frame isotropic cone motion, used to calculate the PCS for each state i in the numerical integration. @type Ri_prime: numpy rank-2, 3D array @return: The averaged PCS value. @rtype: float """ def pseudo_ellipse(theta, phi): """The pseudo-ellipse wrapper formula.""" return tmax_pseudo_ellipse(phi, theta_x, theta_y) # Perform numerical integration. result = tplquad(pcs_pivot_motion_full, -sigma_max, sigma_max, lambda phi: -pi, lambda phi: pi, lambda theta, phi: 0.0, pseudo_ellipse, args=(r_pivot_atom, r_ln_pivot, A, R_eigen, RT_eigen, Ri_prime)) # The surface area normalisation factor. SA = 2.0 * sigma_max * pec(theta_x, theta_y) # Return the value. return c * result[0] / SA
def test_pec_1_0(self): """Test the pec() function for x = 1, y = 0 (nothing).""" # Check the value. self.assertAlmostEqual(pec(1, 0), 0.0)
def test_pec_0_1(self): """Test the pec() function for x = 0, y = 1 (nothing).""" # Check the value. self.assertAlmostEqual(pec(0, 1), 0.0)
def test_pec_partial1(self): """Test the pec() function for x = pi/2, y = pi.""" # Check the value. self.assertAlmostEqual(pec(pi/2, pi), 9.2141334381797524)
def compile_2nd_matrix_pseudo_ellipse(matrix, Rx2_eigen, theta_x, theta_y, sigma_max): """Generate the 2nd degree Frame Order matrix for the pseudo-ellipse. @param matrix: The Frame Order matrix, 2nd degree to be populated. @type matrix: numpy 9D, rank-2 array @param Rx2_eigen: The Kronecker product of the eigenframe rotation matrix with itself. @type Rx2_eigen: numpy 9D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float @param sigma_max: The maximum torsion angle. @type sigma_max: float """ # The rigid case. if theta_x == 0.0 and sigma_max == 0.0: # Set up the matrix as the identity. matrix[:] = 0.0 for i in range(len(matrix)): matrix[i, i] = 1.0 # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen) # The surface area normalisation factor. fact = 12.0 * pec(theta_x, theta_y) # Invert. if fact == 0.0: fact = 1e100 else: fact = 1.0 / fact # Repetitive calculations. sinc_smax = sinc(sigma_max / pi) sinc_2smax = sinc(2.0 * sigma_max / pi) # Diagonal. matrix[0, 0] = fact * (4.0 * pi * (sinc_2smax + 2.0) + quad(part_int_daeg2_pseudo_ellipse_00, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[1, 1] = fact * (4.0 * pi * sinc_2smax + quad(part_int_daeg2_pseudo_ellipse_11, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[2, 2] = fact * 2.0 * sinc_smax * ( 5.0 * pi - quad(part_int_daeg2_pseudo_ellipse_22, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[3, 3] = matrix[1, 1] matrix[4, 4] = fact * (4.0 * pi * (sinc_2smax + 2.0) + quad(part_int_daeg2_pseudo_ellipse_44, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[5, 5] = fact * 2.0 * sinc_smax * ( 5.0 * pi - quad(part_int_daeg2_pseudo_ellipse_55, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[6, 6] = matrix[2, 2] matrix[7, 7] = matrix[5, 5] matrix[8, 8] = 4.0 * fact * (2.0 * pi - quad(part_int_daeg2_pseudo_ellipse_88, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 1. matrix[0, 4] = fact * (4.0 * pi * (2.0 - sinc_2smax) + quad(part_int_daeg2_pseudo_ellipse_04, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[4, 0] = fact * (4.0 * pi * (2.0 - sinc_2smax) + quad(part_int_daeg2_pseudo_ellipse_40, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[0, 8] = 4.0 * fact * (2.0 * pi - quad(part_int_daeg2_pseudo_ellipse_08, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 0] = fact * (8.0 * pi + quad(part_int_daeg2_pseudo_ellipse_80, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[4, 8] = 4.0 * fact * (2.0 * pi - quad(part_int_daeg2_pseudo_ellipse_48, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[8, 4] = fact * (8.0 * pi - quad(part_int_daeg2_pseudo_ellipse_84, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) # Off diagonal set 2. matrix[1, 3] = matrix[3, 1] = fact * (4.0 * pi * sinc_2smax + quad(part_int_daeg2_pseudo_ellipse_13, -pi, pi, args=(theta_x, theta_y, sinc_2smax), full_output=1)[0]) matrix[2, 6] = matrix[6, 2] = -fact * 4.0 * sinc_smax * ( 2.0 * pi + quad(part_int_daeg2_pseudo_ellipse_26, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[5, 7] = matrix[7, 5] = -fact * 4.0 * sinc_smax * ( 2.0 * pi + quad(part_int_daeg2_pseudo_ellipse_57, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen)
def compile_2nd_matrix_pseudo_ellipse_torsionless(matrix, Rx2_eigen, theta_x, theta_y): """Generate the 2nd degree Frame Order matrix for the torsionless pseudo-ellipse. @param matrix: The Frame Order matrix, 2nd degree to be populated. @type matrix: numpy 9D, rank-2 array @param Rx2_eigen: The Kronecker product of the eigenframe rotation matrix with itself. @type Rx2_eigen: numpy 9D, rank-2 array @param theta_x: The cone opening angle along x. @type theta_x: float @param theta_y: The cone opening angle along y. @type theta_y: float """ # The rigid case. if theta_x == 0.0: # Set up the matrix as the identity. matrix[:] = 0.0 for i in range(len(matrix)): matrix[i, i] = 1.0 # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen) # The surface area normalisation factor. fact = 6.0 * pec(theta_x, theta_y) fact2 = 0.5 * fact # Invert. if fact == 0.0: fact = 1e100 fact2 = 1e100 else: fact = 1.0 / fact fact2 = 1.0 / fact2 # Diagonal. matrix[0, 0] = fact2 * (3.0 * pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_00, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[1, 1] = fact * (2.0 * pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_11, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[2, 2] = fact * (5.0 * pi - quad(part_int_daeg2_pseudo_ellipse_torsionless_22, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[3, 3] = matrix[1, 1] matrix[4, 4] = fact2 * (3.0 * pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_44, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[5, 5] = fact * (5.0 * pi - quad(part_int_daeg2_pseudo_ellipse_torsionless_55, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[6, 6] = matrix[2, 2] matrix[7, 7] = matrix[5, 5] matrix[8, 8] = fact2 * (2.0 * pi - quad(part_int_daeg2_pseudo_ellipse_torsionless_88, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 1. matrix[0, 4] = matrix[ 4, 0] = fact2 * (pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_04, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[0, 8] = matrix[8, 0] = fact2 * ( 2.0 * pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_08, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) matrix[4, 8] = matrix[8, 4] = fact2 * ( 2.0 * pi + quad(part_int_daeg2_pseudo_ellipse_torsionless_48, -pi, pi, args=(theta_x, theta_y), full_output=1)[0]) # Off diagonal set 2. matrix[1, 3] = matrix[3, 1] = matrix[0, 4] matrix[2, 6] = matrix[6, 2] = -matrix[0, 8] matrix[5, 7] = matrix[7, 5] = -matrix[4, 8] # Rotate and return the frame order matrix. return rotate_daeg(matrix, Rx2_eigen)
def test_pec_partial3(self): """Test the pec() function for x = pi/6, y = pi/2.""" # Check the value. self.assertAlmostEqual(pec(pi/6, pi/2), 2.3058688920532275)
def test_pec_pi_pi(self): """Test the pec() function for x = pi, y = pi (full sphere).""" # Check the value. self.assertAlmostEqual(pec(pi, pi), 4*pi)
def test_pec_partial2(self): """Test the pec() function for x = pi/2, y = pi/2.""" # Check the value. self.assertAlmostEqual(pec(pi/2, pi/2), 2*pi)
# # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # # # ############################################################################### # Python module imports. from numpy import array, float64 # relax module imports. from lib.geometry.pec import pec # The data ranges. incs = 20 vals = array(range(incs), float64) / incs * 2 * pi # Generate the data. for a in vals: for b in vals: print("%-20f %-20f %-20f" % (a, b, pec(a, b)))