[contrib][haskell] Hkl.Xrd.OneD
[hkl.git] / tests / hkl-pseudoaxis-soleil-sixs-med-t.c
blobf6bb12f5b230059ef31541264c312f6f08f6aa05
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 /* tests */
37 static void qper_qpar(void)
39 int res = TRUE;
40 HklEngineList *engines;
41 HklEngine *engine;
42 HklGeometry *geometry;
43 HklDetector *detector;
44 HklSample *sample;
45 double qper_qpar[2];
46 double gamma;
47 HklGeometryList *geometries;
49 static struct Sample gaas = {
50 .name = "test",
51 .lattice=Cubic(1.54),
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);
69 /* the init part */
70 res &= DIAG(hkl_engine_initialized_set(engine, TRUE, NULL));
72 /* gamma must be positif */
73 qper_qpar[0] = 0.1;
74 qper_qpar[1] = 4.;
75 geometries = hkl_engine_pseudo_axis_values_set(engine, qper_qpar, ARRAY_SIZE(qper_qpar),
76 HKL_UNIT_DEFAULT, NULL);
77 if(geometries){
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 */
84 qper_qpar[0] = -0.1;
85 qper_qpar[1] = 4.;
86 geometries = hkl_engine_pseudo_axis_values_set(engine, qper_qpar, ARRAY_SIZE(qper_qpar),
87 HKL_UNIT_DEFAULT, NULL);
88 if(geometries){
89 gamma = GET_GAMMA(geometries);
90 is_double(-2.7956354, gamma, HKL_EPSILON * 10, __func__);
91 hkl_geometry_list_free(geometries);
94 ok(res, __func__);
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)
104 int res = TRUE;
105 HklEngineList *engines;
106 HklEngine *hkl;
107 HklGeometry *geometry;
108 HklGeometryList *geometries;
109 HklDetector *detector;
110 HklSample *sample;
111 static double hkl_p[] = {1.95, 2, 6};
113 static struct Sample gaas = {
114 .name = "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 */
125 /* Mode mu_fixed */
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);
155 int main(void)
157 plan(4);
159 qper_qpar();
160 med_2_3();
162 return 0;