From 930ac8c40b7d721291f06759bb35cd93e1e172f9 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 17 Jul 2019 11:21:30 +0200 Subject: partialator: Allow refinement of any partiality model --- src/partialator.c | 12 ++++++++---- src/post-refinement.c | 30 +++++++++++++++++++----------- src/post-refinement.h | 3 ++- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/partialator.c b/src/partialator.c index de7eeb4b..5543b041 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -847,6 +847,7 @@ struct log_qargs int n_crystals; RefList *full; int scaleflags; + PartialityModel pmodel; int n_done; }; @@ -856,6 +857,7 @@ struct log_args Crystal *cr; RefList *full; int scaleflags; + PartialityModel pmodel; int iter; int cnum; }; @@ -876,6 +878,7 @@ static void *get_log_task(void *vp) task->iter = qargs->iter; task->cnum = qargs->next; task->scaleflags = qargs->scaleflags; + task->pmodel = qargs->pmodel; qargs->next += 20; return task; @@ -887,7 +890,7 @@ static void write_logs(void *vp, int cookie) struct log_args *args = vp; write_specgraph(args->cr, args->full, args->iter, args->cnum); write_gridscan(args->cr, args->full, args->iter, args->cnum, - args->scaleflags); + args->scaleflags, args->pmodel); write_test_logs(args->cr, args->full, args->iter, args->cnum); } @@ -904,7 +907,7 @@ static void done_log(void *vqargs, void *vp) static void write_logs_parallel(Crystal **crystals, int n_crystals, RefList *full, int iter, int n_threads, - int scaleflags) + int scaleflags, PartialityModel pmodel) { struct log_qargs qargs; @@ -915,6 +918,7 @@ static void write_logs_parallel(Crystal **crystals, int n_crystals, qargs.n_done = 0; qargs.n_crystals = n_crystals; qargs.scaleflags = scaleflags; + qargs.pmodel = pmodel; run_threads(n_threads, write_logs, get_log_task, done_log, &qargs, n_crystals/20, 0, 0, 0); @@ -1497,7 +1501,7 @@ int main(int argc, char *argv[]) if ( do_write_logs ) { write_pgraph(full, crystals, n_crystals, 0, ""); write_logs_parallel(crystals, n_crystals, full, 0, nthreads, - scaleflags); + scaleflags, pmodel); } /* Iterate */ @@ -1580,7 +1584,7 @@ int main(int argc, char *argv[]) if ( do_write_logs ) { write_pgraph(full, crystals, n_crystals, -1, ""); write_logs_parallel(crystals, n_crystals, full, -1, nthreads, - scaleflags); + scaleflags, pmodel); } /* Output results */ diff --git a/src/post-refinement.c b/src/post-refinement.c index f98d56fd..dde81716 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -60,6 +60,7 @@ struct rf_priv const RefList *full; int serial; int scaleflags; + PartialityModel pmodel; Crystal *cr_tgt; /**< Crystal to use for testing modifications */ struct image image_tgt; /**< Image structure to go with cr_tgt */ @@ -194,7 +195,7 @@ static double calc_residual(struct rf_priv *pv, struct rf_alteration alter, } update_predictions(pv->cr_tgt); - calculate_partialities(pv->cr_tgt, PMODEL_XSPHERE); + calculate_partialities(pv->cr_tgt, pv->pmodel); return residual(pv->cr_tgt, pv->full, free, NULL, NULL); @@ -264,7 +265,8 @@ static void reindex_cell(UnitCell *cell, SymOpList *amb, int idx) static void try_reindex(Crystal *crin, const RefList *full, - SymOpList *sym, SymOpList *amb, int scaleflags) + SymOpList *sym, SymOpList *amb, int scaleflags, + PartialityModel pmodel) { RefList *list; Crystal *cr; @@ -293,7 +295,7 @@ static void try_reindex(Crystal *crin, const RefList *full, crystal_set_reflections(cr, list); update_predictions(cr); - calculate_partialities(cr, PMODEL_XSPHERE); + calculate_partialities(cr, pmodel); if ( scale_one_crystal(cr, full, scaleflags) ) return; residual_flipped = residual(cr, full, 0, NULL, NULL); @@ -442,7 +444,8 @@ void write_specgraph(Crystal *crystal, const RefList *full, static void write_angle_grid(Crystal *cr, const RefList *full, - signed int cycle, int serial, int scaleflags) + signed int cycle, int serial, int scaleflags, + PartialityModel pmodel) { FILE *fh; char fn[64]; @@ -456,6 +459,7 @@ static void write_angle_grid(Crystal *cr, const RefList *full, priv.full = full; priv.serial = serial; priv.scaleflags = scaleflags; + priv.pmodel = pmodel; priv.cr_tgt = crystal_copy(cr); priv.image_tgt = *crystal_get_image(cr); spectrum = spectrum_new(); @@ -506,7 +510,8 @@ static void write_angle_grid(Crystal *cr, const RefList *full, static void write_radius_grid(Crystal *cr, const RefList *full, - signed int cycle, int serial, int scaleflags) + signed int cycle, int serial, int scaleflags, + PartialityModel pmodel) { FILE *fh; char fn[64]; @@ -520,6 +525,7 @@ static void write_radius_grid(Crystal *cr, const RefList *full, priv.full = full; priv.serial = serial; priv.scaleflags = scaleflags; + priv.pmodel = pmodel; priv.cr_tgt = crystal_copy(cr); priv.image_tgt = *crystal_get_image(cr); spectrum = spectrum_new(); @@ -570,10 +576,11 @@ static void write_radius_grid(Crystal *cr, const RefList *full, void write_gridscan(Crystal *cr, const RefList *full, - signed int cycle, int serial, int scaleflags) + signed int cycle, int serial, int scaleflags, + PartialityModel pmodel) { - write_angle_grid(cr, full, cycle, serial, scaleflags); - write_radius_grid(cr, full, cycle, serial, scaleflags); + write_angle_grid(cr, full, cycle, serial, scaleflags, pmodel); + write_radius_grid(cr, full, cycle, serial, scaleflags, pmodel); } @@ -653,7 +660,7 @@ static void do_pr_refine(Crystal *cr, const RefList *full, UnitCell *cell; Spectrum *spectrum; - try_reindex(cr, full, sym, amb, scaleflags); + try_reindex(cr, full, sym, amb, scaleflags, pmodel); zero_alter(&alter); @@ -661,6 +668,7 @@ static void do_pr_refine(Crystal *cr, const RefList *full, priv.full = full; priv.serial = serial; priv.scaleflags = scaleflags; + priv.pmodel = pmodel; priv.cr_tgt = crystal_copy(cr); priv.image_tgt = *crystal_get_image(cr); spectrum = spectrum_new(); @@ -713,10 +721,10 @@ static void do_pr_refine(Crystal *cr, const RefList *full, /* Apply the final shifts */ apply_parameters(cr, cr, alter); update_predictions(cr); - calculate_partialities(cr, PMODEL_XSPHERE); + calculate_partialities(cr, pmodel); if ( write_logs ) { - write_gridscan(cr, full, cycle, serial, scaleflags); + write_gridscan(cr, full, cycle, serial, scaleflags, pmodel); write_specgraph(cr, full, cycle, serial); write_test_logs(cr, full, cycle, serial); } diff --git a/src/post-refinement.h b/src/post-refinement.h index 0c84f164..7a86b813 100644 --- a/src/post-refinement.h +++ b/src/post-refinement.h @@ -64,7 +64,8 @@ extern void refine_all(Crystal **crystals, int n_crystals, SymOpList *sym, SymOpList *amb, int scaleflags); extern void write_gridscan(Crystal *cr, const RefList *full, - int cycle, int serial, int scaleflags); + int cycle, int serial, int scaleflags, + PartialityModel model); extern void write_specgraph(Crystal *crystal, const RefList *full, signed int cycle, int serial); -- cgit v1.2.3