From c3ecdf02cdb5f84d7c903db1f260b3f5c606dbcc Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Thu, 2 Nov 2017 10:21:19 +0900 Subject: [PATCH] spglib update to v1.10.1 --- c/spglib/determination.c | 182 +++++++++ c/spglib/hall_symbol.c | 742 ++++++++++++++++++------------------ c/spglib/kgrid.c | 34 +- c/spglib/mathfunc.c | 76 ++-- c/spglib/niggli.c | 20 +- c/spglib/pointgroup.c | 171 +++++---- c/spglib/primitive.c | 63 ++- c/spglib/refinement.c | 224 +++++++---- c/spglib/sitesym_database.c | 6 +- c/spglib/spacegroup.c | 147 +++---- c/spglib/spg_database.c | 8 +- c/spglib/spglib.c | 325 ++++++---------- c/spglib/spin.c | 4 +- c/spglib/symmetry.c | 352 ++++++++--------- c/spglib_h/determination.h | 55 +++ c/spglib_h/refinement.h | 33 +- c/spglib_h/spacegroup.h | 15 +- c/spglib_h/spglib.h | 331 ++++++++-------- c/spglib_h/symmetry.h | 10 +- c/spglib_h/version.h | 4 +- setup.py | 5 +- 21 files changed, 1482 insertions(+), 1325 deletions(-) create mode 100644 c/spglib/determination.c create mode 100644 c/spglib_h/determination.h diff --git a/c/spglib/determination.c b/c/spglib/determination.c new file mode 100644 index 00000000..9d933a74 --- /dev/null +++ b/c/spglib/determination.c @@ -0,0 +1,182 @@ +/* Copyright (C) 2017 Atsushi Togo */ +/* All rights reserved. */ + +/* This file is part of spglib. */ + +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions */ +/* are met: */ + +/* * Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ + +/* * Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the */ +/* distribution. */ + +/* * Neither the name of the phonopy project nor the names of its */ +/* contributors may be used to endorse or promote products derived */ +/* from this software without specific prior written permission. */ + +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */ +/* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ +/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */ +/* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ +/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */ +/* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */ +/* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */ +/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ + +#include +#include "cell.h" +#include "determination.h" +#include "primitive.h" +#include "spacegroup.h" + +#include "debug.h" + +#define REDUCE_RATE_OUTER 0.9 +#define NUM_ATTEMPT_OUTER 10 +#define REDUCE_RATE 0.95 +#define NUM_ATTEMPT 20 + +static int get_spacegroup_and_primitive(DataContainer * container, + const Cell * cell, + const int hall_number, + const double symprec, + const double angle_tolerance); +DataContainer * det_determine_all(const Cell * cell, + const int hall_number, + const double symprec, + const double angle_tolerance) +{ + int attempt; + double tolerance; + DataContainer *container; + + container = NULL; + + if ((container = (DataContainer*) malloc(sizeof(DataContainer))) == NULL) { + warning_print("spglib: Memory could not be allocated."); + return NULL; + } + + container->primitive = NULL; + container->spacegroup = NULL; + container->exact_structure = NULL; + + if ((container->spacegroup = (Spacegroup*) malloc(sizeof(Spacegroup))) + == NULL) { + warning_print("spglib: Memory could not be allocated."); + det_free_container(container); + container = NULL; + return NULL; + } + + tolerance = symprec; + for (attempt = 0; attempt < NUM_ATTEMPT_OUTER; attempt++) { + if (get_spacegroup_and_primitive(container, + cell, + hall_number, + tolerance, + angle_tolerance)) { + if (container->spacegroup->number > 0) { + if ((container->exact_structure = ref_get_exact_structure_and_symmetry( + container->primitive->cell, + cell, + container->spacegroup, + container->primitive->mapping_table, + container->primitive->tolerance)) == NULL) { + warning_print("spglib: ref_get_exact_structure_and_symmetry failed."); + warning_print(" (line %d, %s).\n", __LINE__, __FILE__); + } else { + goto found; + } + } + ref_free_exact_structure(container->exact_structure); + container->exact_structure = NULL; + } + tolerance *= REDUCE_RATE_OUTER; + prm_free_primitive(container->primitive); + container->primitive = NULL; + } + + det_free_container(container); + return NULL; + +found: + return container; +} + +/* NULL is returned if failed */ +static int get_spacegroup_and_primitive(DataContainer * container, + const Cell * cell, + const int hall_number, + const double symprec, + const double angle_tolerance) +{ + int attempt; + double tolerance; + + debug_print("get_spacegroup_and_primitive (tolerance = %f):\n", symprec); + + if (hall_number < 0 || hall_number > 530) { + return 0; + } + + tolerance = symprec; + + for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { + if ((container->primitive = prm_get_primitive(cell, + tolerance, + angle_tolerance)) != NULL) { + *(container->spacegroup) = spa_search_spacegroup( + container->primitive->cell, + hall_number, + container->primitive->tolerance, + container->primitive->angle_tolerance); + + if (container->spacegroup->number > 0) { + goto found; + } + + prm_free_primitive(container->primitive); + container->primitive = NULL; + } + + warning_print("spglib: Attempt %d tolerance = %f failed.", + attempt, tolerance); + warning_print(" (line %d, %s).\n", __LINE__, __FILE__); + + tolerance *= REDUCE_RATE; + } + + return 0; + +found: + return 1; +} + +void det_free_container(DataContainer * container) +{ + if (container != NULL) { + if (container->spacegroup != NULL) { + free(container->spacegroup); + container->spacegroup = NULL; + } + if (container->primitive != NULL) { + prm_free_primitive(container->primitive); + container->primitive = NULL; + } + if (container->exact_structure != NULL) { + ref_free_exact_structure(container->exact_structure); + container->exact_structure = NULL; + } + free(container); + } +} diff --git a/c/spglib/hall_symbol.c b/c/spglib/hall_symbol.c index 01629424..e20c4349 100644 --- a/c/spglib/hall_symbol.c +++ b/c/spglib/hall_symbol.c @@ -906,7 +906,7 @@ static int trigo_generators[][3][9] = { -1, 0, 0, 0, -1, 0, 0, 0, -1, }, }, }; - + static double rhombo_h_VSpU[][3][9] = { { /* 1 */ @@ -1389,113 +1389,113 @@ static int cubic_generators[][3][9] = static int find_hall_symbol(double origin_shift[3], - SPGCONST double bravais_lattice[3][3], - const int hall_number, - const Centering centering, - const Symmetry *symmetry, - const double symprec); + SPGCONST double bravais_lattice[3][3], + const int hall_number, + const Centering centering, + const Symmetry *symmetry, + const double symprec); static int is_hall_symbol(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - Centering centering, - SPGCONST int generators[3][9], - SPGCONST double VSpU[3][9], - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + Centering centering, + SPGCONST int generators[3][9], + SPGCONST double VSpU[3][9], + const double symprec); static int is_hall_symbol_cubic(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec); static int is_hall_symbol_hexa(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec); static int is_hall_symbol_rhombo(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec); static int is_hall_symbol_trigonal(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec); static int is_hall_symbol_tetra(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec); static int is_hall_symbol_ortho(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec); static int is_hall_symbol_monocli(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec); static int is_hall_symbol_tricli(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec); + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec); static int get_translations(double trans[3][3], - const Symmetry *symmetry, - SPGCONST int rot[3][3][3]); + const Symmetry *symmetry, + SPGCONST int rot[3][3][3]); static void transform_translation(double trans_reduced[3], - const Centering centering, - const double trans[3]); + const Centering centering, + const double trans[3]); static void transform_rotation(double rot_reduced[3][3], - const Centering centering, - SPGCONST int rot[3][3]); + const Centering centering, + SPGCONST int rot[3][3]); static int get_origin_shift(double shift[3], - const int hall_number, - SPGCONST int rot[3][3][3], - SPGCONST double trans[3][3], - const Centering centering, - SPGCONST double VSpU[3][9]); + const int hall_number, + SPGCONST int rot[3][3][3], + SPGCONST double trans[3][3], + const Centering centering, + SPGCONST double VSpU[3][9]); static void unpack_generators(int rot[3][3][3], int generators[3][9]); static int set_dw(double dw[3], - const int operation_index[2], - SPGCONST int rot[3][3], - const double trans[3], - const Centering centering); + const int operation_index[2], + SPGCONST int rot[3][3], + const double trans[3], + const Centering centering); static int is_match_database(const int hall_number, - const double shift[3], - SPGCONST double primitive_lattice[3][3], - const Centering centering, - const Symmetry *symmetry, - const double symprec); + const double shift[3], + SPGCONST double primitive_lattice[3][3], + const Centering centering, + const Symmetry *symmetry, + const double symprec); int hal_match_hall_symbol_db(double origin_shift[3], - SPGCONST double bravais_lattice[3][3], - const int hall_number, - const Centering centering, - const Symmetry *symmetry, - const double symprec) + SPGCONST double bravais_lattice[3][3], + const int hall_number, + const Centering centering, + const Symmetry *symmetry, + const double symprec) { return find_hall_symbol(origin_shift, - bravais_lattice, - hall_number, - centering, - symmetry, - symprec); + bravais_lattice, + hall_number, + centering, + symmetry, + symprec); } static int find_hall_symbol(double origin_shift[3], - SPGCONST double bravais_lattice[3][3], - const int hall_number, - const Centering centering, - const Symmetry *symmetry, - const double symprec) + SPGCONST double bravais_lattice[3][3], + const int hall_number, + const Centering centering, + const Symmetry *symmetry, + const double symprec) { double primitive_lattice[3][3]; @@ -1528,21 +1528,21 @@ static int find_hall_symbol(double origin_shift[3], /* CUBIC IT: 195-230, Hall: 489-530 */ if (489 <= hall_number && hall_number <= 530) { if (is_hall_symbol_cubic(origin_shift, - hall_number, - primitive_lattice, - symmetry, - centering, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + centering, + symprec)) {goto found;} return 0; } /* HEXA, IT: 168-194, Hall: 462-488 */ if (462 <= hall_number && hall_number <= 488) { if (is_hall_symbol_hexa(origin_shift, - hall_number, - primitive_lattice, - symmetry, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + symprec)) {goto found;} return 0; } @@ -1563,16 +1563,16 @@ static int find_hall_symbol(double origin_shift[3], hall_number == 460 || hall_number == 461) { if (is_hall_symbol_rhombo(origin_shift, - hall_number, - primitive_lattice, - symmetry, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + symprec)) {goto found;} } else { if (is_hall_symbol_trigonal(origin_shift, - hall_number, - primitive_lattice, - symmetry, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + symprec)) {goto found;} } return 0; } @@ -1580,43 +1580,43 @@ static int find_hall_symbol(double origin_shift[3], /* TETRA, IT: 75-142, Hall: 349-429 */ if (349 <= hall_number && hall_number <= 429) { if (is_hall_symbol_tetra(origin_shift, - hall_number, - primitive_lattice, - symmetry, - centering, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + centering, + symprec)) {goto found;} return 0; } - + /* ORTHO, IT: 16-74, Hall: 108-348 */ if (108 <= hall_number && hall_number <= 348) { if (is_hall_symbol_ortho(origin_shift, - hall_number, - primitive_lattice, - symmetry, - centering, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + centering, + symprec)) {goto found;} return 0; } /* MONOCLI, IT: 3-15, Hall: 3-107 */ if (3 <= hall_number && hall_number <= 107) { if (is_hall_symbol_monocli(origin_shift, - hall_number, - primitive_lattice, - symmetry, - centering, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + centering, + symprec)) {goto found;} return 0; } /* TRICLI, IT: 1-2, Hall: 1-2 */ if (1 <= hall_number && hall_number <= 2) { if (is_hall_symbol_tricli(origin_shift, - hall_number, - primitive_lattice, - symmetry, - symprec)) {goto found;} + hall_number, + primitive_lattice, + symmetry, + symprec)) {goto found;} return 0; } @@ -1651,46 +1651,46 @@ static int find_hall_symbol(double origin_shift[3], } static int is_hall_symbol_cubic(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec) { int i; for (i = 0; i < 10; i++) { if (centering == PRIMITIVE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - cubic_generators[i], - cubic_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + cubic_generators[i], + cubic_VSpU[i], + symprec)) {return 1;} } if (centering == BODY) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - cubic_generators[i], - cubic_I_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + cubic_generators[i], + cubic_I_VSpU[i], + symprec)) {return 1;} } if (centering == FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - cubic_generators[i], - cubic_F_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + cubic_generators[i], + cubic_F_VSpU[i], + symprec)) {return 1;} } } @@ -1698,54 +1698,54 @@ static int is_hall_symbol_cubic(double shift[3], } static int is_hall_symbol_hexa(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec) { int i; for (i = 0; i < 8; i++) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - PRIMITIVE, - hexa_generators[i], - hexa_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + PRIMITIVE, + hexa_generators[i], + hexa_VSpU[i], + symprec)) {return 1;} } return 0; } static int is_hall_symbol_trigonal(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec) { int i; for (i = 0; i < 13; i++) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - PRIMITIVE, - trigo_generators[i], - trigo_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + PRIMITIVE, + trigo_generators[i], + trigo_VSpU[i], + symprec)) {return 1;} } return 0; } static int is_hall_symbol_rhombo(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec) { int i; @@ -1759,25 +1759,25 @@ static int is_hall_symbol_rhombo(double shift[3], /* hP */ for (i = 0; i < 8; i++) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - R_CENTER, - rhombo_h_generators[i], - rhombo_h_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + R_CENTER, + rhombo_h_generators[i], + rhombo_h_VSpU[i], + symprec)) {return 1;} } } else { /* hR */ for (i = 0; i < 8; i++) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - PRIMITIVE, - rhombo_p_generators[i], - rhombo_p_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + PRIMITIVE, + rhombo_p_generators[i], + rhombo_p_VSpU[i], + symprec)) {return 1;} } } @@ -1785,35 +1785,35 @@ static int is_hall_symbol_rhombo(double shift[3], } static int is_hall_symbol_tetra(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec) { int i; for (i = 0; i < 8; i++) { if (centering==PRIMITIVE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - tetra_generators[i], - tetra_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + tetra_generators[i], + tetra_VSpU[i], + symprec)) {return 1;} } if (centering==BODY) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - tetra_generators[i], - tetra_I_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + tetra_generators[i], + tetra_I_VSpU[i], + symprec)) {return 1;} } } @@ -1821,79 +1821,79 @@ static int is_hall_symbol_tetra(double shift[3], } static int is_hall_symbol_ortho(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec) { int i; for (i = 0; i < 5; i++) { if (centering == PRIMITIVE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - ortho_generators[i], - ortho_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + ortho_generators[i], + ortho_VSpU[i], + symprec)) {return 1;} } if (centering == BODY) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - ortho_generators[i], - ortho_I_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + ortho_generators[i], + ortho_I_VSpU[i], + symprec)) {return 1;} } if (centering == FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - ortho_generators[i], - ortho_F_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + ortho_generators[i], + ortho_F_VSpU[i], + symprec)) {return 1;} } if (centering == A_FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - ortho_generators[i], - ortho_A_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + ortho_generators[i], + ortho_A_VSpU[i], + symprec)) {return 1;} } if (centering == B_FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - ortho_generators[i], - ortho_B_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + ortho_generators[i], + ortho_B_VSpU[i], + symprec)) {return 1;} } if (centering == C_FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - ortho_generators[i], - ortho_C_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + ortho_generators[i], + ortho_C_VSpU[i], + symprec)) {return 1;} } } @@ -1901,91 +1901,91 @@ static int is_hall_symbol_ortho(double shift[3], } static int is_hall_symbol_monocli(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const Centering centering, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const Centering centering, + const double symprec) { int i; for (i = 0; i < 9; i++) { if (centering == PRIMITIVE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - monocli_generators[i], - monocli_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + monocli_generators[i], + monocli_VSpU[i], + symprec)) {return 1;} } if (centering == A_FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - monocli_generators[i], - monocli_A_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + monocli_generators[i], + monocli_A_VSpU[i], + symprec)) {return 1;} } if (centering == B_FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - monocli_generators[i], - monocli_B_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + monocli_generators[i], + monocli_B_VSpU[i], + symprec)) {return 1;} } if (centering == C_FACE) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - monocli_generators[i], - monocli_C_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + monocli_generators[i], + monocli_C_VSpU[i], + symprec)) {return 1;} } if (centering == BODY) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - centering, - monocli_generators[i], - monocli_I_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + centering, + monocli_generators[i], + monocli_I_VSpU[i], + symprec)) {return 1;} } } - + return 0; } static int is_hall_symbol_tricli(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + const double symprec) { int i; for (i = 0; i < 2; i++) { if (is_hall_symbol(shift, - hall_number, - primitive_lattice, - symmetry, - PRIMITIVE, - tricli_generators[i], - tricli_VSpU[i], - symprec)) {return 1;} + hall_number, + primitive_lattice, + symmetry, + PRIMITIVE, + tricli_generators[i], + tricli_VSpU[i], + symprec)) {return 1;} } return 0; @@ -1997,20 +1997,20 @@ static void unpack_generators(int rot[3][3][3], int generators[3][9]) for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) { - rot[i][j][k] = generators[i][j*3+k]; + rot[i][j][k] = generators[i][j*3+k]; } } } } static int is_hall_symbol(double shift[3], - const int hall_number, - SPGCONST double primitive_lattice[3][3], - const Symmetry *symmetry, - Centering centering, - SPGCONST int generators[3][9], - SPGCONST double VSpU[3][9], - const double symprec) + const int hall_number, + SPGCONST double primitive_lattice[3][3], + const Symmetry *symmetry, + Centering centering, + SPGCONST int generators[3][9], + SPGCONST double VSpU[3][9], + const double symprec) { int is_origin_shift; int operation_index[2]; @@ -2026,19 +2026,19 @@ static int is_hall_symbol(double shift[3], unpack_generators(rot, generators); if (get_translations(trans, symmetry, rot)) { is_origin_shift = get_origin_shift(shift, - hall_number, - rot, - trans, - centering, - VSpU); + hall_number, + rot, + trans, + centering, + VSpU); if (is_origin_shift) { if (is_match_database(hall_number, - shift, - primitive_lattice, - centering, - symmetry, - symprec)) {goto found;} + shift, + primitive_lattice, + centering, + symmetry, + symprec)) {goto found;} } } else { goto not_found; @@ -2052,14 +2052,14 @@ static int is_hall_symbol(double shift[3], } static int get_translations(double trans[3][3], - const Symmetry *symmetry, - SPGCONST int rot[3][3][3]) + const Symmetry *symmetry, + SPGCONST int rot[3][3][3]) { int i, j; int is_found; - static SPGCONST int zero[3][3] = { { 0, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, }; + static SPGCONST int zero[3][3] = { { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, }; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { @@ -2072,9 +2072,9 @@ static int get_translations(double trans[3][3], is_found = 0; for (j = 0; j < symmetry->size; j++) { if (mat_check_identity_matrix_i3(symmetry->rot[j], rot[i])) { - mat_copy_vector_d3(trans[i], symmetry->trans[j]); - is_found = 1; - break; + mat_copy_vector_d3(trans[i], symmetry->trans[j]); + is_found = 1; + break; } } if (! is_found) { @@ -2090,8 +2090,8 @@ static int get_translations(double trans[3][3], } static void transform_translation(double trans_reduced[3], - const Centering centering, - const double trans[3]) + const Centering centering, + const double trans[3]) { int i; @@ -2127,8 +2127,8 @@ static void transform_translation(double trans_reduced[3], } static void transform_rotation(double rot_reduced[3][3], - const Centering centering, - SPGCONST int rot[3][3]) + const Centering centering, + SPGCONST int rot[3][3]) { mat_cast_matrix_3i_to_3d(rot_reduced, rot); if (centering != PRIMITIVE) { @@ -2158,11 +2158,11 @@ static void transform_rotation(double rot_reduced[3][3], } static int get_origin_shift(double shift[3], - const int hall_number, - SPGCONST int rot[3][3][3], - SPGCONST double trans[3][3], - const Centering centering, - SPGCONST double VSpU[3][9]) + const int hall_number, + SPGCONST int rot[3][3][3], + SPGCONST double trans[3][3], + const Centering centering, + SPGCONST double VSpU[3][9]) { int i, j; int operation_index[2]; @@ -2175,15 +2175,15 @@ static int get_origin_shift(double shift[3], /* Zero matrix is the sign to set dw 0 */ if (mat_get_determinant_i3(rot[i]) == 0) { for (j = 0; j < 3; j++) { - dw[i * 3 + j] = 0; + dw[i * 3 + j] = 0; } } else { if (set_dw(tmp_dw, operation_index, rot[i], trans[i], centering)) { - for (j = 0; j < 3; j++) { - dw[i * 3 + j] = tmp_dw[j]; - } + for (j = 0; j < 3; j++) { + dw[i * 3 + j] = tmp_dw[j]; + } } else { - goto not_found; + goto not_found; } } } @@ -2204,10 +2204,10 @@ static int get_origin_shift(double shift[3], } static int set_dw(double dw[3], - const int operation_index[2], - SPGCONST int rot[3][3], - const double trans[3], - const Centering centering) + const int operation_index[2], + SPGCONST int rot[3][3], + const double trans[3], + const Centering centering) { int i, j; int rot_db[3][3]; @@ -2219,8 +2219,8 @@ static int set_dw(double dw[3], transform_translation(trans_db_prim, centering, trans_db); if (mat_check_identity_matrix_i3(rot_db, rot)) { for (j = 0; j < 3; j++) { - dw[j] = trans_prim[j] - trans_db_prim[j]; - dw[j] = mat_Dmod1(dw[j]); + dw[j] = trans_prim[j] - trans_db_prim[j]; + dw[j] = mat_Dmod1(dw[j]); } goto found; } @@ -2228,17 +2228,17 @@ static int set_dw(double dw[3], /* Not found */ return 0; - + found: return 1; } static int is_match_database(const int hall_number, - const double origin_shift[3], - SPGCONST double primitive_lattice[3][3], - const Centering centering, - const Symmetry *symmetry, - const double symprec) + const double origin_shift[3], + SPGCONST double primitive_lattice[3][3], + const Centering centering, + const Symmetry *symmetry, + const double symprec) { int i, j, k, is_found; int operation_index[2]; @@ -2255,20 +2255,20 @@ static int is_match_database(const int hall_number, for (j = 0; j < operation_index[0]; j++) { spgdb_get_operation(rot_db, trans_db, operation_index[1] + j); if (mat_check_identity_matrix_i3(symmetry->rot[i], rot_db)) { - transform_translation(trans_db_prim, centering, trans_db); - transform_translation(trans_prim, centering, symmetry->trans[i]); - transform_rotation(rot_prim, centering, rot_db); - for (k = 0; k < 3; k++) { - diff[k] = trans_prim[k] - trans_db_prim[k] + origin_shift[k]; - } - mat_multiply_matrix_vector_d3(shift_rot, rot_prim, origin_shift); - if (cel_is_overlap(diff, shift_rot, primitive_lattice, symprec)) { - if (! found_list[j]) { - found_list[j] = 1; - is_found = 1; - break; - } - } + transform_translation(trans_db_prim, centering, trans_db); + transform_translation(trans_prim, centering, symmetry->trans[i]); + transform_rotation(rot_prim, centering, rot_db); + for (k = 0; k < 3; k++) { + diff[k] = trans_prim[k] - trans_db_prim[k] + origin_shift[k]; + } + mat_multiply_matrix_vector_d3(shift_rot, rot_prim, origin_shift); + if (cel_is_overlap(diff, shift_rot, primitive_lattice, symprec)) { + if (! found_list[j]) { + found_list[j] = 1; + is_found = 1; + break; + } + } } } diff --git a/c/spglib/kgrid.c b/c/spglib/kgrid.c index 37e6c17a..67d69db0 100644 --- a/c/spglib/kgrid.c +++ b/c/spglib/kgrid.c @@ -36,7 +36,7 @@ static void get_all_grid_addresses(int grid_address[][3], const int mesh[3]); static int get_grid_point_double_mesh(const int address_double[3], - const int mesh[3]); + const int mesh[3]); static int get_grid_point_single_mesh(const int address[3], const int mesh[3]); static void modulo_i3(int v[3], const int m[3]); static void reduce_grid_address(int address[3], const int mesh[3]); @@ -48,15 +48,15 @@ void kgd_get_all_grid_addresses(int grid_address[][3], const int mesh[3]) } int kgd_get_grid_point_double_mesh(const int address_double[3], - const int mesh[3]) + const int mesh[3]) { return get_grid_point_double_mesh(address_double, mesh); } void kgd_get_grid_address_double_mesh(int address_double[3], - const int address[3], - const int mesh[3], - const int is_shift[3]) + const int address[3], + const int mesh[3], + const int is_shift[3]) { int i; @@ -76,19 +76,19 @@ static void get_all_grid_addresses(int grid_address[][3], const int mesh[3]) for (j = 0; j < mesh[1]; j++) { address[1] = j; for (k = 0; k < mesh[2]; k++) { - address[2] = k; - grid_point = get_grid_point_single_mesh(address, mesh); - grid_address[grid_point][0] = address[0]; - grid_address[grid_point][1] = address[1]; - grid_address[grid_point][2] = address[2]; - reduce_grid_address(grid_address[grid_point], mesh); + address[2] = k; + grid_point = get_grid_point_single_mesh(address, mesh); + grid_address[grid_point][0] = address[0]; + grid_address[grid_point][1] = address[1]; + grid_address[grid_point][2] = address[2]; + reduce_grid_address(grid_address[grid_point], mesh); } } } } static int get_grid_point_double_mesh(const int address_double[3], - const int mesh[3]) + const int mesh[3]) { int i, address[3]; @@ -105,13 +105,13 @@ static int get_grid_point_double_mesh(const int address_double[3], } static int get_grid_point_single_mesh(const int address[3], - const int mesh[3]) -{ + const int mesh[3]) +{ #ifndef GRID_ORDER_XYZ return address[2] * mesh[0] * mesh[1] + address[1] * mesh[0] + address[0]; #else return address[0] * mesh[1] * mesh[2] + address[1] * mesh[2] + address[2]; -#endif +#endif } static void modulo_i3(int v[3], const int m[3]) @@ -137,7 +137,7 @@ static void reduce_grid_address(int address[3], const int mesh[3]) #else address[i] -= mesh[i] * (address[i] > (mesh[i] - 1) / 2); #endif - } + } } static void reduce_grid_address_double(int address[3], const int mesh[3]) @@ -150,5 +150,5 @@ static void reduce_grid_address_double(int address[3], const int mesh[3]) #else address[i] -= 2 * mesh[i] * (address[i] > mesh[i] - 1); #endif - } + } } diff --git a/c/spglib/mathfunc.c b/c/spglib/mathfunc.c index 3c22a1d2..7abc42fc 100644 --- a/c/spglib/mathfunc.c +++ b/c/spglib/mathfunc.c @@ -98,7 +98,7 @@ void mat_copy_vector_i3(int a[3], const int b[3]) } int mat_check_identity_matrix_i3(SPGCONST int a[3][3], - SPGCONST int b[3][3]) + SPGCONST int b[3][3]) { if ( a[0][0] - b[0][0] || a[0][1] - b[0][1] || @@ -117,8 +117,8 @@ int mat_check_identity_matrix_i3(SPGCONST int a[3][3], } int mat_check_identity_matrix_d3(SPGCONST double a[3][3], - SPGCONST double b[3][3], - const double symprec) + SPGCONST double b[3][3], + const double symprec) { if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec || mat_Dabs( a[0][1] - b[0][1] ) > symprec || @@ -137,8 +137,8 @@ int mat_check_identity_matrix_d3(SPGCONST double a[3][3], } int mat_check_identity_matrix_id3(SPGCONST int a[3][3], - SPGCONST double b[3][3], - const double symprec) + SPGCONST double b[3][3], + const double symprec) { if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec || mat_Dabs( a[0][1] - b[0][1] ) > symprec || @@ -158,68 +158,68 @@ int mat_check_identity_matrix_id3(SPGCONST int a[3][3], /* m=axb */ void mat_multiply_matrix_d3(double m[3][3], - SPGCONST double a[3][3], - SPGCONST double b[3][3]) + SPGCONST double a[3][3], + SPGCONST double b[3][3]) { int i, j; /* a_ij */ double c[3][3]; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } mat_copy_matrix_d3(m, c); } void mat_multiply_matrix_i3(int m[3][3], - SPGCONST int a[3][3], - SPGCONST int b[3][3]) + SPGCONST int a[3][3], + SPGCONST int b[3][3]) { int i, j; /* a_ij */ int c[3][3]; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } mat_copy_matrix_i3(m, c); } void mat_multiply_matrix_di3(double m[3][3], - SPGCONST double a[3][3], - SPGCONST int b[3][3]) + SPGCONST double a[3][3], + SPGCONST int b[3][3]) { int i, j; /* a_ij */ double c[3][3]; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } mat_copy_matrix_d3(m, c); } void mat_multiply_matrix_id3(double m[3][3], - SPGCONST int a[3][3], - SPGCONST double b[3][3]) + SPGCONST int a[3][3], + SPGCONST double b[3][3]) { int i, j; /* a_ij */ double c[3][3]; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { c[i][j] = - a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; + a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]; } } mat_copy_matrix_d3(m, c); } void mat_multiply_matrix_vector_i3(int v[3], - SPGCONST int a[3][3], - const int b[3]) + SPGCONST int a[3][3], + const int b[3]) { int i; int c[3]; @@ -230,8 +230,8 @@ void mat_multiply_matrix_vector_i3(int v[3], } void mat_multiply_matrix_vector_d3(double v[3], - SPGCONST double a[3][3], - const double b[3]) + SPGCONST double a[3][3], + const double b[3]) { int i; double c[3]; @@ -242,8 +242,8 @@ void mat_multiply_matrix_vector_d3(double v[3], } void mat_multiply_matrix_vector_id3(double v[3], - SPGCONST int a[3][3], - const double b[3]) + SPGCONST int a[3][3], + const double b[3]) { int i; double c[3]; @@ -254,8 +254,8 @@ void mat_multiply_matrix_vector_id3(double v[3], } void mat_multiply_matrix_vector_di3(double v[3], - SPGCONST double a[3][3], - const int b[3]) + SPGCONST double a[3][3], + const int b[3]) { int i; double c[3]; @@ -266,8 +266,8 @@ void mat_multiply_matrix_vector_di3(double v[3], } void mat_add_matrix_i3(int m[3][3], - SPGCONST int a[3][3], - SPGCONST int b[3][3]) + SPGCONST int a[3][3], + SPGCONST int b[3][3]) { int i, j; for ( i = 0; i < 3; i++ ) { @@ -308,11 +308,11 @@ void mat_cast_matrix_3d_to_3i(int m[3][3], SPGCONST double a[3][3]) /* ruby code for auto generating */ /* 3.times {|i| 3.times {|j| */ /* puts "m[#{j}][#{i}]=(a[#{(i+1)%3}][#{(j+1)%3}]*a[#{(i+2)%3}][#{(j+2)%3}] */ -/* -a[#{(i+1)%3}][#{(j+2)%3}]*a[#{(i+2)%3}][#{(j+1)%3}])/det;" */ +/* -a[#{(i+1)%3}][#{(j+2)%3}]*a[#{(i+2)%3}][#{(j+1)%3}])/det;" */ /* }} */ int mat_inverse_matrix_d3(double m[3][3], - SPGCONST double a[3][3], - const double precision) + SPGCONST double a[3][3], + const double precision) { double det; double c[3][3]; @@ -337,9 +337,9 @@ int mat_inverse_matrix_d3(double m[3][3], /* m = b^-1 a b */ int mat_get_similar_matrix_d3(double m[3][3], - SPGCONST double a[3][3], - SPGCONST double b[3][3], - const double precision) + SPGCONST double a[3][3], + SPGCONST double b[3][3], + const double precision) { double c[3][3]; if (!mat_inverse_matrix_d3(c, b, precision)) { @@ -382,7 +382,7 @@ void mat_transpose_matrix_i3(int a[3][3], SPGCONST int b[3][3]) } void mat_get_metric(double metric[3][3], - SPGCONST double lattice[3][3]) + SPGCONST double lattice[3][3]) { double lattice_t[3][3]; mat_transpose_matrix_d3(lattice_t, lattice); @@ -428,7 +428,7 @@ MatINT * mat_alloc_MatINT(const int size) MatINT *matint; matint = NULL; - + if ((matint = (MatINT*) malloc(sizeof(MatINT))) == NULL) { warning_print("spglib: Memory could not be allocated."); return NULL; @@ -437,7 +437,7 @@ MatINT * mat_alloc_MatINT(const int size) matint->size = size; if (size > 0) { if ((matint->mat = (int (*)[3][3]) malloc(sizeof(int[3][3]) * size)) - == NULL) { + == NULL) { warning_print("spglib: Memory could not be allocated "); warning_print("(MatINT, line %d, %s).\n", __LINE__, __FILE__); free(matint); @@ -471,7 +471,7 @@ VecDBL * mat_alloc_VecDBL(const int size) vecdbl->size = size; if (size > 0) { if ((vecdbl->vec = (double (*)[3]) malloc(sizeof(double[3]) * size)) - == NULL) { + == NULL) { warning_print("spglib: Memory could not be allocated "); warning_print("(VecDBL, line %d, %s).\n", __LINE__, __FILE__); free(vecdbl); @@ -498,7 +498,7 @@ int mat_is_int_matrix(SPGCONST double mat[3][3], const double symprec) for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if (mat_Dabs(mat_Nint(mat[i][j]) - mat[i][j]) > symprec) { - return 0; + return 0; } } } diff --git a/c/spglib/niggli.c b/c/spglib/niggli.c index 55293665..45506c22 100644 --- a/c/spglib/niggli.c +++ b/c/spglib/niggli.c @@ -89,7 +89,7 @@ static void debug_show(const int j, const NiggliParams *p) /* printf("%d %d %d\n", p->l, p->m, p->n); */ /* for (i = 0; i < 3; i++) { */ /* printf("%f %f %f\n", */ - /* p->lattice[i * 3], p->lattice[i * 3 + 1], p->lattice[i * 3 + 2]); */ + /* p->lattice[i * 3], p->lattice[i * 3 + 1], p->lattice[i * 3 + 2]); */ /* } */ } #else @@ -128,7 +128,7 @@ int niggli_reduce(double *lattice_, const double eps_) int i, j, succeeded; NiggliParams *p; int (*steps[8])(NiggliParams *p) = {step1, step2, step3, step4, - step5, step6, step7, step8}; + step5, step6, step7, step8}; p = NULL; succeeded = 0; @@ -145,9 +145,9 @@ int niggli_reduce(double *lattice_, const double eps_) for (i = 0; i < NIGGLI_MAX_NUM_LOOP; i++) { for (j = 0; j < 8; j++) { if ((*steps[j])(p)) { - debug_show(j + 1, p); - if (! reset(p)) {goto ret;} - if (j == 1 || j == 4 || j == 5 || j == 6 || j == 7) {break;} + debug_show(j + 1, p); + if (! reset(p)) {goto ret;} + if (j == 1 || j == 4 || j == 5 || j == 6 || j == 7) {break;} } } if (j == 8) { @@ -203,7 +203,7 @@ static NiggliParams * initialize(const double *lattice_, const double eps_) p = NULL; return NULL; } - + memcpy(p->lattice, lattice_, sizeof(double) * 9); return p; @@ -225,7 +225,7 @@ static int reset(NiggliParams *p) double *lat_tmp; lat_tmp = NULL; - + if ((lat_tmp = multiply_matrices(p->lattice, p->tmat)) == NULL) {return 0;} memcpy(p->lattice, lat_tmp, sizeof(double) * 9); free(lat_tmp); @@ -420,7 +420,7 @@ static double * get_transpose(const double *M) M_T[i * 3 + j] = M[j * 3 + i]; } } - + return M_T; } @@ -456,10 +456,10 @@ static double * multiply_matrices(const double *L, const double *R) for (j = 0; j < 3; j++) { M[i * 3 + j] = 0; for (k = 0; k < 3; k++) { - M[i * 3 + j] += L[i * 3 + k] * R[k * 3 + j]; + M[i * 3 + j] += L[i * 3 + k] * R[k * 3 + j]; } } } - + return M; } diff --git a/c/spglib/pointgroup.c b/c/spglib/pointgroup.c index 2109ecfd..d1b3cb44 100644 --- a/c/spglib/pointgroup.c +++ b/c/spglib/pointgroup.c @@ -306,7 +306,7 @@ static int rot_axes[][3] = { { 1, 1, 0}, { 0, 1,-1}, {-1, 0, 1}, - { 1,-1, 0}, + { 1,-1, 0}, { 1, 1, 1}, /* 10 */ {-1, 1, 1}, { 1,-1, 1}, @@ -374,53 +374,53 @@ static int rot_axes[][3] = { }; static int get_pointgroup_number_by_rotations(SPGCONST int rotations[][3][3], - const int num_rotations); + const int num_rotations); static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym); static int get_pointgroup_class_table(int table[10], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); static int get_rotation_type(SPGCONST int rot[3][3]); static int get_rotation_axis(SPGCONST int rot[3][3]); static int get_orthogonal_axis(int ortho_axes[], - SPGCONST int proper_rot[3][3], - const int rot_order); + SPGCONST int proper_rot[3][3], + const int rot_order); static int laue2m(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); #ifdef SPGDEBUG static int lauemmm(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); static int laue4m(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); static int laue4mmm(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); static int laue3(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); static int laue3m(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); static int lauem3m(int axes[3], - SPGCONST PointSymmetry * pointsym); + SPGCONST PointSymmetry * pointsym); #endif static int laue_one_axis(int axes[3], - SPGCONST PointSymmetry * pointsym, - const int rot_order); + SPGCONST PointSymmetry * pointsym, + const int rot_order); static int lauennn(int axes[3], - SPGCONST PointSymmetry * pointsym, - const int rot_order); + SPGCONST PointSymmetry * pointsym, + const int rot_order); static int get_axes(int axes[3], - const Laue laue, - SPGCONST PointSymmetry * pointsym); + const Laue laue, + SPGCONST PointSymmetry * pointsym); static void get_proper_rotation(int prop_rot[3][3], - SPGCONST int rot[3][3]); + SPGCONST int rot[3][3]); static void set_transformation_matrix(int tmat[3][3], - const int axes[3]); + const int axes[3]); static int is_exist_axis(const int axis_vec[3], const int axis_index); static void sort_axes(int axes[3]); /* Retrun pointgroup.number = 0 if failed */ Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3], - SPGCONST int rotations[][3][3], - const int num_rotations) + SPGCONST int rotations[][3][3], + const int num_rotations) { int i, j, pg_num; int axes[3]; @@ -434,9 +434,9 @@ Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3], transform_mat[i][j] = 0; } } - + pg_num = get_pointgroup_number_by_rotations(rotations, num_rotations); - + if (pg_num > 0) { pointgroup = ptg_get_pointgroup(pg_num); pointsym = ptg_get_pointsymmetry(rotations, num_rotations); @@ -444,7 +444,7 @@ Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3], set_transformation_matrix(transform_mat, axes); } else { pointgroup = ptg_get_pointgroup(0); - } + } return pointgroup; } @@ -474,7 +474,7 @@ Pointgroup ptg_get_pointgroup(const int pointgroup_number) } PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3], - const int num_rotations) + const int num_rotations) { int i, j; PointSymmetry pointsym; @@ -483,7 +483,7 @@ PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3], for (i = 0; i < num_rotations; i++) { for (j = 0; j < pointsym.size; j++) { if (mat_check_identity_matrix_i3(rotations[i], pointsym.rot[j])) { - goto escape; + goto escape; } } mat_copy_matrix_i3(pointsym.rot[pointsym.size], rotations[i]); @@ -496,7 +496,7 @@ PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3], } static int get_pointgroup_number_by_rotations(SPGCONST int rotations[][3][3], - const int num_rotations) + const int num_rotations) { PointSymmetry pointsym; @@ -514,7 +514,7 @@ static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym) pg_num = 0; - + /* Get list of point symmetry operations */ if (! get_pointgroup_class_table(table, pointsym)) { goto end; @@ -538,7 +538,7 @@ static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym) } static int get_pointgroup_class_table(int table[10], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { /* Look-up table */ /* Operation -6 -4 -3 -2 -1 1 2 3 4 6 */ @@ -567,7 +567,7 @@ static int get_pointgroup_class_table(int table[10], table[rot_type]++; } } - + return 1; err: @@ -621,15 +621,15 @@ static int get_rotation_type(SPGCONST int rot[3][3]) default: rot_type = -1; break; - } + } } return rot_type; } static int get_axes(int axes[3], - const Laue laue, - SPGCONST PointSymmetry * pointsym) + const Laue laue, + SPGCONST PointSymmetry * pointsym) { switch (laue) { case LAUE1: @@ -675,7 +675,7 @@ static int get_axes(int axes[3], } static int laue2m(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, num_ortho_axis, norm, min_norm, is_found, tmpval; int prop_rot[3][3], t_mat[3][3]; @@ -697,7 +697,7 @@ static int laue2m(int axes[3], /* The second axis */ num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 2); if (! num_ortho_axis) { goto err; } - + min_norm = 8; is_found = 0; for (i = 0; i < num_ortho_axis; i++) { @@ -709,7 +709,7 @@ static int laue2m(int axes[3], } } if (! is_found) { goto err; } - + /* The third axis */ min_norm = 8; is_found = 0; @@ -738,7 +738,7 @@ static int laue2m(int axes[3], #ifdef SPGDEBUG static int lauemmm(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, count, axis; int prop_rot[3][3]; @@ -756,8 +756,8 @@ static int lauemmm(int axes[3], axis = get_rotation_axis(prop_rot); if (! ((axis == axes[0]) || - (axis == axes[1]) || - (axis == axes[2]))) { + (axis == axes[1]) || + (axis == axes[2]))) { axes[count] = axis; count++; } @@ -769,7 +769,7 @@ static int lauemmm(int axes[3], } static int laue4m(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, num_ortho_axis, norm, min_norm, is_found, tmpval; int axis_vec[3]; @@ -790,7 +790,7 @@ static int laue4m(int axes[3], /* The second axis */ num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 4); if (! num_ortho_axis) { goto err; } - + min_norm = 8; is_found = 0; for (i = 0; i < num_ortho_axis; i++) { @@ -802,7 +802,7 @@ static int laue4m(int axes[3], } } if (! is_found) { goto err; } - + /* The third axis */ mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]); is_found = 0; @@ -829,7 +829,7 @@ static int laue4m(int axes[3], } static int laue4mmm(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, is_found, tmpval, axis; int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3]; @@ -892,7 +892,7 @@ static int laue4mmm(int axes[3], } static int laue3(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, num_ortho_axis, norm, min_norm, is_found, tmpval; int prop_rot[3][3], t_mat[3][3]; @@ -924,7 +924,7 @@ static int laue3(int axes[3], } } if (! is_found) { goto err; } - + /* The third axis */ mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]); is_found = 0; @@ -955,7 +955,7 @@ static int laue3(int axes[3], } static int laue3m(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, is_found, tmpval, axis; int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3]; @@ -1023,7 +1023,7 @@ static int laue3m(int axes[3], } static int lauem3m(int axes[3], - SPGCONST PointSymmetry * pointsym) + SPGCONST PointSymmetry * pointsym) { int i, count, axis; int prop_rot[3][3]; @@ -1040,8 +1040,8 @@ static int lauem3m(int axes[3], axis = get_rotation_axis(prop_rot); if (! ((axis == axes[0]) || - (axis == axes[1]) || - (axis == axes[2]))) { + (axis == axes[1]) || + (axis == axes[2]))) { axes[count] = axis; count++; } @@ -1054,8 +1054,8 @@ static int lauem3m(int axes[3], #endif static int laue_one_axis(int axes[3], - SPGCONST PointSymmetry * pointsym, - const int rot_order) + SPGCONST PointSymmetry * pointsym, + const int rot_order) { int i, j, num_ortho_axis, det, is_found, tmpval; int axis_vec[3], tmp_axes[3]; @@ -1063,25 +1063,25 @@ static int laue_one_axis(int axes[3], int ortho_axes[NUM_ROT_AXES]; debug_print("laue_one_axis with rot_order %d\n", rot_order); - + for (i = 0; i < pointsym->size; i++) { get_proper_rotation(prop_rot, pointsym->rot[i]); /* Search foud-fold rotation */ if (rot_order == 4) { if (mat_get_trace_i3(prop_rot) == 1) { - /* The first axis */ - axes[2] = get_rotation_axis(prop_rot); - break; + /* The first axis */ + axes[2] = get_rotation_axis(prop_rot); + break; } } /* Search three-fold rotation */ if (rot_order == 3) { if (mat_get_trace_i3(prop_rot) == 0) { - /* The first axis */ - axes[2] = get_rotation_axis(prop_rot); - break; + /* The first axis */ + axes[2] = get_rotation_axis(prop_rot); + break; } } } @@ -1096,22 +1096,22 @@ static int laue_one_axis(int axes[3], is_found = 0; tmp_axes[0] = ortho_axes[i]; mat_multiply_matrix_vector_i3(axis_vec, - prop_rot, - rot_axes[tmp_axes[0]]); + prop_rot, + rot_axes[tmp_axes[0]]); for (j = 0; j < num_ortho_axis; j++) { is_found = is_exist_axis(axis_vec, ortho_axes[j]); if (is_found == 1) { - tmp_axes[1] = ortho_axes[j]; - break; + tmp_axes[1] = ortho_axes[j]; + break; } if (is_found == -1) { - tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES; - break; + tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES; + break; } } if (!is_found) { continue; } - + set_transformation_matrix(t_mat, tmp_axes); det = abs(mat_get_determinant_i3(t_mat)); if (det < 4) { /* to avoid F-center choice det=4 */ @@ -1143,8 +1143,8 @@ static int laue_one_axis(int axes[3], } static int lauennn(int axes[3], - SPGCONST PointSymmetry * pointsym, - const int rot_order) + SPGCONST PointSymmetry * pointsym, + const int rot_order) { int i, count, axis; int prop_rot[3][3]; @@ -1159,13 +1159,13 @@ static int lauennn(int axes[3], /* Search two- or four-fold rotation */ if ((mat_get_trace_i3(prop_rot) == -1 && rot_order == 2) || - (mat_get_trace_i3(prop_rot) == 1 && rot_order == 4)) { + (mat_get_trace_i3(prop_rot) == 1 && rot_order == 4)) { axis = get_rotation_axis(prop_rot); if (! ((axis == axes[0]) || - (axis == axes[1]) || - (axis == axes[2]))) { - axes[count] = axis; - count++; + (axis == axes[1]) || + (axis == axes[2]))) { + axes[count] = axis; + count++; } } } @@ -1189,26 +1189,26 @@ static int get_rotation_axis(SPGCONST int proper_rot[3][3]) for (i = 0; i < NUM_ROT_AXES; i++) { mat_multiply_matrix_vector_i3(vec, proper_rot, rot_axes[i]); if (vec[0] == rot_axes[i][0] && - vec[1] == rot_axes[i][1] && - vec[2] == rot_axes[i][2]) { + vec[1] == rot_axes[i][1] && + vec[2] == rot_axes[i][2]) { axis = i; break; } } - + end: #ifdef SPGDEBUG if (axis == -1) { printf("rotation axis cound not found.\n"); } #endif - + return axis; } static int get_orthogonal_axis(int ortho_axes[], - SPGCONST int proper_rot[3][3], - const int rot_order) + SPGCONST int proper_rot[3][3], + const int rot_order) { int i, num_ortho_axis; int vec[3]; @@ -1222,12 +1222,12 @@ static int get_orthogonal_axis(int ortho_axes[], mat_multiply_matrix_i3(rot, proper_rot, rot); mat_add_matrix_i3(sum_rot, rot, sum_rot); } - + for (i = 0; i < NUM_ROT_AXES; i++) { mat_multiply_matrix_vector_i3(vec, sum_rot, rot_axes[i]); if (vec[0] == 0 && - vec[1] == 0 && - vec[2] == 0) { + vec[1] == 0 && + vec[2] == 0) { ortho_axes[num_ortho_axis] = i; num_ortho_axis++; } @@ -1237,7 +1237,7 @@ static int get_orthogonal_axis(int ortho_axes[], } static void get_proper_rotation(int prop_rot[3][3], - SPGCONST int rot[3][3]) + SPGCONST int rot[3][3]) { if (mat_get_determinant_i3(rot) == -1) { mat_multiply_matrix_i3(prop_rot, inversion, rot); @@ -1247,10 +1247,10 @@ static void get_proper_rotation(int prop_rot[3][3], } static void set_transformation_matrix(int tmat[3][3], - const int axes[3]) + const int axes[3]) { int i, j, s[3]; - + for (i = 0; i < 3; i++) { if (axes[i] < NUM_ROT_AXES) { s[i] = 1; @@ -1306,4 +1306,3 @@ static void sort_axes(int axes[3]) axes[2] = axis; } } - diff --git a/c/spglib/primitive.c b/c/spglib/primitive.c index 0fe77ca0..444dba6b 100644 --- a/c/spglib/primitive.c +++ b/c/spglib/primitive.c @@ -46,8 +46,8 @@ #define NUM_ATTEMPT 20 static Primitive * get_primitive(const Cell * cell, - const double symprec, - const double angle_tolerance); + const double symprec, + const double angle_tolerance); static Cell * get_cell_with_smallest_lattice(const Cell * cell, const double symprec); static Cell * get_primitive_cell(int * mapping_table, @@ -128,14 +128,14 @@ void prm_free_primitive(Primitive * primitive) /* Return NULL if failed */ Primitive * prm_get_primitive(const Cell * cell, - const double symprec, - const double angle_tolerance) + const double symprec, + const double angle_tolerance) { return get_primitive(cell, symprec, angle_tolerance); } Symmetry * prm_get_primitive_symmetry(const Symmetry *symmetry, - const double symprec) + const double symprec) { int i, primsym_size; VecDBL *pure_trans; @@ -202,8 +202,8 @@ Symmetry * prm_get_primitive_symmetry(const Symmetry *symmetry, /* Return NULL if failed */ static Primitive * get_primitive(const Cell * cell, - const double symprec, - const double angle_tolerance) + const double symprec, + const double angle_tolerance) { int i, attempt; double tolerance; @@ -222,32 +222,29 @@ static Primitive * get_primitive(const Cell * cell, tolerance = symprec; for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { debug_print("get_primitive (attempt = %d):\n", attempt); - if ((pure_trans = sym_get_pure_translation(cell, tolerance)) == NULL) { - goto cont; - } - - if (pure_trans->size == 1) { - if ((primitive->cell = get_cell_with_smallest_lattice(cell, tolerance)) - != NULL) { - for (i = 0; i < cell->size; i++) { - primitive->mapping_table[i] = i; + if ((pure_trans = sym_get_pure_translation(cell, tolerance)) != NULL) { + if (pure_trans->size == 1) { + if ((primitive->cell = get_cell_with_smallest_lattice(cell, tolerance)) + != NULL) { + for (i = 0; i < cell->size; i++) { + primitive->mapping_table[i] = i; + } + goto found; + } + } else { + if ((primitive->cell = get_primitive_cell(primitive->mapping_table, + cell, + pure_trans, + tolerance, + angle_tolerance)) != NULL) { + goto found; } - goto found; - } - } else { - if ((primitive->cell = get_primitive_cell(primitive->mapping_table, - cell, - pure_trans, - tolerance, - angle_tolerance)) != NULL) { - goto found; } } mat_free_VecDBL(pure_trans); pure_trans = NULL; - cont: tolerance *= REDUCE_RATE; warning_print("spglib: Reduce tolerance to %f ", tolerance); warning_print("(line %d, %s).\n", __LINE__, __FILE__); @@ -325,7 +322,7 @@ static Cell * get_primitive_cell(int * mapping_table, cell, pure_trans, symprec, - angle_tolerance); + angle_tolerance); if (! multi) { goto not_found; } @@ -418,7 +415,7 @@ static int get_primitive_lattice_vectors_iterative(double prim_lattice[3][3], pure_trans_reduced = sym_reduce_pure_translation(cell, tmp_vec, tolerance, - angle_tolerance); + angle_tolerance); mat_free_VecDBL(tmp_vec); tmp_vec = NULL; @@ -556,8 +553,8 @@ static VecDBL * collect_pure_translations(const Symmetry *symmetry) VecDBL *pure_trans; VecDBL *ret_pure_trans; static int identity[3][3] = {{ 1, 0, 0 }, - { 0, 1, 0 }, - { 0, 0, 1 }}; + { 0, 1, 0 }, + { 0, 0, 1 }}; num_pure_trans = 0; pure_trans = NULL; ret_pure_trans = NULL; @@ -582,7 +579,7 @@ static VecDBL * collect_pure_translations(const Symmetry *symmetry) for (i = 0; i < num_pure_trans; i++) { mat_copy_vector_d3(ret_pure_trans->vec[i], pure_trans->vec[i]); } - + mat_free_VecDBL(pure_trans); pure_trans = NULL; @@ -622,9 +619,9 @@ static int get_primitive_in_translation_space(double t_mat_inv[3][3], for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if (i == j) { - cell->lattice[i][j] = 1; + cell->lattice[i][j] = 1; } else { - cell->lattice[i][j] = 0; + cell->lattice[i][j] = 0; } } } diff --git a/c/spglib/refinement.c b/c/spglib/refinement.c index d3209779..ec6fe59f 100644 --- a/c/spglib/refinement.c +++ b/c/spglib/refinement.c @@ -47,11 +47,9 @@ #include "debug.h" -#define REDUCE_RATE 0.95 - static Cell * get_Wyckoff_positions(int * wyckoffs, int * equiv_atoms, - int * mapping_to_primitive, + int * std_mapping_to_primitive, const Cell * primitive, const Cell * cell, SPGCONST Spacegroup * spacegroup, @@ -61,17 +59,17 @@ static Cell * get_Wyckoff_positions(int * wyckoffs, static Cell * get_bravais_exact_positions_and_lattice(int * wyckoffs, int * equiv_atoms, - int * mapping_to_primitive, + int * std_mapping_to_primitive, SPGCONST Spacegroup * spacegroup, const Cell * primitive, const double symprec); -static Cell * expand_positions(int * wyckoffs, - int * equiv_atoms, - int * mapping_to_primitive, - const Cell * conv_prim, - const Symmetry * conv_sym, - const int * wyckoffs_prim, - const int * equiv_atoms_prim); +static Cell * expand_positions_in_bravais(int * wyckoffs, + int * equiv_atoms, + int * std_mapping_to_primitive, + const Cell * conv_prim, + const Symmetry * conv_sym, + const int * wyckoffs_prim, + const int * equiv_atoms_prim); static Cell * get_conventional_primitive(SPGCONST Spacegroup * spacegroup, const Cell * primitive); static int get_number_of_pure_translation(const Symmetry * conv_sym); @@ -149,51 +147,135 @@ static SPGCONST int identity[3][3] = { { 0, 0, 1}, }; +/* Return NULL if failed */ +ExactStructure * +ref_get_exact_structure_and_symmetry(const Cell * primitive, + const Cell * cell, + SPGCONST Spacegroup * spacegroup, + const int * mapping_table, + const double symprec) +{ + int *std_mapping_to_primitive, *wyckoffs, *equivalent_atoms; + Cell *bravais; + Symmetry *symmetry; + ExactStructure *exact_structure; + + std_mapping_to_primitive = NULL; + wyckoffs = NULL; + equivalent_atoms = NULL; + bravais = NULL; + symmetry = NULL; + exact_structure = NULL; + + if ((symmetry = get_refined_symmetry_operations(cell, + primitive, + spacegroup, + symprec)) == NULL) { + goto err; + } + + if ((wyckoffs = (int*) malloc(sizeof(int) * cell->size)) == NULL) { + warning_print("spglib: Memory could not be allocated."); + goto err; + } + + if ((equivalent_atoms = (int*) malloc(sizeof(int) * cell->size)) == NULL) { + warning_print("spglib: Memory could not be allocated."); + goto err; + } + + if ((std_mapping_to_primitive = + (int*) malloc(sizeof(int) * primitive->size * 4)) == NULL) { + warning_print("spglib: Memory could not be allocated."); + goto err; + } + + if ((bravais = get_Wyckoff_positions(wyckoffs, + equivalent_atoms, + std_mapping_to_primitive, + primitive, + cell, + spacegroup, + symmetry, + mapping_table, + symprec)) == NULL) { + sym_free_symmetry(symmetry); + symmetry = NULL; + goto err; + } + + if ((exact_structure = (ExactStructure*) + malloc(sizeof(ExactStructure))) == NULL) { + warning_print("spglib: Memory could not be allocated."); + sym_free_symmetry(symmetry); + symmetry = NULL; + cel_free_cell(bravais); + bravais = NULL; + goto err; + } + + exact_structure->bravais = bravais; + exact_structure->symmetry = symmetry; + exact_structure->wyckoffs = wyckoffs; + exact_structure->equivalent_atoms = equivalent_atoms; + exact_structure->std_mapping_to_primitive = std_mapping_to_primitive; + + return exact_structure; + +err: + if (wyckoffs != NULL) { + free(wyckoffs); + wyckoffs = NULL; + } + if (equivalent_atoms != NULL) { + free(equivalent_atoms); + equivalent_atoms = NULL; + } + if (std_mapping_to_primitive != NULL) { + free(std_mapping_to_primitive); + std_mapping_to_primitive = NULL; + } + + return NULL; +} + +void ref_free_exact_structure(ExactStructure *exstr) +{ + if (exstr != NULL) { + if (exstr->symmetry != NULL) { + sym_free_symmetry(exstr->symmetry); + exstr->symmetry = NULL; + } + if (exstr->bravais != NULL) { + cel_free_cell(exstr->bravais); + exstr->bravais = NULL; + } + if (exstr->wyckoffs != NULL) { + free(exstr->wyckoffs); + exstr->wyckoffs = NULL; + } + if (exstr->equivalent_atoms != NULL) { + free(exstr->equivalent_atoms); + exstr->equivalent_atoms = NULL; + } + if (exstr->std_mapping_to_primitive != NULL) { + free(exstr->std_mapping_to_primitive); + exstr->std_mapping_to_primitive = NULL; + } + free(exstr); + } +} /* Return NULL if failed */ -Symmetry * -ref_get_refined_symmetry_operations(const Cell * cell, +static Cell * get_Wyckoff_positions(int * wyckoffs, + int * equiv_atoms, + int * std_mapping_to_primitive, const Cell * primitive, + const Cell * cell, SPGCONST Spacegroup * spacegroup, + const Symmetry * symmetry, + const int * mapping_table, const double symprec) -{ - return get_refined_symmetry_operations(cell, - primitive, - spacegroup, - symprec); -} - -/* Return NULL if failed */ -Cell * ref_get_Wyckoff_positions(int * wyckoffs, - int * equiv_atoms, - int * mapping_to_primitive, - const Cell * primitive, - const Cell * cell, - SPGCONST Spacegroup * spacegroup, - const Symmetry * symmetry, - const int * mapping_table, - const double symprec) -{ - return get_Wyckoff_positions(wyckoffs, - equiv_atoms, - mapping_to_primitive, - primitive, - cell, - spacegroup, - symmetry, - mapping_table, - symprec); -} - -Cell * get_Wyckoff_positions(int * wyckoffs, - int * equiv_atoms, - int * mapping_to_primitive, - const Cell * primitive, - const Cell * cell, - SPGCONST Spacegroup * spacegroup, - const Symmetry * symmetry, - const int * mapping_table, - const double symprec) { Cell *bravais; int i, num_prim_sym; @@ -223,7 +305,7 @@ Cell * get_Wyckoff_positions(int * wyckoffs, if ((bravais = get_bravais_exact_positions_and_lattice (wyckoffs_bravais, equiv_atoms_bravais, - mapping_to_primitive, + std_mapping_to_primitive, spacegroup, primitive, symprec)) == NULL) { @@ -277,7 +359,7 @@ Cell * get_Wyckoff_positions(int * wyckoffs, static Cell * get_bravais_exact_positions_and_lattice(int * wyckoffs, int * equiv_atoms, - int * mapping_to_primitive, + int * std_mapping_to_primitive, SPGCONST Spacegroup *spacegroup, const Cell * primitive, const double symprec) @@ -303,7 +385,8 @@ get_bravais_exact_positions_and_lattice(int * wyckoffs, return NULL; } - if ((equiv_atoms_prim = (int*)malloc(sizeof(int) * primitive->size)) == NULL) { + if ((equiv_atoms_prim = (int*)malloc(sizeof(int) * primitive->size)) + == NULL) { warning_print("spglib: Memory could not be allocated "); free(wyckoffs_prim); wyckoffs_prim = NULL; @@ -350,13 +433,13 @@ get_bravais_exact_positions_and_lattice(int * wyckoffs, mat_copy_vector_d3(conv_prim->position[i], exact_positions->vec[i]); } - bravais = expand_positions(wyckoffs, - equiv_atoms, - mapping_to_primitive, - conv_prim, - conv_sym, - wyckoffs_prim, - equiv_atoms_prim); + bravais = expand_positions_in_bravais(wyckoffs, + equiv_atoms, + std_mapping_to_primitive, + conv_prim, + conv_sym, + wyckoffs_prim, + equiv_atoms_prim); mat_free_VecDBL(exact_positions); exact_positions = NULL; @@ -374,13 +457,13 @@ get_bravais_exact_positions_and_lattice(int * wyckoffs, } /* Return NULL if failed */ -static Cell * expand_positions(int * wyckoffs, - int * equiv_atoms, - int * mapping_to_primitive, - const Cell * conv_prim, - const Symmetry * conv_sym, - const int * wyckoffs_prim, - const int * equiv_atoms_prim) +static Cell * expand_positions_in_bravais(int * wyckoffs, + int * equiv_atoms, + int * std_mapping_to_primitive, + const Cell * conv_prim, + const Symmetry * conv_sym, + const int * wyckoffs_prim, + const int * equiv_atoms_prim) { int i, j, k, num_pure_trans; int num_atom; @@ -400,8 +483,7 @@ static Cell * expand_positions(int * wyckoffs, if (mat_check_identity_matrix_i3(identity, conv_sym->rot[i])) { for (j = 0; j < conv_prim->size; j++) { bravais->types[num_atom] = conv_prim->types[j]; - mat_copy_vector_d3(bravais->position[num_atom], - conv_prim->position[j]); + mat_copy_vector_d3(bravais->position[num_atom], conv_prim->position[j]); for (k = 0; k < 3; k++) { bravais->position[num_atom][k] += conv_sym->trans[i][k]; bravais->position[num_atom][k] = @@ -409,7 +491,7 @@ static Cell * expand_positions(int * wyckoffs, } wyckoffs[num_atom] = wyckoffs_prim[j]; equiv_atoms[num_atom] = equiv_atoms_prim[j]; - mapping_to_primitive[num_atom] = j; + std_mapping_to_primitive[num_atom] = j; num_atom++; } } diff --git a/c/spglib/sitesym_database.c b/c/spglib/sitesym_database.c index 8c8fe5c8..d36c7551 100644 --- a/c/spglib/sitesym_database.c +++ b/c/spglib/sitesym_database.c @@ -1142,8 +1142,8 @@ static const int num_sitesym[] = int ssmdb_get_coordinate(int rot[3][3], - double trans[3], - const int index) + double trans[3], + const int index) { int i, rot_enc, trans_enc; int rows[3], trans_int[3]; @@ -1151,7 +1151,7 @@ int ssmdb_get_coordinate(int rot[3][3], /* Orbits are compressed using ternary numerical system for */ /* rotation and base-24 system for translation. Elements of the first coloum */ /* of rotation matrix can be one of {-2,-1,0,1,2} and the other elements can */ - /* be one of {-1,0,1}. Translation can have one of */ + /* be one of {-1,0,1}. Translation can have one of */ /* {0,2,3,4,6,8,9,10,12,14,15,16,18,20,21,22} */ /* divided by 24. Therefore 45^3 * 24^3 = 1259712000 different values can */ /* enough map Wyckoff positions. */ diff --git a/c/spglib/spacegroup.c b/c/spglib/spacegroup.c index c2e81640..543586d8 100644 --- a/c/spglib/spacegroup.c +++ b/c/spglib/spacegroup.c @@ -227,11 +227,6 @@ static double F_mat[3][3] = {{ 0, 1./2, 1./2 }, { 1./2, 0, 1./2 }, { 1./2, 1./2, 0 }}; -static Spacegroup search_spacegroup(const Cell * primitive, - const int candidates[], - const int num_candidates, - const double symprec, - const double angle_tolerance); static Spacegroup search_spacegroup_with_symmetry(const Cell * primitive, const int candidates[], const int num_candidates, @@ -298,78 +293,57 @@ static Centering get_centering(double correction_mat[3][3], const Laue laue); static Centering get_base_center(SPGCONST int transform_mat[3][3]); static int get_centering_shifts(double shift[3][3], - const Centering centering); + const Centering centering); -/* NULL is returned if failed */ -Primitive * spa_get_spacegroup(Spacegroup * spacegroup, - const Cell * cell, - const int hall_number, - const double symprec, - const double angle_tolerance) +/* Return spacegroup.number = 0 if failed */ +Spacegroup spa_search_spacegroup(const Cell * primitive, + const int hall_number, + const double symprec, + const double angle_tolerance) { - int attempt; + Spacegroup spacegroup; + Symmetry *symmetry; int candidate[1]; - double tolerance; - Primitive *primitive; - debug_print("spa_get_spacegroup (tolerance = %f):\n", symprec); + debug_print("search_spacegroup (tolerance = %f):\n", symprec); - primitive = NULL; + symmetry = NULL; + spacegroup.number = 0; - if (hall_number < 0 || hall_number > 530) { - return NULL; + if ((symmetry = sym_get_operation(primitive, symprec, angle_tolerance)) == + NULL) { + goto ret; } if (hall_number > 0) { candidate[0] = hall_number; } - tolerance = symprec; - - for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { - if ((primitive = prm_get_primitive(cell, tolerance, angle_tolerance)) == - NULL) { - goto cont; - } - - if (hall_number) { - *spacegroup = search_spacegroup(primitive->cell, - candidate, - 1, - primitive->tolerance, - primitive->angle_tolerance); - } else { - *spacegroup = search_spacegroup(primitive->cell, - spacegroup_to_hall_number, - 230, - primitive->tolerance, - primitive->angle_tolerance); - } - - if (spacegroup->number > 0) { - break; - } else { - prm_free_primitive(primitive); - primitive = NULL; - } - - cont: - warning_print("spglib: Attempt %d tolerance = %f failed.", - attempt, tolerance); - warning_print(" (line %d, %s).\n", __LINE__, __FILE__); - - tolerance *= REDUCE_RATE; + if (hall_number) { + spacegroup = search_spacegroup_with_symmetry(primitive, + candidate, + 1, + symmetry, + symprec, + angle_tolerance); + } else { + spacegroup = search_spacegroup_with_symmetry(primitive, + spacegroup_to_hall_number, + 230, + symmetry, + symprec, + angle_tolerance); } - if (primitive == NULL) { - warning_print("spglib: Space group could not be found "); - warning_print("(line %d, %s).\n", __LINE__, __FILE__); - } + sym_free_symmetry(symmetry); + symmetry = NULL; - return primitive; + ret: + return spacegroup; } + Spacegroup spa_search_spacegroup_with_symmetry(const Symmetry *symmetry, const double symprec) { @@ -445,8 +419,8 @@ Cell * spa_transform_to_primitive(int * mapping_table, /* Return NULL if failed */ Cell * spa_transform_from_primitive(const Cell * primitive, - const Centering centering, - const double symprec) + const Centering centering, + const double symprec) { int multi, i, j, k, num_atom; int *mapping_table; @@ -503,8 +477,8 @@ Cell * spa_transform_from_primitive(const Cell * primitive, num_atom = 0; for (i = 0; i < primitive->size; i++) { mat_multiply_matrix_vector_d3(std_cell->position[num_atom], - tmat, - primitive->position[i]); + tmat, + primitive->position[i]); std_cell->types[num_atom] = primitive->types[i]; num_atom++; } @@ -512,9 +486,9 @@ Cell * spa_transform_from_primitive(const Cell * primitive, for (i = 0; i < multi - 1; i++) { for (j = 0; j < primitive->size; j++) { mat_copy_vector_d3(std_cell->position[num_atom], - std_cell->position[j]); + std_cell->position[j]); for (k = 0; k < 3; k++) { - std_cell->position[num_atom][k] += shift[i][k]; + std_cell->position[num_atom][k] += shift[i][k]; } std_cell->types[num_atom] = std_cell->types[j]; num_atom++; @@ -522,9 +496,9 @@ Cell * spa_transform_from_primitive(const Cell * primitive, } trimmed_cell = cel_trim_cell(mapping_table, - std_cell->lattice, - std_cell, - symprec); + std_cell->lattice, + std_cell, + symprec); cel_free_cell(std_cell); std_cell = NULL; free(mapping_table); @@ -534,39 +508,6 @@ Cell * spa_transform_from_primitive(const Cell * primitive, return trimmed_cell; } -/* Return spacegroup.number = 0 if failed */ -static Spacegroup search_spacegroup(const Cell * primitive, - const int candidates[], - const int num_candidates, - const double symprec, - const double angle_tolerance) -{ - Spacegroup spacegroup; - Symmetry *symmetry; - - debug_print("search_spacegroup (tolerance = %f):\n", symprec); - - symmetry = NULL; - spacegroup.number = 0; - - if ((symmetry = sym_get_operation(primitive, symprec, angle_tolerance)) == - NULL) { - goto ret; - } - - spacegroup = search_spacegroup_with_symmetry(primitive, - candidates, - num_candidates, - symmetry, - symprec, - angle_tolerance); - sym_free_symmetry(symmetry); - symmetry = NULL; - - ret: - return spacegroup; -} - /* Return spacegroup.number = 0 if failed */ static Spacegroup search_spacegroup_with_symmetry(const Cell * primitive, const int candidates[], @@ -1434,7 +1375,7 @@ static Centering get_base_center(SPGCONST int transform_mat[3][3]) } static int get_centering_shifts(double shift[3][3], - const Centering centering) + const Centering centering) { int i, j, multi; @@ -1443,7 +1384,7 @@ static int get_centering_shifts(double shift[3][3], for (j = 0; j < 3; j++) { shift[i][j] = 0; } - } + } if (centering != PRIMITIVE) { if (centering != FACE && centering != R_CENTER) { diff --git a/c/spglib/spg_database.c b/c/spglib/spg_database.c index 87d95ff8..7c62bad6 100644 --- a/c/spglib/spg_database.c +++ b/c/spglib/spg_database.c @@ -570,7 +570,7 @@ static const SpacegroupType spacegroup_types[] = { {230, "Oh^10 ", "-I 4bd 2c 3 ", "I a -3 d ", "I 4_1/a -3 2/d ", "Ia-3d ", " ", BODY, 32 }, /* 530 */ }; -static const int symmetry_operations[] = { +static const int symmetry_operations[] = { 0 , /* dummy */ 16484 , /* 1 ( 1) [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] */ 16484 , /* 2 ( 2) [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] */ @@ -8570,11 +8570,11 @@ Symmetry * spgdb_get_spacegroup_operations(const int hall_number) /* Return spgtype.number = 0 if hall_number is out of range. */ SpacegroupType spgdb_get_spacegroup_type(const int hall_number) { - int position; + int position; SpacegroupType spgtype; spgtype.number = 0; - + if (0 < hall_number && hall_number < 531) { spgtype = spacegroup_types[hall_number]; } else { @@ -8588,7 +8588,7 @@ SpacegroupType spgdb_get_spacegroup_type(const int hall_number) remove_space(spgtype.international_full, 20); remove_space(spgtype.international_short, 11); remove_space(spgtype.choice, 6); - + return spgtype; } diff --git a/c/spglib/spglib.c b/c/spglib/spglib.c index 7b068aa2..772c66cb 100644 --- a/c/spglib/spglib.c +++ b/c/spglib/spglib.c @@ -39,6 +39,7 @@ #include "cell.h" #include "debug.h" #include "delaunay.h" +#include "determination.h" #include "kgrid.h" #include "kpoint.h" #include "mathfunc.h" @@ -53,9 +54,6 @@ #include "symmetry.h" #include "version.h" -#define REDUCE_RATE 0.9 -#define NUM_ATTEMPT 10 - /*-------*/ /* error */ /*-------*/ @@ -94,7 +92,7 @@ static int set_dataset(SpglibDataset * dataset, const Cell * cell, const Primitive * primitive, SPGCONST Spacegroup * spacegroup, - const double tolerance); + ExactStructure *exstr); static int get_symmetry_from_dataset(int rotation[][3][3], double translation[][3], const int max_size, @@ -114,13 +112,13 @@ static int get_symmetry_with_collinear_spin(int rotation[][3][3], const double spins[], const int num_atom, const double symprec, - const double angle_tolerance); + const double angle_tolerance); static int get_multiplicity(SPGCONST double lattice[3][3], SPGCONST double position[][3], const int types[], const int num_atom, const double symprec, - const double angle_tolerance); + const double angle_tolerance); static int standardize_primitive(double lattice[3][3], double position[][3], int types[], @@ -153,7 +151,7 @@ static int get_international(char symbol[11], const int types[], const int num_atom, const double symprec, - const double angle_tolerance); + const double angle_tolerance); static int get_schoenflies(char symbol[7], SPGCONST double lattice[3][3], SPGCONST double position[][3], @@ -252,7 +250,7 @@ SpglibDataset * spg_get_dataset(SPGCONST double lattice[3][3], num_atom, 0, symprec, - -1.0); + -1.0); } /* Return NULL if failed */ @@ -269,7 +267,7 @@ SpglibDataset * spgat_get_dataset(SPGCONST double lattice[3][3], num_atom, 0, symprec, - angle_tolerance); + angle_tolerance); } /* Return NULL if failed */ @@ -286,7 +284,7 @@ SpglibDataset * spg_get_dataset_with_hall_number(SPGCONST double lattice[3][3], num_atom, hall_number, symprec, - -1.0); + -1.0); } /* Return NULL if failed */ @@ -305,7 +303,7 @@ spgat_get_dataset_with_hall_number(SPGCONST double lattice[3][3], num_atom, hall_number, symprec, - angle_tolerance); + angle_tolerance); } void spg_free_dataset(SpglibDataset *dataset) @@ -365,7 +363,7 @@ int spg_get_symmetry(int rotation[][3][3], types, num_atom, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -387,7 +385,7 @@ int spgat_get_symmetry(int rotation[][3][3], types, num_atom, symprec, - angle_tolerance); + angle_tolerance); } /* Return 0 if failed */ @@ -412,7 +410,7 @@ int spg_get_symmetry_with_collinear_spin(int rotation[][3][3], spins, num_atom, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -438,7 +436,7 @@ int spgat_get_symmetry_with_collinear_spin(int rotation[][3][3], spins, num_atom, symprec, - angle_tolerance); + angle_tolerance); } int spg_get_hall_number_from_symmetry(SPGCONST int rotation[][3][3], @@ -484,7 +482,7 @@ int spg_get_multiplicity(SPGCONST double lattice[3][3], types, num_atom, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -500,7 +498,7 @@ int spgat_get_multiplicity(SPGCONST double lattice[3][3], types, num_atom, symprec, - angle_tolerance); + angle_tolerance); } /* Return 0 if failed */ @@ -517,7 +515,7 @@ int spg_get_international(char symbol[11], types, num_atom, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -535,7 +533,7 @@ int spgat_get_international(char symbol[11], types, num_atom, symprec, - angle_tolerance); + angle_tolerance); } /* Return 0 if failed */ @@ -552,7 +550,7 @@ int spg_get_schoenflies(char symbol[7], types, num_atom, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -570,7 +568,7 @@ int spgat_get_schoenflies(char symbol[7], types, num_atom, symprec, - angle_tolerance); + angle_tolerance); } /* Return 0 if failed */ @@ -709,14 +707,14 @@ int spgat_standardize_cell(double lattice[3][3], 0, 1, symprec, - angle_tolerance); + angle_tolerance); } else { return standardize_primitive(lattice, position, types, num_atom, symprec, - angle_tolerance); + angle_tolerance); } } else { if (no_idealize) { @@ -727,7 +725,7 @@ int spgat_standardize_cell(double lattice[3][3], 0, 0, symprec, - angle_tolerance); + angle_tolerance); } else { return standardize_cell(lattice, position, @@ -735,7 +733,7 @@ int spgat_standardize_cell(double lattice[3][3], num_atom, 0, symprec, - angle_tolerance); + angle_tolerance); } } } @@ -752,7 +750,7 @@ int spg_find_primitive(double lattice[3][3], types, num_atom, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -768,7 +766,7 @@ int spgat_find_primitive(double lattice[3][3], types, num_atom, symprec, - angle_tolerance); + angle_tolerance); } /* Return 0 if failed */ @@ -784,7 +782,7 @@ int spg_refine_cell(double lattice[3][3], num_atom, 0, symprec, - -1.0); + -1.0); } /* Return 0 if failed */ @@ -801,7 +799,7 @@ int spgat_refine_cell(double lattice[3][3], num_atom, 0, symprec, - angle_tolerance); + angle_tolerance); } int spg_delaunay_reduce(double lattice[3][3], const double symprec) @@ -865,7 +863,7 @@ int spg_get_ir_reciprocal_mesh(int grid_address[][3], types, num_atom, symprec, - -1.0); + -1.0); } int spg_get_stabilized_reciprocal_mesh(int grid_address[][3], @@ -1016,17 +1014,13 @@ static SpglibDataset * get_dataset(SPGCONST double lattice[3][3], const double symprec, const double angle_tolerance) { - int attempt; - double tolerance; - Spacegroup spacegroup; SpglibDataset *dataset; Cell *cell; - Primitive *primitive; + DataContainer *container; - spacegroup.number = 0; dataset = NULL; cell = NULL; - primitive = NULL; + container = NULL; if ((dataset = init_dataset()) == NULL) { goto not_found; @@ -1047,35 +1041,18 @@ static SpglibDataset * get_dataset(SPGCONST double lattice[3][3], goto atoms_too_close; } - tolerance = symprec; - for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { - if ((primitive = spa_get_spacegroup(&spacegroup, - cell, - hall_number, - tolerance, - angle_tolerance)) - == NULL) { - cel_free_cell(cell); - cell = NULL; - free(dataset); - dataset = NULL; - goto not_found; + if ((container = det_determine_all(cell, + hall_number, + symprec, + angle_tolerance)) + != NULL) { + if (set_dataset(dataset, + cell, + container->primitive, + container->spacegroup, + container->exact_structure)) { + goto found; } - - if (spacegroup.number > 0) { - if (set_dataset(dataset, - cell, - primitive, - &spacegroup, - primitive->tolerance)) { - goto found; - } else { - tolerance *= REDUCE_RATE; - } - } - - prm_free_primitive(primitive); - primitive = NULL; } cel_free_cell(cell); @@ -1092,8 +1069,7 @@ static SpglibDataset * get_dataset(SPGCONST double lattice[3][3], return NULL; found: - prm_free_primitive(primitive); - primitive = NULL; + det_free_container(container); cel_free_cell(cell); cell = NULL; @@ -1142,19 +1118,12 @@ static int set_dataset(SpglibDataset * dataset, const Cell * cell, const Primitive * primitive, SPGCONST Spacegroup * spacegroup, - const double tolerance) + ExactStructure *exstr) { int i; - int *std_mapping_to_primitive; double inv_lat[3][3]; - Cell *bravais; - Symmetry *symmetry; Pointgroup pointgroup; - std_mapping_to_primitive = NULL; - bravais = NULL; - symmetry = NULL; - /* Spacegroup type, transformation matrix, origin shift */ dataset->n_atoms = cell->size; dataset->spacegroup_number = spacegroup->number; @@ -1164,19 +1133,10 @@ static int set_dataset(SpglibDataset * dataset, strcpy(dataset->choice, spacegroup->choice); mat_inverse_matrix_d3(inv_lat, spacegroup->bravais_lattice, 0); mat_multiply_matrix_d3(dataset->transformation_matrix, - inv_lat, - cell->lattice); + inv_lat, cell->lattice); mat_copy_vector_d3(dataset->origin_shift, spacegroup->origin_shift); - /* Symmetry operations */ - if ((symmetry = ref_get_refined_symmetry_operations(cell, - primitive->cell, - spacegroup, - tolerance)) == NULL) { - return 0; - } - - dataset->n_operations = symmetry->size; + dataset->n_operations = exstr->symmetry->size; if ((dataset->rotations = (int (*)[3][3]) malloc(sizeof(int[3][3]) * dataset->n_operations)) @@ -1192,9 +1152,9 @@ static int set_dataset(SpglibDataset * dataset, goto err; } - for (i = 0; i < symmetry->size; i++) { - mat_copy_matrix_i3(dataset->rotations[i], symmetry->rot[i]); - mat_copy_vector_d3(dataset->translations[i], symmetry->trans[i]); + for (i = 0; i < exstr->symmetry->size; i++) { + mat_copy_matrix_i3(dataset->rotations[i], exstr->symmetry->rot[i]); + mat_copy_vector_d3(dataset->translations[i], exstr->symmetry->trans[i]); } /* Wyckoff positions */ @@ -1210,65 +1170,36 @@ static int set_dataset(SpglibDataset * dataset, goto err; } + for (i = 0; i < dataset->n_atoms; i++) { + dataset->wyckoffs[i] = exstr->wyckoffs[i]; + dataset->equivalent_atoms[i] = exstr->equivalent_atoms[i]; + } + if ((dataset->mapping_to_primitive = (int*) malloc(sizeof(int) * dataset->n_atoms)) == NULL) { warning_print("spglib: Memory could not be allocated."); goto err; } - if ((std_mapping_to_primitive = - (int*) malloc(sizeof(int) * primitive->cell->size * 4)) == NULL) { - warning_print("spglib: Memory could not be allocated."); - goto err; - } - - if ((bravais = ref_get_Wyckoff_positions(dataset->wyckoffs, - dataset->equivalent_atoms, - std_mapping_to_primitive, - primitive->cell, - cell, - spacegroup, - symmetry, - primitive->mapping_table, - tolerance)) == NULL) { - - warning_print("spglib: ref_get_Wyckoff_positions failed."); - warning_print(" (line %d, %s).\n", __LINE__, __FILE__); - - goto err; - } - - - for (i = 0; i < primitive->cell->size; i++) { - /* This is an assertion. */ - if (std_mapping_to_primitive[i] != i) { - warning_print("spglib: ref_get_Wyckoff_positions failed."); - warning_print("Unexpected atom index mapping of bravais (%d != %d).\n", - std_mapping_to_primitive[i], i); - warning_print(" (line %d, %s).\n", __LINE__, __FILE__); - goto err; - } - } - debug_print("Refined cell after ref_get_Wyckoff_positions\n"); debug_print(" (line %d, %s).\n", __LINE__, __FILE__); - debug_print_matrix_d3(bravais->lattice); + debug_print_matrix_d3(exstr->bravais->lattice); #ifdef SPGDEBUG for (i = 0; i < bravais->size; i++) { printf("%d: %f %f %f\n", - bravais->types[i], - bravais->position[i][0], - bravais->position[i][1], - bravais->position[i][2]); + exstr->bravais->types[i], + exstr->bravais->position[i][0], + exstr->bravais->position[i][1], + exstr->bravais->position[i][2]); } #endif for (i = 0; i < dataset->n_atoms; i++) { dataset->mapping_to_primitive[i] = primitive->mapping_table[i]; - } + } - dataset->n_std_atoms = bravais->size; - mat_copy_matrix_d3(dataset->std_lattice, bravais->lattice); + dataset->n_std_atoms = exstr->bravais->size; + mat_copy_matrix_d3(dataset->std_lattice, exstr->bravais->lattice); if ((dataset->std_positions = (double (*)[3]) malloc(sizeof(double[3]) * dataset->n_std_atoms)) @@ -1290,18 +1221,11 @@ static int set_dataset(SpglibDataset * dataset, } for (i = 0; i < dataset->n_std_atoms; i++) { - mat_copy_vector_d3(dataset->std_positions[i], bravais->position[i]); - dataset->std_types[i] = bravais->types[i]; - dataset->std_mapping_to_primitive[i] = std_mapping_to_primitive[i]; + mat_copy_vector_d3(dataset->std_positions[i], exstr->bravais->position[i]); + dataset->std_types[i] = exstr->bravais->types[i]; + dataset->std_mapping_to_primitive[i] = exstr->std_mapping_to_primitive[i]; } - free(std_mapping_to_primitive); - std_mapping_to_primitive = NULL; - cel_free_cell(bravais); - bravais = NULL; - sym_free_symmetry(symmetry); - symmetry = NULL; - /* dataset->pointgroup_number = spacegroup->pointgroup_number; */ pointgroup = ptg_get_pointgroup(spacegroup->pointgroup_number); strcpy(dataset->pointgroup_symbol, pointgroup.symbol); @@ -1317,14 +1241,6 @@ static int set_dataset(SpglibDataset * dataset, free(dataset->std_mapping_to_primitive); dataset->std_mapping_to_primitive = NULL; } - if (std_mapping_to_primitive != NULL) { - free(std_mapping_to_primitive); - std_mapping_to_primitive = NULL; - } - if (bravais != NULL) { - cel_free_cell(bravais); - bravais = NULL; - } if (dataset->equivalent_atoms != NULL) { free(dataset->equivalent_atoms); dataset->equivalent_atoms = NULL; @@ -1345,10 +1261,6 @@ static int set_dataset(SpglibDataset * dataset, free(dataset->rotations); dataset->rotations = NULL; } - if (symmetry != NULL) { - sym_free_symmetry(symmetry); - symmetry = NULL; - } return 0; } @@ -1376,7 +1288,7 @@ static int get_symmetry_from_dataset(int rotation[][3][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { return 0; } @@ -1441,7 +1353,7 @@ static int get_symmetry_with_collinear_spin(int rotation[][3][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { cel_free_cell(cell); cell = NULL; goto get_dataset_failed; @@ -1527,7 +1439,7 @@ static int get_multiplicity(SPGCONST double lattice[3][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { return 0; } @@ -1567,7 +1479,7 @@ static int standardize_primitive(double lattice[3][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { return 0; } @@ -1661,7 +1573,7 @@ static int standardize_cell(double lattice[3][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { goto err; } @@ -1720,7 +1632,7 @@ static int get_standardized_cell(double lattice[3][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { goto err; } @@ -1854,45 +1766,36 @@ static int get_international(char symbol[11], const int types[], const int num_atom, const double symprec, - const double angle_tolerance) + const double angle_tolerance) { - Cell *cell; - Primitive *primitive; - Spacegroup spacegroup; + SpglibDataset *dataset; + int number; - cell = NULL; - primitive = NULL; - spacegroup.number = 0; + dataset = NULL; - if ((cell = cel_alloc_cell(num_atom)) == NULL) { + if ((dataset = get_dataset(lattice, + position, + types, + num_atom, + 0, + symprec, + angle_tolerance)) == NULL) { goto err; } - cel_set_cell(cell, lattice, position, types); - - if ((primitive = spa_get_spacegroup(&spacegroup, - cell, - 0, - symprec, - angle_tolerance)) == NULL) { - cel_free_cell(cell); - cell = NULL; - goto err; - } - - prm_free_primitive(primitive); - primitive = NULL; - cel_free_cell(cell); - cell = NULL; - - if (spacegroup.number > 0) { - strcpy(symbol, spacegroup.international_short); + if (dataset->spacegroup_number > 0) { + number = dataset->spacegroup_number; + strcpy(symbol, dataset->international_symbol); + spg_free_dataset(dataset); + dataset = NULL; } else { + spg_free_dataset(dataset); + dataset = NULL; goto err; } spglib_error_code = SPGLIB_SUCCESS; - return spacegroup.number; + return number; err: spglib_error_code = SPGERR_SPACEGROUP_SEARCH_FAILED; @@ -1907,48 +1810,40 @@ static int get_schoenflies(char symbol[7], const double symprec, const double angle_tolerance) { - Cell *cell; - Primitive *primitive; - Spacegroup spacegroup; + SpglibDataset *dataset; + SpglibSpacegroupType spgtype; + int number; - cell = NULL; - primitive = NULL; - spacegroup.number = 0; + dataset = NULL; - if ((cell = cel_alloc_cell(num_atom)) == NULL) { + if ((dataset = get_dataset(lattice, + position, + types, + num_atom, + 0, + symprec, + angle_tolerance)) == NULL) { goto err; } - cel_set_cell(cell, lattice, position, types); - - if ((primitive = spa_get_spacegroup(&spacegroup, - cell, - 0, - symprec, - angle_tolerance)) == NULL) { - cel_free_cell(cell); - cell = NULL; - goto err; - } - - prm_free_primitive(primitive); - primitive = NULL; - cel_free_cell(cell); - cell = NULL; - - if (spacegroup.number > 0) { - strcpy(symbol, spacegroup.schoenflies); + if (dataset->spacegroup_number > 0) { + number = dataset->spacegroup_number; + spgtype = spg_get_spacegroup_type(dataset->hall_number); + strcpy(symbol, spgtype.schoenflies); + spg_free_dataset(dataset); + dataset = NULL; } else { + spg_free_dataset(dataset); + dataset = NULL; goto err; } spglib_error_code = SPGLIB_SUCCESS; - return spacegroup.number; + return number; err: spglib_error_code = SPGERR_SPACEGROUP_SEARCH_FAILED; return 0; - } @@ -1977,7 +1872,7 @@ static int get_ir_reciprocal_mesh(int grid_address[][3], num_atom, 0, symprec, - angle_tolerance)) == NULL) { + angle_tolerance)) == NULL) { return 0; } diff --git a/c/spglib/spin.c b/c/spglib/spin.c index 168749a0..b465abae 100644 --- a/c/spglib/spin.c +++ b/c/spglib/spin.c @@ -95,7 +95,7 @@ static Symmetry * get_collinear_operations(const Symmetry *sym_nonspin, rot = mat_alloc_MatINT(sym_nonspin->size); trans = mat_alloc_VecDBL(sym_nonspin->size); num_sym = 0; - + for (i = 0; i < sym_nonspin->size; i++) { sign = 0; /* Set sign as undetermined */ is_found = 1; @@ -172,7 +172,7 @@ static int set_equivalent_atoms(int * equiv_atoms, if ((mapping_table = get_mapping_table(symmetry, cell, symprec)) == NULL) { return 0; } - + for (i = 0; i < cell->size; i++) { if (mapping_table[i] != i) { continue; diff --git a/c/spglib/symmetry.c b/c/spglib/symmetry.c index 27971603..ab31b019 100644 --- a/c/spglib/symmetry.c +++ b/c/spglib/symmetry.c @@ -78,57 +78,58 @@ static int relative_axes[][3] = { }; static int identity[3][3] = {{1, 0, 0}, - {0, 1, 0}, - {0, 0, 1}}; + {0, 1, 0}, + {0, 0, 1}}; static int get_index_with_least_atoms(const Cell *cell); static VecDBL * get_translation(SPGCONST int rot[3][3], - const Cell *cell, - const double symprec, - const int is_identity); + const Cell *cell, + const double symprec, + const int is_identity); static Symmetry * get_operations(const Cell *primitive, - const double symprec, - const double angle_symprec); + const double symprec, + const double angle_symprec); static Symmetry * reduce_operation(const Cell * primitive, - const Symmetry * symmetry, - const double symprec, - const double angle_symprec); + const Symmetry * symmetry, + const double symprec, + const double angle_symprec, + const int is_pure_trans); static int search_translation_part(int atoms_found[], - const Cell * cell, - SPGCONST int rot[3][3], - const int min_atom_index, - const double origin[3], - const double symprec, - const int is_identity); + const Cell * cell, + SPGCONST int rot[3][3], + const int min_atom_index, + const double origin[3], + const double symprec, + const int is_identity); static int search_pure_translations(int atoms_found[], const Cell * cell, const double trans[3], const double symprec); static int is_overlap_all_atoms(const double test_trans[3], - SPGCONST int rot[3][3], - const Cell * cell, - const double symprec, - const int is_identity); + SPGCONST int rot[3][3], + const Cell * cell, + const double symprec, + const int is_identity); static PointSymmetry transform_pointsymmetry(SPGCONST PointSymmetry * point_sym_prim, - SPGCONST double new_lattice[3][3], - SPGCONST double original_lattice[3][3]); + SPGCONST double new_lattice[3][3], + SPGCONST double original_lattice[3][3]); static Symmetry * get_space_group_operations(SPGCONST PointSymmetry *lattice_sym, - const Cell *primitive, - const double symprec); + const Cell *primitive, + const double symprec); static void set_axes(int axes[3][3], - const int a1, const int a2, const int a3); + const int a1, const int a2, const int a3); static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3], - const double symprec, - const double angle_symprec); + const double symprec, + const double angle_symprec); static int is_identity_metric(SPGCONST double metric_rotated[3][3], - SPGCONST double metric_orig[3][3], - const double symprec, - const double angle_symprec); + SPGCONST double metric_orig[3][3], + const double symprec, + const double angle_symprec); static double get_angle(SPGCONST double metric[3][3], - const int i, - const int j); + const int i, + const int j); /* Return NULL if failed */ Symmetry * sym_alloc_symmetry(const int size) @@ -185,8 +186,8 @@ void sym_free_symmetry(Symmetry *symmetry) /* Return NULL if failed */ Symmetry * sym_get_operation(const Cell * primitive, - const double symprec, - const double angle_tolerance) + const double symprec, + const double angle_tolerance) { debug_print("sym_get_operations:\n"); @@ -196,16 +197,16 @@ Symmetry * sym_get_operation(const Cell * primitive, /* Return NULL if failed */ Symmetry * sym_reduce_operation(const Cell * primitive, - const Symmetry * symmetry, - const double symprec, - const double angle_tolerance) + const Symmetry * symmetry, + const double symprec, + const double angle_tolerance) { - return reduce_operation(primitive, symmetry, symprec, angle_tolerance); + return reduce_operation(primitive, symmetry, symprec, angle_tolerance, 0); } /* Return NULL if failed */ VecDBL * sym_get_pure_translation(const Cell *cell, - const double symprec) + const double symprec) { int multi; VecDBL * pure_trans; @@ -217,7 +218,7 @@ VecDBL * sym_get_pure_translation(const Cell *cell, if ((pure_trans = get_translation(identity, cell, symprec, 1)) == NULL) { warning_print("spglib: get_translation failed (line %d, %s).\n", - __LINE__, __FILE__); + __LINE__, __FILE__); return NULL; } @@ -226,7 +227,8 @@ VecDBL * sym_get_pure_translation(const Cell *cell, debug_print(" sym_get_pure_translation: pure_trans->size = %d\n", multi); } else { ; - warning_print("spglib: Finding pure translation failed (line %d, %s).\n", __LINE__, __FILE__); + warning_print("spglib: Finding pure translation failed (line %d, %s).\n", + __LINE__, __FILE__); warning_print(" cell->size %d, multi %d\n", cell->size, multi); } @@ -235,9 +237,9 @@ VecDBL * sym_get_pure_translation(const Cell *cell, /* Return NULL if failed */ VecDBL * sym_reduce_pure_translation(const Cell * cell, - const VecDBL * pure_trans, - const double symprec, - const double angle_tolerance) + const VecDBL * pure_trans, + const double symprec, + const double angle_tolerance) { int i, multi; Symmetry *symmetry, *symmetry_reduced; @@ -259,7 +261,7 @@ VecDBL * sym_reduce_pure_translation(const Cell * cell, } if ((symmetry_reduced = - reduce_operation(cell, symmetry, symprec, angle_tolerance)) == NULL) { + reduce_operation(cell, symmetry, symprec, angle_tolerance, 1)) == NULL) { sym_free_symmetry(symmetry); symmetry = NULL; return NULL; @@ -294,8 +296,8 @@ VecDBL * sym_reduce_pure_translation(const Cell * cell, /* transformed to those of original input cells, if the input cell */ /* was not a primitive cell. */ static Symmetry * get_operations(const Cell *primitive, - const double symprec, - const double angle_symprec) + const double symprec, + const double angle_symprec) { PointSymmetry lattice_sym; Symmetry *symmetry; @@ -305,15 +307,15 @@ static Symmetry * get_operations(const Cell *primitive, symmetry = NULL; lattice_sym = get_lattice_symmetry(primitive->lattice, - symprec, - angle_symprec); + symprec, + angle_symprec); if (lattice_sym.size == 0) { return NULL; } if ((symmetry = get_space_group_operations(&lattice_sym, - primitive, - symprec)) == NULL) { + primitive, + symprec)) == NULL) { return NULL; } @@ -322,9 +324,10 @@ static Symmetry * get_operations(const Cell *primitive, /* Return NULL if failed */ static Symmetry * reduce_operation(const Cell * primitive, - const Symmetry * symmetry, - const double symprec, - const double angle_symprec) + const Symmetry * symmetry, + const double symprec, + const double angle_symprec, + const int is_pure_trans) { int i, j, num_sym; Symmetry * sym_reduced; @@ -338,11 +341,16 @@ static Symmetry * reduce_operation(const Cell * primitive, rot = NULL; trans = NULL; - point_symmetry = get_lattice_symmetry(primitive->lattice, - symprec, - angle_symprec); - if (point_symmetry.size == 0) { - return NULL; + if (is_pure_trans) { + point_symmetry.size = 1; + mat_copy_matrix_i3(point_symmetry.rot[0], identity); + } else { + point_symmetry = get_lattice_symmetry(primitive->lattice, + symprec, + angle_symprec); + if (point_symmetry.size == 0) { + return NULL; + } } if ((rot = mat_alloc_MatINT(symmetry->size)) == NULL) { @@ -359,16 +367,16 @@ static Symmetry * reduce_operation(const Cell * primitive, for (i = 0; i < point_symmetry.size; i++) { for (j = 0; j < symmetry->size; j++) { if (mat_check_identity_matrix_i3(point_symmetry.rot[i], - symmetry->rot[j])) { - if (is_overlap_all_atoms(symmetry->trans[j], - symmetry->rot[j], - primitive, - symprec, - 0)) { - mat_copy_matrix_i3(rot->mat[num_sym], symmetry->rot[j]); - mat_copy_vector_d3(trans->vec[num_sym], symmetry->trans[j]); - num_sym++; - } + symmetry->rot[j])) { + if (is_overlap_all_atoms(symmetry->trans[j], + symmetry->rot[j], + primitive, + symprec, + 0)) { + mat_copy_matrix_i3(rot->mat[num_sym], symmetry->rot[j]); + mat_copy_vector_d3(trans->vec[num_sym], symmetry->trans[j]); + num_sym++; + } } } } @@ -392,9 +400,9 @@ static Symmetry * reduce_operation(const Cell * primitive, /* This function is heaviest in this code. */ /* Return NULL if failed */ static VecDBL * get_translation(SPGCONST int rot[3][3], - const Cell *cell, - const double symprec, - const int is_identity) + const Cell *cell, + const double symprec, + const int is_identity) { int i, j, k, min_atom_index, num_trans; int *is_found; @@ -438,12 +446,12 @@ static VecDBL * get_translation(SPGCONST int rot[3][3], if (cell->size < NUM_ATOMS_CRITERION_FOR_OPENMP || is_identity) { /* In this case, OpenMP multithreading is not used. */ num_trans = search_translation_part(is_found, - cell, - rot, - min_atom_index, - origin, - symprec, - is_identity); + cell, + rot, + min_atom_index, + origin, + symprec, + is_identity); if (num_trans == 0) { goto ret; } @@ -459,21 +467,21 @@ static VecDBL * get_translation(SPGCONST int rot[3][3], num_min_type_atoms = 0; for (i = 0; i < cell->size; i++) { if (cell->types[i] == cell->types[min_atom_index]) { - min_type_atoms[num_min_type_atoms] = i; - num_min_type_atoms++; + min_type_atoms[num_min_type_atoms] = i; + num_min_type_atoms++; } } #pragma omp parallel for private(j, vec) for (i = 0; i < num_min_type_atoms; i++) { for (j = 0; j < 3; j++) { - vec[j] = cell->position[min_type_atoms[i]][j] - origin[j]; + vec[j] = cell->position[min_type_atoms[i]][j] - origin[j]; } if (is_overlap_all_atoms(vec, - rot, - cell, - symprec, - is_identity)) { - is_found[min_type_atoms[i]] = 1; + rot, + cell, + symprec, + is_identity)) { + is_found[min_type_atoms[i]] = 1; } } @@ -486,12 +494,12 @@ static VecDBL * get_translation(SPGCONST int rot[3][3], } #else num_trans = search_translation_part(is_found, - cell, - rot, - min_atom_index, - origin, - symprec, - is_identity); + cell, + rot, + min_atom_index, + origin, + symprec, + is_identity); if (num_trans == 0) { goto ret; } @@ -505,8 +513,8 @@ static VecDBL * get_translation(SPGCONST int rot[3][3], for (i = 0; i < cell->size; i++) { if (is_found[i]) { for (j = 0; j < 3; j++) { - trans->vec[k][j] = cell->position[i][j] - origin[j]; - trans->vec[k][j] -= mat_Nint(trans->vec[k][j]); + trans->vec[k][j] = cell->position[i][j] - origin[j]; + trans->vec[k][j] -= mat_Nint(trans->vec[k][j]); } k++; } @@ -520,12 +528,12 @@ static VecDBL * get_translation(SPGCONST int rot[3][3], } static int search_translation_part(int atoms_found[], - const Cell * cell, - SPGCONST int rot[3][3], - const int min_atom_index, - const double origin[3], - const double symprec, - const int is_identity) + const Cell * cell, + SPGCONST int rot[3][3], + const int min_atom_index, + const double origin[3], + const double symprec, + const int is_identity) { int i, j, num_trans; double trans[3]; @@ -545,10 +553,10 @@ static int search_translation_part(int atoms_found[], trans[j] = cell->position[i][j] - origin[j]; } if (is_overlap_all_atoms(trans, - rot, - cell, - symprec, - is_identity)) { + rot, + cell, + symprec, + is_identity)) { atoms_found[i] = 1; num_trans++; if (is_identity) { @@ -583,7 +591,7 @@ static int search_pure_translations(int atoms_found[], if (!copy_atoms_found[initial_atom]) { continue; } - + i_atom = initial_atom; for (i = 0; i < cell->size; i++) { @@ -603,7 +611,7 @@ static int search_pure_translations(int atoms_found[], num_trans++; } i_atom = j; - + break; } } @@ -620,10 +628,10 @@ static int search_pure_translations(int atoms_found[], } static int is_overlap_all_atoms(const double trans[3], - SPGCONST int rot[3][3], - const Cell * cell, - const double symprec, - const int is_identity) + SPGCONST int rot[3][3], + const Cell * cell, + const double symprec, + const int is_identity) { int i, j, k, is_found; double pos_rot[3], d_frac[3], d[3]; @@ -631,31 +639,31 @@ static int is_overlap_all_atoms(const double trans[3], for (i = 0; i < cell->size; i++) { if (is_identity) { /* Identity matrix is treated as special for speed-up. */ for (j = 0; j < 3; j++) { - pos_rot[j] = cell->position[i][j] + trans[j]; + pos_rot[j] = cell->position[i][j] + trans[j]; } } else { mat_multiply_matrix_vector_id3(pos_rot, - rot, - cell->position[i]); + rot, + cell->position[i]); for (j = 0; j < 3; j++) { - pos_rot[j] += trans[j]; + pos_rot[j] += trans[j]; } } is_found = 0; for (j = 0; j < cell->size; j++) { if (cell->types[i] == cell->types[j]) { - /* here cel_is_overlap can be used, but for the tuning */ - /* purpose, write it again */ - for (k = 0; k < 3; k++) { - d_frac[k] = pos_rot[k] - cell->position[j][k]; - d_frac[k] -= mat_Nint(d_frac[k]); - } - mat_multiply_matrix_vector_d3(d, cell->lattice, d_frac); - if (sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]) < symprec) { - is_found = 1; - break; - } + /* here cel_is_overlap can be used, but for the tuning */ + /* purpose, write it again */ + for (k = 0; k < 3; k++) { + d_frac[k] = pos_rot[k] - cell->position[j][k]; + d_frac[k] -= mat_Nint(d_frac[k]); + } + mat_multiply_matrix_vector_d3(d, cell->lattice, d_frac); + if (sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]) < symprec) { + is_found = 1; + break; + } } } @@ -689,8 +697,8 @@ static int get_index_with_least_atoms(const Cell *cell) for (i = 0; i < cell->size; i++) { for (j = 0; j < cell->size; j++) { if (cell->types[i] == cell->types[j]) { - mapping[j]++; - break; + mapping[j]++; + break; } } } @@ -713,8 +721,8 @@ static int get_index_with_least_atoms(const Cell *cell) /* Return NULL if failed */ static Symmetry * get_space_group_operations(SPGCONST PointSymmetry *lattice_sym, - const Cell *primitive, - const double symprec) + const Cell *primitive, + const double symprec) { int i, j, num_sym, total_num_sym; VecDBL **trans; @@ -739,10 +747,10 @@ get_space_group_operations(SPGCONST PointSymmetry *lattice_sym, for (i = 0; i < lattice_sym->size; i++) { if ((trans[i] = get_translation(lattice_sym->rot[i], primitive, symprec, 0)) - != NULL) { + != NULL) { debug_print(" match translation %d/%d; tolerance = %f\n", - i + 1, lattice_sym->size, symprec); + i + 1, lattice_sym->size, symprec); total_num_sym += trans[i]->size; } @@ -778,8 +786,8 @@ get_space_group_operations(SPGCONST PointSymmetry *lattice_sym, } static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3], - const double symprec, - const double angle_symprec) + const double symprec, + const double angle_symprec) { int i, j, k, attempt, num_sym; double angle_tol; @@ -803,28 +811,28 @@ static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3], num_sym = 0; for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { - for (k = 0; k < 26; k++) { - set_axes(axes, i, j, k); - if (! ((mat_get_determinant_i3(axes) == 1) || - (mat_get_determinant_i3(axes) == -1))) { - continue; - } - mat_multiply_matrix_di3(lattice, min_lattice, axes); - mat_get_metric(metric, lattice); + for (k = 0; k < 26; k++) { + set_axes(axes, i, j, k); + if (! ((mat_get_determinant_i3(axes) == 1) || + (mat_get_determinant_i3(axes) == -1))) { + continue; + } + mat_multiply_matrix_di3(lattice, min_lattice, axes); + mat_get_metric(metric, lattice); - if (is_identity_metric(metric, metric_orig, symprec, angle_tol)) { - if (num_sym > 47) { - angle_tol *= ANGLE_REDUCE_RATE; - warning_print("spglib: Too many lattice symmetries was found.\n"); - warning_print(" Reduce angle tolerance to %f", angle_tol); - warning_print(" (line %d, %s).\n", __LINE__, __FILE__); - goto next_attempt; - } + if (is_identity_metric(metric, metric_orig, symprec, angle_tol)) { + if (num_sym > 47) { + angle_tol *= ANGLE_REDUCE_RATE; + warning_print("spglib: Too many lattice symmetries was found.\n"); + warning_print(" Reduce angle tolerance to %f", angle_tol); + warning_print(" (line %d, %s).\n", __LINE__, __FILE__); + goto next_attempt; + } - mat_copy_matrix_i3(lattice_sym.rot[num_sym], axes); - num_sym++; - } - } + mat_copy_matrix_i3(lattice_sym.rot[num_sym], axes); + num_sym++; + } + } } } @@ -843,14 +851,14 @@ static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3], } static int is_identity_metric(SPGCONST double metric_rotated[3][3], - SPGCONST double metric_orig[3][3], - const double symprec, - const double angle_symprec) + SPGCONST double metric_orig[3][3], + const double symprec, + const double angle_symprec) { int i, j, k; int elem_sets[3][2] = {{0, 1}, - {0, 2}, - {1, 2}}; + {0, 2}, + {1, 2}}; double cos1, cos2, x, length_ave2, sin_dtheta2; double length_orig[3], length_rot[3]; @@ -867,8 +875,8 @@ static int is_identity_metric(SPGCONST double metric_rotated[3][3], k = elem_sets[i][1]; if (angle_symprec > 0) { if (mat_Dabs(get_angle(metric_orig, j, k) - - get_angle(metric_rotated, j, k)) > angle_symprec) { - goto fail; + get_angle(metric_rotated, j, k)) > angle_symprec) { + goto fail; } } else { /* dtheta = arccos(cos(theta1) - arccos(cos(theta2))) */ @@ -880,11 +888,11 @@ static int is_identity_metric(SPGCONST double metric_rotated[3][3], x = cos1 * cos2 + sqrt(1 - cos1 * cos1) * sqrt(1 - cos2 * cos2); sin_dtheta2 = 1 - x * x; length_ave2 = ((length_orig[j] + length_rot[j]) * - (length_orig[k] + length_rot[k])) / 4; + (length_orig[k] + length_rot[k])) / 4; if (sin_dtheta2 > 1e-12) { - if (sin_dtheta2 * length_ave2 > symprec * symprec) { - goto fail; - } + if (sin_dtheta2 * length_ave2 > symprec * symprec) { + goto fail; + } } } } @@ -896,8 +904,8 @@ static int is_identity_metric(SPGCONST double metric_rotated[3][3], } static double get_angle(SPGCONST double metric[3][3], - const int i, - const int j) + const int i, + const int j) { double length_i, length_j; @@ -909,8 +917,8 @@ static double get_angle(SPGCONST double metric[3][3], static PointSymmetry transform_pointsymmetry(SPGCONST PointSymmetry * lat_sym_orig, - SPGCONST double new_lattice[3][3], - SPGCONST double original_lattice[3][3]) + SPGCONST double new_lattice[3][3], + SPGCONST double original_lattice[3][3]) { int i, size; double trans_mat[3][3], inv_mat[3][3], drot[3][3]; @@ -931,9 +939,9 @@ transform_pointsymmetry(SPGCONST PointSymmetry * lat_sym_orig, if (mat_is_int_matrix(drot, mat_Dabs(mat_get_determinant_d3(trans_mat)) / 10)) { mat_cast_matrix_3d_to_3i(lat_sym_new.rot[size], drot); if (abs(mat_get_determinant_i3(lat_sym_new.rot[size])) != 1) { - warning_print("spglib: A point symmetry operation is not unimodular."); - warning_print("(line %d, %s).\n", __LINE__, __FILE__); - goto err; + warning_print("spglib: A point symmetry operation is not unimodular."); + warning_print("(line %d, %s).\n", __LINE__, __FILE__); + goto err; } size++; } @@ -954,7 +962,7 @@ transform_pointsymmetry(SPGCONST PointSymmetry * lat_sym_orig, } static void set_axes(int axes[3][3], - const int a1, const int a2, const int a3) + const int a1, const int a2, const int a3) { int i; for (i = 0; i < 3; i++) {axes[i][0] = relative_axes[a1][i]; } diff --git a/c/spglib_h/determination.h b/c/spglib_h/determination.h new file mode 100644 index 00000000..fe3701c1 --- /dev/null +++ b/c/spglib_h/determination.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2017 Atsushi Togo */ +/* All rights reserved. */ + +/* This file is part of spglib. */ + +/* Redistribution and use in source and binary forms, with or without */ +/* modification, are permitted provided that the following conditions */ +/* are met: */ + +/* * Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ + +/* * Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the */ +/* distribution. */ + +/* * Neither the name of the phonopy project nor the names of its */ +/* contributors may be used to endorse or promote products derived */ +/* from this software without specific prior written permission. */ + +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */ +/* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ +/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */ +/* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ +/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */ +/* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */ +/* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */ +/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ +/* POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef __determination_H__ +#define __determination_H__ + +#include "cell.h" +#include "primitive.h" +#include "refinement.h" +#include "spacegroup.h" + +typedef struct { + Primitive *primitive; + Spacegroup *spacegroup; + ExactStructure *exact_structure; +} DataContainer; + +DataContainer * det_determine_all(const Cell * cell, + const int hall_number, + const double symprec, + const double angle_tolerance); +void det_free_container(DataContainer * container); + +#endif diff --git a/c/spglib_h/refinement.h b/c/spglib_h/refinement.h index 3f7b30e6..8966e4cc 100644 --- a/c/spglib_h/refinement.h +++ b/c/spglib_h/refinement.h @@ -36,22 +36,23 @@ #define __refinement_H__ #include "cell.h" -#include "mathfunc.h" -#include "spacegroup.h" #include "symmetry.h" +#include "spacegroup.h" + +typedef struct { + Cell *bravais; + Symmetry *symmetry; + int *wyckoffs; + int *equivalent_atoms; + int *std_mapping_to_primitive; +} ExactStructure; + +ExactStructure * +ref_get_exact_structure_and_symmetry(const Cell * primitive, + const Cell * cell, + SPGCONST Spacegroup * spacegroup, + const int * mapping_table, + const double symprec); +void ref_free_exact_structure(ExactStructure *exstr); -Symmetry * -ref_get_refined_symmetry_operations(const Cell * cell, - const Cell * primitive, - SPGCONST Spacegroup * spacegroup, - const double symprec); -Cell * ref_get_Wyckoff_positions(int * wyckoffs, - int * equiv_atoms, - int * mapping_to_primitive, - const Cell * primitive, - const Cell * cell, - SPGCONST Spacegroup * spacegroup, - const Symmetry * symmetry, - const int * mapping_table, - const double symprec); #endif diff --git a/c/spglib_h/spacegroup.h b/c/spglib_h/spacegroup.h index 869d4d8a..c7ffef4e 100644 --- a/c/spglib_h/spacegroup.h +++ b/c/spglib_h/spacegroup.h @@ -66,20 +66,19 @@ typedef enum { R_CENTER, } Centering; -Primitive * spa_get_spacegroup(Spacegroup * spacegroup, - const Cell * cell, - const int hall_number, - const double symprec, - const double angle_tolerance); +Spacegroup spa_search_spacegroup(const Cell * primitive, + const int hall_number, + const double symprec, + const double angle_tolerance); Spacegroup spa_search_spacegroup_with_symmetry(const Symmetry *symmetry, - const double symprec); + const double symprec); Cell * spa_transform_to_primitive(int * mapping_table, const Cell * cell, SPGCONST double trans_mat[3][3], const Centering centering, const double symprec); Cell * spa_transform_from_primitive(const Cell * primitive, - const Centering centering, - const double symprec); + const Centering centering, + const double symprec); #endif diff --git a/c/spglib_h/spglib.h b/c/spglib_h/spglib.h index 01b48aec..e1746b1d 100644 --- a/c/spglib_h/spglib.h +++ b/c/spglib_h/spglib.h @@ -51,10 +51,10 @@ [ a_z, b_z, c_z ] ] position: Atomic positions (in fractional coordinates) - - [ [ x1_a, x1_b, x1_c ], - [ x2_a, x2_b, x2_c ], - [ x3_a, x3_b, x3_c ], + + [ [ x1_a, x1_b, x1_c ], + [ x2_a, x2_b, x2_c ], + [ x3_a, x3_b, x3_c ], ... ] types: Atom types, i.e., species identified by number @@ -149,35 +149,35 @@ SpglibError spg_get_error_code(void); char * spg_get_error_message(SpglibError spglib_error); SpglibDataset * spg_get_dataset(SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec); + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec); SpglibDataset * spgat_get_dataset(SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* hall_number = 0 gives the same as spg_get_dataset. */ SpglibDataset * spg_get_dataset_with_hall_number(SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const int hall_number, - const double symprec); + SPGCONST double position[][3], + const int types[], + const int num_atom, + const int hall_number, + const double symprec); /* hall_number = 0 gives the same as spgat_get_dataset. */ SpglibDataset * spgat_get_dataset_with_hall_number(SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const int hall_number, - const double symprec, - const double angle_tolerance); + SPGCONST double position[][3], + const int types[], + const int num_atom, + const int hall_number, + const double symprec, + const double angle_tolerance); void spg_free_dataset(SpglibDataset *dataset); @@ -188,47 +188,47 @@ void spg_free_dataset(SpglibDataset *dataset); /* ``translation[i]`` with same index give a symmetry oprations, */ /* i.e., these have to be used togather. */ int spg_get_symmetry(int rotation[][3][3], - double translation[][3], - const int max_size, - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec); + double translation[][3], + const int max_size, + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec); int spgat_get_symmetry(int rotation[][3][3], - double translation[][3], - const int max_size, - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + double translation[][3], + const int max_size, + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* Find symmetry operations with collinear spins on atoms. */ int spg_get_symmetry_with_collinear_spin(int rotation[][3][3], - double translation[][3], - int equivalent_atoms[], - const int max_size, - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const double spins[], - const int num_atom, - const double symprec); + double translation[][3], + int equivalent_atoms[], + const int max_size, + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const double spins[], + const int num_atom, + const double symprec); int spgat_get_symmetry_with_collinear_spin(int rotation[][3][3], - double translation[][3], - int equivalent_atoms[], - const int max_size, - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const double spins[], - const int num_atom, - const double symprec, - const double angle_tolerance); + double translation[][3], + int equivalent_atoms[], + const int max_size, + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const double spins[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* Space group type (hall_number) is searched from symmetry operations. */ int spg_get_hall_number_from_symmetry(SPGCONST int rotation[][3][3], @@ -240,65 +240,65 @@ int spg_get_hall_number_from_symmetry(SPGCONST int rotation[][3][3], /* be used in advance to allocate memoery space for symmetry */ /* operations. */ int spg_get_multiplicity(SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec); + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec); int spgat_get_multiplicity(SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* Space group is found in international table symbol (``symbol``) and */ /* number (return value). 0 is returned when it fails. */ int spg_get_international(char symbol[11], - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec); + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec); int spgat_get_international(char symbol[11], - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* Space group is found in schoenflies (``symbol``) and as number (return */ /* value). 0 is returned when it fails. */ int spg_get_schoenflies(char symbol[7], - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec); + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec); int spgat_get_schoenflies(char symbol[7], - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* Point group symbol is obtained from the rotation part of */ /* symmetry operations */ int spg_get_pointgroup(char symbol[6], - int trans_mat[3][3], - SPGCONST int rotations[][3][3], - const int num_rotations); + int trans_mat[3][3], + SPGCONST int rotations[][3][3], + const int num_rotations); /* Space-group operations in built-in database are accessed by index */ /* of hall symbol. The index is defined as number from 1 to 530. */ /* The muximum number of symmetry operations is 192. */ int spg_get_symmetry_from_database(int rotations[192][3][3], - double translations[192][3], - const int hall_number); + double translations[192][3], + const int hall_number); /* Space-group type information is accessed by index of hall symbol. */ /* The index is defined as number from 1 to 530. */ @@ -306,21 +306,21 @@ SpglibSpacegroupType spg_get_spacegroup_type(const int hall_number); int spg_standardize_cell(double lattice[3][3], - double position[][3], - int types[], - const int num_atom, - const int to_primitive, - const int no_idealize, - const double symprec); + double position[][3], + int types[], + const int num_atom, + const int to_primitive, + const int no_idealize, + const double symprec); int spgat_standardize_cell(double lattice[3][3], - double position[][3], - int types[], - const int num_atom, - const int to_primitive, - const int no_idealize, - const double symprec, - const double angle_tolerance); + double position[][3], + int types[], + const int num_atom, + const int to_primitive, + const int no_idealize, + const double symprec, + const double angle_tolerance); /* This is a wrapper of spg_standardize_cell. */ /* A primitive cell is found from an input cell. */ @@ -328,17 +328,17 @@ int spgat_standardize_cell(double lattice[3][3], /* ``num_atom`` is returned as return value. */ /* When any primitive cell is not found, 0 is returned. */ int spg_find_primitive(double lattice[3][3], - double position[][3], - int types[], - const int num_atom, - const double symprec); + double position[][3], + int types[], + const int num_atom, + const double symprec); int spgat_find_primitive(double lattice[3][3], - double position[][3], - int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + double position[][3], + int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* This is a wrapper of spg_standardize_cell. */ /* Bravais lattice with internal atomic points are returned. */ @@ -347,17 +347,17 @@ int spgat_find_primitive(double lattice[3][3], /* When bravais lattice could not be found, or could not be */ /* symmetrized, 0 is returned. */ int spg_refine_cell(double lattice[3][3], - double position[][3], - int types[], - const int num_atom, - const double symprec); + double position[][3], + int types[], + const int num_atom, + const double symprec); int spgat_refine_cell(double lattice[3][3], - double position[][3], - int types[], - const int num_atom, - const double symprec, - const double angle_tolerance); + double position[][3], + int types[], + const int num_atom, + const double symprec, + const double angle_tolerance); /* Delaunay reduction for lattice parameters */ /* ``lattice`` is overwritten when the redution ends succeeded. */ @@ -373,7 +373,7 @@ int spg_delaunay_reduce(double lattice[3][3], const double symprec); /* ((grid_address * 2 + (shift != 0)) / (mesh * 2)). */ /* Each element of shift[] is 0 or non-zero. */ int spg_get_grid_point_from_address(const int grid_address[3], - const int mesh[3]); + const int mesh[3]); /* Irreducible reciprocal grid points are searched from uniform */ /* mesh grid points specified by ``mesh`` and ``is_shift``. */ @@ -392,15 +392,15 @@ int spg_get_grid_point_from_address(const int grid_address[3], /* returned as the return value. The time reversal symmetry is */ /* imposed by setting ``is_time_reversal`` 1. */ int spg_get_ir_reciprocal_mesh(int grid_address[][3], - int map[], - const int mesh[3], - const int is_shift[3], - const int is_time_reversal, - SPGCONST double lattice[3][3], - SPGCONST double position[][3], - const int types[], - const int num_atom, - const double symprec); + int map[], + const int mesh[3], + const int is_shift[3], + const int is_time_reversal, + SPGCONST double lattice[3][3], + SPGCONST double position[][3], + const int types[], + const int num_atom, + const double symprec); /* The irreducible k-points are searched from unique k-point mesh */ /* grids from real space lattice vectors and rotation matrices of */ @@ -411,32 +411,32 @@ int spg_get_ir_reciprocal_mesh(int grid_address[][3], /* reduced k-points with stabilizers are returned as the return */ /* value. */ int spg_get_stabilized_reciprocal_mesh(int grid_address[][3], - int map[], - const int mesh[3], - const int is_shift[3], - const int is_time_reversal, - const int num_rot, - SPGCONST int rotations[][3][3], - const int num_q, - SPGCONST double qpoints[][3]); + int map[], + const int mesh[3], + const int is_shift[3], + const int is_time_reversal, + const int num_rot, + SPGCONST int rotations[][3][3], + const int num_q, + SPGCONST double qpoints[][3]); /* Rotation operations in reciprocal space ``rot_reciprocal`` are applied */ /* to a grid address ``address_orig`` and resulting grid points are stored in */ /* ``rot_grid_points``. Return 0 if failed. */ int spg_get_grid_points_by_rotations(int rot_grid_points[], - const int address_orig[3], - const int num_rot, - SPGCONST int rot_reciprocal[][3][3], - const int mesh[3], - const int is_shift[3]); + const int address_orig[3], + const int num_rot, + SPGCONST int rot_reciprocal[][3][3], + const int mesh[3], + const int is_shift[3]); int spg_get_BZ_grid_points_by_rotations(int rot_grid_points[], - const int address_orig[3], - const int num_rot, - SPGCONST int rot_reciprocal[][3][3], - const int mesh[3], - const int is_shift[3], - const int bz_map[]); + const int address_orig[3], + const int num_rot, + SPGCONST int rot_reciprocal[][3][3], + const int mesh[3], + const int is_shift[3], + const int bz_map[]); /* Grid addresses are relocated inside Brillouin zone. */ /* Number of ir-grid-points inside Brillouin zone is returned. */ @@ -461,19 +461,19 @@ int spg_get_BZ_grid_points_by_rotations(int rot_grid_points[], /* surface from grid address. The grid point indices are mapped to */ /* (mesh[0] * 2) x (mesh[1] * 2) x (mesh[2] * 2) space (bz_map). */ int spg_relocate_BZ_grid_address(int bz_grid_address[][3], - int bz_map[], - SPGCONST int grid_address[][3], - const int mesh[3], - SPGCONST double rec_lattice[3][3], - const int is_shift[3]); + int bz_map[], + SPGCONST int grid_address[][3], + const int mesh[3], + SPGCONST double rec_lattice[3][3], + const int is_shift[3]); void spg_get_neighboring_grid_points(int relative_grid_points[], - const int grid_point, - SPGCONST int relative_grid_address[][3], - const int num_relative_grid_address, - const int mesh[3], - SPGCONST int bz_grid_address[][3], - const int bz_map[]); + const int grid_point, + SPGCONST int relative_grid_address[][3], + const int num_relative_grid_address, + const int mesh[3], + SPGCONST int bz_grid_address[][3], + const int bz_map[]); /*--------*/ /* Niggli */ @@ -482,4 +482,3 @@ void spg_get_neighboring_grid_points(int relative_grid_points[], int spg_niggli_reduce(double lattice[3][3], const double symprec); #endif - diff --git a/c/spglib_h/symmetry.h b/c/spglib_h/symmetry.h index adc4fd6e..f6410b74 100644 --- a/c/spglib_h/symmetry.h +++ b/c/spglib_h/symmetry.h @@ -57,12 +57,12 @@ Symmetry * sym_get_operation(const Cell * primitive, Symmetry * sym_reduce_operation(const Cell * primitive, const Symmetry * symmetry, const double symprec, - const double angle_tolerance); + const double angle_tolerance); VecDBL * sym_get_pure_translation(const Cell *cell, - const double symprec); + const double symprec); VecDBL * sym_reduce_pure_translation(const Cell * cell, - const VecDBL * pure_trans, - const double symprec, - const double angle_tolerance); + const VecDBL * pure_trans, + const double symprec, + const double angle_tolerance); #endif diff --git a/c/spglib_h/version.h b/c/spglib_h/version.h index bbea1588..fef12dc5 100644 --- a/c/spglib_h/version.h +++ b/c/spglib_h/version.h @@ -36,8 +36,8 @@ #define __version_H__ #define SPGLIB_MAJOR_VERSION 1 -#define SPGLIB_MINOR_VERSION 9 -#define SPGLIB_MICRO_VERSION 10 +#define SPGLIB_MINOR_VERSION 10 +#define SPGLIB_MICRO_VERSION 1 #endif diff --git a/setup.py b/setup.py index 9191805f..ba6a1ec1 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ import sysconfig config_var = sysconfig.get_config_var("CFLAGS") if config_var is not None and "-Werror=declaration-after-statement" in config_var: os.environ['CFLAGS'] = config_var.replace( - "-Werror=declaration-after-statement", "") + "-Werror=declaration-after-statement", "") ###################### # _phonopy extension # @@ -94,6 +94,7 @@ extension_spglib = Extension( 'c/spglib/arithmetic.c', 'c/spglib/cell.c', 'c/spglib/delaunay.c', + 'c/spglib/determination.c', 'c/spglib/hall_symbol.c', 'c/spglib/kgrid.c', 'c/spglib/kpoint.c', @@ -186,5 +187,3 @@ if __name__ == '__main__': provides=['phonopy'], scripts=scripts_phonopy, ext_modules=ext_modules_phonopy) - -