aboutsummaryrefslogtreecommitdiff
path: root/src/cell_tool.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-02-28 10:53:43 +0100
committerThomas White <taw@physics.org>2019-03-11 16:49:37 +0100
commit3e850c6c2ed2a3dbc0fe0be27d36c0d1e6b57614 (patch)
treed5b9f2c02a9b71ac909bde1579d764441fdc79f0 /src/cell_tool.c
parent2dad9da2661389cf5c34a49e933dab20bd6d943c (diff)
New way of doing cell comparisons, similar to match_cell()
Diffstat (limited to 'src/cell_tool.c')
-rw-r--r--src/cell_tool.c80
1 files changed, 7 insertions, 73 deletions
diff --git a/src/cell_tool.c b/src/cell_tool.c
index 03c58f5e..d6c5b6cd 100644
--- a/src/cell_tool.c
+++ b/src/cell_tool.c
@@ -72,14 +72,9 @@ static void show_help(const char *s)
static int comparecells(UnitCell *cell, const char *comparecell,
double ltl, double atl)
{
- signed int i[9];
- int b[9];
- const int maxorder = 2;
UnitCell *cell2;
RationalMatrix *m;
- STATUS("Comparing with: %s\n", comparecell);
-
cell2 = load_cell_from_file(comparecell);
if ( cell2 == NULL ) {
ERROR("Failed to load unit cell from '%s'\n", comparecell);
@@ -92,75 +87,14 @@ static int comparecells(UnitCell *cell, const char *comparecell,
STATUS("------------------> The reference unit cell:\n");
cell_print(cell2);
- STATUS("Comparing cells up to %ix each lattice length.\n", maxorder);
- STATUS("Reciprocal axis length tolerance %f %%\n", ltl);
- STATUS("Reciprocal angle tolerance %f degrees\n", rad2deg(atl));
- STATUS("This will take about 30 seconds. Please wait...\n");
-
- m = rtnl_mtx_new(3, 3);
- for ( i[0]=-maxorder; i[0]<=+maxorder; i[0]++ ) {
- for ( i[1]=-maxorder; i[1]<=+maxorder; i[1]++ ) {
- for ( i[2]=-maxorder; i[2]<=+maxorder; i[2]++ ) {
- for ( i[3]=-maxorder; i[3]<=+maxorder; i[3]++ ) {
- for ( i[4]=-maxorder; i[4]<=+maxorder; i[4]++ ) {
- for ( i[5]=-maxorder; i[5]<=+maxorder; i[5]++ ) {
- for ( i[6]=-maxorder; i[6]<=+maxorder; i[6]++ ) {
- for ( i[7]=-maxorder; i[7]<=+maxorder; i[7]++ ) {
- for ( i[8]=-maxorder; i[8]<=+maxorder; i[8]++ ) {
- for ( b[0]=0; b[0]<=1; b[0]++ ) {
- for ( b[1]=0; b[1]<=1; b[1]++ ) {
- for ( b[2]=0; b[2]<=1; b[2]++ ) {
- for ( b[3]=0; b[3]<=1; b[3]++ ) {
- for ( b[4]=0; b[4]<=1; b[4]++ ) {
- for ( b[5]=0; b[5]<=1; b[5]++ ) {
- for ( b[6]=0; b[6]<=1; b[6]++ ) {
- for ( b[7]=0; b[7]<=1; b[7]++ ) {
- for ( b[8]=0; b[8]<=1; b[8]++ ) {
-
- UnitCell *nc;
- int j, k;
- int l = 0;
-
- for ( j=0; j<3; j++ ) {
- for ( k=0; k<3; k++ ) {
- if ( b[l] || i[l]==1 || i[l]==-1 ) {
- rtnl_mtx_set(m, j, k, rtnl(i[l], 1));
- } else {
- rtnl_mtx_set(m, j, k, rtnl(1, i[l]));
- }
- l++;
- }
- }
-
- nc = cell_transform_rational(cell, m);
-
- if ( compare_cell_parameters(cell2, nc, ltl, atl) ) {
- STATUS("-----------------------------------------------"
- "-------------------------------------------\n");
- cell_print(nc);
- rtnl_mtx_print(m);
- }
-
- cell_free(nc);
-
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
+ STATUS("------------------> The comparison results:\n");
+ if ( !compare_reindexed_cell_parameters(cell, cell2, ltl, atl, &m) ) {
+ STATUS("No relationship found between lattices.\n");
+ return 0;
+ } else {
+ STATUS("Relationship found:\n");
}
+
rtnl_mtx_free(m);
return 0;