static int test_spg_get_symmetry(void) { double lattice[3][3] = {{4, 0, 0}, {0, 4, 0}, {0, 0, 3}}; double position[][3] = { {0, 0, 0}, {0.5, 0.5, 0.25}, {0.3, 0.3, 0}, {0.7, 0.7, 0}, {0.2, 0.8, 0.25}, {0.8, 0.2, 0.25}, {0, 0, 0.5}, {0.5, 0.5, 0.75}, {0.3, 0.3, 0.5}, {0.7, 0.7, 0.5}, {0.2, 0.8, 0.75}, {0.8, 0.2, 0.75} }; int types[] = {1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2}; int num_atom = 12; int max_size = 50; int i, j, size; int rotation[max_size][3][3]; double translation[max_size][3]; double origin_shift[3] = {0.1, 0.1, 0}; for (i = 0; i < num_atom; i++) { for (j = 0; j < 3; j++) { position[i][j] += origin_shift[j]; } } printf("*** spg_get_symmetry (Rutile two unit cells) ***:\n"); size = spg_get_symmetry(rotation, translation, max_size, lattice, position, types, num_atom, 1e-5); if (size) { for (i = 0; i < size; i++) { printf("--- %d ---\n", i + 1); for (j = 0; j < 3; j++) printf("%2d %2d %2d\n", rotation[i][j][0], rotation[i][j][1], rotation[i][j][2]); printf("%f %f %f\n", translation[i][0], translation[i][1], translation[i][2]); } return 0; } else { return 1; } }
void spgw_get_symmetry(generated_group<rotrans<REAL,true> > & G, geometry<REAL,CELL> & geom, REAL R = geometry<REAL,CELL>::tol_geom_default) { int nat = geom.size(); auto lattice = new double[3][3](); auto position = new double[nat][3](); auto types = new int[nat](); get_spgdata_from_geom(geom,lattice,position,types); int max_size = nat*48, nsymm; double translation[max_size][3]; int rotation[max_size][3][3]; //std::cout << "before get symmetry\n"; nsymm = spg_get_symmetry(rotation, translation, max_size, lattice, position, types, nat, R); matrix3<REAL> f2c,c2f; //std::cout << "after get symmetry\n"; G.group.clear(); for (int i=0; i<3; i++) for (int j=0; j<3; j++) f2c(i,j) = geom.cell(i)(j); c2f = f2c.inverse(); for (int i=0; i<nsymm; i++) { //std::cout << "i= " << i << "\n"; matrix3<REAL> rot; vector3<REAL> transl = {translation[i][0],translation[i][1],translation[i][2]}; for (int j=0; j<3; j++) for (int k=0; k<3; k++) rot(j,k) = rotation[i][j][k]; rot = f2c*rot*c2f; G.group.push_back(rotrans<REAL,true>(f2c*transl,rot,&geom.cell)); } /* std::cout << "Leaving get_symmetry\n"; for (int i=0; i<G.group.size(); i++) std:: cout << G.group[i] << "\n"; */ }
int FC_FUNC_(spglib_get_symmetry, SPGLIB_GET_SYMMETRY) (int rotation[][3][3], double translation[][3], const int * max_size, const double lattice[3][3], const double position[][3], const int types[], const int * num_atom, const double * symprec){ return spg_get_symmetry(rotation, translation, *max_size, lattice, position, types, *num_atom, *symprec); }