Esempio n. 1
0
static int get_schoenflies(char symbol[10],
			   SPGCONST double lattice[3][3],
			   SPGCONST double position[][3],
			   const int types[],
			   const int num_atom,
			   const double symprec)
{
  Cell *cell;
  Primitive *primitive;
  Spacegroup spacegroup;

  cell = NULL;
  primitive = NULL;
  spacegroup.number = 0;

  cell = cel_alloc_cell(num_atom);
  cel_set_cell(cell, lattice, position, types);

  if ((primitive = spa_get_spacegroup(&spacegroup, cell, symprec)) != NULL) {
    prm_free_primitive(primitive);
    if (spacegroup.number > 0) {
      strcpy(symbol, spacegroup.schoenflies);
    }
  }

  cel_free_cell(cell);

  return spacegroup.number;
}
Esempio n. 2
0
int spg_get_schoenflies( char symbol[10],
			 SPGCONST double lattice[3][3],
			 SPGCONST double position[][3],
			 const int types[], const int num_atom,
			 const double symprec )
{
  Cell *cell;
  Spacegroup spacegroup;

  cell = cel_alloc_cell( num_atom );
  cel_set_cell( cell, lattice, position, types );

  spacegroup = spa_get_spacegroup( cell, symprec );
  if ( spacegroup.number > 0 ) {
    strcpy(symbol, spacegroup.schoenflies);
  }

  cel_free_cell( cell );

  return spacegroup.number;
}
Esempio n. 3
0
/* Return NULL if failed */
static SpglibDataset * get_dataset(SPGCONST double lattice[3][3],
				   SPGCONST double position[][3],
				   const int types[],
				   const int num_atom,
				   const int hall_number,
				   const double symprec)
{
  Spacegroup spacegroup;
  SpacegroupType spacegroup_type;
  SpglibDataset *dataset;
  Cell *cell;
  Primitive *primitive;

  spacegroup.number = 0;
  dataset = NULL;
  cell = NULL;
  primitive = NULL;

  if ((dataset = (SpglibDataset*) malloc(sizeof(SpglibDataset))) == NULL) {
    warning_print("spglib: Memory could not be allocated.");
    return NULL;
  }

  dataset->spacegroup_number = 0;
  strcpy(dataset->international_symbol, "");
  strcpy(dataset->hall_symbol, "");
  strcpy(dataset->setting, "");
  dataset->origin_shift[0] = 0;
  dataset->origin_shift[1] = 0;
  dataset->origin_shift[2] = 0;
  dataset->n_atoms = 0;
  dataset->wyckoffs = NULL;
  dataset->equivalent_atoms = NULL;
  dataset->n_operations = 0;
  dataset->rotations = NULL;
  dataset->translations = NULL;
  dataset->n_brv_atoms = 0;
  dataset->brv_positions = NULL;
  dataset->brv_types = NULL;

  if ((cell = cel_alloc_cell(num_atom)) == NULL) {
    free(dataset);
    dataset = NULL;
    return NULL;
  }

  cel_set_cell(cell, lattice, position, types);

  primitive = spa_get_spacegroup(&spacegroup, cell, symprec);

  if ((spacegroup.number > 0) && (primitive != NULL)) {

    /* With hall_number > 0, specific choice is searched. */
    if (hall_number > 0) {
      spacegroup_type = spgdb_get_spacegroup_type(hall_number);
      if (spacegroup.number == spacegroup_type.number) {
	spacegroup = spa_get_spacegroup_with_hall_number(primitive,
							 hall_number);
      } else {
	goto err;
      }

      if (spacegroup.number == 0) {
	goto err;
      }
    }

    if (spacegroup.number > 0) {
      if ((set_dataset(dataset,
		       cell,
		       primitive->cell,
		       &spacegroup,
		       primitive->mapping_table,
		       primitive->tolerance)) == 0) {
	goto err;
      }
    }
  }

  cel_free_cell(cell);
  prm_free_primitive(primitive);

  return dataset;

 err:
  cel_free_cell(cell);
  prm_free_primitive(primitive);
  free(dataset);
  dataset = NULL;
  return NULL;
}