From 3c38652002e2793e5e6fc8115290a701fae9bb48 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 12 Jul 2010 17:25:42 +0200 Subject: Add coset decomposition and twinning stuff --- src/symmetry.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/symmetry.h | 6 ++++ 2 files changed, 113 insertions(+) diff --git a/src/symmetry.c b/src/symmetry.c index 6f3ce675..e0b92335 100644 --- a/src/symmetry.c +++ b/src/symmetry.c @@ -216,3 +216,110 @@ void get_asymm(signed int h, signed int k, signed int l, ERROR("No match found in %s for %i %i %i\n", sym, h, k, l); abort(); } + + +static const char *get_holohedral(const char *sym) +{ + /* Triclinic */ + if ( strcmp(sym, "1") == 0 ) return "-1"; + if ( strcmp(sym, "1") == 0 ) return "-1"; + + /* Hexagonal */ + if ( strcmp(sym, "6") == 0 ) return "6/m"; + if ( strcmp(sym, "6/m") == 0 ) return "6/mmm"; + if ( strcmp(sym, "6/mmm") == 0 ) return "6/mmm"; + + /* TODO: Add more groups here */ + + ERROR("Couldn't find holohedral point group for '%s'\n", sym); + abort(); +} + + +/* This is kind of like a "numerical" left coset decomposition. + * Given a reflection index and a point group, it returns the "idx-th" + * twinning possibility for the reflection. It returns "idx" if + * successful. To just count the number of possibilities, set idx=-1. + * + * The sequence of operators producing each possibility is guaranteed to + * be the same for any choice of indices given the same point group. */ +static int coset_decomp(signed int hs, signed int ks, signed int ls, + signed int *hp, signed int *kp, signed int *lp, + const char *mero, signed int idx) +{ + const char *holo = get_holohedral(mero); + int n_mero, n_holo; + int i; + signed int n_twins = 1; + signed int h, k, l; + ReflItemList *twins; + + twins = new_items(); + + if ( idx == 0 ) { + /* Twin index zero is always the original orientation */ + *hp = hs; *kp = ks; *lp = ls; + return 0; + } + + get_asymm(hs, ks, ls, &h, &k, &l, mero); + + /* How many equivalents in the holohedral point group are not + * equivalents according to the (possibly) merohedral group? */ + n_holo = num_equivs(h, k, l, holo); + n_mero = num_equivs(h, k, l, mero); + + for ( i=0; i