spglib update to v1.10.1

This commit is contained in:
Atsushi Togo 2017-11-02 10:21:19 +09:00
parent 3c80b1b5a4
commit c3ecdf02cd
21 changed files with 1482 additions and 1325 deletions

182
c/spglib/determination.c Normal file
View File

@ -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 <stdlib.h>
#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);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@
static void get_all_grid_addresses(int grid_address[][3], const int mesh[3]); 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], 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 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 modulo_i3(int v[3], const int m[3]);
static void reduce_grid_address(int address[3], const int mesh[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], 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); return get_grid_point_double_mesh(address_double, mesh);
} }
void kgd_get_grid_address_double_mesh(int address_double[3], void kgd_get_grid_address_double_mesh(int address_double[3],
const int address[3], const int address[3],
const int mesh[3], const int mesh[3],
const int is_shift[3]) const int is_shift[3])
{ {
int i; 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++) { for (j = 0; j < mesh[1]; j++) {
address[1] = j; address[1] = j;
for (k = 0; k < mesh[2]; k++) { for (k = 0; k < mesh[2]; k++) {
address[2] = k; address[2] = k;
grid_point = get_grid_point_single_mesh(address, mesh); grid_point = get_grid_point_single_mesh(address, mesh);
grid_address[grid_point][0] = address[0]; grid_address[grid_point][0] = address[0];
grid_address[grid_point][1] = address[1]; grid_address[grid_point][1] = address[1];
grid_address[grid_point][2] = address[2]; grid_address[grid_point][2] = address[2];
reduce_grid_address(grid_address[grid_point], mesh); reduce_grid_address(grid_address[grid_point], mesh);
} }
} }
} }
} }
static int get_grid_point_double_mesh(const int address_double[3], static int get_grid_point_double_mesh(const int address_double[3],
const int mesh[3]) const int mesh[3])
{ {
int i, address[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], static int get_grid_point_single_mesh(const int address[3],
const int mesh[3]) const int mesh[3])
{ {
#ifndef GRID_ORDER_XYZ #ifndef GRID_ORDER_XYZ
return address[2] * mesh[0] * mesh[1] + address[1] * mesh[0] + address[0]; return address[2] * mesh[0] * mesh[1] + address[1] * mesh[0] + address[0];
#else #else
return address[0] * mesh[1] * mesh[2] + address[1] * mesh[2] + address[2]; 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]) 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 #else
address[i] -= mesh[i] * (address[i] > (mesh[i] - 1) / 2); address[i] -= mesh[i] * (address[i] > (mesh[i] - 1) / 2);
#endif #endif
} }
} }
static void reduce_grid_address_double(int address[3], const int mesh[3]) 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 #else
address[i] -= 2 * mesh[i] * (address[i] > mesh[i] - 1); address[i] -= 2 * mesh[i] * (address[i] > mesh[i] - 1);
#endif #endif
} }
} }

View File

