From 75e043b195c166818dddd1d8a6f6771f3a1ce0ee Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 3 Oct 2008 16:07:32 +0100 Subject: Tidy up confidence stuff --- src/refine.c | 60 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/src/refine.c b/src/refine.c index e1f4939..a264ad6 100644 --- a/src/refine.c +++ b/src/refine.c @@ -188,12 +188,19 @@ static void refine_cell_delta(Basis *devcell_try, int comp) { } -static void refine_test_confidence(Deviation *d, int nf) { +static void refine_show_cell(Basis cell) { + + printf("a: %+10.8f %+10.8f %+10.8f\n", cell.a.x/DISPFACTOR, cell.a.y/DISPFACTOR, cell.a.z/DISPFACTOR); + printf("b: %+10.8f %+10.8f %+10.8f\n", cell.b.x/DISPFACTOR, cell.b.y/DISPFACTOR, cell.b.z/DISPFACTOR); + printf("c: %+10.8f %+10.8f %+10.8f\n", cell.c.x/DISPFACTOR, cell.c.y/DISPFACTOR, cell.c.z/DISPFACTOR); + +} + +static Basis refine_test_confidence(Deviation *d, int nf) { Basis *devcell; double val, new_val; - - printf("Testing confidence...\n"); + Basis confidence; devcell = malloc(sizeof(Basis)); devcell->a.x = 0.0e9; devcell->b.x = 0.0e9; devcell->c.x = 0.0e9; @@ -203,48 +210,50 @@ static void refine_test_confidence(Deviation *d, int nf) { devcell->a.x = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("ax: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.a.x = new_val-val; devcell->a.x = 0.0; devcell->a.y = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("ay: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.a.y = new_val-val; devcell->a.y = 0.0; devcell->a.z = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("az: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.a.z = new_val-val; devcell->a.z = 0.0; devcell->b.x = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("bx: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.b.x = new_val-val; devcell->b.x = 0.0; devcell->b.y = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("by: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.b.y = new_val-val; devcell->b.y = 0.0; devcell->b.z = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("bz: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.b.z = new_val-val; devcell->b.z = 0.0; devcell->c.x = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("cx: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.c.x = new_val-val; devcell->c.x = 0.0; devcell->c.y = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("cy: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.c.y = new_val-val; devcell->c.y = 0.0; devcell->c.z = 1.0e9; new_val = refine_mean_dev(d, nf, devcell, 0); - printf("cz: %10.8f\n", (new_val - val)/DISPFACTOR); + confidence.c.z = new_val-val; devcell->c.z = 0.0; + + return confidence; } @@ -258,6 +267,8 @@ double refine_do_cell(ControlContext *ctx) { double mean_dev; double mean_dev_try; int it; + Basis conf; + double conf_threshold; if ( !ctx->cell_lattice ) { displaywindow_error("No reciprocal unit cell has been found.", ctx->dw); @@ -365,7 +376,8 @@ double refine_do_cell(ControlContext *ctx) { #endif /* REFINE_DEBUG */ /* Test confidence */ - refine_test_confidence(d, nf); + printf("Testing confidence...\n"); + conf = refine_test_confidence(d, nf); /* Determine direction of steepest gradient */ devcell_try = malloc(sizeof(Basis)); @@ -420,18 +432,22 @@ double refine_do_cell(ControlContext *ctx) { #if REFINE_DEBUG printf("Final mean dev (%5i iterations) = %13.8f nm^1\n", it, mean_dev/DISPFACTOR); printf("Final cell deviation:\n"); - printf("a = %+10.8f %+10.8f %+10.8f nm^-1\n", devcell->a.x/DISPFACTOR, devcell->a.y/DISPFACTOR, - devcell->a.z/DISPFACTOR); - printf("b = %+10.8f %+10.8f %+10.8f nm^-1\n", devcell->b.x/DISPFACTOR, devcell->b.y/DISPFACTOR, - devcell->b.z/DISPFACTOR); - printf("c = %+10.8f %+10.8f %+10.8f nm^-1\n", devcell->c.x/DISPFACTOR, devcell->c.y/DISPFACTOR, - devcell->c.z/DISPFACTOR); + refine_show_cell(*devcell); + printf("Confidence:\n"); + refine_show_cell(conf); #endif /* REFINE_DEBUG */ /* Apply the final values to the cell */ - ctx->cell->a.x += devcell->a.x; ctx->cell->b.x += devcell->b.x; ctx->cell->c.x += devcell->c.x; - ctx->cell->a.y += devcell->a.y; ctx->cell->b.y += devcell->b.y; ctx->cell->c.y += devcell->c.y; - ctx->cell->a.z += devcell->a.z; ctx->cell->b.z += devcell->b.z; ctx->cell->c.z += devcell->c.z; + conf_threshold = 2.5; + if ( conf.a.x > conf_threshold ) ctx->cell->a.x += devcell->a.x; + if ( conf.a.y > conf_threshold ) ctx->cell->a.y += devcell->a.y; + if ( conf.a.z > conf_threshold ) ctx->cell->a.z += devcell->a.z; + if ( conf.b.x > conf_threshold ) ctx->cell->b.x += devcell->b.x; + if ( conf.b.y > conf_threshold ) ctx->cell->b.y += devcell->b.y; + if ( conf.b.z > conf_threshold ) ctx->cell->b.z += devcell->b.z; + if ( conf.c.x > conf_threshold ) ctx->cell->c.x += devcell->c.x; + if ( conf.c.y > conf_threshold ) ctx->cell->c.y += devcell->c.y; + if ( conf.c.z > conf_threshold ) ctx->cell->c.z += devcell->c.z; ctx->images->images[ctx->dw->cur_image].rflist = NULL; reproject_lattice_changed(ctx); -- cgit v1.2.3