Beispiel #1
0
static int test_spg_relocate_BZ_grid_address(void)
{
  double rec_lattice[3][3] = {{-0.17573761,  0.17573761,  0.17573761},
			      { 0.17573761, -0.17573761,  0.17573761},
			      { 0.17573761,  0.17573761, -0.17573761}};
  int rotations[][3][3] = {{{1, 0, 0},
			    {0, 1, 0},
			    {0, 0, 1}}};

  
  int m = 40;
  int mesh[] = {m, m, m};
  int is_shift[] = {0, 0, 0};
  int bz_grid_address[(m + 1) * (m + 1) * (m + 1)][3];
  int bz_map[m * m * m * 8];
  int grid_address[m * m * m][3];
  int grid_mapping_table[m * m * m];
  double q[] = {0, 0, 0};

  int num_ir = spg_get_stabilized_reciprocal_mesh(grid_address,
						  grid_mapping_table,
						  mesh,
						  is_shift,
						  1,
						  1,
						  rotations,
						  1,
						  (double(*)[3])q);
  if (num_ir) {
    printf("*** spg_relocate_BZ_grid_address of NaCl structure ***:\n");

    int num_q = spg_relocate_BZ_grid_address(bz_grid_address,
					     bz_map,
					     grid_address,
					     mesh,
					     rec_lattice,
					     is_shift);

    printf("Number of k-points of NaCl Brillouin zone\n");
    printf("with Gamma-centered 40x40x40 Monkhorst-Pack mesh is %d (65861).\n", num_q);
    return 0;
  } else {
    return 1;
  }
}
Beispiel #2
0
static PyObject * relocate_BZ_grid_address(PyObject *self, PyObject *args)
{
  PyArrayObject* bz_grid_address_py;
  PyArrayObject* bz_map_py;
  PyArrayObject* grid_address_py;
  PyArrayObject* mesh_py;
  PyArrayObject* is_shift_py;
  PyArrayObject* reciprocal_lattice_py;
  if (!PyArg_ParseTuple(args, "OOOOOO",
			&bz_grid_address_py,
			&bz_map_py,
			&grid_address_py,
			&mesh_py,
			&reciprocal_lattice_py,
			&is_shift_py)) {
    return NULL;
  }

  int (*bz_grid_address)[3] = (int(*)[3])PyArray_DATA(bz_grid_address_py);
  int *bz_map = (int*)PyArray_DATA(bz_map_py);
  SPGCONST int (*grid_address)[3] = (int(*)[3])PyArray_DATA(grid_address_py);
  const int* mesh = (int*)PyArray_DATA(mesh_py);
  const int* is_shift = (int*)PyArray_DATA(is_shift_py);
  SPGCONST double (*reciprocal_lattice)[3]  =
    (double(*)[3])PyArray_DATA(reciprocal_lattice_py);
  int num_ir_gp;

  num_ir_gp = spg_relocate_BZ_grid_address(bz_grid_address,
					   bz_map,
					   grid_address,
					   mesh,
					   reciprocal_lattice,
					   is_shift);

  return PyLong_FromLong((long) num_ir_gp);
}