Ejemplo n.º 1
0
/* Return NULL if failed */
Symmetry * spn_get_collinear_operations(int equiv_atoms[],
					SPGCONST Symmetry *sym_nonspin,
					SPGCONST Cell *cell,
					const double spins[],
					const double symprec)
{
  Symmetry *symmetry;

  symmetry = NULL;

  if ((symmetry = get_collinear_operations(sym_nonspin,
					   cell,
					   spins,
					   symprec)) == NULL) {
    return NULL;
  }

  if ((set_equivalent_atoms(equiv_atoms,
			    symmetry,
			    cell,
			    symprec)) == 0) {
    sym_free_symmetry(symmetry);
    symmetry = NULL;
  }

  return symmetry;
}
Ejemplo n.º 2
0
Cell * get_Wyckoff_positions(int * wyckoffs,
			     int * equiv_atoms,
			     SPGCONST Cell * primitive,
			     SPGCONST Cell * cell,
			     SPGCONST Spacegroup * spacegroup,
			     SPGCONST Symmetry * symmetry,
			     const int * mapping_table,
			     const double symprec)
{
  Cell *bravais;
  int i, num_prim_sym;
  int *wyckoffs_bravais, *equiv_atoms_bravais;
  int operation_index[2];

  debug_print("get_Wyckoff_positions\n");

  bravais = NULL;
  wyckoffs_bravais = NULL;
  equiv_atoms_bravais = NULL;

  if ((wyckoffs_bravais = (int*)malloc(sizeof(int) * primitive->size * 4))
      == NULL) {
    warning_print("spglib: Memory could not be allocated ");
    return NULL;
  }

  if ((equiv_atoms_bravais = (int*)malloc(sizeof(int) * primitive->size * 4))
      == NULL) {
    warning_print("spglib: Memory could not be allocated ");
    free(wyckoffs_bravais);
    wyckoffs_bravais = NULL;
    return NULL;
  }

  if ((bravais = get_bravais_exact_positions_and_lattice
       (wyckoffs_bravais,
	equiv_atoms_bravais,
	spacegroup,
	primitive,
	symprec)) == NULL) {
    goto ret;
  }

  for (i = 0; i < cell->size; i++) {
    wyckoffs[i] = wyckoffs_bravais[mapping_table[i]];
  }

  spgdb_get_operation_index(operation_index, spacegroup->hall_number);
  num_prim_sym = operation_index[0] / (bravais->size / primitive->size);

  /* Check symmetry breaking by unusual multiplicity of primitive cell. */
  if (cell->size * num_prim_sym != symmetry->size * primitive->size) {
    set_equivalent_atoms_broken_symmetry(equiv_atoms,
					 cell,
					 symmetry,
					 mapping_table,
					 symprec);
  } else {
    if (set_equivalent_atoms(equiv_atoms,
			     primitive,
			     cell,
			     equiv_atoms_bravais,
			     mapping_table) == 0) {
      cel_free_cell(bravais);
      bravais = NULL;
    }
  }

 ret:
  free(equiv_atoms_bravais);
  equiv_atoms_bravais = NULL;
  free(wyckoffs_bravais);
  wyckoffs_bravais = NULL;

  return bravais;
}