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>
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)
37 static void qper_qpar(void)
40 HklEngineList
*engines
;
42 HklGeometry
*geometry
;
43 HklDetector
*detector
;
47 HklGeometryList
*geometries
;
49 static struct Sample gaas
= {
52 .ux
= -90.0 * HKL_DEGTORAD
,
53 .uy
= 0.0 * HKL_DEGTORAD
,
54 .uz
= 0.0 * HKL_DEGTORAD
,
57 struct Geometry gconfig
= SoleilSixsMed2_3(1.54, 0., 0.1, 0., 0., 90., 0.);
59 geometry
= newGeometry(gconfig
);
60 engines
= newEngines(gconfig
);
61 sample
= newSample(gaas
);
63 detector
= hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D
);
65 hkl_engine_list_init(engines
, geometry
, detector
, sample
);
67 engine
= hkl_engine_list_engine_get_by_name(engines
, "qper_qpar", NULL
);
70 res
&= DIAG(hkl_engine_initialized_set(engine
, TRUE
, NULL
));
72 /* gamma must be positif */
75 geometries
= hkl_engine_pseudo_axis_values_set(engine
, qper_qpar
, ARRAY_SIZE(qper_qpar
),
76 HKL_UNIT_DEFAULT
, NULL
);
78 gamma
= GET_GAMMA(geometries
);
79 is_double(2.61077, gamma
, HKL_EPSILON
* 10, __func__
);
80 hkl_geometry_list_free(geometries
);
83 /* gamma must be negatif */
86 geometries
= hkl_engine_pseudo_axis_values_set(engine
, qper_qpar
, ARRAY_SIZE(qper_qpar
),
87 HKL_UNIT_DEFAULT
, NULL
);
89 gamma
= GET_GAMMA(geometries
);
90 is_double(-2.7956354, gamma
, HKL_EPSILON
* 10, __func__
);
91 hkl_geometry_list_free(geometries
);
96 hkl_engine_list_free(engines
);
97 hkl_detector_free(detector
);
98 hkl_sample_free(sample
);
99 hkl_geometry_free(geometry
);
102 static void med_2_3(void)
105 HklEngineList
*engines
;
107 HklGeometry
*geometry
;
108 HklGeometryList
*geometries
;
109 HklDetector
*detector
;
111 static double hkl_p
[] = {1.95, 2, 6};
113 static struct Sample gaas
= {
115 .lattice
= Hexagonal(4.759, 12.992),
116 .ux
= -90.59 * HKL_DEGTORAD
,
117 .uy
= -9.97 * HKL_DEGTORAD
,
118 .uz
= 176.35 * HKL_DEGTORAD
,
121 static struct Geometry gconfig
= SoleilSixsMed2_3(1.54980,
122 0, 1, -14.27, 99.62, 60.98, 0);
124 /* Wavelength 1.54980 */
126 /* Ux -90.59 Uy -9.97 Uz 176.35 */
127 /* A 4.759 B 4.759 C 12.992 */
128 /* Alpha 90 Beta 90 Gamma 120 */
130 geometry
= newGeometry(gconfig
);
131 engines
= newEngines(gconfig
);
132 sample
= newSample(gaas
);
133 detector
= hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D
);
135 hkl_engine_list_init(engines
, geometry
, detector
, sample
);
137 hkl
= hkl_engine_list_engine_get_by_name(engines
, "hkl", NULL
);
138 res
&= DIAG(hkl_engine_current_mode_set(hkl
, "mu_fixed", NULL
));
140 /* hkl 1.95, 2, 6 (should not fail) */
141 geometries
= hkl_engine_pseudo_axis_values_set(hkl
,
142 hkl_p
, ARRAY_SIZE(hkl_p
),
143 HKL_UNIT_DEFAULT
, NULL
);
144 res
&= DIAG((geometries
!= NULL
));
145 hkl_geometry_list_free(geometries
);
147 ok(res
== TRUE
, __func__
);
149 hkl_engine_list_free(engines
);
150 hkl_detector_free(detector
);
151 hkl_sample_free(sample
);
152 hkl_geometry_free(geometry
);