@ -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], 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] || if ( a[0][0] - b[0][0] ||
a[0][1] - b[0][1] || 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], int mat_check_identity_matrix_d3(SPGCONST double a[3][3],
SPGCONST double b[3][3], SPGCONST double b[3][3],
const double symprec) const double symprec)
{ {
if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec || if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec ||
mat_Dabs( a[0][1] - b[0][1] ) > 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], int mat_check_identity_matrix_id3(SPGCONST int a[3][3],
SPGCONST double b[3][3], SPGCONST double b[3][3],
const double symprec) const double symprec)
{ {
if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec || if ( mat_Dabs( a[0][0] - b[0][0] ) > symprec ||
mat_Dabs( a[0][1] - b[0][1] ) > 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 */ /* m=axb */
void mat_multiply_matrix_d3(double m[3][3], void mat_multiply_matrix_d3(double m[3][3],
SPGCONST double a[3][3], SPGCONST double a[3][3],
SPGCONST double b[3][3]) SPGCONST double b[3][3])
{ {
int i, j; /* a_ij */ int i, j; /* a_ij */
double c[3][3]; double c[3][3];
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
c[i][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); mat_copy_matrix_d3(m, c);
} }
void mat_multiply_matrix_i3(int m[3][3], void mat_multiply_matrix_i3(int m[3][3],
SPGCONST int a[3][3], SPGCONST int a[3][3],
SPGCONST int b[3][3]) SPGCONST int b[3][3])
{ {
int i, j; /* a_ij */ int i, j; /* a_ij */
int c[3][3]; int c[3][3];
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
c[i][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); mat_copy_matrix_i3(m, c);
} }
void mat_multiply_matrix_di3(double m[3][3], void mat_multiply_matrix_di3(double m[3][3],
SPGCONST double a[3][3], SPGCONST double a[3][3],
SPGCONST int b[3][3]) SPGCONST int b[3][3])
{ {
int i, j; /* a_ij */ int i, j; /* a_ij */
double c[3][3]; double c[3][3];
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
c[i][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); mat_copy_matrix_d3(m, c);
} }
void mat_multiply_matrix_id3(double m[3][3], void mat_multiply_matrix_id3(double m[3][3],
SPGCONST int a[3][3], SPGCONST int a[3][3],
SPGCONST double b[3][3]) SPGCONST double b[3][3])
{ {
int i, j; /* a_ij */ int i, j; /* a_ij */
double c[3][3]; double c[3][3];
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
c[i][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); mat_copy_matrix_d3(m, c);
} }
void mat_multiply_matrix_vector_i3(int v[3], void mat_multiply_matrix_vector_i3(int v[3],
SPGCONST int a[3][3], SPGCONST int a[3][3],
const int b[3]) const int b[3])
{ {
int i; int i;
int c[3]; 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], void mat_multiply_matrix_vector_d3(double v[3],
SPGCONST double a[3][3], SPGCONST double a[3][3],
const double b[3]) const double b[3])
{ {
int i; int i;
double c[3]; 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], void mat_multiply_matrix_vector_id3(double v[3],
SPGCONST int a[3][3], SPGCONST int a[3][3],
const double b[3]) const double b[3])
{ {
int i; int i;
double c[3]; 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], void mat_multiply_matrix_vector_di3(double v[3],
SPGCONST double a[3][3], SPGCONST double a[3][3],
const int b[3]) const int b[3])
{ {
int i; int i;
double c[3]; 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], void mat_add_matrix_i3(int m[3][3],
SPGCONST int a[3][3], SPGCONST int a[3][3],
SPGCONST int b[3][3]) SPGCONST int b[3][3])
{ {
int i, j; int i, j;
for ( i = 0; i < 3; i++ ) { 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 */ /* ruby code for auto generating */
/* 3.times {|i| 3.times {|j| */ /* 3.times {|i| 3.times {|j| */
/* puts "m[#{j}][#{i}]=(a[#{(i+1)%3}][#{(j+1)%3}]*a[#{(i+2)%3}][#{(j+2)%3}] */ /* 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], int mat_inverse_matrix_d3(double m[3][3],
SPGCONST double a[3][3], SPGCONST double a[3][3],
const double precision) const double precision)
{ {
double det; double det;
double c[3][3]; double c[3][3];
@ -337,9 +337,9 @@ int mat_inverse_matrix_d3(double m[3][3],
/* m = b^-1 a b */ /* m = b^-1 a b */
int mat_get_similar_matrix_d3(double m[3][3], int mat_get_similar_matrix_d3(double m[3][3],
SPGCONST double a[3][3], SPGCONST double a[3][3],
SPGCONST double b[3][3], SPGCONST double b[3][3],
const double precision) const double precision)
{ {
double c[3][3]; double c[3][3];
if (!mat_inverse_matrix_d3(c, b, precision)) { 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], void mat_get_metric(double metric[3][3],
SPGCONST double lattice[3][3]) SPGCONST double lattice[3][3])
{ {
double lattice_t[3][3]; double lattice_t[3][3];
mat_transpose_matrix_d3(lattice_t, lattice); mat_transpose_matrix_d3(lattice_t, lattice);
@ -428,7 +428,7 @@ MatINT * mat_alloc_MatINT(const int size)
MatINT *matint; MatINT *matint;
matint = NULL; matint = NULL;
if ((matint = (MatINT*) malloc(sizeof(MatINT))) == NULL) { if ((matint = (MatINT*) malloc(sizeof(MatINT))) == NULL) {
warning_print("spglib: Memory could not be allocated."); warning_print("spglib: Memory could not be allocated.");
return NULL; return NULL;
@ -437,7 +437,7 @@ MatINT * mat_alloc_MatINT(const int size)
matint->size = size; matint->size = size;
if (size > 0) { if (size > 0) {
if ((matint->mat = (int (*)[3][3]) malloc(sizeof(int[3][3]) * size)) if ((matint->mat = (int (*)[3][3]) malloc(sizeof(int[3][3]) * size))
== NULL) { == NULL) {
warning_print("spglib: Memory could not be allocated "); warning_print("spglib: Memory could not be allocated ");
warning_print("(MatINT, line %d, %s).\n", __LINE__, __FILE__); warning_print("(MatINT, line %d, %s).\n", __LINE__, __FILE__);
free(matint); free(matint);
@ -471,7 +471,7 @@ VecDBL * mat_alloc_VecDBL(const int size)
vecdbl->size = size; vecdbl->size = size;
if (size > 0) { if (size > 0) {
if ((vecdbl->vec = (double (*)[3]) malloc(sizeof(double[3]) * size)) if ((vecdbl->vec = (double (*)[3]) malloc(sizeof(double[3]) * size))
== NULL) { == NULL) {
warning_print("spglib: Memory could not be allocated "); warning_print("spglib: Memory could not be allocated ");
warning_print("(VecDBL, line %d, %s).\n", __LINE__, __FILE__); warning_print("(VecDBL, line %d, %s).\n", __LINE__, __FILE__);
free(vecdbl); 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 (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
if (mat_Dabs(mat_Nint(mat[i][j]) - mat[i][j]) > symprec) { if (mat_Dabs(mat_Nint(mat[i][j]) - mat[i][j]) > symprec) {
return 0; return 0;
} }
} }
} }

View File

@ -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); */ /* printf("%d %d %d\n", p->l, p->m, p->n); */
/* for (i = 0; i < 3; i++) { */ /* for (i = 0; i < 3; i++) { */
/* printf("%f %f %f\n", */ /* 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 #else
@ -128,7 +128,7 @@ int niggli_reduce(double *lattice_, const double eps_)
int i, j, succeeded; int i, j, succeeded;
NiggliParams *p; NiggliParams *p;
int (*steps[8])(NiggliParams *p) = {step1, step2, step3, step4, int (*steps[8])(NiggliParams *p) = {step1, step2, step3, step4,
step5, step6, step7, step8}; step5, step6, step7, step8};
p = NULL; p = NULL;
succeeded = 0; succeeded = 0;
@ -145,9 +145,9 @@ int niggli_reduce(double *lattice_, const double eps_)
for (i = 0; i < NIGGLI_MAX_NUM_LOOP; i++) { for (i = 0; i < NIGGLI_MAX_NUM_LOOP; i++) {
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
if ((*steps[j])(p)) { if ((*steps[j])(p)) {
debug_show(j + 1, p); debug_show(j + 1, p);
if (! reset(p)) {goto ret;} if (! reset(p)) {goto ret;}
if (j == 1 || j == 4 || j == 5 || j == 6 || j == 7) {break;} if (j == 1 || j == 4 || j == 5 || j == 6 || j == 7) {break;}
} }
} }
if (j == 8) { if (j == 8) {
@ -203,7 +203,7 @@ static NiggliParams * initialize(const double *lattice_, const double eps_)
p = NULL; p = NULL;
return NULL; return NULL;
} }
memcpy(p->lattice, lattice_, sizeof(double) * 9); memcpy(p->lattice, lattice_, sizeof(double) * 9);
return p; return p;
@ -225,7 +225,7 @@ static int reset(NiggliParams *p)
double *lat_tmp; double *lat_tmp;
lat_tmp = NULL; lat_tmp = NULL;
if ((lat_tmp = multiply_matrices(p->lattice, p->tmat)) == NULL) {return 0;} if ((lat_tmp = multiply_matrices(p->lattice, p->tmat)) == NULL) {return 0;}
memcpy(p->lattice, lat_tmp, sizeof(double) * 9); memcpy(p->lattice, lat_tmp, sizeof(double) * 9);
free(lat_tmp); free(lat_tmp);
@ -420,7 +420,7 @@ static double * get_transpose(const double *M)
M_T[i * 3 + j] = M[j * 3 + i]; M_T[i * 3 + j] = M[j * 3 + i];
} }
} }
return M_T; return M_T;
} }
@ -456,10 +456,10 @@ static double * multiply_matrices(const double *L, const double *R)
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
M[i * 3 + j] = 0; M[i * 3 + j] = 0;
for (k = 0; k < 3; k++) { 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; return M;
} }

View File

@ -306,7 +306,7 @@ static int rot_axes[][3] = {
{ 1, 1, 0}, { 1, 1, 0},
{ 0, 1,-1}, { 0, 1,-1},
{-1, 0, 1}, {-1, 0, 1},
{ 1,-1, 0}, { 1,-1, 0},
{ 1, 1, 1}, /* 10 */ { 1, 1, 1}, /* 10 */
{-1, 1, 1}, {-1, 1, 1},
{ 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], 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_number(SPGCONST PointSymmetry * pointsym);
static int get_pointgroup_class_table(int table[10], 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_type(SPGCONST int rot[3][3]);
static int get_rotation_axis(SPGCONST int rot[3][3]); static int get_rotation_axis(SPGCONST int rot[3][3]);
static int get_orthogonal_axis(int ortho_axes[], static int get_orthogonal_axis(int ortho_axes[],
SPGCONST int proper_rot[3][3], SPGCONST int proper_rot[3][3],
const int rot_order); const int rot_order);
static int laue2m(int axes[3], static int laue2m(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
#ifdef SPGDEBUG #ifdef SPGDEBUG
static int lauemmm(int axes[3], static int lauemmm(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
static int laue4m(int axes[3], static int laue4m(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
static int laue4mmm(int axes[3], static int laue4mmm(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
static int laue3(int axes[3], static int laue3(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
static int laue3m(int axes[3], static int laue3m(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
static int lauem3m(int axes[3], static int lauem3m(int axes[3],
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
#endif #endif
static int laue_one_axis(int axes[3], static int laue_one_axis(int axes[3],
SPGCONST PointSymmetry * pointsym, SPGCONST PointSymmetry * pointsym,
const int rot_order); const int rot_order);
static int lauennn(int axes[3], static int lauennn(int axes[3],
SPGCONST PointSymmetry * pointsym, SPGCONST PointSymmetry * pointsym,
const int rot_order); const int rot_order);
static int get_axes(int axes[3], static int get_axes(int axes[3],
const Laue laue, const Laue laue,
SPGCONST PointSymmetry * pointsym); SPGCONST PointSymmetry * pointsym);
static void get_proper_rotation(int prop_rot[3][3], 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], 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 int is_exist_axis(const int axis_vec[3], const int axis_index);
static void sort_axes(int axes[3]); static void sort_axes(int axes[3]);
/* Retrun pointgroup.number = 0 if failed */ /* Retrun pointgroup.number = 0 if failed */
Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3], Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3],
SPGCONST int rotations[][3][3], SPGCONST int rotations[][3][3],
const int num_rotations) const int num_rotations)
{ {
int i, j, pg_num; int i, j, pg_num;
int axes[3]; int axes[3];
@ -434,9 +434,9 @@ Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3],
transform_mat[i][j] = 0; transform_mat[i][j] = 0;
} }
} }
pg_num = get_pointgroup_number_by_rotations(rotations, num_rotations); pg_num = get_pointgroup_number_by_rotations(rotations, num_rotations);
if (pg_num > 0) { if (pg_num > 0) {
pointgroup = ptg_get_pointgroup(pg_num); pointgroup = ptg_get_pointgroup(pg_num);
pointsym = ptg_get_pointsymmetry(rotations, num_rotations); 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); set_transformation_matrix(transform_mat, axes);
} else { } else {
pointgroup = ptg_get_pointgroup(0); pointgroup = ptg_get_pointgroup(0);
} }
return pointgroup; return pointgroup;
} }
@ -474,7 +474,7 @@ Pointgroup ptg_get_pointgroup(const int pointgroup_number)
} }
PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3], PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3],
const int num_rotations) const int num_rotations)
{ {
int i, j; int i, j;
PointSymmetry pointsym; PointSymmetry pointsym;
@ -483,7 +483,7 @@ PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3],
for (i = 0; i < num_rotations; i++) { for (i = 0; i < num_rotations; i++) {
for (j = 0; j < pointsym.size; j++) { for (j = 0; j < pointsym.size; j++) {
if (mat_check_identity_matrix_i3(rotations[i], pointsym.rot[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]); 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], static int get_pointgroup_number_by_rotations(SPGCONST int rotations[][3][3],
const int num_rotations) const int num_rotations)
{ {
PointSymmetry pointsym; PointSymmetry pointsym;
@ -514,7 +514,7 @@ static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym)
pg_num = 0; pg_num = 0;
/* Get list of point symmetry operations */ /* Get list of point symmetry operations */
if (! get_pointgroup_class_table(table, pointsym)) { if (! get_pointgroup_class_table(table, pointsym)) {
goto end; goto end;
@ -538,7 +538,7 @@ static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym)
} }
static int get_pointgroup_class_table(int table[10], static int get_pointgroup_class_table(int table[10],
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
/* Look-up table */ /* Look-up table */
/* Operation -6 -4 -3 -2 -1 1 2 3 4 6 */ /* 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]++; table[rot_type]++;
} }
} }
return 1; return 1;
err: err:
@ -621,15 +621,15 @@ static int get_rotation_type(SPGCONST int rot[3][3])
default: default:
rot_type = -1; rot_type = -1;
break; break;
} }
} }
return rot_type; return rot_type;
} }
static int get_axes(int axes[3], static int get_axes(int axes[3],
const Laue laue, const Laue laue,
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
switch (laue) { switch (laue) {
case LAUE1: case LAUE1:
@ -675,7 +675,7 @@ static int get_axes(int axes[3],
} }
static int laue2m(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 i, num_ortho_axis, norm, min_norm, is_found, tmpval;
int prop_rot[3][3], t_mat[3][3]; int prop_rot[3][3], t_mat[3][3];
@ -697,7 +697,7 @@ static int laue2m(int axes[3],
/* The second axis */ /* The second axis */
num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 2); num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 2);
if (! num_ortho_axis) { goto err; } if (! num_ortho_axis) { goto err; }
min_norm = 8; min_norm = 8;
is_found = 0; is_found = 0;
for (i = 0; i < num_ortho_axis; i++) { for (i = 0; i < num_ortho_axis; i++) {
@ -709,7 +709,7 @@ static int laue2m(int axes[3],
} }
} }
if (! is_found) { goto err; } if (! is_found) { goto err; }
/* The third axis */ /* The third axis */
min_norm = 8; min_norm = 8;
is_found = 0; is_found = 0;
@ -738,7 +738,7 @@ static int laue2m(int axes[3],
#ifdef SPGDEBUG #ifdef SPGDEBUG
static int lauemmm(int axes[3], static int lauemmm(int axes[3],
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
int i, count, axis; int i, count, axis;
int prop_rot[3][3]; int prop_rot[3][3];
@ -756,8 +756,8 @@ static int lauemmm(int axes[3],
axis = get_rotation_axis(prop_rot); axis = get_rotation_axis(prop_rot);
if (! ((axis == axes[0]) || if (! ((axis == axes[0]) ||
(axis == axes[1]) || (axis == axes[1]) ||
(axis == axes[2]))) { (axis == axes[2]))) {
axes[count] = axis; axes[count] = axis;
count++; count++;
} }
@ -769,7 +769,7 @@ static int lauemmm(int axes[3],
} }
static int laue4m(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 i, num_ortho_axis, norm, min_norm, is_found, tmpval;
int axis_vec[3]; int axis_vec[3];
@ -790,7 +790,7 @@ static int laue4m(int axes[3],
/* The second axis */ /* The second axis */
num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 4); num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 4);
if (! num_ortho_axis) { goto err; } if (! num_ortho_axis) { goto err; }
min_norm = 8; min_norm = 8;
is_found = 0; is_found = 0;
for (i = 0; i < num_ortho_axis; i++) { for (i = 0; i < num_ortho_axis; i++) {
@ -802,7 +802,7 @@ static int laue4m(int axes[3],
} }
} }
if (! is_found) { goto err; } if (! is_found) { goto err; }
/* The third axis */ /* The third axis */
mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]); mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]);
is_found = 0; is_found = 0;
@ -829,7 +829,7 @@ static int laue4m(int axes[3],
} }
static int laue4mmm(int axes[3], static int laue4mmm(int axes[3],
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
int i, is_found, tmpval, axis; int i, is_found, tmpval, axis;
int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3]; 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], static int laue3(int axes[3],
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
int i, num_ortho_axis, norm, min_norm, is_found, tmpval; int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
int prop_rot[3][3], t_mat[3][3]; int prop_rot[3][3], t_mat[3][3];
@ -924,7 +924,7 @@ static int laue3(int axes[3],
} }
} }
if (! is_found) { goto err; } if (! is_found) { goto err; }
/* The third axis */ /* The third axis */
mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]); mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]);
is_found = 0; is_found = 0;
@ -955,7 +955,7 @@ static int laue3(int axes[3],
} }
static int laue3m(int axes[3], static int laue3m(int axes[3],
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
int i, is_found, tmpval, axis; int i, is_found, tmpval, axis;
int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3]; 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], static int lauem3m(int axes[3],
SPGCONST PointSymmetry * pointsym) SPGCONST PointSymmetry * pointsym)
{ {
int i, count, axis; int i, count, axis;
int prop_rot[3][3]; int prop_rot[3][3];
@ -1040,8 +1040,8 @@ static int lauem3m(int axes[3],
axis = get_rotation_axis(prop_rot); axis = get_rotation_axis(prop_rot);
if (! ((axis == axes[0]) || if (! ((axis == axes[0]) ||
(axis == axes[1]) || (axis == axes[1]) ||
(axis == axes[2]))) { (axis == axes[2]))) {
axes[count] = axis; axes[count] = axis;
count++; count++;
} }
@ -1054,8 +1054,8 @@ static int lauem3m(int axes[3],
#endif #endif
static int laue_one_axis(int axes[3], static int laue_one_axis(int axes[3],
SPGCONST PointSymmetry * pointsym, SPGCONST PointSymmetry * pointsym,
const int rot_order) const int rot_order)
{ {
int i, j, num_ortho_axis, det, is_found, tmpval; int i, j, num_ortho_axis, det, is_found, tmpval;
int axis_vec[3], tmp_axes[3]; 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]; int ortho_axes[NUM_ROT_AXES];
debug_print("laue_one_axis with rot_order %d\n", rot_order); debug_print("laue_one_axis with rot_order %d\n", rot_order);
for (i = 0; i < pointsym->size; i++) { for (i = 0; i < pointsym->size; i++) {
get_proper_rotation(prop_rot, pointsym->rot[i]); get_proper_rotation(prop_rot, pointsym->rot[i]);
/* Search foud-fold rotation */ /* Search foud-fold rotation */
if (rot_order == 4) { if (rot_order == 4) {
if (mat_get_trace_i3(prop_rot) == 1) { if (mat_get_trace_i3(prop_rot) == 1) {
/* The first axis */ /* The first axis */
axes[2] = get_rotation_axis(prop_rot); axes[2] = get_rotation_axis(prop_rot);
break; break;
} }
} }
/* Search three-fold rotation */ /* Search three-fold rotation */
if (rot_order == 3) { if (rot_order == 3) {
if (mat_get_trace_i3(prop_rot) == 0) { if (mat_get_trace_i3(prop_rot) == 0) {
/* The first axis */ /* The first axis */
axes[2] = get_rotation_axis(prop_rot); axes[2] = get_rotation_axis(prop_rot);
break; break;
} }
} }
} }
@ -1096,22 +1096,22 @@ static int laue_one_axis(int axes[3],
is_found = 0; is_found = 0;
tmp_axes[0] = ortho_axes[i]; tmp_axes[0] = ortho_axes[i];
mat_multiply_matrix_vector_i3(axis_vec, mat_multiply_matrix_vector_i3(axis_vec,
prop_rot, prop_rot,
rot_axes[tmp_axes[0]]); rot_axes[tmp_axes[0]]);
for (j = 0; j < num_ortho_axis; j++) { for (j = 0; j < num_ortho_axis; j++) {
is_found = is_exist_axis(axis_vec, ortho_axes[j]); is_found = is_exist_axis(axis_vec, ortho_axes[j]);
if (is_found == 1) { if (is_found == 1) {
tmp_axes[1] = ortho_axes[j]; tmp_axes[1] = ortho_axes[j];
break; break;
} }
if (is_found == -1) { if (is_found == -1) {
tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES; tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES;
break; break;
} }
} }
if (!is_found) { continue; } if (!is_found) { continue; }
set_transformation_matrix(t_mat, tmp_axes); set_transformation_matrix(t_mat, tmp_axes);
det = abs(mat_get_determinant_i3(t_mat)); det = abs(mat_get_determinant_i3(t_mat));
if (det < 4) { /* to avoid F-center choice det=4 */ 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], static int lauennn(int axes[3],
SPGCONST PointSymmetry * pointsym, SPGCONST PointSymmetry * pointsym,
const int rot_order) const int rot_order)
{ {
int i, count, axis; int i, count, axis;
int prop_rot[3][3]; int prop_rot[3][3];
@ -1159,13 +1159,13 @@ static int lauennn(int axes[3],
/* Search two- or four-fold rotation */ /* Search two- or four-fold rotation */
if ((mat_get_trace_i3(prop_rot) == -1 && rot_order == 2) || 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); axis = get_rotation_axis(prop_rot);
if (! ((axis == axes[0]) || if (! ((axis == axes[0]) ||
(axis == axes[1]) || (axis == axes[1]) ||
(axis == axes[2]))) { (axis == axes[2]))) {
axes[count] = axis; axes[count] = axis;
count++; count++;
} }
} }
} }
@ -1189,26 +1189,26 @@ static int get_rotation_axis(SPGCONST int proper_rot[3][3])
for (i = 0; i < NUM_ROT_AXES; i++) { for (i = 0; i < NUM_ROT_AXES; i++) {
mat_multiply_matrix_vector_i3(vec, proper_rot, rot_axes[i]); mat_multiply_matrix_vector_i3(vec, proper_rot, rot_axes[i]);
if (vec[0] == rot_axes[i][0] && if (vec[0] == rot_axes[i][0] &&
vec[1] == rot_axes[i][1] && vec[1] == rot_axes[i][1] &&
vec[2] == rot_axes[i][2]) { vec[2] == rot_axes[i][2]) {
axis = i; axis = i;
break; break;
} }
} }
end: end:
#ifdef SPGDEBUG #ifdef SPGDEBUG
if (axis == -1) { if (axis == -1) {
printf("rotation axis cound not found.\n"); printf("rotation axis cound not found.\n");
} }
#endif #endif
return axis; return axis;
} }
static int get_orthogonal_axis(int ortho_axes[], static int get_orthogonal_axis(int ortho_axes[],
SPGCONST int proper_rot[3][3], SPGCONST int proper_rot[3][3],
const int rot_order) const int rot_order)
{ {
int i, num_ortho_axis; int i, num_ortho_axis;
int vec[3]; int vec[3];
@ -1222,12 +1222,12 @@ static int get_orthogonal_axis(int ortho_axes[],
mat_multiply_matrix_i3(rot, proper_rot, rot); mat_multiply_matrix_i3(rot, proper_rot, rot);
mat_add_matrix_i3(sum_rot, rot, sum_rot); mat_add_matrix_i3(sum_rot, rot, sum_rot);
} }
for (i = 0; i < NUM_ROT_AXES; i++) { for (i = 0; i < NUM_ROT_AXES; i++) {
mat_multiply_matrix_vector_i3(vec, sum_rot, rot_axes[i]); mat_multiply_matrix_vector_i3(vec, sum_rot, rot_axes[i]);
if (vec[0] == 0 && if (vec[0] == 0 &&
vec[1] == 0 && vec[1] == 0 &&
vec[2] == 0) { vec[2] == 0) {
ortho_axes[num_ortho_axis] = i; ortho_axes[num_ortho_axis] = i;
num_ortho_axis++; 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], 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) { if (mat_get_determinant_i3(rot) == -1) {
mat_multiply_matrix_i3(prop_rot, inversion, rot); 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], static void set_transformation_matrix(int tmat[3][3],
const int axes[3]) const int axes[3])
{ {
int i, j, s[3]; int i, j, s[3];
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (axes[i] < NUM_ROT_AXES) { if (axes[i] < NUM_ROT_AXES) {
s[i] = 1; s[i] = 1;
@ -1306,4 +1306,3 @@ static void sort_axes(int axes[3])
axes[2] = axis; axes[2] = axis;
} }
} }

View File

@ -46,8 +46,8 @@
#define NUM_ATTEMPT 20 #define NUM_ATTEMPT 20
static Primitive * get_primitive(const Cell * cell, static Primitive * get_primitive(const Cell * cell,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
static Cell * get_cell_with_smallest_lattice(const Cell * cell, static Cell * get_cell_with_smallest_lattice(const Cell * cell,
const double symprec); const double symprec);
static Cell * get_primitive_cell(int * mapping_table, static Cell * get_primitive_cell(int * mapping_table,
@ -128,14 +128,14 @@ void prm_free_primitive(Primitive * primitive)
/* Return NULL if failed */ /* Return NULL if failed */
Primitive * prm_get_primitive(const Cell * cell, Primitive * prm_get_primitive(const Cell * cell,
const double symprec, const double symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
return get_primitive(cell, symprec, angle_tolerance); return get_primitive(cell, symprec, angle_tolerance);
} }
Symmetry * prm_get_primitive_symmetry(const Symmetry *symmetry, Symmetry * prm_get_primitive_symmetry(const Symmetry *symmetry,
const double symprec) const double symprec)
{ {
int i, primsym_size; int i, primsym_size;
VecDBL *pure_trans; VecDBL *pure_trans;
@ -202,8 +202,8 @@ Symmetry * prm_get_primitive_symmetry(const Symmetry *symmetry,
/* Return NULL if failed */ /* Return NULL if failed */
static Primitive * get_primitive(const Cell * cell, static Primitive * get_primitive(const Cell * cell,
const double symprec, const double symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
int i, attempt; int i, attempt;
double tolerance; double tolerance;
@ -222,32 +222,29 @@ static Primitive * get_primitive(const Cell * cell,
tolerance = symprec; tolerance = symprec;
for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) {
debug_print("get_primitive (attempt = %d):\n", attempt); debug_print("get_primitive (attempt = %d):\n", attempt);
if ((pure_trans = sym_get_pure_translation(cell, tolerance)) == NULL) { 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) {
if (pure_trans->size == 1) { for (i = 0; i < cell->size; i++) {
if ((primitive->cell = get_cell_with_smallest_lattice(cell, tolerance)) primitive->mapping_table[i] = i;
!= NULL) { }
for (i = 0; i < cell->size; i++) { goto found;
primitive->mapping_table[i] = i; }
} 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); mat_free_VecDBL(pure_trans);
pure_trans = NULL; pure_trans = NULL;
cont:
tolerance *= REDUCE_RATE; tolerance *= REDUCE_RATE;
warning_print("spglib: Reduce tolerance to %f ", tolerance); warning_print("spglib: Reduce tolerance to %f ", tolerance);
warning_print("(line %d, %s).\n", __LINE__, __FILE__); warning_print("(line %d, %s).\n", __LINE__, __FILE__);
@ -325,7 +322,7 @@ static Cell * get_primitive_cell(int * mapping_table,
cell, cell,
pure_trans, pure_trans,
symprec, symprec,
angle_tolerance); angle_tolerance);
if (! multi) { if (! multi) {
goto not_found; 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, pure_trans_reduced = sym_reduce_pure_translation(cell,
tmp_vec, tmp_vec,
tolerance, tolerance,
angle_tolerance); angle_tolerance);
mat_free_VecDBL(tmp_vec); mat_free_VecDBL(tmp_vec);
tmp_vec = NULL; tmp_vec = NULL;
@ -556,8 +553,8 @@ static VecDBL * collect_pure_translations(const Symmetry *symmetry)
VecDBL *pure_trans; VecDBL *pure_trans;
VecDBL *ret_pure_trans; VecDBL *ret_pure_trans;
static int identity[3][3] = {{ 1, 0, 0 }, static int identity[3][3] = {{ 1, 0, 0 },
{ 0, 1, 0 }, { 0, 1, 0 },
{ 0, 0, 1 }}; { 0, 0, 1 }};
num_pure_trans = 0; num_pure_trans = 0;
pure_trans = NULL; pure_trans = NULL;
ret_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++) { for (i = 0; i < num_pure_trans; i++) {
mat_copy_vector_d3(ret_pure_trans->vec[i], pure_trans->vec[i]); mat_copy_vector_d3(ret_pure_trans->vec[i], pure_trans->vec[i]);
} }
mat_free_VecDBL(pure_trans); mat_free_VecDBL(pure_trans);
pure_trans = NULL; 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 (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
if (i == j) { if (i == j) {
cell->lattice[i][j] = 1; cell->lattice[i][j] = 1;
} else { } else {
cell->lattice[i][j] = 0; cell->lattice[i][j] = 0;
} }
} }
} }

View File

@ -47,11 +47,9 @@
#include "debug.h" #include "debug.h"
#define REDUCE_RATE 0.95
static Cell * get_Wyckoff_positions(int * wyckoffs, static Cell * get_Wyckoff_positions(int * wyckoffs,
int * equiv_atoms, int * equiv_atoms,
int * mapping_to_primitive, int * std_mapping_to_primitive,
const Cell * primitive, const Cell * primitive,
const Cell * cell, const Cell * cell,
SPGCONST Spacegroup * spacegroup, SPGCONST Spacegroup * spacegroup,
@ -61,17 +59,17 @@ static Cell * get_Wyckoff_positions(int * wyckoffs,
static Cell * static Cell *
get_bravais_exact_positions_and_lattice(int * wyckoffs, get_bravais_exact_positions_and_lattice(int * wyckoffs,
int * equiv_atoms, int * equiv_atoms,
int * mapping_to_primitive, int * std_mapping_to_primitive,
SPGCONST Spacegroup * spacegroup, SPGCONST Spacegroup * spacegroup,
const Cell * primitive, const Cell * primitive,
const double symprec); const double symprec);
static Cell * expand_positions(int * wyckoffs, static Cell * expand_positions_in_bravais(int * wyckoffs,
int * equiv_atoms, int * equiv_atoms,
int * mapping_to_primitive, int * std_mapping_to_primitive,
const Cell * conv_prim, const Cell * conv_prim,
const Symmetry * conv_sym, const Symmetry * conv_sym,
const int * wyckoffs_prim, const int * wyckoffs_prim,
const int * equiv_atoms_prim); const int * equiv_atoms_prim);
static Cell * get_conventional_primitive(SPGCONST Spacegroup * spacegroup, static Cell * get_conventional_primitive(SPGCONST Spacegroup * spacegroup,
const Cell * primitive); const Cell * primitive);
static int get_number_of_pure_translation(const Symmetry * conv_sym); static int get_number_of_pure_translation(const Symmetry * conv_sym);
@ -149,51 +147,135 @@ static SPGCONST int identity[3][3] = {
{ 0, 0, 1}, { 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 */ /* Return NULL if failed */
Symmetry * static Cell * get_Wyckoff_positions(int * wyckoffs,
ref_get_refined_symmetry_operations(const Cell * cell, int * equiv_atoms,
int * std_mapping_to_primitive,
const Cell * primitive, const Cell * primitive,
const Cell * cell,
SPGCONST Spacegroup * spacegroup, SPGCONST Spacegroup * spacegroup,
const Symmetry * symmetry,
const int * mapping_table,
const double symprec) 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; Cell *bravais;
int i, num_prim_sym; int i, num_prim_sym;
@ -223,7 +305,7 @@ Cell * get_Wyckoff_positions(int * wyckoffs,
if ((bravais = get_bravais_exact_positions_and_lattice if ((bravais = get_bravais_exact_positions_and_lattice
(wyckoffs_bravais, (wyckoffs_bravais,
equiv_atoms_bravais, equiv_atoms_bravais,
mapping_to_primitive, std_mapping_to_primitive,
spacegroup, spacegroup,
primitive, primitive,
symprec)) == NULL) { symprec)) == NULL) {
@ -277,7 +359,7 @@ Cell * get_Wyckoff_positions(int * wyckoffs,
static Cell * static Cell *
get_bravais_exact_positions_and_lattice(int * wyckoffs, get_bravais_exact_positions_and_lattice(int * wyckoffs,
int * equiv_atoms, int * equiv_atoms,
int * mapping_to_primitive, int * std_mapping_to_primitive,
SPGCONST Spacegroup *spacegroup, SPGCONST Spacegroup *spacegroup,
const Cell * primitive, const Cell * primitive,
const double symprec) const double symprec)
@ -303,7 +385,8 @@ get_bravais_exact_positions_and_lattice(int * wyckoffs,
return NULL; 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 "); warning_print("spglib: Memory could not be allocated ");
free(wyckoffs_prim); free(wyckoffs_prim);
wyckoffs_prim = NULL; 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]); mat_copy_vector_d3(conv_prim->position[i], exact_positions->vec[i]);
} }
bravais = expand_positions(wyckoffs, bravais = expand_positions_in_bravais(wyckoffs,
equiv_atoms, equiv_atoms,
mapping_to_primitive, std_mapping_to_primitive,
conv_prim, conv_prim,
conv_sym, conv_sym,
wyckoffs_prim, wyckoffs_prim,
equiv_atoms_prim); equiv_atoms_prim);
mat_free_VecDBL(exact_positions); mat_free_VecDBL(exact_positions);
exact_positions = NULL; exact_positions = NULL;
@ -374,13 +457,13 @@ get_bravais_exact_positions_and_lattice(int * wyckoffs,
} }
/* Return NULL if failed */ /* Return NULL if failed */
static Cell * expand_positions(int * wyckoffs, static Cell * expand_positions_in_bravais(int * wyckoffs,
int * equiv_atoms, int * equiv_atoms,
int * mapping_to_primitive, int * std_mapping_to_primitive,
const Cell * conv_prim, const Cell * conv_prim,
const Symmetry * conv_sym, const Symmetry * conv_sym,
const int * wyckoffs_prim, const int * wyckoffs_prim,
const int * equiv_atoms_prim) const int * equiv_atoms_prim)
{ {
int i, j, k, num_pure_trans; int i, j, k, num_pure_trans;
int num_atom; int num_atom;
@ -400,8 +483,7 @@ static Cell * expand_positions(int * wyckoffs,
if (mat_check_identity_matrix_i3(identity, conv_sym->rot[i])) { if (mat_check_identity_matrix_i3(identity, conv_sym->rot[i])) {
for (j = 0; j < conv_prim->size; j++) { for (j = 0; j < conv_prim->size; j++) {
bravais->types[num_atom] = conv_prim->types[j]; bravais->types[num_atom] = conv_prim->types[j];
mat_copy_vector_d3(bravais->position[num_atom], mat_copy_vector_d3(bravais->position[num_atom], conv_prim->position[j]);
conv_prim->position[j]);
for (k = 0; k < 3; k++) { for (k = 0; k < 3; k++) {
bravais->position[num_atom][k] += conv_sym->trans[i][k]; bravais->position[num_atom][k] += conv_sym->trans[i][k];
bravais->position[num_atom][k] = bravais->position[num_atom][k] =
@ -409,7 +491,7 @@ static Cell * expand_positions(int * wyckoffs,
} }
wyckoffs[num_atom] = wyckoffs_prim[j]; wyckoffs[num_atom] = wyckoffs_prim[j];
equiv_atoms[num_atom] = equiv_atoms_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++; num_atom++;
} }
} }

View File

@ -1142,8 +1142,8 @@ static const int num_sitesym[] =
int ssmdb_get_coordinate(int rot[3][3], int ssmdb_get_coordinate(int rot[3][3],
double trans[3], double trans[3],
const int index) const int index)
{ {
int i, rot_enc, trans_enc; int i, rot_enc, trans_enc;
int rows[3], trans_int[3]; 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 */ /* Orbits are compressed using ternary numerical system for */
/* rotation and base-24 system for translation. Elements of the first coloum */ /* 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 */ /* 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} */ /* {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 */ /* divided by 24. Therefore 45^3 * 24^3 = 1259712000 different values can */
/* enough map Wyckoff positions. */ /* enough map Wyckoff positions. */

View File

@ -227,11 +227,6 @@ static double F_mat[3][3] = {{ 0, 1./2, 1./2 },
{ 1./2, 0, 1./2 }, { 1./2, 0, 1./2 },
{ 1./2, 1./2, 0 }}; { 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, static Spacegroup search_spacegroup_with_symmetry(const Cell * primitive,
const int candidates[], const int candidates[],
const int num_candidates, const int num_candidates,
@ -298,78 +293,57 @@ static Centering get_centering(double correction_mat[3][3],
const Laue laue); const Laue laue);
static Centering get_base_center(SPGCONST int transform_mat[3][3]); static Centering get_base_center(SPGCONST int transform_mat[3][3]);
static int get_centering_shifts(double shift[3][3], static int get_centering_shifts(double shift[3][3],
const Centering centering); const Centering centering);
/* NULL is returned if failed */ /* Return spacegroup.number = 0 if failed */
Primitive * spa_get_spacegroup(Spacegroup * spacegroup, Spacegroup spa_search_spacegroup(const Cell * primitive,
const Cell * cell, const int hall_number,
const int hall_number, const double symprec,
const double symprec, const double angle_tolerance)
const double angle_tolerance)
{ {
int attempt; Spacegroup spacegroup;
Symmetry *symmetry;
int candidate[1]; 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) { if ((symmetry = sym_get_operation(primitive, symprec, angle_tolerance)) ==
return NULL; NULL) {
goto ret;
} }
if (hall_number > 0) { if (hall_number > 0) {
candidate[0] = hall_number; candidate[0] = hall_number;
} }
tolerance = symprec; if (hall_number) {
spacegroup = search_spacegroup_with_symmetry(primitive,
for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { candidate,
if ((primitive = prm_get_primitive(cell, tolerance, angle_tolerance)) == 1,
NULL) { symmetry,
goto cont; symprec,
} angle_tolerance);
} else {
if (hall_number) { spacegroup = search_spacegroup_with_symmetry(primitive,
*spacegroup = search_spacegroup(primitive->cell, spacegroup_to_hall_number,
candidate, 230,
1, symmetry,
primitive->tolerance, symprec,
primitive->angle_tolerance); 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 (primitive == NULL) { sym_free_symmetry(symmetry);
warning_print("spglib: Space group could not be found "); symmetry = NULL;
warning_print("(line %d, %s).\n", __LINE__, __FILE__);
}
return primitive; ret:
return spacegroup;
} }
Spacegroup spa_search_spacegroup_with_symmetry(const Symmetry *symmetry, Spacegroup spa_search_spacegroup_with_symmetry(const Symmetry *symmetry,
const double symprec) const double symprec)
{ {
@ -445,8 +419,8 @@ Cell * spa_transform_to_primitive(int * mapping_table,
/* Return NULL if failed */ /* Return NULL if failed */
Cell * spa_transform_from_primitive(const Cell * primitive, Cell * spa_transform_from_primitive(const Cell * primitive,
const Centering centering, const Centering centering,
const double symprec) const double symprec)
{ {
int multi, i, j, k, num_atom; int multi, i, j, k, num_atom;
int *mapping_table; int *mapping_table;
@ -503,8 +477,8 @@ Cell * spa_transform_from_primitive(const Cell * primitive,
num_atom = 0; num_atom = 0;
for (i = 0; i < primitive->size; i++) { for (i = 0; i < primitive->size; i++) {
mat_multiply_matrix_vector_d3(std_cell->position[num_atom], mat_multiply_matrix_vector_d3(std_cell->position[num_atom],
tmat, tmat,
primitive->position[i]); primitive->position[i]);
std_cell->types[num_atom] = primitive->types[i]; std_cell->types[num_atom] = primitive->types[i];
num_atom++; num_atom++;
} }
@ -512,9 +486,9 @@ Cell * spa_transform_from_primitive(const Cell * primitive,
for (i = 0; i < multi - 1; i++) { for (i = 0; i < multi - 1; i++) {
for (j = 0; j < primitive->size; j++) { for (j = 0; j < primitive->size; j++) {
mat_copy_vector_d3(std_cell->position[num_atom], mat_copy_vector_d3(std_cell->position[num_atom],
std_cell->position[j]); std_cell->position[j]);
for (k = 0; k < 3; k++) { 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]; std_cell->types[num_atom] = std_cell->types[j];
num_atom++; num_atom++;
@ -522,9 +496,9 @@ Cell * spa_transform_from_primitive(const Cell * primitive,
} }
trimmed_cell = cel_trim_cell(mapping_table, trimmed_cell = cel_trim_cell(mapping_table,
std_cell->lattice, std_cell->lattice,
std_cell, std_cell,
symprec); symprec);
cel_free_cell(std_cell); cel_free_cell(std_cell);
std_cell = NULL; std_cell = NULL;
free(mapping_table); free(mapping_table);
@ -534,39 +508,6 @@ Cell * spa_transform_from_primitive(const Cell * primitive,
return trimmed_cell; 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 */ /* Return spacegroup.number = 0 if failed */
static Spacegroup search_spacegroup_with_symmetry(const Cell * primitive, static Spacegroup search_spacegroup_with_symmetry(const Cell * primitive,
const int candidates[], 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], static int get_centering_shifts(double shift[3][3],
const Centering centering) const Centering centering)
{ {
int i, j, multi; int i, j, multi;
@ -1443,7 +1384,7 @@ static int get_centering_shifts(double shift[3][3],
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
shift[i][j] = 0; shift[i][j] = 0;
} }
} }
if (centering != PRIMITIVE) { if (centering != PRIMITIVE) {
if (centering != FACE && centering != R_CENTER) { if (centering != FACE && centering != R_CENTER) {

View File

@ -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 */ {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 */ 0 , /* dummy */
16484 , /* 1 ( 1) [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] */ 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] */ 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. */ /* Return spgtype.number = 0 if hall_number is out of range. */
SpacegroupType spgdb_get_spacegroup_type(const int hall_number) SpacegroupType spgdb_get_spacegroup_type(const int hall_number)
{ {
int position; int position;
SpacegroupType spgtype; SpacegroupType spgtype;
spgtype.number = 0; spgtype.number = 0;
if (0 < hall_number && hall_number < 531) { if (0 < hall_number && hall_number < 531) {
spgtype = spacegroup_types[hall_number]; spgtype = spacegroup_types[hall_number];
} else { } else {
@ -8588,7 +8588,7 @@ SpacegroupType spgdb_get_spacegroup_type(const int hall_number)
remove_space(spgtype.international_full, 20); remove_space(spgtype.international_full, 20);
remove_space(spgtype.international_short, 11); remove_space(spgtype.international_short, 11);
remove_space(spgtype.choice, 6); remove_space(spgtype.choice, 6);
return spgtype; return spgtype;
} }

View File

@ -39,6 +39,7 @@
#include "cell.h" #include "cell.h"
#include "debug.h" #include "debug.h"
#include "delaunay.h" #include "delaunay.h"
#include "determination.h"
#include "kgrid.h" #include "kgrid.h"
#include "kpoint.h" #include "kpoint.h"
#include "mathfunc.h" #include "mathfunc.h"
@ -53,9 +54,6 @@
#include "symmetry.h" #include "symmetry.h"
#include "version.h" #include "version.h"
#define REDUCE_RATE 0.9
#define NUM_ATTEMPT 10
/*-------*/ /*-------*/
/* error */ /* error */
/*-------*/ /*-------*/
@ -94,7 +92,7 @@ static int set_dataset(SpglibDataset * dataset,
const Cell * cell, const Cell * cell,
const Primitive * primitive, const Primitive * primitive,
SPGCONST Spacegroup * spacegroup, SPGCONST Spacegroup * spacegroup,
const double tolerance); ExactStructure *exstr);
static int get_symmetry_from_dataset(int rotation[][3][3], static int get_symmetry_from_dataset(int rotation[][3][3],
double translation[][3], double translation[][3],
const int max_size, const int max_size,
@ -114,13 +112,13 @@ static int get_symmetry_with_collinear_spin(int rotation[][3][3],
const double spins[], const double spins[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
static int get_multiplicity(SPGCONST double lattice[3][3], static int get_multiplicity(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
static int standardize_primitive(double lattice[3][3], static int standardize_primitive(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
@ -153,7 +151,7 @@ static int get_international(char symbol[11],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
static int get_schoenflies(char symbol[7], static int get_schoenflies(char symbol[7],
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
@ -252,7 +250,7 @@ SpglibDataset * spg_get_dataset(SPGCONST double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
-1.0); -1.0);
} }
/* Return NULL if failed */ /* Return NULL if failed */
@ -269,7 +267,7 @@ SpglibDataset * spgat_get_dataset(SPGCONST double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
/* Return NULL if failed */ /* Return NULL if failed */
@ -286,7 +284,7 @@ SpglibDataset * spg_get_dataset_with_hall_number(SPGCONST double lattice[3][3],
num_atom, num_atom,
hall_number, hall_number,
symprec, symprec,
-1.0); -1.0);
} }
/* Return NULL if failed */ /* Return NULL if failed */
@ -305,7 +303,7 @@ spgat_get_dataset_with_hall_number(SPGCONST double lattice[3][3],
num_atom, num_atom,
hall_number, hall_number,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
void spg_free_dataset(SpglibDataset *dataset) void spg_free_dataset(SpglibDataset *dataset)
@ -365,7 +363,7 @@ int spg_get_symmetry(int rotation[][3][3],
types, types,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -387,7 +385,7 @@ int spgat_get_symmetry(int rotation[][3][3],
types, types,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -412,7 +410,7 @@ int spg_get_symmetry_with_collinear_spin(int rotation[][3][3],
spins, spins,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -438,7 +436,7 @@ int spgat_get_symmetry_with_collinear_spin(int rotation[][3][3],
spins, spins,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
int spg_get_hall_number_from_symmetry(SPGCONST int rotation[][3][3], 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, types,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -500,7 +498,7 @@ int spgat_get_multiplicity(SPGCONST double lattice[3][3],
types, types,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -517,7 +515,7 @@ int spg_get_international(char symbol[11],
types, types,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -535,7 +533,7 @@ int spgat_get_international(char symbol[11],
types, types,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -552,7 +550,7 @@ int spg_get_schoenflies(char symbol[7],
types, types,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -570,7 +568,7 @@ int spgat_get_schoenflies(char symbol[7],
types, types,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -709,14 +707,14 @@ int spgat_standardize_cell(double lattice[3][3],
0, 0,
1, 1,
symprec, symprec,
angle_tolerance); angle_tolerance);
} else { } else {
return standardize_primitive(lattice, return standardize_primitive(lattice,
position, position,
types, types,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
} else { } else {
if (no_idealize) { if (no_idealize) {
@ -727,7 +725,7 @@ int spgat_standardize_cell(double lattice[3][3],
0, 0,
0, 0,
symprec, symprec,
angle_tolerance); angle_tolerance);
} else { } else {
return standardize_cell(lattice, return standardize_cell(lattice,
position, position,
@ -735,7 +733,7 @@ int spgat_standardize_cell(double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
} }
} }
@ -752,7 +750,7 @@ int spg_find_primitive(double lattice[3][3],
types, types,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -768,7 +766,7 @@ int spgat_find_primitive(double lattice[3][3],
types, types,
num_atom, num_atom,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -784,7 +782,7 @@ int spg_refine_cell(double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
-1.0); -1.0);
} }
/* Return 0 if failed */ /* Return 0 if failed */
@ -801,7 +799,7 @@ int spgat_refine_cell(double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance); angle_tolerance);
} }
int spg_delaunay_reduce(double lattice[3][3], const double symprec) 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, types,
num_atom, num_atom,
symprec, symprec,
-1.0); -1.0);
} }
int spg_get_stabilized_reciprocal_mesh(int grid_address[][3], 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 symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
int attempt;
double tolerance;
Spacegroup spacegroup;
SpglibDataset *dataset; SpglibDataset *dataset;
Cell *cell; Cell *cell;
Primitive *primitive; DataContainer *container;
spacegroup.number = 0;
dataset = NULL; dataset = NULL;
cell = NULL; cell = NULL;
primitive = NULL; container = NULL;
if ((dataset = init_dataset()) == NULL) { if ((dataset = init_dataset()) == NULL) {
goto not_found; goto not_found;
@ -1047,35 +1041,18 @@ static SpglibDataset * get_dataset(SPGCONST double lattice[3][3],
goto atoms_too_close; goto atoms_too_close;
} }
tolerance = symprec; if ((container = det_determine_all(cell,
for (attempt = 0; attempt < NUM_ATTEMPT; attempt++) { hall_number,
if ((primitive = spa_get_spacegroup(&spacegroup, symprec,
cell, angle_tolerance))
hall_number, != NULL) {
tolerance, if (set_dataset(dataset,
angle_tolerance)) cell,
== NULL) { container->primitive,
cel_free_cell(cell); container->spacegroup,
cell = NULL; container->exact_structure)) {
free(dataset); goto found;
dataset = NULL;
goto not_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); cel_free_cell(cell);
@ -1092,8 +1069,7 @@ static SpglibDataset * get_dataset(SPGCONST double lattice[3][3],
return NULL; return NULL;
found: found:
prm_free_primitive(primitive); det_free_container(container);
primitive = NULL;
cel_free_cell(cell); cel_free_cell(cell);
cell = NULL; cell = NULL;
@ -1142,19 +1118,12 @@ static int set_dataset(SpglibDataset * dataset,
const Cell * cell, const Cell * cell,
const Primitive * primitive, const Primitive * primitive,
SPGCONST Spacegroup * spacegroup, SPGCONST Spacegroup * spacegroup,
const double tolerance) ExactStructure *exstr)
{ {
int i; int i;
int *std_mapping_to_primitive;
double inv_lat[3][3]; double inv_lat[3][3];
Cell *bravais;
Symmetry *symmetry;
Pointgroup pointgroup; Pointgroup pointgroup;
std_mapping_to_primitive = NULL;
bravais = NULL;
symmetry = NULL;
/* Spacegroup type, transformation matrix, origin shift */ /* Spacegroup type, transformation matrix, origin shift */
dataset->n_atoms = cell->size; dataset->n_atoms = cell->size;
dataset->spacegroup_number = spacegroup->number; dataset->spacegroup_number = spacegroup->number;
@ -1164,19 +1133,10 @@ static int set_dataset(SpglibDataset * dataset,
strcpy(dataset->choice, spacegroup->choice); strcpy(dataset->choice, spacegroup->choice);
mat_inverse_matrix_d3(inv_lat, spacegroup->bravais_lattice, 0); mat_inverse_matrix_d3(inv_lat, spacegroup->bravais_lattice, 0);
mat_multiply_matrix_d3(dataset->transformation_matrix, mat_multiply_matrix_d3(dataset->transformation_matrix,
inv_lat, inv_lat, cell->lattice);
cell->lattice);
mat_copy_vector_d3(dataset->origin_shift, spacegroup->origin_shift); mat_copy_vector_d3(dataset->origin_shift, spacegroup->origin_shift);
/* Symmetry operations */ dataset->n_operations = exstr->symmetry->size;
if ((symmetry = ref_get_refined_symmetry_operations(cell,
primitive->cell,
spacegroup,
tolerance)) == NULL) {
return 0;
}
dataset->n_operations = symmetry->size;
if ((dataset->rotations = if ((dataset->rotations =
(int (*)[3][3]) malloc(sizeof(int[3][3]) * dataset->n_operations)) (int (*)[3][3]) malloc(sizeof(int[3][3]) * dataset->n_operations))
@ -1192,9 +1152,9 @@ static int set_dataset(SpglibDataset * dataset,
goto err; goto err;
} }
for (i = 0; i < symmetry->size; i++) { for (i = 0; i < exstr->symmetry->size; i++) {
mat_copy_matrix_i3(dataset->rotations[i], symmetry->rot[i]); mat_copy_matrix_i3(dataset->rotations[i], exstr->symmetry->rot[i]);
mat_copy_vector_d3(dataset->translations[i], symmetry->trans[i]); mat_copy_vector_d3(dataset->translations[i], exstr->symmetry->trans[i]);
} }
/* Wyckoff positions */ /* Wyckoff positions */
@ -1210,65 +1170,36 @@ static int set_dataset(SpglibDataset * dataset,
goto err; 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 = if ((dataset->mapping_to_primitive =
(int*) malloc(sizeof(int) * dataset->n_atoms)) == NULL) { (int*) malloc(sizeof(int) * dataset->n_atoms)) == NULL) {
warning_print("spglib: Memory could not be allocated."); warning_print("spglib: Memory could not be allocated.");
goto err; 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("Refined cell after ref_get_Wyckoff_positions\n");
debug_print(" (line %d, %s).\n", __LINE__, __FILE__); debug_print(" (line %d, %s).\n", __LINE__, __FILE__);
debug_print_matrix_d3(bravais->lattice); debug_print_matrix_d3(exstr->bravais->lattice);
#ifdef SPGDEBUG #ifdef SPGDEBUG
for (i = 0; i < bravais->size; i++) { for (i = 0; i < bravais->size; i++) {
printf("%d: %f %f %f\n", printf("%d: %f %f %f\n",
bravais->types[i], exstr->bravais->types[i],
bravais->position[i][0], exstr->bravais->position[i][0],
bravais->position[i][1], exstr->bravais->position[i][1],
bravais->position[i][2]); exstr->bravais->position[i][2]);
} }
#endif #endif
for (i = 0; i < dataset->n_atoms; i++) { for (i = 0; i < dataset->n_atoms; i++) {
dataset->mapping_to_primitive[i] = primitive->mapping_table[i]; dataset->mapping_to_primitive[i] = primitive->mapping_table[i];
} }
dataset->n_std_atoms = bravais->size; dataset->n_std_atoms = exstr->bravais->size;
mat_copy_matrix_d3(dataset->std_lattice, bravais->lattice); mat_copy_matrix_d3(dataset->std_lattice, exstr->bravais->lattice);
if ((dataset->std_positions = if ((dataset->std_positions =
(double (*)[3]) malloc(sizeof(double[3]) * dataset->n_std_atoms)) (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++) { for (i = 0; i < dataset->n_std_atoms; i++) {
mat_copy_vector_d3(dataset->std_positions[i], bravais->position[i]); mat_copy_vector_d3(dataset->std_positions[i], exstr->bravais->position[i]);
dataset->std_types[i] = bravais->types[i]; dataset->std_types[i] = exstr->bravais->types[i];
dataset->std_mapping_to_primitive[i] = std_mapping_to_primitive[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; */ /* dataset->pointgroup_number = spacegroup->pointgroup_number; */
pointgroup = ptg_get_pointgroup(spacegroup->pointgroup_number); pointgroup = ptg_get_pointgroup(spacegroup->pointgroup_number);
strcpy(dataset->pointgroup_symbol, pointgroup.symbol); strcpy(dataset->pointgroup_symbol, pointgroup.symbol);
@ -1317,14 +1241,6 @@ static int set_dataset(SpglibDataset * dataset,
free(dataset->std_mapping_to_primitive); free(dataset->std_mapping_to_primitive);
dataset->std_mapping_to_primitive = NULL; 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) { if (dataset->equivalent_atoms != NULL) {
free(dataset->equivalent_atoms); free(dataset->equivalent_atoms);
dataset->equivalent_atoms = NULL; dataset->equivalent_atoms = NULL;
@ -1345,10 +1261,6 @@ static int set_dataset(SpglibDataset * dataset,
free(dataset->rotations); free(dataset->rotations);
dataset->rotations = NULL; dataset->rotations = NULL;
} }
if (symmetry != NULL) {
sym_free_symmetry(symmetry);
symmetry = NULL;
}
return 0; return 0;
} }
@ -1376,7 +1288,7 @@ static int get_symmetry_from_dataset(int rotation[][3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
return 0; return 0;
} }
@ -1441,7 +1353,7 @@ static int get_symmetry_with_collinear_spin(int rotation[][3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
cel_free_cell(cell); cel_free_cell(cell);
cell = NULL; cell = NULL;
goto get_dataset_failed; goto get_dataset_failed;
@ -1527,7 +1439,7 @@ static int get_multiplicity(SPGCONST double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
return 0; return 0;
} }
@ -1567,7 +1479,7 @@ static int standardize_primitive(double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
return 0; return 0;
} }
@ -1661,7 +1573,7 @@ static int standardize_cell(double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
goto err; goto err;
} }
@ -1720,7 +1632,7 @@ static int get_standardized_cell(double lattice[3][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
goto err; goto err;
} }
@ -1854,45 +1766,36 @@ static int get_international(char symbol[11],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
Cell *cell; SpglibDataset *dataset;
Primitive *primitive; int number;
Spacegroup spacegroup;
cell = NULL; dataset = NULL;
primitive = NULL;
spacegroup.number = 0;
if ((cell = cel_alloc_cell(num_atom)) == NULL) { if ((dataset = get_dataset(lattice,
position,
types,
num_atom,
0,
symprec,
angle_tolerance)) == NULL) {
goto err; goto err;
} }
cel_set_cell(cell, lattice, position, types); if (dataset->spacegroup_number > 0) {
number = dataset->spacegroup_number;
if ((primitive = spa_get_spacegroup(&spacegroup, strcpy(symbol, dataset->international_symbol);
cell, spg_free_dataset(dataset);
0, dataset = NULL;
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);
} else { } else {
spg_free_dataset(dataset);
dataset = NULL;
goto err; goto err;
} }
spglib_error_code = SPGLIB_SUCCESS; spglib_error_code = SPGLIB_SUCCESS;
return spacegroup.number; return number;
err: err:
spglib_error_code = SPGERR_SPACEGROUP_SEARCH_FAILED; spglib_error_code = SPGERR_SPACEGROUP_SEARCH_FAILED;
@ -1907,48 +1810,40 @@ static int get_schoenflies(char symbol[7],
const double symprec, const double symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
Cell *cell; SpglibDataset *dataset;
Primitive *primitive; SpglibSpacegroupType spgtype;
Spacegroup spacegroup; int number;
cell = NULL; dataset = NULL;
primitive = NULL;
spacegroup.number = 0;
if ((cell = cel_alloc_cell(num_atom)) == NULL) { if ((dataset = get_dataset(lattice,
position,
types,
num_atom,
0,
symprec,
angle_tolerance)) == NULL) {
goto err; goto err;
} }
cel_set_cell(cell, lattice, position, types); if (dataset->spacegroup_number > 0) {
number = dataset->spacegroup_number;
if ((primitive = spa_get_spacegroup(&spacegroup, spgtype = spg_get_spacegroup_type(dataset->hall_number);
cell, strcpy(symbol, spgtype.schoenflies);
0, spg_free_dataset(dataset);
symprec, dataset = NULL;
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);
} else { } else {
spg_free_dataset(dataset);
dataset = NULL;
goto err; goto err;
} }
spglib_error_code = SPGLIB_SUCCESS; spglib_error_code = SPGLIB_SUCCESS;
return spacegroup.number; return number;
err: err:
spglib_error_code = SPGERR_SPACEGROUP_SEARCH_FAILED; spglib_error_code = SPGERR_SPACEGROUP_SEARCH_FAILED;
return 0; return 0;
} }
@ -1977,7 +1872,7 @@ static int get_ir_reciprocal_mesh(int grid_address[][3],
num_atom, num_atom,
0, 0,
symprec, symprec,
angle_tolerance)) == NULL) { angle_tolerance)) == NULL) {
return 0; return 0;
} }

View File

@ -95,7 +95,7 @@ static Symmetry * get_collinear_operations(const Symmetry *sym_nonspin,
rot = mat_alloc_MatINT(sym_nonspin->size); rot = mat_alloc_MatINT(sym_nonspin->size);
trans = mat_alloc_VecDBL(sym_nonspin->size); trans = mat_alloc_VecDBL(sym_nonspin->size);
num_sym = 0; num_sym = 0;
for (i = 0; i < sym_nonspin->size; i++) { for (i = 0; i < sym_nonspin->size; i++) {
sign = 0; /* Set sign as undetermined */ sign = 0; /* Set sign as undetermined */
is_found = 1; 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) { if ((mapping_table = get_mapping_table(symmetry, cell, symprec)) == NULL) {
return 0; return 0;
} }
for (i = 0; i < cell->size; i++) { for (i = 0; i < cell->size; i++) {
if (mapping_table[i] != i) { if (mapping_table[i] != i) {
continue; continue;

View File

@ -78,57 +78,58 @@ static int relative_axes[][3] = {
}; };
static int identity[3][3] = {{1, 0, 0}, static int identity[3][3] = {{1, 0, 0},
{0, 1, 0}, {0, 1, 0},
{0, 0, 1}}; {0, 0, 1}};
static int get_index_with_least_atoms(const Cell *cell); static int get_index_with_least_atoms(const Cell *cell);
static VecDBL * get_translation(SPGCONST int rot[3][3], static VecDBL * get_translation(SPGCONST int rot[3][3],
const Cell *cell, const Cell *cell,
const double symprec, const double symprec,
const int is_identity); const int is_identity);
static Symmetry * get_operations(const Cell *primitive, static Symmetry * get_operations(const Cell *primitive,
const double symprec, const double symprec,
const double angle_symprec); const double angle_symprec);
static Symmetry * reduce_operation(const Cell * primitive, static Symmetry * reduce_operation(const Cell * primitive,
const Symmetry * symmetry, const Symmetry * symmetry,
const double symprec, const double symprec,
const double angle_symprec); const double angle_symprec,
const int is_pure_trans);
static int search_translation_part(int atoms_found[], static int search_translation_part(int atoms_found[],
const Cell * cell, const Cell * cell,
SPGCONST int rot[3][3], SPGCONST int rot[3][3],
const int min_atom_index, const int min_atom_index,
const double origin[3], const double origin[3],
const double symprec, const double symprec,
const int is_identity); const int is_identity);
static int search_pure_translations(int atoms_found[], static int search_pure_translations(int atoms_found[],
const Cell * cell, const Cell * cell,
const double trans[3], const double trans[3],
const double symprec); const double symprec);
static int is_overlap_all_atoms(const double test_trans[3], static int is_overlap_all_atoms(const double test_trans[3],
SPGCONST int rot[3][3], SPGCONST int rot[3][3],
const Cell * cell, const Cell * cell,
const double symprec, const double symprec,
const int is_identity); const int is_identity);
static PointSymmetry static PointSymmetry
transform_pointsymmetry(SPGCONST PointSymmetry * point_sym_prim, transform_pointsymmetry(SPGCONST PointSymmetry * point_sym_prim,
SPGCONST double new_lattice[3][3], SPGCONST double new_lattice[3][3],
SPGCONST double original_lattice[3][3]); SPGCONST double original_lattice[3][3]);
static Symmetry * static Symmetry *
get_space_group_operations(SPGCONST PointSymmetry *lattice_sym, get_space_group_operations(SPGCONST PointSymmetry *lattice_sym,
const Cell *primitive, const Cell *primitive,
const double symprec); const double symprec);
static void set_axes(int axes[3][3], 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], static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3],
const double symprec, const double symprec,
const double angle_symprec); const double angle_symprec);
static int is_identity_metric(SPGCONST double metric_rotated[3][3], static int is_identity_metric(SPGCONST double metric_rotated[3][3],
SPGCONST double metric_orig[3][3], SPGCONST double metric_orig[3][3],
const double symprec, const double symprec,
const double angle_symprec); const double angle_symprec);
static double get_angle(SPGCONST double metric[3][3], static double get_angle(SPGCONST double metric[3][3],
const int i, const int i,
const int j); const int j);
/* Return NULL if failed */ /* Return NULL if failed */
Symmetry * sym_alloc_symmetry(const int size) Symmetry * sym_alloc_symmetry(const int size)
@ -185,8 +186,8 @@ void sym_free_symmetry(Symmetry *symmetry)
/* Return NULL if failed */ /* Return NULL if failed */
Symmetry * sym_get_operation(const Cell * primitive, Symmetry * sym_get_operation(const Cell * primitive,
const double symprec, const double symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
debug_print("sym_get_operations:\n"); debug_print("sym_get_operations:\n");
@ -196,16 +197,16 @@ Symmetry * sym_get_operation(const Cell * primitive,
/* Return NULL if failed */ /* Return NULL if failed */
Symmetry * sym_reduce_operation(const Cell * primitive, Symmetry * sym_reduce_operation(const Cell * primitive,
const Symmetry * symmetry, const Symmetry * symmetry,
const double symprec, const double symprec,
const double angle_tolerance) 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 */ /* Return NULL if failed */
VecDBL * sym_get_pure_translation(const Cell *cell, VecDBL * sym_get_pure_translation(const Cell *cell,
const double symprec) const double symprec)
{ {
int multi; int multi;
VecDBL * pure_trans; 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) { if ((pure_trans = get_translation(identity, cell, symprec, 1)) == NULL) {
warning_print("spglib: get_translation failed (line %d, %s).\n", warning_print("spglib: get_translation failed (line %d, %s).\n",
__LINE__, __FILE__); __LINE__, __FILE__);
return NULL; 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); debug_print(" sym_get_pure_translation: pure_trans->size = %d\n", multi);
} else { } 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); 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 */ /* Return NULL if failed */
VecDBL * sym_reduce_pure_translation(const Cell * cell, VecDBL * sym_reduce_pure_translation(const Cell * cell,
const VecDBL * pure_trans, const VecDBL * pure_trans,
const double symprec, const double symprec,
const double angle_tolerance) const double angle_tolerance)
{ {
int i, multi; int i, multi;
Symmetry *symmetry, *symmetry_reduced; Symmetry *symmetry, *symmetry_reduced;
@ -259,7 +261,7 @@ VecDBL * sym_reduce_pure_translation(const Cell * cell,
} }
if ((symmetry_reduced = if ((symmetry_reduced =
reduce_operation(cell, symmetry, symprec, angle_tolerance)) == NULL) { reduce_operation(cell, symmetry, symprec, angle_tolerance, 1)) == NULL) {
sym_free_symmetry(symmetry); sym_free_symmetry(symmetry);
symmetry = NULL; symmetry = NULL;
return 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 */ /* transformed to those of original input cells, if the input cell */
/* was not a primitive cell. */ /* was not a primitive cell. */
static Symmetry * get_operations(const Cell *primitive, static Symmetry * get_operations(const Cell *primitive,
const double symprec, const double symprec,
const double angle_symprec) const double angle_symprec)
{ {
PointSymmetry lattice_sym; PointSymmetry lattice_sym;
Symmetry *symmetry; Symmetry *symmetry;
@ -305,15 +307,15 @@ static Symmetry * get_operations(const Cell *primitive,
symmetry = NULL; symmetry = NULL;
lattice_sym = get_lattice_symmetry(primitive->lattice, lattice_sym = get_lattice_symmetry(primitive->lattice,
symprec, symprec,
angle_symprec); angle_symprec);
if (lattice_sym.size == 0) { if (lattice_sym.size == 0) {
return NULL; return NULL;
} }
if ((symmetry = get_space_group_operations(&lattice_sym, if ((symmetry = get_space_group_operations(&lattice_sym,
primitive, primitive,
symprec)) == NULL) { symprec)) == NULL) {
return NULL; return NULL;
} }
@ -322,9 +324,10 @@ static Symmetry * get_operations(const Cell *primitive,
/* Return NULL if failed */ /* Return NULL if failed */
static Symmetry * reduce_operation(const Cell * primitive, static Symmetry * reduce_operation(const Cell * primitive,
const Symmetry * symmetry, const Symmetry * symmetry,
const double symprec, const double symprec,
const double angle_symprec) const double angle_symprec,
const int is_pure_trans)
{ {
int i, j, num_sym; int i, j, num_sym;
Symmetry * sym_reduced; Symmetry * sym_reduced;
@ -338,11 +341,16 @@ static Symmetry * reduce_operation(const Cell * primitive,
rot = NULL; rot = NULL;
trans = NULL; trans = NULL;
point_symmetry = get_lattice_symmetry(primitive->lattice, if (is_pure_trans) {
symprec, point_symmetry.size = 1;
angle_symprec); mat_copy_matrix_i3(point_symmetry.rot[0], identity);
if (point_symmetry.size == 0) { } else {
return NULL; 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) { 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 (i = 0; i < point_symmetry.size; i++) {
for (j = 0; j < symmetry->size; j++) { for (j = 0; j < symmetry->size; j++) {
if (mat_check_identity_matrix_i3(point_symmetry.rot[i], if (mat_check_identity_matrix_i3(point_symmetry.rot[i],
symmetry->rot[j])) { symmetry->rot[j])) {
if (is_overlap_all_atoms(symmetry->trans[j], if (is_overlap_all_atoms(symmetry->trans[j],
symmetry->rot[j], symmetry->rot[j],
primitive, primitive,
symprec, symprec,
0)) { 0)) {
mat_copy_matrix_i3(rot->mat[num_sym], symmetry->rot[j]); mat_copy_matrix_i3(rot->mat[num_sym], symmetry->rot[j]);
mat_copy_vector_d3(trans->vec[num_sym], symmetry->trans[j]); mat_copy_vector_d3(trans->vec[num_sym], symmetry->trans[j]);
num_sym++; num_sym++;
} }
} }
} }
} }
@ -392,9 +400,9 @@ static Symmetry * reduce_operation(const Cell * primitive,
/* This function is heaviest in this code. */ /* This function is heaviest in this code. */
/* Return NULL if failed */ /* Return NULL if failed */
static VecDBL * get_translation(SPGCONST int rot[3][3], static VecDBL * get_translation(SPGCONST int rot[3][3],
const Cell *cell, const Cell *cell,
const double symprec, const double symprec,
const int is_identity) const int is_identity)
{ {
int i, j, k, min_atom_index, num_trans; int i, j, k, min_atom_index, num_trans;
int *is_found; 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) { if (cell->size < NUM_ATOMS_CRITERION_FOR_OPENMP || is_identity) {
/* In this case, OpenMP multithreading is not used. */ /* In this case, OpenMP multithreading is not used. */
num_trans = search_translation_part(is_found, num_trans = search_translation_part(is_found,
cell, cell,
rot, rot,
min_atom_index, min_atom_index,
origin, origin,
symprec, symprec,
is_identity); is_identity);
if (num_trans == 0) { if (num_trans == 0) {
goto ret; goto ret;
} }
@ -459,21 +467,21 @@ static VecDBL * get_translation(SPGCONST int rot[3][3],
num_min_type_atoms = 0; num_min_type_atoms = 0;
for (i = 0; i < cell->size; i++) { for (i = 0; i < cell->size; i++) {
if (cell->types[i] == cell->types[min_atom_index]) { if (cell->types[i] == cell->types[min_atom_index]) {
min_type_atoms[num_min_type_atoms] = i; min_type_atoms[num_min_type_atoms] = i;
num_min_type_atoms++; num_min_type_atoms++;
} }
} }
#pragma omp parallel for private(j, vec) #pragma omp parallel for private(j, vec)
for (i = 0; i < num_min_type_atoms; i++) { for (i = 0; i < num_min_type_atoms; i++) {
for (j = 0; j < 3; j++) { 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, if (is_overlap_all_atoms(vec,
rot, rot,
cell, cell,
symprec, symprec,
is_identity)) { is_identity)) {
is_found[min_type_atoms[i]] = 1; is_found[min_type_atoms[i]] = 1;
} }
} }
@ -486,12 +494,12 @@ static VecDBL * get_translation(SPGCONST int rot[3][3],
} }
#else #else
num_trans = search_translation_part(is_found, num_trans = search_translation_part(is_found,
cell, cell,
rot, rot,
min_atom_index, min_atom_index,
origin, origin,
symprec, symprec,
is_identity); is_identity);
if (num_trans == 0) { if (num_trans == 0) {
goto ret; goto ret;
} }
@ -505,8 +513,8 @@ static VecDBL * get_translation(SPGCONST int rot[3][3],
for (i = 0; i < cell->size; i++) { for (i = 0; i < cell->size; i++) {
if (is_found[i]) { if (is_found[i]) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
trans->vec[k][j] = cell->position[i][j] - origin[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] -= mat_Nint(trans->vec[k][j]);
} }
k++; k++;
} }
@ -520,12 +528,12 @@ static VecDBL * get_translation(SPGCONST int rot[3][3],
} }
static int search_translation_part(int atoms_found[], static int search_translation_part(int atoms_found[],
const Cell * cell, const Cell * cell,
SPGCONST int rot[3][3], SPGCONST int rot[3][3],
const int min_atom_index, const int min_atom_index,
const double origin[3], const double origin[3],
const double symprec, const double symprec,
const int is_identity) const int is_identity)
{ {
int i, j, num_trans; int i, j, num_trans;
double trans[3]; double trans[3];
@ -545,10 +553,10 @@ static int search_translation_part(int atoms_found[],
trans[j] = cell->position[i][j] - origin[j]; trans[j] = cell->position[i][j] - origin[j];
} }
if (is_overlap_all_atoms(trans, if (is_overlap_all_atoms(trans,
rot, rot,
cell, cell,
symprec, symprec,
is_identity)) { is_identity)) {
atoms_found[i] = 1; atoms_found[i] = 1;
num_trans++; num_trans++;
if (is_identity) { if (is_identity) {
@ -583,7 +591,7 @@ static int search_pure_translations(int atoms_found[],
if (!copy_atoms_found[initial_atom]) { if (!copy_atoms_found[initial_atom]) {
continue; continue;
} }
i_atom = initial_atom; i_atom = initial_atom;
for (i = 0; i < cell->size; i++) { for (i = 0; i < cell->size; i++) {
@ -603,7 +611,7 @@ static int search_pure_translations(int atoms_found[],
num_trans++; num_trans++;
} }
i_atom = j; i_atom = j;
break; break;
} }
} }
@ -620,10 +628,10 @@ static int search_pure_translations(int atoms_found[],
} }
static int is_overlap_all_atoms(const double trans[3], static int is_overlap_all_atoms(const double trans[3],
SPGCONST int rot[3][3], SPGCONST int rot[3][3],
const Cell * cell, const Cell * cell,
const double symprec, const double symprec,
const int is_identity) const int is_identity)
{ {
int i, j, k, is_found; int i, j, k, is_found;
double pos_rot[3], d_frac[3], d[3]; 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++) { for (i = 0; i < cell->size; i++) {
if (is_identity) { /* Identity matrix is treated as special for speed-up. */ if (is_identity) { /* Identity matrix is treated as special for speed-up. */
for (j = 0; j < 3; j++) { 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 { } else {
mat_multiply_matrix_vector_id3(pos_rot, mat_multiply_matrix_vector_id3(pos_rot,
rot, rot,
cell->position[i]); cell->position[i]);
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
pos_rot[j] += trans[j]; pos_rot[j] += trans[j];
} }
} }
is_found = 0; is_found = 0;
for (j = 0; j < cell->size; j++) { for (j = 0; j < cell->size; j++) {
if (cell->types[i] == cell->types[j]) { if (cell->types[i] == cell->types[j]) {
/* here cel_is_overlap can be used, but for the tuning */ /* here cel_is_overlap can be used, but for the tuning */
/* purpose, write it again */ /* purpose, write it again */
for (k = 0; k < 3; k++) { for (k = 0; k < 3; k++) {
d_frac[k] = pos_rot[k] - cell->position[j][k]; d_frac[k] = pos_rot[k] - cell->position[j][k];
d_frac[k] -= mat_Nint(d_frac[k]); d_frac[k] -= mat_Nint(d_frac[k]);
} }
mat_multiply_matrix_vector_d3(d, cell->lattice, d_frac); 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) { if (sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]) < symprec) {
is_found = 1; is_found = 1;
break; break;
} }
} }
} }
@ -689,8 +697,8 @@ static int get_index_with_least_atoms(const Cell *cell)
for (i = 0; i < cell->size; i++) { for (i = 0; i < cell->size; i++) {
for (j = 0; j < cell->size; j++) { for (j = 0; j < cell->size; j++) {
if (cell->types[i] == cell->types[j]) { if (cell->types[i] == cell->types[j]) {
mapping[j]++; mapping[j]++;
break; break;
} }
} }
} }
@ -713,8 +721,8 @@ static int get_index_with_least_atoms(const Cell *cell)
/* Return NULL if failed */ /* Return NULL if failed */
static Symmetry * static Symmetry *
get_space_group_operations(SPGCONST PointSymmetry *lattice_sym, get_space_group_operations(SPGCONST PointSymmetry *lattice_sym,
const Cell *primitive, const Cell *primitive,
const double symprec) const double symprec)
{ {
int i, j, num_sym, total_num_sym; int i, j, num_sym, total_num_sym;
VecDBL **trans; VecDBL **trans;
@ -739,10 +747,10 @@ get_space_group_operations(SPGCONST PointSymmetry *lattice_sym,
for (i = 0; i < lattice_sym->size; i++) { for (i = 0; i < lattice_sym->size; i++) {
if ((trans[i] = get_translation(lattice_sym->rot[i], primitive, symprec, 0)) if ((trans[i] = get_translation(lattice_sym->rot[i], primitive, symprec, 0))
!= NULL) { != NULL) {
debug_print(" match translation %d/%d; tolerance = %f\n", 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; 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], static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3],
const double symprec, const double symprec,
const double angle_symprec) const double angle_symprec)
{ {
int i, j, k, attempt, num_sym; int i, j, k, attempt, num_sym;
double angle_tol; double angle_tol;
@ -803,28 +811,28 @@ static PointSymmetry get_lattice_symmetry(SPGCONST double cell_lattice[3][3],
num_sym = 0; num_sym = 0;
for (i = 0; i < 26; i++) { for (i = 0; i < 26; i++) {
for (j = 0; j < 26; j++) { for (j = 0; j < 26; j++) {
for (k = 0; k < 26; k++) { for (k = 0; k < 26; k++) {
set_axes(axes, i, j, k); set_axes(axes, i, j, k);
if (! ((mat_get_determinant_i3(axes) == 1) || if (! ((mat_get_determinant_i3(axes) == 1) ||
(mat_get_determinant_i3(axes) == -1))) { (mat_get_determinant_i3(axes) == -1))) {
continue; continue;
} }
mat_multiply_matrix_di3(lattice, min_lattice, axes); mat_multiply_matrix_di3(lattice, min_lattice, axes);
mat_get_metric(metric, lattice); mat_get_metric(metric, lattice);
if (is_identity_metric(metric, metric_orig, symprec, angle_tol)) { if (is_identity_metric(metric, metric_orig, symprec, angle_tol)) {
if (num_sym > 47) { if (num_sym > 47) {
angle_tol *= ANGLE_REDUCE_RATE; angle_tol *= ANGLE_REDUCE_RATE;
warning_print("spglib: Too many lattice symmetries was found.\n"); warning_print("spglib: Too many lattice symmetries was found.\n");
warning_print(" Reduce angle tolerance to %f", angle_tol); warning_print(" Reduce angle tolerance to %f", angle_tol);
warning_print(" (line %d, %s).\n", __LINE__, __FILE__); warning_print(" (line %d, %s).\n", __LINE__, __FILE__);
goto next_attempt; goto next_attempt;
} }
mat_copy_matrix_i3(lattice_sym.rot[num_sym], axes); mat_copy_matrix_i3(lattice_sym.rot[num_sym], axes);
num_sym++; 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], static int is_identity_metric(SPGCONST double metric_rotated[3][3],
SPGCONST double metric_orig[3][3], SPGCONST double metric_orig[3][3],
const double symprec, const double symprec,
const double angle_symprec) const double angle_symprec)
{ {
int i, j, k; int i, j, k;
int elem_sets[3][2] = {{0, 1}, int elem_sets[3][2] = {{0, 1},
{0, 2}, {0, 2},
{1, 2}}; {1, 2}};
double cos1, cos2, x, length_ave2, sin_dtheta2; double cos1, cos2, x, length_ave2, sin_dtheta2;
double length_orig[3], length_rot[3]; 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]; k = elem_sets[i][1];
if (angle_symprec > 0) { if (angle_symprec > 0) {
if (mat_Dabs(get_angle(metric_orig, j, k) - if (mat_Dabs(get_angle(metric_orig, j, k) -
get_angle(metric_rotated, j, k)) > angle_symprec) { get_angle(metric_rotated, j, k)) > angle_symprec) {
goto fail; goto fail;
} }
} else { } else {
/* dtheta = arccos(cos(theta1) - arccos(cos(theta2))) */ /* 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); x = cos1 * cos2 + sqrt(1 - cos1 * cos1) * sqrt(1 - cos2 * cos2);
sin_dtheta2 = 1 - x * x; sin_dtheta2 = 1 - x * x;
length_ave2 = ((length_orig[j] + length_rot[j]) * 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 > 1e-12) {
if (sin_dtheta2 * length_ave2 > symprec * symprec) { if (sin_dtheta2 * length_ave2 > symprec * symprec) {
goto fail; 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], static double get_angle(SPGCONST double metric[3][3],
const int i, const int i,
const int j) const int j)
{ {
double length_i, length_j; double length_i, length_j;
@ -909,8 +917,8 @@ static double get_angle(SPGCONST double metric[3][3],
static PointSymmetry static PointSymmetry
transform_pointsymmetry(SPGCONST PointSymmetry * lat_sym_orig, transform_pointsymmetry(SPGCONST PointSymmetry * lat_sym_orig,
SPGCONST double new_lattice[3][3], SPGCONST double new_lattice[3][3],
SPGCONST double original_lattice[3][3]) SPGCONST double original_lattice[3][3])
{ {
int i, size; int i, size;
double trans_mat[3][3], inv_mat[3][3], drot[3][3]; 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)) { 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); mat_cast_matrix_3d_to_3i(lat_sym_new.rot[size], drot);
if (abs(mat_get_determinant_i3(lat_sym_new.rot[size])) != 1) { if (abs(mat_get_determinant_i3(lat_sym_new.rot[size])) != 1) {
warning_print("spglib: A point symmetry operation is not unimodular."); warning_print("spglib: A point symmetry operation is not unimodular.");
warning_print("(line %d, %s).\n", __LINE__, __FILE__); warning_print("(line %d, %s).\n", __LINE__, __FILE__);
goto err; goto err;
} }
size++; size++;
} }
@ -954,7 +962,7 @@ transform_pointsymmetry(SPGCONST PointSymmetry * lat_sym_orig,
} }
static void set_axes(int axes[3][3], 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; int i;
for (i = 0; i < 3; i++) {axes[i][0] = relative_axes[a1][i]; } for (i = 0; i < 3; i++) {axes[i][0] = relative_axes[a1][i]; }

View File

@ -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

View File

@ -36,22 +36,23 @@
#define __refinement_H__ #define __refinement_H__
#include "cell.h" #include "cell.h"
#include "mathfunc.h"
#include "spacegroup.h"
#include "symmetry.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 #endif

View File

@ -66,20 +66,19 @@ typedef enum {
R_CENTER, R_CENTER,
} Centering; } Centering;
Primitive * spa_get_spacegroup(Spacegroup * spacegroup, Spacegroup spa_search_spacegroup(const Cell * primitive,
const Cell * cell, const int hall_number,
const int hall_number, const double symprec,
const double symprec, const double angle_tolerance);
const double angle_tolerance);
Spacegroup spa_search_spacegroup_with_symmetry(const Symmetry *symmetry, Spacegroup spa_search_spacegroup_with_symmetry(const Symmetry *symmetry,
const double symprec); const double symprec);
Cell * spa_transform_to_primitive(int * mapping_table, Cell * spa_transform_to_primitive(int * mapping_table,
const Cell * cell, const Cell * cell,
SPGCONST double trans_mat[3][3], SPGCONST double trans_mat[3][3],
const Centering centering, const Centering centering,
const double symprec); const double symprec);
Cell * spa_transform_from_primitive(const Cell * primitive, Cell * spa_transform_from_primitive(const Cell * primitive,
const Centering centering, const Centering centering,
const double symprec); const double symprec);
#endif #endif

View File

@ -51,10 +51,10 @@
[ a_z, b_z, c_z ] ] [ a_z, b_z, c_z ] ]
position: Atomic positions (in fractional coordinates) position: Atomic positions (in fractional coordinates)
[ [ x1_a, x1_b, x1_c ], [ [ x1_a, x1_b, x1_c ],
[ x2_a, x2_b, x2_c ], [ x2_a, x2_b, x2_c ],
[ x3_a, x3_b, x3_c ], [ x3_a, x3_b, x3_c ],
... ] ... ]
types: Atom types, i.e., species identified by number 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); char * spg_get_error_message(SpglibError spglib_error);
SpglibDataset * spg_get_dataset(SPGCONST double lattice[3][3], SpglibDataset * spg_get_dataset(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
SpglibDataset * spgat_get_dataset(SPGCONST double lattice[3][3], SpglibDataset * spgat_get_dataset(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* hall_number = 0 gives the same as spg_get_dataset. */ /* hall_number = 0 gives the same as spg_get_dataset. */
SpglibDataset * spg_get_dataset_with_hall_number(SPGCONST double lattice[3][3], SpglibDataset * spg_get_dataset_with_hall_number(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const int hall_number, const int hall_number,
const double symprec); const double symprec);
/* hall_number = 0 gives the same as spgat_get_dataset. */ /* hall_number = 0 gives the same as spgat_get_dataset. */
SpglibDataset * SpglibDataset *
spgat_get_dataset_with_hall_number(SPGCONST double lattice[3][3], spgat_get_dataset_with_hall_number(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const int hall_number, const int hall_number,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
void spg_free_dataset(SpglibDataset *dataset); 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, */ /* ``translation[i]`` with same index give a symmetry oprations, */
/* i.e., these have to be used togather. */ /* i.e., these have to be used togather. */
int spg_get_symmetry(int rotation[][3][3], int spg_get_symmetry(int rotation[][3][3],
double translation[][3], double translation[][3],
const int max_size, const int max_size,
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_get_symmetry(int rotation[][3][3], int spgat_get_symmetry(int rotation[][3][3],
double translation[][3], double translation[][3],
const int max_size, const int max_size,
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* Find symmetry operations with collinear spins on atoms. */ /* Find symmetry operations with collinear spins on atoms. */
int spg_get_symmetry_with_collinear_spin(int rotation[][3][3], int spg_get_symmetry_with_collinear_spin(int rotation[][3][3],
double translation[][3], double translation[][3],
int equivalent_atoms[], int equivalent_atoms[],
const int max_size, const int max_size,
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const double spins[], const double spins[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_get_symmetry_with_collinear_spin(int rotation[][3][3], int spgat_get_symmetry_with_collinear_spin(int rotation[][3][3],
double translation[][3], double translation[][3],
int equivalent_atoms[], int equivalent_atoms[],
const int max_size, const int max_size,
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const double spins[], const double spins[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* Space group type (hall_number) is searched from symmetry operations. */ /* Space group type (hall_number) is searched from symmetry operations. */
int spg_get_hall_number_from_symmetry(SPGCONST int rotation[][3][3], 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 */ /* be used in advance to allocate memoery space for symmetry */
/* operations. */ /* operations. */
int spg_get_multiplicity(SPGCONST double lattice[3][3], int spg_get_multiplicity(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_get_multiplicity(SPGCONST double lattice[3][3], int spgat_get_multiplicity(SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* Space group is found in international table symbol (``symbol``) and */ /* Space group is found in international table symbol (``symbol``) and */
/* number (return value). 0 is returned when it fails. */ /* number (return value). 0 is returned when it fails. */
int spg_get_international(char symbol[11], int spg_get_international(char symbol[11],
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_get_international(char symbol[11], int spgat_get_international(char symbol[11],
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* Space group is found in schoenflies (``symbol``) and as number (return */ /* Space group is found in schoenflies (``symbol``) and as number (return */
/* value). 0 is returned when it fails. */ /* value). 0 is returned when it fails. */
int spg_get_schoenflies(char symbol[7], int spg_get_schoenflies(char symbol[7],
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_get_schoenflies(char symbol[7], int spgat_get_schoenflies(char symbol[7],
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* Point group symbol is obtained from the rotation part of */ /* Point group symbol is obtained from the rotation part of */
/* symmetry operations */ /* symmetry operations */
int spg_get_pointgroup(char symbol[6], int spg_get_pointgroup(char symbol[6],
int trans_mat[3][3], int trans_mat[3][3],
SPGCONST int rotations[][3][3], SPGCONST int rotations[][3][3],
const int num_rotations); const int num_rotations);
/* Space-group operations in built-in database are accessed by index */ /* Space-group operations in built-in database are accessed by index */
/* of hall symbol. The index is defined as number from 1 to 530. */ /* of hall symbol. The index is defined as number from 1 to 530. */
/* The muximum number of symmetry operations is 192. */ /* The muximum number of symmetry operations is 192. */
int spg_get_symmetry_from_database(int rotations[192][3][3], int spg_get_symmetry_from_database(int rotations[192][3][3],
double translations[192][3], double translations[192][3],
const int hall_number); const int hall_number);
/* Space-group type information is accessed by index of hall symbol. */ /* Space-group type information is accessed by index of hall symbol. */
/* The index is defined as number from 1 to 530. */ /* 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], int spg_standardize_cell(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
const int num_atom, const int num_atom,
const int to_primitive, const int to_primitive,
const int no_idealize, const int no_idealize,
const double symprec); const double symprec);
int spgat_standardize_cell(double lattice[3][3], int spgat_standardize_cell(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
const int num_atom, const int num_atom,
const int to_primitive, const int to_primitive,
const int no_idealize, const int no_idealize,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* This is a wrapper of spg_standardize_cell. */ /* This is a wrapper of spg_standardize_cell. */
/* A primitive cell is found from an input 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. */ /* ``num_atom`` is returned as return value. */
/* When any primitive cell is not found, 0 is returned. */ /* When any primitive cell is not found, 0 is returned. */
int spg_find_primitive(double lattice[3][3], int spg_find_primitive(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_find_primitive(double lattice[3][3], int spgat_find_primitive(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* This is a wrapper of spg_standardize_cell. */ /* This is a wrapper of spg_standardize_cell. */
/* Bravais lattice with internal atomic points are returned. */ /* 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 */ /* When bravais lattice could not be found, or could not be */
/* symmetrized, 0 is returned. */ /* symmetrized, 0 is returned. */
int spg_refine_cell(double lattice[3][3], int spg_refine_cell(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
int spgat_refine_cell(double lattice[3][3], int spgat_refine_cell(double lattice[3][3],
double position[][3], double position[][3],
int types[], int types[],
const int num_atom, const int num_atom,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
/* Delaunay reduction for lattice parameters */ /* Delaunay reduction for lattice parameters */
/* ``lattice`` is overwritten when the redution ends succeeded. */ /* ``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)). */ /* ((grid_address * 2 + (shift != 0)) / (mesh * 2)). */
/* Each element of shift[] is 0 or non-zero. */ /* Each element of shift[] is 0 or non-zero. */
int spg_get_grid_point_from_address(const int grid_address[3], 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 */ /* Irreducible reciprocal grid points are searched from uniform */
/* mesh grid points specified by ``mesh`` and ``is_shift``. */ /* 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 */ /* returned as the return value. The time reversal symmetry is */
/* imposed by setting ``is_time_reversal`` 1. */ /* imposed by setting ``is_time_reversal`` 1. */
int spg_get_ir_reciprocal_mesh(int grid_address[][3], int spg_get_ir_reciprocal_mesh(int grid_address[][3],
int map[], int map[],
const int mesh[3], const int mesh[3],
const int is_shift[3], const int is_shift[3],
const int is_time_reversal, const int is_time_reversal,
SPGCONST double lattice[3][3], SPGCONST double lattice[3][3],
SPGCONST double position[][3], SPGCONST double position[][3],
const int types[], const int types[],
const int num_atom, const int num_atom,
const double symprec); const double symprec);
/* The irreducible k-points are searched from unique k-point mesh */ /* The irreducible k-points are searched from unique k-point mesh */
/* grids from real space lattice vectors and rotation matrices of */ /* 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 */ /* reduced k-points with stabilizers are returned as the return */
/* value. */ /* value. */
int spg_get_stabilized_reciprocal_mesh(int grid_address[][3], int spg_get_stabilized_reciprocal_mesh(int grid_address[][3],
int map[], int map[],
const int mesh[3], const int mesh[3],
const int is_shift[3], const int is_shift[3],
const int is_time_reversal, const int is_time_reversal,
const int num_rot, const int num_rot,
SPGCONST int rotations[][3][3], SPGCONST int rotations[][3][3],
const int num_q, const int num_q,
SPGCONST double qpoints[][3]); SPGCONST double qpoints[][3]);
/* Rotation operations in reciprocal space ``rot_reciprocal`` are applied */ /* Rotation operations in reciprocal space ``rot_reciprocal`` are applied */
/* to a grid address ``address_orig`` and resulting grid points are stored in */ /* to a grid address ``address_orig`` and resulting grid points are stored in */
/* ``rot_grid_points``. Return 0 if failed. */ /* ``rot_grid_points``. Return 0 if failed. */
int spg_get_grid_points_by_rotations(int rot_grid_points[], int spg_get_grid_points_by_rotations(int rot_grid_points[],
const int address_orig[3], const int address_orig[3],
const int num_rot, const int num_rot,
SPGCONST int rot_reciprocal[][3][3], SPGCONST int rot_reciprocal[][3][3],
const int mesh[3], const int mesh[3],
const int is_shift[3]); const int is_shift[3]);
int spg_get_BZ_grid_points_by_rotations(int rot_grid_points[], int spg_get_BZ_grid_points_by_rotations(int rot_grid_points[],
const int address_orig[3], const int address_orig[3],
const int num_rot, const int num_rot,
SPGCONST int rot_reciprocal[][3][3], SPGCONST int rot_reciprocal[][3][3],
const int mesh[3], const int mesh[3],
const int is_shift[3], const int is_shift[3],
const int bz_map[]); const int bz_map[]);
/* Grid addresses are relocated inside Brillouin zone. */ /* Grid addresses are relocated inside Brillouin zone. */
/* Number of ir-grid-points inside Brillouin zone is returned. */ /* 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 */ /* 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). */ /* (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 spg_relocate_BZ_grid_address(int bz_grid_address[][3],
int bz_map[], int bz_map[],
SPGCONST int grid_address[][3], SPGCONST int grid_address[][3],
const int mesh[3], const int mesh[3],
SPGCONST double rec_lattice[3][3], SPGCONST double rec_lattice[3][3],
const int is_shift[3]); const int is_shift[3]);
void spg_get_neighboring_grid_points(int relative_grid_points[], void spg_get_neighboring_grid_points(int relative_grid_points[],
const int grid_point, const int grid_point,
SPGCONST int relative_grid_address[][3], SPGCONST int relative_grid_address[][3],
const int num_relative_grid_address, const int num_relative_grid_address,
const int mesh[3], const int mesh[3],
SPGCONST int bz_grid_address[][3], SPGCONST int bz_grid_address[][3],
const int bz_map[]); const int bz_map[]);
/*--------*/ /*--------*/
/* Niggli */ /* 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); int spg_niggli_reduce(double lattice[3][3], const double symprec);
#endif #endif

View File

@ -57,12 +57,12 @@ Symmetry * sym_get_operation(const Cell * primitive,
Symmetry * sym_reduce_operation(const Cell * primitive, Symmetry * sym_reduce_operation(const Cell * primitive,
const Symmetry * symmetry, const Symmetry * symmetry,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
VecDBL * sym_get_pure_translation(const Cell *cell, VecDBL * sym_get_pure_translation(const Cell *cell,
const double symprec); const double symprec);
VecDBL * sym_reduce_pure_translation(const Cell * cell, VecDBL * sym_reduce_pure_translation(const Cell * cell,
const VecDBL * pure_trans, const VecDBL * pure_trans,
const double symprec, const double symprec,
const double angle_tolerance); const double angle_tolerance);
#endif #endif

View File

@ -36,8 +36,8 @@
#define __version_H__ #define __version_H__
#define SPGLIB_MAJOR_VERSION 1 #define SPGLIB_MAJOR_VERSION 1
#define SPGLIB_MINOR_VERSION 9 #define SPGLIB_MINOR_VERSION 10
#define SPGLIB_MICRO_VERSION 10 #define SPGLIB_MICRO_VERSION 1
#endif #endif

View File

@ -38,7 +38,7 @@ import sysconfig
config_var = sysconfig.get_config_var("CFLAGS") config_var = sysconfig.get_config_var("CFLAGS")
if config_var is not None and "-Werror=declaration-after-statement" in config_var: if config_var is not None and "-Werror=declaration-after-statement" in config_var:
os.environ['CFLAGS'] = config_var.replace( os.environ['CFLAGS'] = config_var.replace(
"-Werror=declaration-after-statement", "") "-Werror=declaration-after-statement", "")
###################### ######################
# _phonopy extension # # _phonopy extension #
@ -94,6 +94,7 @@ extension_spglib = Extension(
'c/spglib/arithmetic.c', 'c/spglib/arithmetic.c',
'c/spglib/cell.c', 'c/spglib/cell.c',
'c/spglib/delaunay.c', 'c/spglib/delaunay.c',
'c/spglib/determination.c',
'c/spglib/hall_symbol.c', 'c/spglib/hall_symbol.c',
'c/spglib/kgrid.c', 'c/spglib/kgrid.c',
'c/spglib/kpoint.c', 'c/spglib/kpoint.c',
@ -186,5 +187,3 @@ if __name__ == '__main__':
provides=['phonopy'], provides=['phonopy'],
scripts=scripts_phonopy, scripts=scripts_phonopy,
ext_modules=ext_modules_phonopy) ext_modules=ext_modules_phonopy)