/// /// @brief Sets up matrices for performing CMC in an arbitrary space /// void mat_polar_rot_matrix() { for(int mat=0;mat<mp::num_materials;mat++){ const double phi=cmc::cmc_mat[mat].constraint_phi; const double theta=cmc::cmc_mat[mat].constraint_theta; std::vector< std::vector<double> > polar_matrix; std::vector< std::vector<double> > polar_matrix_tp; std::vector< std::vector<double> > polar_vector; double dx,dy,dz; //change in angle in radians double ddx,ddy,ddz; //change in angle in degrees double sin_x,sin_y,sin_z,cos_x,cos_y,cos_z; std::vector<double> reference_vector(3); double pi=3.14159265358979323846264338327; //-------------------------------------------------- // Initialise varibales //-------------------------------------------------- ddx = 0.0; ddy = phi; ddz = theta;// assumues x = cos(theta)sin(phi), y = sin(theta)sin(phi) dx = (ddx/360.0)*2.0*pi; dy = (ddy/360.0)*2.0*pi; dz = (ddz/360.0)*2.0*pi; reference_vector[0] = 0.0; reference_vector[1] = 0.0; reference_vector[2] = 1.0; sin_x = sin(dx); cos_x = cos(dx); sin_y = sin(dy); cos_y = cos(dy); sin_z = sin(dz); cos_z = cos(dz); std::vector< std::vector<double> > x_rotation_matrix,y_rotation_matrix,z_rotation_matrix,ref_vec; x_rotation_matrix=vmath::set_matrix(3,3); y_rotation_matrix=vmath::set_matrix(3,3); z_rotation_matrix=vmath::set_matrix(3,3); ref_vec=vmath::set_matrix(1,3,reference_vector); x_rotation_matrix[0][0] = 1.0; x_rotation_matrix[1][0] = 0.0; x_rotation_matrix[2][0] = 0.0; x_rotation_matrix[0][1] = 0.0; x_rotation_matrix[1][1] = cos_x; x_rotation_matrix[2][1] = -sin_x; x_rotation_matrix[0][2] = 0.0; x_rotation_matrix[1][2] = sin_x; x_rotation_matrix[2][2] = cos_x; y_rotation_matrix[0][0] = cos_y; y_rotation_matrix[1][0] = 0.0; y_rotation_matrix[2][0] = sin_y; y_rotation_matrix[0][1] = 0.0; y_rotation_matrix[1][1] = 1.0; y_rotation_matrix[2][1] = 0.0; y_rotation_matrix[0][2] = -sin_y; y_rotation_matrix[1][2] = 0.0; y_rotation_matrix[2][2] = cos_y; z_rotation_matrix[0][0] = cos_z; z_rotation_matrix[1][0] = -sin_z; z_rotation_matrix[2][0] = 0.0; z_rotation_matrix[0][1] = sin_z; z_rotation_matrix[1][1] = cos_z; z_rotation_matrix[2][1] = 0.0; z_rotation_matrix[0][2] = 0.0; z_rotation_matrix[1][2] = 0.0; z_rotation_matrix[2][2] = 1.0; polar_matrix = vmath::matmul(y_rotation_matrix,z_rotation_matrix); polar_matrix_tp = vmath::transpose(polar_matrix); polar_vector = vmath::matmul(ref_vec,polar_matrix); // copy matrices to performance optimised class variables for (int i=0;i<3;i++){ cmc::cmc_mat[mat].ppolar_vector[i]=polar_vector[0][i]; for (int j=0;j<3;j++){ cmc::cmc_mat[mat].ppolar_matrix[i][j]=polar_matrix[i][j]; cmc::cmc_mat[mat].ppolar_matrix_tp[i][j]=polar_matrix_tp[i][j]; } } } // end of loop over materials } // end of polar rotation initialisation
/// /// @brief Sets up matrices for performing CMC in an arbitrary space /// /// @param[in] phi Magnetisation azimuthal angle /// @param[in] theta Magnetisation rotational angle /// @param[out] polar_matrix Matrix to rotate v to z /// @param[out] polar_matrix_tp Matrix to rotate z to v /// @param[out] polar_vector Constraint Vector /// @return void /// void polar_rot_matrix( double phi, double theta, std::vector< std::vector<double> > & polar_matrix, std::vector< std::vector<double> > & polar_matrix_tp, std::vector< std::vector<double> > & polar_vector) { double dx,dy,dz; //change in angle in radians double ddx,ddy,ddz; //change in angle in degrees double sin_x,sin_y,sin_z,cos_x,cos_y,cos_z; std::vector<double> reference_vector(3); double pi=3.14159265358979323846264338327; //-------------------------------------------------- // Initialise varibales //-------------------------------------------------- ddx = 0.0; ddy = phi; ddz = theta;// assumues x = cos(theta)sin(phi), y = sin(theta)sin(phi) dx = (ddx/360.0)*2.0*pi; dy = (ddy/360.0)*2.0*pi; dz = (ddz/360.0)*2.0*pi; reference_vector[0] = 0.0; reference_vector[1] = 0.0; reference_vector[2] = 1.0; sin_x = sin(dx); cos_x = cos(dx); sin_y = sin(dy); cos_y = cos(dy); sin_z = sin(dz); cos_z = cos(dz); std::vector< std::vector<double> > x_rotation_matrix,y_rotation_matrix,z_rotation_matrix,ref_vec; x_rotation_matrix=vmath::set_matrix(3,3); y_rotation_matrix=vmath::set_matrix(3,3); z_rotation_matrix=vmath::set_matrix(3,3); ref_vec=vmath::set_matrix(1,3,reference_vector); x_rotation_matrix[0][0] = 1.0; x_rotation_matrix[1][0] = 0.0; x_rotation_matrix[2][0] = 0.0; x_rotation_matrix[0][1] = 0.0; x_rotation_matrix[1][1] = cos_x; x_rotation_matrix[2][1] = -sin_x; x_rotation_matrix[0][2] = 0.0; x_rotation_matrix[1][2] = sin_x; x_rotation_matrix[2][2] = cos_x; y_rotation_matrix[0][0] = cos_y; y_rotation_matrix[1][0] = 0.0; y_rotation_matrix[2][0] = sin_y; y_rotation_matrix[0][1] = 0.0; y_rotation_matrix[1][1] = 1.0; y_rotation_matrix[2][1] = 0.0; y_rotation_matrix[0][2] = -sin_y; y_rotation_matrix[1][2] = 0.0; y_rotation_matrix[2][2] = cos_y; z_rotation_matrix[0][0] = cos_z; z_rotation_matrix[1][0] = -sin_z; z_rotation_matrix[2][0] = 0.0; z_rotation_matrix[0][1] = sin_z; z_rotation_matrix[1][1] = cos_z; z_rotation_matrix[2][1] = 0.0; z_rotation_matrix[0][2] = 0.0; z_rotation_matrix[1][2] = 0.0; z_rotation_matrix[2][2] = 1.0; polar_matrix = vmath::matmul(y_rotation_matrix,z_rotation_matrix); polar_matrix_tp = vmath::transpose(polar_matrix); polar_vector = vmath::matmul(ref_vec,polar_matrix); }