[hkl] add hkl_geometry_[sample/detector]_rotation_get
[hkl.git] / tests / hkl-pseudoaxis-soleil-sixs-med-t.c
bloba75a4bc3b35cc05825b02d00454d86e304b1e8dc
1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2010 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
22 #include "hkl.h"
23 #include <tap/basic.h>
24 #include <tap/float.h>
25 #include <tap/hkl-tap.h>
27 #include "hkl-axis-private.h" /* temporary */
29 #define GET_GAMMA(geometries) hkl_parameter_value_get( \
30 hkl_geometry_axis_get( \
31 hkl_geometry_list_item_geometry_get( \
32 hkl_geometry_list_items_first_get((geometries))), \
33 "gamma", NULL), HKL_UNIT_USER)
35 static void qper_qpar(void)
37 int res = TRUE;
38 HklEngineList *engines;
39 HklEngine *engine;
40 const HklFactory *factory;
41 HklGeometry *geom;
42 HklDetector *detector;
43 HklSample *sample;
44 double qper_qpar[2];
45 double gamma;
46 HklGeometryList *geometries;
47 HklMatrix *U;
49 factory = hkl_factory_get_by_name("SOLEIL SIXS MED2+3", NULL);
50 geom = hkl_factory_create_new_geometry(factory);
52 sample = hkl_sample_new("test");
53 U = hkl_matrix_new_euler(-90.0 * HKL_DEGTORAD, 0., 0.);
54 hkl_sample_U_set(sample, U, NULL);
55 hkl_matrix_free(U);
57 detector = hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D);
59 engines = hkl_factory_create_new_engine_list(factory);
60 hkl_engine_list_init(engines, geom, detector, sample);
62 engine = hkl_engine_list_engine_get_by_name(engines, "qper_qpar", NULL);
64 /* the init part */
65 res &= DIAG(hkl_geometry_set_values_v(geom, HKL_UNIT_USER, NULL, 0., 0.1, 0., 0., 90., 0.));
66 res &= DIAG(hkl_engine_initialized_set(engine, TRUE, NULL));
68 /* gamma must be positif */
69 qper_qpar[0] = 0.1;
70 qper_qpar[1] = 4.;
71 geometries = hkl_engine_pseudo_axis_values_set(engine, qper_qpar, ARRAY_SIZE(qper_qpar),
72 HKL_UNIT_DEFAULT, NULL);
73 if(geometries){
74 gamma = GET_GAMMA(geometries);
75 is_double(2.61077, gamma, HKL_EPSILON * 10, __func__);
76 hkl_geometry_list_free(geometries);
79 /* gamma must be negatif */
80 qper_qpar[0] = -0.1;
81 qper_qpar[1] = 4.;
82 geometries = hkl_engine_pseudo_axis_values_set(engine, qper_qpar, ARRAY_SIZE(qper_qpar),
83 HKL_UNIT_DEFAULT, NULL);
84 if(geometries){
85 gamma = GET_GAMMA(geometries);
86 is_double(-2.7956354, gamma, HKL_EPSILON * 10, __func__);
87 hkl_geometry_list_free(geometries);
90 ok(res, __func__);
92 hkl_engine_list_free(engines);
93 hkl_detector_free(detector);
94 hkl_sample_free(sample);
95 hkl_geometry_free(geom);
98 static void med_2_3(void)
100 int res = TRUE;
101 HklEngineList *engines;
102 HklEngine *hkl;
103 const HklFactory *factory;
104 HklGeometry *geometry;
105 HklGeometryList *geometries;
106 HklDetector *detector;
107 HklSample *sample;
108 HklLattice *lattice;
109 HklMatrix *U;
110 static double positions[] = {0, 1, -14.27, 99.62, 60.98, 0};
111 static double hkl_p[] = {1.95, 2, 6};
113 /* Wavelength 1.54980 */
114 /* Mode mu_fixed */
115 /* Ux -90.59 Uy -9.97 Uz 176.35 */
116 /* A 4.759 B 4.759 C 12.992 */
117 /* Alpha 90 Beta 90 Gamma 120 */
119 factory = hkl_factory_get_by_name("SOLEIL SIXS MED2+3", NULL);
120 geometry = hkl_factory_create_new_geometry(factory);
122 res &= DIAG(hkl_geometry_axis_values_set(geometry,
123 positions, ARRAY_SIZE(positions), HKL_UNIT_USER,
124 NULL));
125 res &= DIAG(hkl_geometry_wavelength_set(geometry, 1.54980, HKL_UNIT_DEFAULT, NULL));
127 sample = hkl_sample_new("test");
128 lattice = hkl_lattice_new(4.759, 4.759, 12.992,
129 90*HKL_DEGTORAD, 90*HKL_DEGTORAD, 120*HKL_DEGTORAD,
130 NULL);
131 hkl_sample_lattice_set(sample, lattice);
132 hkl_lattice_free(lattice);
133 U = hkl_matrix_new_euler(-90.59 * HKL_DEGTORAD,
134 -9.97 * HKL_DEGTORAD,
135 176.35 * HKL_DEGTORAD);
136 hkl_sample_U_set(sample, U, NULL);
137 hkl_matrix_free(U);
139 detector = hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D);
141 engines = hkl_factory_create_new_engine_list(factory);
142 hkl_engine_list_init(engines, geometry, detector, sample);
144 hkl = hkl_engine_list_engine_get_by_name(engines, "hkl", NULL);
145 res &= DIAG(hkl_engine_current_mode_set(hkl, "mu_fixed", NULL));
147 /* hkl 1.95, 2, 6 (should not fail) */
148 geometries = hkl_engine_pseudo_axis_values_set(hkl,
149 hkl_p, ARRAY_SIZE(hkl_p),
150 HKL_UNIT_DEFAULT, NULL);
151 res &= DIAG((geometries != NULL));
152 hkl_geometry_list_free(geometries);
154 ok(res == TRUE, __func__);
156 hkl_engine_list_free(engines);
157 hkl_detector_free(detector);
158 hkl_sample_free(sample);
159 hkl_geometry_free(geometry);
162 int main(void)
164 plan(4);
166 qper_qpar();
167 med_2_3();
169 return 0;