From 7a7202862defd2b3638fbe16b7ec315c6c871321 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 29 Aug 2012 16:30:36 +0200 Subject: Add tests/centering_check --- tests/.gitignore | 1 + tests/centering_check.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 tests/centering_check.c (limited to 'tests') diff --git a/tests/.gitignore b/tests/.gitignore index c2a45f5a..16acffc3 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -5,4 +5,5 @@ gpu_sim_check integration_check pr_gradient_check symmetry_check +centering_check .dirstamp diff --git a/tests/centering_check.c b/tests/centering_check.c new file mode 100644 index 00000000..0dc79a5f --- /dev/null +++ b/tests/centering_check.c @@ -0,0 +1,113 @@ +/* + * centering_check.c + * + * Check that centering of cells works + * + * Copyright © 2012 Thomas White + * + * This file is part of CrystFEL. + * + * CrystFEL is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CrystFEL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CrystFEL. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include +#include +#include + +#include +#include + + +static int check_cell(UnitCell *cell) +{ + int err = 0; + + if ( !cell_is_sensible(cell) ) { + ERROR("Warning: Unit cell parameters are not sensible.\n"); + err = 1; + } + + if ( !bravais_lattice(cell) ) { + ERROR("Warning: Unit cell is not a conventional Bravais" + " lattice.\n"); + err = 1; + } + + if ( !right_handed(cell) ) { + ERROR("Warning: Unit cell is not right handed.\n"); + err = 1; + } + + return err; +} + + +static int check_centering() +{ + UnitCell *cell; + UnitCell *n; + int fail = 0; + + cell = cell_new(); + + cell_set_parameters(cell, 10e-10, 20e-10, 30e-10, + deg2rad(90.0), deg2rad(90.0), deg2rad(100.0)); + cell_set_centering(cell, 'C'); + cell_set_lattice_type(cell, L_MONOCLINIC); + cell_set_unique_axis(cell, 'c'); + if ( check_cell(cell) ) fail = 1; + n = uncenter_cell(cell); + if ( check_cell(n) ) fail = 1; + + return fail; +} + + + +int main(int argc, char *argv[]) +{ + int fail = 0; + + /* Triclinic P */ + check_centering(10e-10, 20e-10, 30e-10, 100.0, 120.0, 140.0, + L_TRICLINIC, 'P', '*', + ); + /* Monoclinic P */ + /* Monoclinic A */ + /* Monoclinic B */ + /* Monoclinic C */ + /* Orthorhombic P */ + /* Orthorhombic A */ + /* Orthorhombic B */ + /* Orthorhombic C */ + /* Orthorhombic I */ + /* Orthorhombic F */ + /* Tetragonal P */ + /* Tetragonal I */ + /* Rhombohedral R */ + /* Hexagonal P */ + /* Hexagonal H (PDB-speak for rhombohedral) */ + /* Cubic P */ + /* Cubic I */ + /* Cubic F */ + + + return fail; +} -- cgit v1.2.3