aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-07-20 19:08:33 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:34 +0100
commit93f5d444a533651154a7cf507f02c1eb40fad087 (patch)
tree23c9d2b78b27ffb2502524fb8797c54e278a41c6
parentc1103a3d7f0cdbc06f74c46fdcc02b06264aeb5e (diff)
More PG checking
-rw-r--r--src/symmetry.c27
-rw-r--r--src/symmetry.h1
-rw-r--r--tests/symmetry_check.c40
3 files changed, 58 insertions, 10 deletions
diff --git a/src/symmetry.c b/src/symmetry.c
index b0e430b5..6c290756 100644
--- a/src/symmetry.c
+++ b/src/symmetry.c
@@ -405,8 +405,9 @@ static SymOpList *make_4m()
static SymOpList *make_4()
{
SymOpList *new = new_symoplist();
- add_symop(new, v(0,1,0,0), v(1,0,0,0), v(0,0,0,1), 4); /* 4 */
- return NULL;
+ add_symop(new, v(0,-1,0,0), v(1,0,0,0), v(0,0,0,1), 4); /* 4 */
+ new->name = strdup("4");
+ return expand_ops(new);
}
@@ -673,6 +674,28 @@ void get_asymm(const SymOpList *ops,
}
+static int is_inversion(const struct sym_op *op)
+{
+ if ( (op->h[0]!=-1) || (op->h[1]!=0) || (op->h[2]!=0) ) return 0;
+ if ( (op->k[0]!=0) || (op->k[1]!=-1) || (op->k[2]!=0) ) return 0;
+ if ( (op->l[0]!=0) || (op->l[1]!=0) || (op->l[2]!=-1) ) return 0;
+ return 1;
+}
+
+
+int is_centrosymmetric(const SymOpList *s)
+{
+ int i, n;
+
+ n = num_ops(s);
+ for ( i=0; i<n; i++ ) {
+ if ( is_inversion(&s->ops[i]) ) return 1;
+ }
+
+ return 0;
+}
+
+
/**
* get_twins:
*
diff --git a/src/symmetry.h b/src/symmetry.h
index 45ffe318..4ecf11a4 100644
--- a/src/symmetry.h
+++ b/src/symmetry.h
@@ -48,6 +48,7 @@ extern void get_equiv(const SymOpList *ops, const SymOpMask *m, int idx,
signed int h, signed int k, signed int l,
signed int *he, signed int *ke, signed int *le);
+extern int is_centrosymmetric(const SymOpList *s);
extern SymOpList *get_twins(const SymOpList *source, const SymOpList *target);
#endif /* SYMMETRY_H */
diff --git a/tests/symmetry_check.c b/tests/symmetry_check.c
index bda6961e..b3d4cb34 100644
--- a/tests/symmetry_check.c
+++ b/tests/symmetry_check.c
@@ -22,10 +22,20 @@
#include "../src/utils.h"
-static void check_nequiv(const char *pg, int answer, int *fail)
+static const char *maybenot(int v)
+{
+ if ( v ) {
+ return "";
+ } else {
+ return " not";
+ }
+}
+
+
+static void check_pg_props(const char *pg, int answer, int centro, int *fail)
{
SymOpList *sym;
- int n;
+ int n, c;
//STATUS("**************************************** Testing '%s'\n", pg);
@@ -33,11 +43,18 @@ static void check_nequiv(const char *pg, int answer, int *fail)
n = num_equivs(sym, NULL);
if ( n != answer ) {
- ERROR("Number of equivalents in '%s' is %i (not %i)\n",
+ ERROR("Number of equivalents in '%s' is %i (not %i).\n",
pg, n, answer);
*fail = 1;
}
+ c = is_centrosymmetric(sym);
+ if ( c != centro ) {
+ ERROR("'%s' should%s be centrosymmetric, but is%s.\n",
+ pg, maybenot(centro), maybenot(c));
+ *fail = 1;
+ }
+
free_symoplist(sym);
}
@@ -46,11 +63,18 @@ int main(int argc, char *argv[])
{
int fail = 0;
- check_nequiv( "1", 1, &fail);
- check_nequiv( "-1", 2, &fail);
- check_nequiv( "2", 2, &fail);
- check_nequiv( "m", 2, &fail);
- check_nequiv("2/m", 4, &fail);
+ check_pg_props( "1", 1, 0, &fail);
+ check_pg_props( "-1", 2, 1, &fail);
+
+ check_pg_props( "2", 2, 0, &fail);
+ check_pg_props( "m", 2, 0, &fail);
+ check_pg_props("2/m", 4, 1, &fail);
+
+ check_pg_props("222", 4, 0, &fail);
+ check_pg_props("mm2", 4, 0, &fail);
+ check_pg_props("mmm", 8, 1, &fail);
+
+ check_pg_props( "4", 4, 0, &fail);
return fail;
}