static Centering get_centering(double correction_mat[3][3], SPGCONST int transform_mat[3][3], const Laue laue) { int det; double trans_corr_mat[3][3]; Centering centering; mat_copy_matrix_d3(correction_mat, identity); det = abs(mat_get_determinant_i3(transform_mat)); debug_print("laue class: %d\n", laue); debug_print("multiplicity: %d\n", det); if (det == 1) { centering = NO_CENTER; } if (det == 2) { centering = get_base_center(transform_mat); if (centering == A_FACE) { if (laue == LAUE2M) { debug_print("Monocli A to C\n"); mat_copy_matrix_d3(correction_mat, monocli_a2c); } else { mat_copy_matrix_d3(correction_mat, a2c); } centering = C_FACE; } if (centering == B_FACE) { mat_copy_matrix_d3(correction_mat, b2c); centering = C_FACE; } if (laue == LAUE2M && centering == BODY) { debug_print("Monocli I to C\n"); mat_copy_matrix_d3(correction_mat, monocli_i2c); centering = C_FACE; } } if (det == 3) { centering = NO_CENTER; mat_multiply_matrix_id3(trans_corr_mat, transform_mat, rhombo_obverse); if (mat_is_int_matrix(trans_corr_mat, INT_PREC)) { mat_copy_matrix_d3(correction_mat, rhombo_obverse); debug_print("R-center observe setting\n"); debug_print_matrix_d3(trans_corr_mat); } mat_multiply_matrix_id3(trans_corr_mat, transform_mat, rhomb_reverse); if (mat_is_int_matrix(trans_corr_mat, INT_PREC)) { mat_copy_matrix_d3(correction_mat, rhomb_reverse); debug_print("R-center reverse setting\n"); debug_print_matrix_d3(trans_corr_mat); } } if (det == 4) { centering = FACE; } return centering; }
static Centering get_transformation_matrix( double trans_mat[3][3], SPGCONST Symmetry * symmetry ) { int pg_num; double correction_mat[3][3]; Centering centering; Pointgroup pointgroup; pg_num = ptg_get_pointgroup_number( symmetry ); pointgroup = ptg_get_pointgroup( pg_num ); ptg_get_transformation_matrix( &pointgroup, symmetry ); /* Centering is not determined only from symmetry operations */ /* sometimes. Therefore centering and transformation matrix are */ /* related. */ centering = lat_get_centering( correction_mat, pointgroup.transform_mat, pointgroup.laue ); mat_multiply_matrix_id3( trans_mat, pointgroup.transform_mat, correction_mat ); debug_print("correction matrix\n"); debug_print_matrix_d3( correction_mat ); return centering; }
/* Return 0 if failed */ int spg_get_pointgroup(char symbol[6], int transform_mat[3][3], SPGCONST int rotations[][3][3], const int num_rotations) { int tmp_transform_mat[3][3]; double correction_mat[3][3], transform_mat_double[3][3]; Pointgroup pointgroup; pointgroup = ptg_get_transformation_matrix(tmp_transform_mat, rotations, num_rotations); strcpy(symbol, pointgroup.symbol); lat_get_centering(correction_mat, tmp_transform_mat, pointgroup.laue); mat_multiply_matrix_id3(transform_mat_double, tmp_transform_mat, correction_mat); mat_cast_matrix_3d_to_3i(transform_mat, transform_mat_double); return pointgroup.number; }
/* Return 0 if failed */ static int search_hall_number(double origin_shift[3], double conv_lattice[3][3], const int candidates[], const int num_candidates, SPGCONST double primitive_lattice[3][3], SPGCONST Symmetry * symmetry, const double symprec) { int i, hall_number; Centering centering; Pointgroup pointgroup; Symmetry * conv_symmetry; int int_transform_mat[3][3]; double correction_mat[3][3], transform_mat[3][3]; debug_print("search_hall_number:\n"); hall_number = 0; conv_symmetry = NULL; pointgroup = ptg_get_transformation_matrix(int_transform_mat, symmetry->rot, symmetry->size); if (pointgroup.number == 0) { goto err; } mat_multiply_matrix_di3(conv_lattice, primitive_lattice, int_transform_mat); if (pointgroup.laue == LAUE1) { if (! change_basis_tricli(int_transform_mat, conv_lattice, primitive_lattice, symprec)) { goto err; } } if (pointgroup.laue == LAUE2M) { if (! change_basis_monocli(int_transform_mat, conv_lattice, primitive_lattice, symprec)) { goto err; } } if ((centering = get_centering(correction_mat, int_transform_mat, pointgroup.laue)) == CENTERING_ERROR) { goto err; } mat_multiply_matrix_id3(transform_mat, int_transform_mat, correction_mat); mat_multiply_matrix_d3(conv_lattice, primitive_lattice, transform_mat); if ((conv_symmetry = get_initial_conventional_symmetry(centering, transform_mat, symmetry)) == NULL) { goto err; } for (i = 0; i < num_candidates; i++) { if (match_hall_symbol_db(origin_shift, conv_lattice, /* <-- modified only matched */ candidates[i], pointgroup.number, pointgroup.holohedry, centering, conv_symmetry, symprec)) { hall_number = candidates[i]; break; } } sym_free_symmetry(conv_symmetry); conv_symmetry = NULL; return hall_number; err: return 0; }
/* Return CENTERING_ERROR if failed */ static Centering get_centering(double correction_mat[3][3], SPGCONST int transform_mat[3][3], const Laue laue) { int det; double trans_corr_mat[3][3]; Centering centering; mat_copy_matrix_d3(correction_mat, identity); det = abs(mat_get_determinant_i3(transform_mat)); debug_print("laue class: %d\n", laue); debug_print("multiplicity: %d\n", det); switch (det) { case 1: centering = PRIMITIVE; break; case 2: centering = get_base_center(transform_mat); if (centering == A_FACE) { if (laue == LAUE2M) { debug_print("Monocli A to C\n"); mat_copy_matrix_d3(correction_mat, monocli_a2c); } else { mat_copy_matrix_d3(correction_mat, a2c); } centering = C_FACE; } if (centering == B_FACE) { mat_copy_matrix_d3(correction_mat, b2c); centering = C_FACE; } if (laue == LAUE2M && centering == BODY) { debug_print("Monocli I to C\n"); mat_copy_matrix_d3(correction_mat, monocli_i2c); centering = C_FACE; } break; case 3: /* hP (a=b) but not hR (a=b=c) */ centering = R_CENTER; mat_multiply_matrix_id3(trans_corr_mat, transform_mat, rhombo_obverse); if (mat_is_int_matrix(trans_corr_mat, INT_PREC)) { mat_copy_matrix_d3(correction_mat, rhombo_obverse); debug_print("R-center observe setting\n"); debug_print_matrix_d3(trans_corr_mat); } mat_multiply_matrix_id3(trans_corr_mat, transform_mat, rhomb_reverse); if (mat_is_int_matrix(trans_corr_mat, INT_PREC)) { mat_copy_matrix_d3(correction_mat, rhomb_reverse); debug_print("R-center reverse setting\n"); debug_print_matrix_d3(trans_corr_mat); } break; case 4: centering = FACE; break; default: centering = CENTERING_ERROR; break; } return centering; }