diff options
author | Thomas White <taw@physics.org> | 2011-07-25 14:37:52 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:34 +0100 |
commit | b7184faf532b11afc567557903c113cbe7cbc63a (patch) | |
tree | 55ff1c806085e14819ebf02c53570a2cd88ec89e /tests | |
parent | a10ce212b7496bc64bf57616fe4736774f198b5f (diff) |
Finish symmetry tests and update table one last time
Diffstat (limited to 'tests')
-rw-r--r-- | tests/symmetry_check.c | 168 |
1 files changed, 153 insertions, 15 deletions
diff --git a/tests/symmetry_check.c b/tests/symmetry_check.c index a83b0d53..2e47bf83 100644 --- a/tests/symmetry_check.c +++ b/tests/symmetry_check.c @@ -17,11 +17,72 @@ #include <stdlib.h> #include <stdio.h> +#include <stdarg.h> #include "../src/symmetry.h" #include "../src/utils.h" +static void find_all_ambiguities(const char *first, ...) +{ + va_list vp; + int i; + const char *arg; + SymOpList *test[32]; + int n = 0; + + test[n++] = get_pointgroup(first); + + va_start(vp, first); + + + do { + + arg = va_arg(vp, const char *); + if ( arg != NULL ) { + test[n++] = get_pointgroup(arg); + } + + } while ( arg != NULL ); + + for ( i=0; i<n; i++ ) { + + SymOpList *holo; + int j; + + holo = test[i]; + STATUS("%7s :", symmetry_name(holo)); + for ( j=0; j<n; j++ ) { + + SymOpList *twins; + + if ( i == j ) continue; + + if ( !is_subgroup(holo, test[j]) ) continue; + + twins = get_ambiguities(holo, test[j]); + if ( twins == NULL ) continue; + + if ( num_equivs(twins, NULL) == 1 ) { + free_symoplist(twins); + continue; + } + + if ( num_equivs(twins, NULL) == 2 ) { + STATUS(" %5s ", symmetry_name(test[j])); + } else { + STATUS(" %5s*", symmetry_name(test[j])); + } + + } + STATUS("\n"); + + } + + STATUS("\n"); +} + + static const char *maybenot(int v) { if ( v ) { @@ -66,11 +127,12 @@ static void check_pg_props(const char *pg, int answer, int centro, int *fail) static void check_subgroup(const char *ssource, const char *starget, - int *fail) + int should_be_subgroup, int should_be_ambiguity, + int n_exp, int *fail) { SymOpList *source; SymOpList *target; - SymOpList *twins; + int sub; source = get_pointgroup(ssource); target = get_pointgroup(starget); @@ -79,8 +141,56 @@ static void check_subgroup(const char *ssource, const char *starget, return; } - twins = get_ambiguities(source, target); - describe_symmetry(twins); + sub = is_subgroup(source, target); + if ( sub != should_be_subgroup ) { + ERROR("'%s' should%s be a subgroup of '%s', but is%s.\n", + starget, maybenot(should_be_subgroup), + ssource, maybenot(sub)); + *fail = 1; + return; + } + + if ( should_be_subgroup ) { + + SymOpList *twins; + int nf; + int amb = 1; + + twins = get_ambiguities(source, target); + if ( twins == NULL ) amb = 0; + if ( amb != should_be_ambiguity ) { + ERROR("'%s' should%s be a rotational subgroup of '%s'" + " but is%s.\n", + starget, maybenot(should_be_ambiguity), + ssource, maybenot(amb)); + *fail = 1; + return; + } + + if ( amb ) { + + describe_symmetry(twins); + nf = num_equivs(twins, NULL); + if ( nf != n_exp ) { + ERROR("Expected %i operations, found %i\n", + n_exp, nf); + *fail = 1; + return; + } + + } else { + + STATUS("%15s : subgroup of %s, but no ambiguity without" + " inversion or mirroring\n", starget, ssource); + + + } + + } else { + + STATUS("%15s : not a subgroup of %s\n", starget, ssource); + + } free_symoplist(target); free_symoplist(source); @@ -145,20 +255,48 @@ int main(int argc, char *argv[]) check_pg_props( "23", 12, 0, &fail); check_pg_props( "m-3", 24, 1, &fail); check_pg_props( "432", 24, 0, &fail); - check_pg_props( "-432", 24, 0, &fail); + check_pg_props( "-43m", 24, 0, &fail); check_pg_props( "m-3m", 48, 1, &fail); STATUS("\n"); - check_subgroup("2/m", "m", &fail); - check_subgroup("mmm", "mm2", &fail); - check_subgroup("-4m2", "-4", &fail); - check_subgroup("-42m", "-4", &fail); - check_subgroup("-3m1_H", "-3_H", &fail); - check_subgroup("-31m_H", "-3_H", &fail); - check_subgroup("6/mmm", "-3_H", &fail); - check_subgroup("-432", "m-3m", &fail); - check_subgroup("m-3", "m-3m", &fail); - check_subgroup("23", "432", &fail); + /* Check some easy subgroups */ + check_subgroup("2/m", "m", 1, 1, 2, &fail); + check_subgroup("mmm", "mm2", 1, 1, 2, &fail); + check_subgroup("-4m2", "-4", 1, 1, 2, &fail); + check_subgroup("-42m", "-4", 1, 1, 2, &fail); + check_subgroup("-3m1_H", "-3_H", 1, 1, 2, &fail); + check_subgroup("-31m_H", "-3_H", 1, 1, 2, &fail); + check_subgroup("m-3m", "-43m", 1, 1, 2, &fail); + check_subgroup("m-3m", "m-3", 1, 1, 2, &fail); + check_subgroup("432", "23", 1, 1, 2, &fail); + check_subgroup("6/m", "-3_H", 1, 1, 2, &fail); + check_subgroup("4/m", "-4", 1, 1, 2, &fail); + + /* Tetartohedral */ + check_subgroup("6/mmm", "-3_H", 1, 1, 4, &fail); + + /* Check some things that are valid subgroups, but no valid ambiguities + * exist because inversions and mirrors are not allowed */ + check_subgroup("-1", "1", 1, 0, -1, &fail); + check_subgroup("4/mmm", "4", 1, 0, -1, &fail); + check_subgroup("m-3m", "23", 1, 0, -1, &fail); + + /* Check some invalid combinations */ + check_subgroup("432", "-43m", 0, 0, -1, &fail); + check_subgroup("432", "m-3", 0, 0, -1, &fail); + + /* Derive all merohedral ambiguities */ + STATUS("\nMerohedral ambiguities:\n\n"); + find_all_ambiguities("1", "-1", NULL); + find_all_ambiguities("2", "m", "2/m", NULL); + find_all_ambiguities("mm2", "mmm", "222", NULL); + find_all_ambiguities("4", "-4", "-42m", "-4m2", "4mm", + "4/m", "422", "4/mmm", NULL); + find_all_ambiguities("3_R", "32_R", "-3_R", "3m_R", "-3m_R", NULL); + find_all_ambiguities("6", "3_H", "312_H", "321_H", "622", "-3_H", + "3m1_H", "-6", "31m_H", "-3m1_H", "-6m2", + "-62m", "-31m_H", "6/mmm", "6/m", "6mm", NULL); + find_all_ambiguities("23", "432", "-43m", "m-3", "m-3m", NULL); return fail; } |