silent for now the diffractometer when the computation is not possible
[hkl.git] / tests / hkl-pseudoaxis-soleil-sixs-med-t.c
blob1d15aebcde651078bb4e6f3f5443743de69830e0
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(items, index) hkl_parameter_value_unit_get( \
30 darray_item(*hkl_geometry_axes_get( \
31 hkl_geometry_list_item_geometry_get( \
32 darray_item(*(items), (index)))), \
33 3))
36 static void qper_qpar(void)
38 HklEngineList *engines;
39 HklEngine *engine;
40 const HklFactory *factory;
41 HklGeometry *geom;
42 HklDetector *detector;
43 HklSample *sample;
44 size_t i, f_idx;
45 double *Qper, *Qpar;
46 double gamma;
47 darray_parameter *pseudo_axes;
48 const HklGeometryList *geometries;
49 const darray_item *items;
50 HklMatrix *U;
52 factory = hkl_factory_get_by_name("SOLEIL SIXS MED2+3");
53 geom = hkl_factory_create_new_geometry(factory);
55 sample = hkl_sample_new("test");
56 U = hkl_matrix_new_euler(-90.0 * HKL_DEGTORAD, 0., 0.);
57 hkl_sample_U_set(sample, U);
58 hkl_matrix_free(U);
60 detector = hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D);
61 hkl_detector_idx_set(detector, 1);
63 engines = hkl_factory_create_new_engine_list(factory);
64 hkl_engine_list_init(engines, geom, detector, sample);
65 geometries = hkl_engine_list_geometries(engines);
66 items = hkl_geometry_list_items_get(geometries);
68 engine = hkl_engine_list_get_by_name(engines, "qper_qpar");
69 pseudo_axes = hkl_engine_pseudo_axes(engine);
71 Qper = &darray_item(*pseudo_axes, 0)->_value;
72 Qpar = &darray_item(*pseudo_axes, 1)->_value;
74 /* the init part */
75 hkl_geometry_set_values_unit_v(geom, 0., 0.1, 0., 0., 90., 0.);
76 hkl_engine_initialize(engine, NULL);
78 /* gamma must be positif */
79 *Qper = 0.1;
80 *Qpar = 4.;
81 if(hkl_engine_set(engine, NULL) == HKL_TRUE){
82 gamma = GET_GAMMA(items, 0);
83 is_double(2.61077, gamma, HKL_EPSILON * 10, __func__);
86 /* gamma must be negatif */
87 *Qper = -0.1;
88 *Qpar = 4.;
89 if(hkl_engine_set(engine, NULL) == HKL_TRUE){
90 gamma = GET_GAMMA(items, 0);
91 is_double(-2.7956354, gamma, HKL_EPSILON * 10, __func__);
94 hkl_engine_list_free(engines);
95 hkl_detector_free(detector);
96 hkl_sample_free(sample);
97 hkl_geometry_free(geom);
100 int main(int argc, char** argv)
102 plan(2);
104 qper_qpar();
106 return 0;