Ejemplo n.º 1
0
  int spgw_standartize_cell(geometry<VALTYPE,CELL> &inGeom,geometry<VALTYPE,CELL>
                            &outGeom, float symprec = 1e-5)
  {

    int num_atoms = inGeom.size();
    auto latticev = new VALTYPE[3][3]();
    auto position = new VALTYPE[num_atoms][3]();
    auto types = new int[num_atoms]();
    get_spgdata_from_geom(inGeom,latticev,position,types);

    int to_primitive = 1;
    int no_idealize = 0;
    int num_primitive_atom = spg_standardize_cell(latticev, position, types,
                                                  to_primitive, no_idealize,
                                                  num_atoms, symprec);

    //Get standartized cell back to user
    for(int i=0; i<3; i++){
      outGeom.cell.v[i].x() = latticev[i][0];
      outGeom.cell.v[i].y() = latticev[i][1];
      outGeom.cell.v[i].z() = latticev[i][2];
    }

    for(int i=0; i<num_atoms; i++){
      outGeom.add(inGeom.atom_of_type(types[i]),
                  position[i][0], position[i][1], position[i][2]);
    }

    return num_primitive_atom;
  }
Ejemplo n.º 2
0
static int sub_spg_standardize_cell(double lattice[3][3],
				    double position[][3],
				    int types[],
				    const int num_atom,
				    const double symprec,
				    const int to_primitive,
				    const int no_idealize)
{
  int i, num_primitive_atom;
  double lat[3][3], pos[num_atom][3];
  int typ[num_atom];

  for (i = 0; i < 3; i++) {
    lat[i][0] = lattice[i][0];
    lat[i][1] = lattice[i][1];
    lat[i][2] = lattice[i][2];
  }

  for (i = 0; i < num_atom; i++) {
    pos[i][0] = position[i][0];
    pos[i][1] = position[i][1];
    pos[i][2] = position[i][2];
    typ[i] = types[i];
  }
  
  /* lattice, position, and types are overwirtten. */
  num_primitive_atom = spg_standardize_cell(lat,
					    pos,
					    typ,
					    num_atom,
					    to_primitive,
					    no_idealize,
					    symprec);
  printf("VASP POSCAR format: ");
  if (to_primitive == 0) {
    printf("to_primitive=0 and ");
  } else {
    printf("to_primitive=1 and ");
  }

  if (no_idealize == 0) {
    printf("no_idealize=0\n");
  } else {
    printf("no_idealize=1\n");
  }
  printf("1.0\n");
  for (i = 0; i < 3; i++) {
    printf("%f %f %f\n", lat[0][i], lat[1][i], lat[2][i]);
  }
  printf("%d\n", num_primitive_atom);
  printf("Direct\n");
  for (i = 0; i < num_primitive_atom; i++) {
    printf("%f %f %f\n", pos[i][0], pos[i][1], pos[i][2]);
  }

  return 0;
}