aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-07-07 16:50:26 +0200
committerThomas White <taw@physics.org>2023-07-28 13:22:05 +0200
commitbf0bd78b04123d084884053599dd0917afccf8e0 (patch)
tree5ed38d44149fee0aa6502358e00fc829e62c15e8 /tests
parent5fb6775ad236542e38b089e54593e5bb81f611ff (diff)
Add tests for unit cell parameters
Diffstat (limited to 'tests')
-rw-r--r--tests/gradient_panel_move.c35
-rw-r--r--tests/meson.build26
2 files changed, 54 insertions, 7 deletions
diff --git a/tests/gradient_panel_move.c b/tests/gradient_panel_move.c
index b3c950ab..46d366d6 100644
--- a/tests/gradient_panel_move.c
+++ b/tests/gradient_panel_move.c
@@ -50,14 +50,32 @@ int main(int argc, char *argv[])
int n_wrong_ss = 0;
int n_wrong_obsr = 0;
int fail = 0;
- double step = 0.1; /* Pixels */
+ double step;
gsl_matrix **panel_matrices;
rps = make_test_image(&n_refls, &image);
panel_matrices = make_panel_minvs(image.detgeom);
before = make_dev_list(rps, n_refls, image.detgeom);
+
+ #ifdef MOVE_PANEL
+ step = 0.1; /* Pixels */
image.detgeom->panels[0].THING_TO_MOVE += step;
+ #endif
+
+ #ifdef CHANGE_CELL
+ double asx, asy, asz, bsx, bsy, bsz, csx, csy, csz;
+ UnitCell *cell = crystal_get_cell(image.crystals[0]);
+ step = 0.5e5;
+ cell_get_reciprocal(cell, &asx, &asy, &asz,
+ &bsx, &bsy, &bsz,
+ &csx, &csy, &csz);
+ THING_TO_MOVE += step;
+ cell_set_reciprocal(cell, asx, asy, asz,
+ bsx, bsy, bsz,
+ csx, csy, csz);
+ #endif
+
update_predictions(image.crystals[0]);
after = make_dev_list(rps, n_refls, image.detgeom);
@@ -80,13 +98,18 @@ int main(int argc, char *argv[])
obs[1] = (after[1][i] - before[1][i]) / step;
obs[2] = (after[2][i] - before[2][i]) / step;
- /* Gradient of excitation error w.r.t. panel should be zero */
- if ( fabs(obs[0]) > 1e-12 ) n_wrong_obsr++;
- if ( fabs(calc[0]) > 1e-12 ) n_wrong_r++;
-
- /* Panel gradients should be within tolerance */
+ #ifdef MOVE_PANEL
+ if ( fabs(calc[0]) > 1e-12 ) n_wrong_r++; /* Should be zero */
+ if ( fabs(obs[0]) > 1e-12 ) n_wrong_obsr++; /* Should also be zero */
if ( fabs(obs[1] - calc[1]) > 1e-3 ) n_wrong_fs++;
if ( fabs(obs[2] - calc[2]) > 1e-3 ) n_wrong_ss++;
+ #endif
+
+ #ifdef CHANGE_CELL
+ if ( fabs(obs[0] - calc[0]) > 1e-2 ) n_wrong_r++;
+ if ( fabs(obs[1] - calc[1]) > 1e-8 ) n_wrong_fs++;
+ if ( fabs(obs[2] - calc[2]) > 1e-8 ) n_wrong_ss++;
+ #endif
}
diff --git a/tests/meson.build b/tests/meson.build
index 16c8f3a1..cfaac300 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -106,7 +106,31 @@ foreach name : panel_gradient_tests
['gradient_panel_move.c',
'gradient_check_utils.c'],
c_args : ['-DTHING_TO_MOVE='+name[1],
- '-DTEST_GPARAM='+name[2]],
+ '-DTEST_GPARAM='+name[2],
+ '-DMOVE_PANEL=1'],
+ dependencies : [libcrystfeldep, mdep, gsldep])
+ test(name[0], exe)
+endforeach
+
+
+# Refinement gradient checks, part 2: diffraction physics
+panel_gradient_tests = [['gradient_cell_asx', 'asx', 'GPARAM_ASX'],
+ ['gradient_cell_asy', 'asy', 'GPARAM_ASY'],
+ ['gradient_cell_asz', 'asz', 'GPARAM_ASZ'],
+ ['gradient_cell_bsx', 'bsx', 'GPARAM_BSX'],
+ ['gradient_cell_bsy', 'bsy', 'GPARAM_BSY'],
+ ['gradient_cell_bsz', 'bsz', 'GPARAM_BSZ'],
+ ['gradient_cell_csx', 'csx', 'GPARAM_CSX'],
+ ['gradient_cell_csy', 'csy', 'GPARAM_CSY'],
+ ['gradient_cell_csz', 'csz', 'GPARAM_CSZ']]
+
+foreach name : panel_gradient_tests
+ exe = executable(name[0],
+ ['gradient_panel_move.c',
+ 'gradient_check_utils.c'],
+ c_args : ['-DTHING_TO_MOVE='+name[1],
+ '-DTEST_GPARAM='+name[2],
+ '-DCHANGE_CELL=1'],
dependencies : [libcrystfeldep, mdep, gsldep])
test(name[0], exe)
endforeach