diff options
author | Thomas White <taw@physics.org> | 2010-06-29 17:55:12 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:26:51 +0100 |
commit | da7591b21895dd274ffffac916f71bd84b9cd783 (patch) | |
tree | b32cbea9b482a7ad4ce16e0eb30cc0b9f230611e /src/symmetry.c | |
parent | 15cf6053dbb67c8d44c588add3a40fed8014f611 (diff) |
Make symmetry implementation more flexible
Diffstat (limited to 'src/symmetry.c')
-rw-r--r-- | src/symmetry.c | 90 |
1 files changed, 61 insertions, 29 deletions
diff --git a/src/symmetry.c b/src/symmetry.c index 913e887f..bedc146c 100644 --- a/src/symmetry.c +++ b/src/symmetry.c @@ -23,8 +23,9 @@ /* Conditions for a reflection to be in the asymmetric unit cell */ #define COND_1(h, k, l) (1) -#define COND_6MMM(h, k, i, l) ( (h>=0) && (k>=0) && (l>=0) && ((h>k)||((h==0)&&(k==0))) ) - +#define COND_6MMM(h, k, i, l) ( (h>=0) && (k>=0) && (l>=0) \ + && ((h>k)||((h==0)&&(k==0))) ) +/* TODO: Add more groups here */ /* Macros for checking the above conditions and returning if satisfied */ #define CHECK_COND_FOURIDX(h, k, i, l, cond) \ @@ -46,6 +47,55 @@ abort(); +/* FIXME: Should take into account special indices + * e.g. l==0 has fewer equivalent reflections */ +static int num_equivs4(signed int h, signed int k, signed int i, signed int l, + const char *sym) +{ + if ( strcmp(sym, "6/mmm") == 0 ) return 24; + /* TODO: Add more groups here */ + + return 1; +} + + +static void get_equiv4(signed int h, signed int k, signed int i, signed int l, + signed int *he, signed int *ke, signed int *ie, + signed int *le, const char *sym, int idx) +{ + if ( strcmp(sym, "6/mmm") == 0 ) { + switch ( idx ) { + case 0 : *he = h; *ke = k; *ie = i; *le = l; return; + case 1 : *he = h; *ke = i; *ie = k; *le = l; return; + case 2 : *he = k; *ke = h; *ie = i; *le = l; return; + case 3 : *he = k; *ke = i; *ie = h; *le = l; return; + case 4 : *he = i; *ke = h; *ie = k; *le = l; return; + case 5 : *he = i; *ke = k; *ie = h; *le = l; return; + case 6 : *he = h; *ke = k; *ie = i; *le = -l; return; + case 7 : *he = h; *ke = i; *ie = k; *le = -l; return; + case 8 : *he = k; *ke = h; *ie = i; *le = -l; return; + case 9 : *he = k; *ke = i; *ie = h; *le = -l; return; + case 10 : *he = i; *ke = h; *ie = k; *le = -l; return; + case 11 : *he = i; *ke = k; *ie = h; *le = -l; return; + case 12 : *he = -h; *ke = -k; *ie = -i; *le = l; return; + case 13 : *he = -h; *ke = -i; *ie = -k; *le = l; return; + case 14 : *he = -k; *ke = -h; *ie = -i; *le = l; return; + case 15 : *he = -k; *ke = -i; *ie = -h; *le = l; return; + case 16 : *he = -i; *ke = -h; *ie = -k; *le = l; return; + case 17 : *he = -i; *ke = -k; *ie = -h; *le = l; return; + case 18 : *he = -h; *ke = -k; *ie = -i; *le = -l; return; + case 19 : *he = -h; *ke = -i; *ie = -k; *le = -l; return; + case 20 : *he = -k; *ke = -h; *ie = -i; *le = -l; return; + case 21 : *he = -k; *ke = -i; *ie = -h; *le = -l; return; + case 22 : *he = -i; *ke = -h; *ie = -k; *le = -l; return; + case 23 : *he = -i; *ke = -k; *ie = -h; *le = -l; return; + } + } + + *he = h; *ke = k; *ie = i; *le = l; +} + + void get_asymm(signed int h, signed int k, signed int l, signed int *hp, signed int *kp, signed int *lp, const char *sym) @@ -58,39 +108,21 @@ void get_asymm(signed int h, signed int k, signed int l, if ( strcmp(sym, "6/mmm") == 0 ) { const signed int i = h+k; + int nequiv = num_equivs4(h, k, i, l, sym); + int p; - CHECK_COND_FOURIDX(h, k, i, l, 6MMM); - CHECK_COND_FOURIDX(h, i, k, l, 6MMM); - CHECK_COND_FOURIDX(k, h, i, l, 6MMM); - CHECK_COND_FOURIDX(k, i, h, l, 6MMM); - CHECK_COND_FOURIDX(i, h, k, l, 6MMM); - CHECK_COND_FOURIDX(i, k, h, l, 6MMM); - - CHECK_COND_FOURIDX(h, k, i, -l, 6MMM); - CHECK_COND_FOURIDX(h, i, k, -l, 6MMM); - CHECK_COND_FOURIDX(k, h, i, -l, 6MMM); - CHECK_COND_FOURIDX(k, i, h, -l, 6MMM); - CHECK_COND_FOURIDX(i, h, k, -l, 6MMM); - CHECK_COND_FOURIDX(i, k, h, -l, 6MMM); - - CHECK_COND_FOURIDX(-h, -k, -i, l, 6MMM); - CHECK_COND_FOURIDX(-h, -i, -k, l, 6MMM); - CHECK_COND_FOURIDX(-k, -h, -i, l, 6MMM); - CHECK_COND_FOURIDX(-k, -i, -h, l, 6MMM); - CHECK_COND_FOURIDX(-i, -h, -k, l, 6MMM); - CHECK_COND_FOURIDX(-i, -k, -h, l, 6MMM); - - CHECK_COND_FOURIDX(-h, -k, -i, -l, 6MMM); - CHECK_COND_FOURIDX(-h, -i, -k, -l, 6MMM); - CHECK_COND_FOURIDX(-k, -h, -i, -l, 6MMM); - CHECK_COND_FOURIDX(-k, -i, -h, -l, 6MMM); - CHECK_COND_FOURIDX(-i, -h, -k, -l, 6MMM); - CHECK_COND_FOURIDX(-i, -k, -h, -l, 6MMM); + for ( p=0; p<nequiv; p++ ) { + signed int he, ke, ie, le; + get_equiv4(h, k, i, l, &he, &ke, &ie, &le, sym, p); + CHECK_COND_FOURIDX(he, ke, ie, le, 6MMM); + } SYM_ABORT; /* Should never reach here */ } + /* TODO: Add more groups here */ + ERROR("Unknown point group '%s'\n", sym); abort(); } |