diff options
author | Thomas White <taw@physics.org> | 2018-02-16 15:16:25 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-02-27 17:12:42 +0100 |
commit | 98c233a97459eba3170901d186a07d16f6ed3eb2 (patch) | |
tree | 09ec81c821f5e0232830b428624c40a0ea28d8a0 /src/post-refinement.c | |
parent | 6ac71ea6671b9bf4b5c8978603c84d4d49775d38 (diff) |
Save multiple grid maps
Diffstat (limited to 'src/post-refinement.c')
-rw-r--r-- | src/post-refinement.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c index 0966d454..92059987 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -613,19 +613,30 @@ static gsl_multimin_fminimizer *setup_minimiser(Crystal *cr, const RefList *full } -void write_gridscan(Crystal *cr, const RefList *full, - signed int cycle, int serial) +static void write_grid(Crystal *cr, const RefList *full, + signed int cycle, int serial, + const enum gparam par1, const enum gparam par2, + const char *name) { FILE *fh; char fn[64]; char ins[5]; - const enum gparam par1 = GPARAM_ANG1; - const enum gparam par2 = GPARAM_WAVELENGTH; gsl_multimin_fminimizer *min; struct rf_priv priv; + int idx1, idx2; + int i; min = setup_minimiser(cr, full, 0, serial, &priv); + idx1 = 99; + idx2 = 99; + for ( i=0; i<priv.f.n; i++ ) { + if ( priv.rv[i] == par1 ) idx1 = i; + if ( priv.rv[i] == par2 ) idx2 = i; + } + assert(idx1 != 99); + assert(idx2 != 99); + if ( cycle >= 0 ) { snprintf(ins, 4, "%i", cycle); } else { @@ -633,7 +644,8 @@ void write_gridscan(Crystal *cr, const RefList *full, ins[1] = '\0'; } - snprintf(fn, 63, "pr-logs/grid-crystal%i-cycle%s.dat", serial, ins); + snprintf(fn, 63, "pr-logs/grid-crystal%i-cycle%s-%s.dat", + serial, ins, name); fh = fopen(fn, "w"); if ( fh != NULL ) { double v1, v2; @@ -649,8 +661,8 @@ void write_gridscan(Crystal *cr, const RefList *full, int first=1; for ( v1=-5.0; v1<=5.0; v1+=0.2 ) { double res; - gsl_vector_set(min->x, 0, v1); - gsl_vector_set(min->x, 3, v2); + gsl_vector_set(min->x, idx1, v1); + gsl_vector_set(min->x, idx2, v2); res = residual_f(min->x, &priv); if ( !first ) fprintf(fh, " "); first = 0; @@ -668,6 +680,18 @@ void write_gridscan(Crystal *cr, const RefList *full, } +void write_gridscan(Crystal *cr, const RefList *full, + signed int cycle, int serial) +{ + write_grid(cr, full, cycle, serial, + GPARAM_ANG1, GPARAM_ANG2, "ang1-ang2"); + write_grid(cr, full, cycle, serial, + GPARAM_ANG1, GPARAM_WAVELENGTH, "ang1-wave"); + write_grid(cr, full, cycle, serial, + GPARAM_R, GPARAM_WAVELENGTH, "R-wave"); +} + + static void do_pr_refine(Crystal *cr, const RefList *full, PartialityModel pmodel, int verbose, int serial, int cycle) |