static int test_spg_refine_cell_BCC(void) { double lattice[3][3] = {{0, 2, 2}, {2, 0, 2}, {2, 2, 0}}; /* 4 times larger memory space must be prepared. */ double position[4][3]; int types[4]; int num_atom_bravais, num_atom = 1; double symprec = 1e-5; position[0][0] = 0; position[0][1] = 0; position[0][2] = 0; types[0] = 1; /* lattice, position, and types are overwirtten. */ printf("*** spg_refine_cell ***:\n"); num_atom_bravais = spg_refine_cell(lattice, position, types, num_atom, symprec); if (num_atom_bravais == 0) { printf("Refine cell failed.\n"); return 1; } else { show_cell(lattice, position, types, num_atom_bravais); return 0; } }
static PyObject * get_crystallographic_cell(PyObject *self, PyObject *args) { int num_atom, num_atom_brv; double symprec; PyArrayObject* lattice_vectors; PyArrayObject* atomic_positions; PyArrayObject* atom_types; PyObject *array; double *p_lattice; double *p_positions; double lattice[3][3]; double (*positions)[3]; int *types_int; int *types; if (!PyArg_ParseTuple(args, "OOOd", &lattice_vectors, &atomic_positions, &atom_types, &symprec)) { return NULL; } p_lattice = (double(*))lattice_vectors->data; p_positions = (double(*))atomic_positions->data; num_atom = atom_types->dimensions[0]; positions = (double(*)[3]) malloc(sizeof(double[3]) * num_atom * 4); types_int = (int*)atom_types->data; types = (int*) malloc(sizeof(int) * num_atom * 4); set_spglib_cell(lattice, positions, types, num_atom, p_lattice, p_positions, types_int); num_atom_brv = spg_refine_cell(lattice, positions, types, num_atom, symprec); array = set_cell(num_atom_brv, lattice, positions, types); free(types); free(positions); return array; }