diff options
author | Thomas White <taw@physics.org> | 2024-01-19 12:59:47 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | fd363c300c1767681ac6b03f05132d9e6d8a6884 (patch) | |
tree | be6ce156bd9ca66a0682393675dd77c1a2ac18c3 /src | |
parent | a40db3a0a67914934f214d5ea9473ad3465235b5 (diff) |
Fix incorrect uses of cell_free
This also gets rid of crystal_copy_deep. From now on, all crystal_copy
calls also copy the UnitCell.
Diffstat (limited to 'src')
-rw-r--r-- | src/partialator.c | 2 | ||||
-rw-r--r-- | src/post-refinement.c | 39 |
2 files changed, 20 insertions, 21 deletions
diff --git a/src/partialator.c b/src/partialator.c index 659a12c5..7d3f19f6 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -1611,7 +1611,7 @@ int main(int argc, char *argv[]) return 1; } crystals = crystals_new; - cr = crystal_copy_deep(image->crystals[i].cr); + cr = crystal_copy(image->crystals[i].cr); crystals[n_crystals].cr = cr; images_new = realloc(images, (n_crystals+1)*sizeof(struct image *)); diff --git a/src/post-refinement.c b/src/post-refinement.c index c67c0348..8a846b0f 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -268,7 +268,6 @@ static void try_reindex(RefList **prefls, Crystal *crin, struct image *image, const RefList *full, SymOpList *sym, SymOpList *amb, int scaleflags, PartialityModel pmodel) { - Crystal *cr; double residual_original; int idx, n; @@ -277,39 +276,39 @@ static void try_reindex(RefList **prefls, Crystal *crin, struct image *image, if ( scale_one_crystal(*prefls, crin, full, scaleflags) ) return; residual_original = residual(*prefls, crin, full, 0, NULL, NULL); - cr = crystal_copy(crin); - n = num_equivs(amb, NULL); for ( idx=0; idx<n; idx++ ) { RefList *list; UnitCell *cell; - double residual_flipped; + Crystal *cr; - cell = cell_new_from_cell(crystal_get_cell(crin)); - if ( cell == NULL ) return; - reindex_cell(cell, amb, idx); - crystal_set_cell(cr, cell); + cr = crystal_copy(crin); + reindex_cell(crystal_get_cell(cr), amb, idx); list = reindex_reflections(*prefls, amb, sym, idx); + update_predictions(list, cr, image); calculate_partialities(list, cr, image, pmodel); - if ( scale_one_crystal(list, cr, full, scaleflags) ) return; - residual_flipped = residual(list, cr, full, 0, NULL, NULL); - - if ( residual_flipped < residual_original ) { - crystal_set_cell(crin, cell); - reflist_free(*prefls); - *prefls = list; - residual_original = residual_flipped; - } else { - cell_free(crystal_get_cell(cr)); - reflist_free(list); + if ( scale_one_crystal(list, cr, full, scaleflags) == 0 ) { + + double residual_flipped; + residual_flipped = residual(list, cr, full, 0, NULL, NULL); + + if ( residual_flipped < residual_original ) { + crystal_set_cell(crin, crystal_relinquish_cell(cr)); + reflist_free(*prefls); + *prefls = list; + residual_original = residual_flipped; + } else { + reflist_free(list); + } } + + crystal_free(cr); } - crystal_free(cr); } |