diff options
author | Thomas White <taw@physics.org> | 2015-11-19 13:08:02 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-11-19 14:33:08 +0100 |
commit | 08b93f124d2fc60cfa1dfff82b1700a2f2fbf91f (patch) | |
tree | 04519b9805cc1893f09809c5dacf1638e40c2cea | |
parent | 40dd7ff04a44688544e22cc3a0384bef808abc64 (diff) |
Count reflections in merge and scaling
-rw-r--r-- | src/merge.c | 13 | ||||
-rw-r--r-- | src/scaling.c | 20 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/merge.c b/src/merge.c index 488b25df..8d1fae0f 100644 --- a/src/merge.c +++ b/src/merge.c @@ -62,6 +62,7 @@ struct merge_queue_args PartialityModel pmodel; double push_res; int use_weak; + long long int n_reflections; }; @@ -70,6 +71,7 @@ struct merge_worker_args struct merge_queue_args *qargs; Crystal *crystal; int crystal_number; + int n_reflections; }; @@ -140,6 +142,8 @@ static void run_merge_job(void *vwargs, int cookie) RefListIterator *iter; double G, B; + wargs->n_reflections = 0; + /* If this crystal's scaling was dodgy, it doesn't contribute to the * merged intensities */ if ( crystal_get_user_flag(cr) != 0 ) return; @@ -207,12 +211,18 @@ static void run_merge_job(void *vwargs, int cookie) set_temp1(f, temp); set_redundancy(f, get_redundancy(f)+1); unlock_reflection(f); + + wargs->n_reflections++; + } } static void finalise_merge_job(void *vqargs, void *vwargs) { + struct merge_queue_args *qargs = vqargs; + struct merge_worker_args *wargs = vwargs; + qargs->n_reflections += wargs->n_reflections; free(vwargs); } @@ -240,6 +250,7 @@ RefList *merge_intensities(Crystal **crystals, int n, int n_threads, qargs.pmodel = pmodel; qargs.push_res = push_res; qargs.use_weak = use_weak; + qargs.n_reflections = 0; pthread_rwlock_init(&qargs.full_lock, NULL); run_threads(n_threads, run_merge_job, create_merge_job, @@ -273,6 +284,8 @@ RefList *merge_intensities(Crystal **crystals, int n, int n_threads, } } + STATUS("%lli reflections went into the merge.\n", qargs.n_reflections); + reflist_free(full); return full2; } diff --git a/src/scaling.c b/src/scaling.c index 5bfba451..dfe76d69 100644 --- a/src/scaling.c +++ b/src/scaling.c @@ -79,7 +79,7 @@ static void apply_shift(Crystal *cr, int k, double shift) /* Perform one cycle of scaling of 'cr' against 'full' */ static double scale_iterate(Crystal *cr, const RefList *full, - PartialityModel pmodel) + PartialityModel pmodel, int *nr) { gsl_matrix *M; gsl_vector *v; @@ -94,6 +94,8 @@ static double scale_iterate(Crystal *cr, const RefList *full, enum gparam rv[32]; double G, B; + *nr = 0; + rv[num_params++] = GPARAM_OSF; rv[num_params++] = GPARAM_BFAC; @@ -191,6 +193,8 @@ static double scale_iterate(Crystal *cr, const RefList *full, nref++; } + *nr = nref; + if ( nref < num_params ) { crystal_set_user_flag(cr, PRFLAG_FEWREFL); gsl_matrix_free(M); @@ -287,7 +291,7 @@ double log_residual(Crystal *cr, const RefList *full, int free, static void do_scale_refine(Crystal *cr, const RefList *full, - PartialityModel pmodel) + PartialityModel pmodel, int *nr) { int i, done; double old_dev; @@ -300,7 +304,7 @@ static void do_scale_refine(Crystal *cr, const RefList *full, double dev; - scale_iterate(cr, full, pmodel); + scale_iterate(cr, full, pmodel, nr); dev = log_residual(cr, full, 0, 0, NULL); if ( fabs(dev - old_dev) < dev*0.01 ) done = 1; @@ -317,6 +321,7 @@ struct scale_args RefList *full; Crystal *crystal; PartialityModel pmodel; + int n_reflections; }; @@ -326,6 +331,7 @@ struct queue_args int n_done; Crystal **crystals; int n_crystals; + long long int n_reflections; struct scale_args task_defaults; }; @@ -333,7 +339,8 @@ struct queue_args static void scale_crystal(void *task, int id) { struct scale_args *pargs = task; - do_scale_refine(pargs->crystal, pargs->full, pargs->pmodel); + do_scale_refine(pargs->crystal, pargs->full, pargs->pmodel, + &pargs->n_reflections); } @@ -356,8 +363,10 @@ static void *get_crystal(void *vqargs) static void done_crystal(void *vqargs, void *task) { struct queue_args *qa = vqargs; + struct scale_args *wargs = task; qa->n_done++; + qa->n_reflections += wargs->n_reflections; progress_bar(qa->n_done, qa->n_crystals, "Scaling"); free(task); @@ -419,8 +428,11 @@ void scale_all(Crystal **crystals, int n_crystals, int nthreads, qargs.task_defaults.full = full; qargs.n_started = 0; qargs.n_done = 0; + qargs.n_reflections = 0; run_threads(nthreads, scale_crystal, get_crystal, done_crystal, &qargs, n_crystals, 0, 0, 0); + STATUS("%lli reflections went into the scaling.\n", + qargs.n_reflections); new_res = total_log_r(crystals, n_crystals, full, &ninc); STATUS("Log residual went from %e to %e, %i crystals\n", |