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

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

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

View File

@ -374,53 +374,53 @@ static int rot_axes[][3] = {
};
static int get_pointgroup_number_by_rotations(SPGCONST int rotations[][3][3],
const int num_rotations);
const int num_rotations);
static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym);
static int get_pointgroup_class_table(int table[10],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
static int get_rotation_type(SPGCONST int rot[3][3]);
static int get_rotation_axis(SPGCONST int rot[3][3]);
static int get_orthogonal_axis(int ortho_axes[],
SPGCONST int proper_rot[3][3],
const int rot_order);
SPGCONST int proper_rot[3][3],
const int rot_order);
static int laue2m(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
#ifdef SPGDEBUG
static int lauemmm(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
static int laue4m(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
static int laue4mmm(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
static int laue3(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
static int laue3m(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
static int lauem3m(int axes[3],
SPGCONST PointSymmetry * pointsym);
SPGCONST PointSymmetry * pointsym);
#endif
static int laue_one_axis(int axes[3],
SPGCONST PointSymmetry * pointsym,
const int rot_order);
SPGCONST PointSymmetry * pointsym,
const int rot_order);
static int lauennn(int axes[3],
SPGCONST PointSymmetry * pointsym,
const int rot_order);
SPGCONST PointSymmetry * pointsym,
const int rot_order);
static int get_axes(int axes[3],
const Laue laue,
SPGCONST PointSymmetry * pointsym);
const Laue laue,
SPGCONST PointSymmetry * pointsym);
static void get_proper_rotation(int prop_rot[3][3],
SPGCONST int rot[3][3]);
SPGCONST int rot[3][3]);
static void set_transformation_matrix(int tmat[3][3],
const int axes[3]);
const int axes[3]);
static int is_exist_axis(const int axis_vec[3], const int axis_index);
static void sort_axes(int axes[3]);
/* Retrun pointgroup.number = 0 if failed */
Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3],
SPGCONST int rotations[][3][3],
const int num_rotations)
SPGCONST int rotations[][3][3],
const int num_rotations)
{
int i, j, pg_num;
int axes[3];
@ -474,7 +474,7 @@ Pointgroup ptg_get_pointgroup(const int pointgroup_number)
}
PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3],
const int num_rotations)
const int num_rotations)
{
int i, j;
PointSymmetry pointsym;
@ -483,7 +483,7 @@ PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3],
for (i = 0; i < num_rotations; i++) {
for (j = 0; j < pointsym.size; j++) {
if (mat_check_identity_matrix_i3(rotations[i], pointsym.rot[j])) {
goto escape;
goto escape;
}
}
mat_copy_matrix_i3(pointsym.rot[pointsym.size], rotations[i]);
@ -496,7 +496,7 @@ PointSymmetry ptg_get_pointsymmetry(SPGCONST int rotations[][3][3],
}
static int get_pointgroup_number_by_rotations(SPGCONST int rotations[][3][3],
const int num_rotations)
const int num_rotations)
{
PointSymmetry pointsym;
@ -538,7 +538,7 @@ static int get_pointgroup_number(SPGCONST PointSymmetry * pointsym)
}
static int get_pointgroup_class_table(int table[10],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
/* Look-up table */
/* Operation -6 -4 -3 -2 -1 1 2 3 4 6 */
@ -628,8 +628,8 @@ static int get_rotation_type(SPGCONST int rot[3][3])
}
static int get_axes(int axes[3],
const Laue laue,
SPGCONST PointSymmetry * pointsym)
const Laue laue,
SPGCONST PointSymmetry * pointsym)
{
switch (laue) {
case LAUE1:
@ -675,7 +675,7 @@ static int get_axes(int axes[3],
}
static int laue2m(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
int prop_rot[3][3], t_mat[3][3];
@ -738,7 +738,7 @@ static int laue2m(int axes[3],
#ifdef SPGDEBUG
static int lauemmm(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, count, axis;
int prop_rot[3][3];
@ -756,8 +756,8 @@ static int lauemmm(int axes[3],
axis = get_rotation_axis(prop_rot);
if (! ((axis == axes[0]) ||
(axis == axes[1]) ||
(axis == axes[2]))) {
(axis == axes[1]) ||
(axis == axes[2]))) {
axes[count] = axis;
count++;
}
@ -769,7 +769,7 @@ static int lauemmm(int axes[3],
}
static int laue4m(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
int axis_vec[3];
@ -829,7 +829,7 @@ static int laue4m(int axes[3],
}
static int laue4mmm(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, is_found, tmpval, axis;
int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3];
@ -892,7 +892,7 @@ static int laue4mmm(int axes[3],
}
static int laue3(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
int prop_rot[3][3], t_mat[3][3];
@ -955,7 +955,7 @@ static int laue3(int axes[3],
}
static int laue3m(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, is_found, tmpval, axis;
int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3];
@ -1023,7 +1023,7 @@ static int laue3m(int axes[3],
}
static int lauem3m(int axes[3],
SPGCONST PointSymmetry * pointsym)
SPGCONST PointSymmetry * pointsym)
{
int i, count, axis;
int prop_rot[3][3];
@ -1040,8 +1040,8 @@ static int lauem3m(int axes[3],
axis = get_rotation_axis(prop_rot);
if (! ((axis == axes[0]) ||
(axis == axes[1]) ||
(axis == axes[2]))) {
(axis == axes[1]) ||
(axis == axes[2]))) {
axes[count] = axis;
count++;
}
@ -1054,8 +1054,8 @@ static int lauem3m(int axes[3],
#endif
static int laue_one_axis(int axes[3],
SPGCONST PointSymmetry * pointsym,
const int rot_order)
SPGCONST PointSymmetry * pointsym,
const int rot_order)
{
int i, j, num_ortho_axis, det, is_found, tmpval;
int axis_vec[3], tmp_axes[3];
@ -1070,18 +1070,18 @@ static int laue_one_axis(int axes[3],
/* Search foud-fold rotation */
if (rot_order == 4) {
if (mat_get_trace_i3(prop_rot) == 1) {
/* The first axis */
axes[2] = get_rotation_axis(prop_rot);
break;
/* The first axis */
axes[2] = get_rotation_axis(prop_rot);
break;
}
}
/* Search three-fold rotation */
if (rot_order == 3) {
if (mat_get_trace_i3(prop_rot) == 0) {
/* The first axis */
axes[2] = get_rotation_axis(prop_rot);
break;
/* The first axis */
axes[2] = get_rotation_axis(prop_rot);
break;
}
}
}
@ -1096,17 +1096,17 @@ static int laue_one_axis(int axes[3],
is_found = 0;
tmp_axes[0] = ortho_axes[i];
mat_multiply_matrix_vector_i3(axis_vec,
prop_rot,
rot_axes[tmp_axes[0]]);
prop_rot,
rot_axes[tmp_axes[0]]);
for (j = 0; j < num_ortho_axis; j++) {
is_found = is_exist_axis(axis_vec, ortho_axes[j]);
if (is_found == 1) {
tmp_axes[1] = ortho_axes[j];
break;
tmp_axes[1] = ortho_axes[j];
break;
}
if (is_found == -1) {
tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES;
break;
tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES;
break;
}
}
@ -1143,8 +1143,8 @@ static int laue_one_axis(int axes[3],
}
static int lauennn(int axes[3],
SPGCONST PointSymmetry * pointsym,
const int rot_order)
SPGCONST PointSymmetry * pointsym,
const int rot_order)
{
int i, count, axis;
int prop_rot[3][3];
@ -1159,13 +1159,13 @@ static int lauennn(int axes[3],
/* Search two- or four-fold rotation */
if ((mat_get_trace_i3(prop_rot) == -1 && rot_order == 2) ||
(mat_get_trace_i3(prop_rot) == 1 && rot_order == 4)) {
(mat_get_trace_i3(prop_rot) == 1 && rot_order == 4)) {
axis = get_rotation_axis(prop_rot);
if (! ((axis == axes[0]) ||
(axis == axes[1]) ||
(axis == axes[2]))) {
axes[count] = axis;
count++;
(axis == axes[1]) ||
(axis == axes[2]))) {
axes[count] = axis;
count++;
}
}
}
@ -1189,8 +1189,8 @@ static int get_rotation_axis(SPGCONST int proper_rot[3][3])
for (i = 0; i < NUM_ROT_AXES; i++) {
mat_multiply_matrix_vector_i3(vec, proper_rot, rot_axes[i]);
if (vec[0] == rot_axes[i][0] &&
vec[1] == rot_axes[i][1] &&
vec[2] == rot_axes[i][2]) {
vec[1] == rot_axes[i][1] &&
vec[2] == rot_axes[i][2]) {
axis = i;
break;
}
@ -1207,8 +1207,8 @@ static int get_rotation_axis(SPGCONST int proper_rot[3][3])
}
static int get_orthogonal_axis(int ortho_axes[],
SPGCONST int proper_rot[3][3],
const int rot_order)
SPGCONST int proper_rot[3][3],
const int rot_order)
{
int i, num_ortho_axis;
int vec[3];
@ -1226,8 +1226,8 @@ static int get_orthogonal_axis(int ortho_axes[],
for (i = 0; i < NUM_ROT_AXES; i++) {
mat_multiply_matrix_vector_i3(vec, sum_rot, rot_axes[i]);
if (vec[0] == 0 &&
vec[1] == 0 &&
vec[2] == 0) {
vec[1] == 0 &&
vec[2] == 0) {
ortho_axes[num_ortho_axis] = i;
num_ortho_axis++;
}
@ -1237,7 +1237,7 @@ static int get_orthogonal_axis(int ortho_axes[],
}
static void get_proper_rotation(int prop_rot[3][3],
SPGCONST int rot[3][3])
SPGCONST int rot[3][3])
{
if (mat_get_determinant_i3(rot) == -1) {
mat_multiply_matrix_i3(prop_rot, inversion, rot);
@ -1247,7 +1247,7 @@ static void get_proper_rotation(int prop_rot[3][3],
}
static void set_transformation_matrix(int tmat[3][3],
const int axes[3])
const int axes[3])
{
int i, j, s[3];
@ -1306,4 +1306,3 @@ static void sort_axes(int axes[3])
axes[2] = axis;
}
}

View File

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

View File

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

View File

@ -1142,8 +1142,8 @@ static const int num_sitesym[] =
int ssmdb_get_coordinate(int rot[3][3],
double trans[3],
const int index)
double trans[3],
const int index)
{
int i, rot_enc, trans_enc;
int rows[3], trans_int[3];

View File

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

View File

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

View File

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

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__
#include "cell.h"
#include "mathfunc.h"
#include "spacegroup.h"
#include "symmetry.h"
#include "spacegroup.h"
typedef struct {
Cell *bravais;
Symmetry *symmetry;
int *wyckoffs;
int *equivalent_atoms;
int *std_mapping_to_primitive;
} ExactStructure;
ExactStructure *
ref_get_exact_structure_and_symmetry(const Cell * primitive,
const Cell * cell,
SPGCONST Spacegroup * spacegroup,
const int * mapping_table,
const double symprec);
void ref_free_exact_structure(ExactStructure *exstr);
Symmetry *
ref_get_refined_symmetry_operations(const Cell * cell,
const Cell * primitive,
SPGCONST Spacegroup * spacegroup,
const double symprec);
Cell * ref_get_Wyckoff_positions(int * wyckoffs,
int * equiv_atoms,
int * mapping_to_primitive,
const Cell * primitive,
const Cell * cell,
SPGCONST Spacegroup * spacegroup,
const Symmetry * symmetry,
const int * mapping_table,
const double symprec);
#endif

View File

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

View File

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

View File

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

View File

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

View File

@ -94,6 +94,7 @@ extension_spglib = Extension(
'c/spglib/arithmetic.c',
'c/spglib/cell.c',
'c/spglib/delaunay.c',
'c/spglib/determination.c',
'c/spglib/hall_symbol.c',
'c/spglib/kgrid.c',
'c/spglib/kpoint.c',
@ -186,5 +187,3 @@ if __name__ == '__main__':
provides=['phonopy'],
scripts=scripts_phonopy,
ext_modules=ext_modules_phonopy)