Пример #1
0
static Symmetry * get_refined_symmetry_operations(SPGCONST Cell * cell,
        SPGCONST Cell * primitive,
        SPGCONST Spacegroup * spacegroup,
        const double symprec)
{
    int t_mat_int[3][3];
    int frame[3];
    double inv_mat[3][3], t_mat[3][3];
    Symmetry *conv_sym, *prim_sym, *symmetry;

    /* Primitive symmetry from database */
    conv_sym = get_db_symmetry(spacegroup->hall_number);
    set_translation_with_origin_shift(conv_sym, spacegroup->origin_shift);
    mat_inverse_matrix_d3(inv_mat, primitive->lattice, symprec);
    mat_multiply_matrix_d3(t_mat, inv_mat, spacegroup->bravais_lattice);
    prim_sym = get_primitive_db_symmetry(t_mat, conv_sym, symprec);

    /* Input cell symmetry from primitive symmetry */
    mat_inverse_matrix_d3(inv_mat, primitive->lattice, symprec);
    mat_multiply_matrix_d3(t_mat, inv_mat, cell->lattice);
    mat_cast_matrix_3d_to_3i(t_mat_int, t_mat);
    get_surrounding_frame(frame, t_mat_int);
    symmetry = reduce_symmetry_in_frame(frame,
                                        prim_sym,
                                        t_mat_int,
                                        cell->lattice,
                                        cell->size / primitive->size,
                                        symprec);

    /* sym_free_symmetry(f_sym); */
    sym_free_symmetry(prim_sym);
    sym_free_symmetry(conv_sym);

    return symmetry;
}
Пример #2
0
static Cell * refine_cell(SPGCONST Cell * cell,
                          const double symprec)
{
    int *wyckoffs, *equiv_atoms;
    double tolerance;
    Cell *primitive, *bravais, *conv_prim;
    Symmetry *conv_sym;
    Spacegroup spacegroup;

    debug_print("refine_cell:\n");

    primitive = prm_get_primitive(cell, symprec);

    if (primitive->size == 0) {
        cel_free_cell(primitive);
        bravais = cel_alloc_cell(0);
        goto end;
    }

    tolerance = prm_get_current_tolerance();
    spacegroup = spa_get_spacegroup_with_primitive(primitive, tolerance);

    wyckoffs = (int*)malloc(sizeof(int) * primitive->size);
    equiv_atoms = (int*)malloc(sizeof(int) * primitive->size);
    conv_prim = get_bravais_exact_positions_and_lattice(wyckoffs,
                equiv_atoms,
                &spacegroup,
                primitive,
                tolerance);
    free(equiv_atoms);
    equiv_atoms = NULL;
    free(wyckoffs);
    wyckoffs = NULL;

    conv_sym = get_db_symmetry(spacegroup.hall_number);
    bravais = expand_positions(conv_prim, conv_sym);

    debug_print("primitive cell in refine_cell:\n");
    debug_print_matrix_d3(primitive->lattice);
    debug_print("conventional lattice in refine_cell:\n");
    debug_print_matrix_d3(conv_prim->lattice);
    debug_print("bravais lattice in refine_cell:\n");
    debug_print_matrix_d3(bravais->lattice);

    cel_free_cell(conv_prim);
    sym_free_symmetry(conv_sym);
    cel_free_cell(primitive);

end:  /* Return bravais->size = 0, if the bravais could not be found. */
    return bravais;
}
Пример #3
0
static Cell * refine_cell( SPGCONST Cell * cell,
			   const double symprec )
{
  int *mapping_table, *wyckoffs, *equiv_atoms;
  Cell *primitive, *bravais, *conv_prim;
  Symmetry *conv_sym;
  VecDBL *pure_trans;
  Spacegroup spacegroup;

  pure_trans = sym_get_pure_translation( cell, symprec );

  mapping_table = (int*) malloc( sizeof(int) * cell->size );
  primitive = prm_get_primitive( mapping_table, cell, pure_trans, symprec );
  free( mapping_table );
  mapping_table = NULL;
  
  if ( primitive->size == -1 ) {
    cel_free_cell( primitive );
    bravais = cel_alloc_cell( -1 );
    goto ret;
  }

  spacegroup = spa_get_spacegroup_with_primitive( primitive, symprec );
  wyckoffs = (int*)malloc( sizeof( int ) * primitive->size );
  equiv_atoms = (int*)malloc( sizeof( int ) * primitive->size );
  conv_prim = get_bravais_exact_positions_and_lattice( wyckoffs,
						       equiv_atoms,
						       &spacegroup,
						       primitive,
						       symprec );
  free( equiv_atoms );
  equiv_atoms = NULL;
  free( wyckoffs );
  wyckoffs = NULL;


  conv_sym = get_db_symmetry( spacegroup.hall_number );
  bravais = expand_positions( conv_prim, conv_sym );
  cel_free_cell( conv_prim );
  sym_free_symmetry( conv_sym );

  cel_free_cell( primitive );

 ret:
  /* Return bravais->size = -1, if the bravais could not be found. */
  return bravais;
}
Пример #4
0
/* Only the atoms corresponding to those in primitive are returned. */
static Cell * get_bravais_exact_positions_and_lattice(int * wyckoffs,
        int * equiv_atoms,
        SPGCONST Spacegroup *spacegroup,
        SPGCONST Cell * primitive,
        const double symprec)
{
    int i;
    Symmetry *conv_sym;
    Cell *bravais;
    VecDBL *exact_positions;

    /* Positions of primitive atoms are represented wrt Bravais lattice */
    bravais = get_conventional_primitive(spacegroup, primitive);
    /* Symmetries in database (wrt Bravais lattice) */
    conv_sym = get_db_symmetry(spacegroup->hall_number);
    /* Lattice vectors are set. */
    get_conventional_lattice(bravais->lattice,
                             spacegroup->holohedry,
                             spacegroup->bravais_lattice);

    /* Symmetrize atomic positions of conventional unit cell */
    exact_positions = ssm_get_exact_positions(wyckoffs,
                      equiv_atoms,
                      bravais,
                      conv_sym,
                      spacegroup->hall_number,
                      symprec);
    sym_free_symmetry(conv_sym);

    if (exact_positions->size > 0) {
        for (i = 0; i < bravais->size; i++) {
            mat_copy_vector_d3(bravais->position[i], exact_positions->vec[i]);
        }
    } else {
        cel_free_cell(bravais);
        bravais = cel_alloc_cell(0);
    }

    mat_free_VecDBL(exact_positions);

    return bravais;
}