diff options
Diffstat (limited to 'src/refinetest2d.c')
-rw-r--r-- | src/refinetest2d.c | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/src/refinetest2d.c b/src/refinetest2d.c index 5df7f19..49a0c6b 100644 --- a/src/refinetest2d.c +++ b/src/refinetest2d.c @@ -26,6 +26,64 @@ #include "control.h" #include "displaywindow.h" +static int check_cell(Basis *cell, Basis *cell_real) { + + int fail; + +// printf(" Calculated Actual\n"); +// printf("---------------------------\n"); +// printf("ax %+8f %+8f\n", cell->a.x/1e9, cell_real->a.x/1e9); +// printf("ay %+8f %+8f\n", cell->a.y/1e9, cell_real->a.y/1e9); +// printf("az %+8f %+8f\n", cell->a.z/1e9, cell_real->a.z/1e9); +// printf("bx %+8f %+8f\n", cell->b.x/1e9, cell_real->b.x/1e9); +// printf("by %+8f %+8f\n", cell->b.y/1e9, cell_real->b.y/1e9); +// printf("bz %+8f %+8f\n", cell->b.z/1e9, cell_real->b.z/1e9); +// printf("cx %+8f %+8f\n", cell->c.x/1e9, cell_real->c.x/1e9); +// printf("cy %+8f %+8f\n", cell->c.y/1e9, cell_real->c.y/1e9); +// printf("cz %+8f %+8f\n", cell->c.z/1e9, cell_real->c.z/1e9); + + fail = 0; + if ( fabs(cell->a.x - cell_real->a.x) > 0.01e9 ) { + fprintf(stderr, "refinetest3d: ax not determined correctly (got %8f, should be %8f)\n", cell->a.x/1e9, cell_real->a.x/1e9); + fail = 1; + } + if ( fabs(cell->a.y - cell_real->a.y) > 0.01e9 ) { + fprintf(stderr, "refinetest3d: ay not determined correctly (got %8f, should be %8f)\n", cell->a.y/1e9, cell_real->a.y/1e9); + fail = 1; + } +// if ( fabs(cell->a.z - cell_real->a.z) > 0.01e9 ) { +// fprintf(stderr, "refinetest3d: az not determined correctly (got %8f, should be %8f)\n", cell->a.z/1e9, cell_real->a.z/1e9); +// fail = 1; +// } + if ( fabs(cell->b.x - cell_real->b.x) > 0.01e9 ) { + fprintf(stderr, "refinetest3d: bx not determined correctly (got %8f, should be %8f)\n", cell->b.x/1e9, cell_real->b.x/1e9); + fail = 1; + } + if ( fabs(cell->b.y - cell_real->b.y) > 0.01e9 ) { + fprintf(stderr, "refinetest3d: by not determined correctly (got %8f, should be %8f)\n", cell->b.y/1e9, cell_real->b.y/1e9); + fail = 1; + } +// if ( fabs(cell->b.z - cell_real->b.z) > 0.01e9 ) { +// fprintf(stderr, "refinetest3d: bz not determined correctly (got %8f, should be %8f)\n", cell->b.z/1e9, cell_real->b.z/1e9); +// fail = 1; +// } +// if ( fabs(cell->c.x - cell_real->c.x) > 0.01e9 ) { +// fprintf(stderr, "refinetest3d: cx not determined correctly (got %8f, should be %8f)\n", cell->c.x/1e9, cell_real->c.x/1e9); +// fail = 1; +// } +// if ( fabs(cell->c.y - cell_real->c.y) > 0.01e9 ) { +// fprintf(stderr, "refinetest3d: cy not determined correctly (got %8f, should be %8f)\n", cell->c.y/1e9, cell_real->c.y/1e9); +// fail = 1; +// } +// if ( fabs(cell->c.z - cell_real->c.z) > 0.01e9 ) { +// fprintf(stderr, "refinetest3d: cz not determined correctly (got %8f, should be %8f)\n", cell->c.z/1e9, cell_real->c.z/1e9); +// fail = 1; +// } + + return fail; + +} + int main(int argc, char *argv[]) { ControlContext *ctx; @@ -59,9 +117,10 @@ int main(int argc, char *argv[]) { /* The "model" cell to be refined */ ctx->cell = malloc(sizeof(Basis)); - ctx->cell->a.x = 5.2e9; ctx->cell->a.y = 0.1e9; ctx->cell->a.z = 0.0e9; - ctx->cell->b.x = 0.2e9; ctx->cell->b.y = 4.8e9; ctx->cell->b.z = 0.0e9; - ctx->cell->c.x = 0.0e9; ctx->cell->c.y = 0.0e9; ctx->cell->c.z = 5.0e9; + ctx->cell->a.x = 5.2e9; ctx->cell->a.y = 0.1e9; ctx->cell->a.z = 0.1e9; + ctx->cell->b.x = 0.2e9; ctx->cell->b.y = 4.8e9; ctx->cell->b.z = 0.1e9; + ctx->cell->c.x = 0.1e9; ctx->cell->c.y = 0.1e9; ctx->cell->c.z = 5.3e9; + ctx->cell_lattice = reflection_list_from_cell(ctx->cell); ctx->cell_lattice = reflection_list_from_cell(ctx->cell); ctx->images->images[0].rflist = reproject_get_reflections(&ctx->images->images[0], ctx->cell_lattice); reproject_partner_features(ctx->images->images[0].rflist, &ctx->images->images[0]); @@ -71,25 +130,7 @@ int main(int argc, char *argv[]) { reflection_list_from_new_cell(ctx->cell_lattice, ctx->cell); ctx->images->images[0].rflist = reproject_get_reflections(&ctx->images->images[0], ctx->cell_lattice); - fail = 0; - if ( fabs(ctx->cell->a.x - cell_real->a.x) > 0.01e9 ) { - fprintf(stderr, "refinetest2d: ax not determined correctly\n"); - fail = 1; - } - if ( fabs(ctx->cell->a.y - cell_real->a.y) > 0.01e9 ) { - fprintf(stderr, "refinetest2d: ay not determined correctly\n"); - fail = 1; - } - if ( fabs(ctx->cell->b.x - cell_real->b.x) > 0.01e9 ) { - fprintf(stderr, "refinetest2d: bx not determined correctly\n"); - fail = 1; - } - if ( fabs(ctx->cell->b.y - cell_real->b.y) > 0.01e9 ) { - fprintf(stderr, "refinetest2d: by not determined correctly\n"); - fail = 1; - } - /* az, bz, cx, cy and cz are unconstrained hence will 'float' to meaningless values. - * This is ok. */ + fail = check_cell(ctx->cell, cell_real); free(ctx); |