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-2017 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 <gsl/gsl_sys.h> // for gsl_isnan
23 #include "hkl-factory-private.h" // for autodata_factories_, etc
24 #include "hkl-pseudoaxis-common-hkl-private.h"
37 static HklMode
*zaxis_alpha_fixed()
39 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
40 static const char *axes_w
[] = {OMEGA
, DELTA
, GAMMA
};
41 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
42 static const HklModeAutoInfo info
= {
43 HKL_MODE_AUTO_INFO("zaxis + alpha-fixed", axes_r
, axes_w
, functions
),
46 return hkl_mode_auto_new(&info
,
47 &hkl_full_mode_operations
,
51 static HklMode
*zaxis_beta_fixed()
53 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
54 static const char *axes_w
[] = {MU
, DELTA
, GAMMA
};
55 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
56 static const HklModeAutoInfo info
= {
57 HKL_MODE_AUTO_INFO("zaxis + beta-fixed", axes_r
, axes_w
, functions
),
60 return hkl_mode_auto_new(&info
,
61 &hkl_full_mode_operations
,
65 /* zaxis + alpha=beta */
67 static int _reflectivity(const gsl_vector
*x
, void *params
, gsl_vector
*f
)
69 const double mu
= x
->data
[0];
70 const double gamma
= x
->data
[3];
72 CHECK_NAN(x
->data
, x
->size
);
74 RUBh_minus_Q(x
->data
, params
, f
->data
);
75 f
->data
[3] = mu
- gamma
;
80 static const HklFunction reflectivity
= {
81 .function
= _reflectivity
,
86 static HklMode
*zaxis_alpha_eq_beta()
88 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
89 static const char *axes_w
[] = {MU
, OMEGA
, DELTA
, GAMMA
};
90 static const HklFunction
*functions
[] = {&reflectivity
};
91 static const HklModeAutoInfo info
= {
92 HKL_MODE_AUTO_INFO("zaxis + alpha=beta", axes_r
, axes_w
, functions
),
95 return hkl_mode_auto_new(&info
,
96 &hkl_full_mode_operations
,
100 /* 4-circles bissecting horizontal */
102 static int _bissector_horizontal(const gsl_vector
*x
, void *params
, gsl_vector
*f
)
104 const double omega
= x
->data
[0];
105 const double delta
= x
->data
[3];
107 CHECK_NAN(x
->data
, x
->size
);
109 RUBh_minus_Q(x
->data
, params
, f
->data
);
110 f
->data
[3] = delta
- 2 * fmod(omega
, M_PI
);
115 static const HklFunction bissector_horizontal
= {
116 .function
= _bissector_horizontal
,
120 static HklMode
*fourc_bissector_horizontal()
122 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
123 static const char *axes_w
[] = {OMEGA
, CHI
, PHI
, DELTA
};
124 static const HklFunction
*functions
[] = {&bissector_horizontal
};
125 static const HklModeAutoInfo info
= {
126 HKL_MODE_AUTO_INFO("4-circles bissecting horizontal", axes_r
, axes_w
, functions
),
129 return hkl_mode_auto_new(&info
,
130 &hkl_full_mode_operations
,
134 static HklMode
*fourc_constant_omega_horizontal()
136 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
137 static const char *axes_w
[] = {CHI
, PHI
, DELTA
};
138 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
139 static const HklModeAutoInfo info
= {
140 HKL_MODE_AUTO_INFO("4-circles constant omega horizontal", axes_r
, axes_w
, functions
),
143 return hkl_mode_auto_new(&info
,
144 &hkl_full_mode_operations
,
148 static HklMode
*fourc_constant_chi_horizontal()
150 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
151 static const char *axes_w
[] = {OMEGA
, PHI
, DELTA
};
152 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
153 static const HklModeAutoInfo info
= {
154 HKL_MODE_AUTO_INFO("4-circles constant chi horizontal", axes_r
, axes_w
, functions
),
157 return hkl_mode_auto_new(&info
,
158 &hkl_full_mode_operations
,
162 static HklMode
*fourc_constant_phi_horizontal()
164 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
165 static const char *axes_w
[] = {OMEGA
, CHI
, DELTA
};
166 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
167 static const HklModeAutoInfo info
= {
168 HKL_MODE_AUTO_INFO("4-circles constant phi horizontal", axes_r
, axes_w
, functions
),
171 return hkl_mode_auto_new(&info
,
172 &hkl_full_mode_operations
,
176 static HklMode
*lifting_detector_mu()
178 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
179 static const char *axes_w
[] = {MU
, DELTA
, GAMMA
};
180 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
181 static const HklModeAutoInfo info
= {
182 HKL_MODE_AUTO_INFO("lifting detector mu", axes_r
, axes_w
, functions
),
185 return hkl_mode_auto_new(&info
,
186 &hkl_full_mode_operations
,
190 static HklMode
*lifting_detector_omega()
192 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
193 static const char *axes_w
[] = {OMEGA
, DELTA
, GAMMA
};
194 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
195 static const HklModeAutoInfo info
= {
196 HKL_MODE_AUTO_INFO("lifting detector omega", axes_r
, axes_w
, functions
),
199 return hkl_mode_auto_new(&info
,
200 &hkl_full_mode_operations
,
204 static HklMode
*lifting_detector_chi()
206 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
207 static const char *axes_w
[] = {CHI
, DELTA
, GAMMA
};
208 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
209 static const HklModeAutoInfo info
= {
210 HKL_MODE_AUTO_INFO("lifting detector chi", axes_r
, axes_w
, functions
),
213 return hkl_mode_auto_new(&info
,
214 &hkl_full_mode_operations
,
218 static HklMode
*lifting_detector_phi()
220 static const char *axes_r
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
221 static const char *axes_w
[] = {PHI
, DELTA
, GAMMA
};
222 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
223 static const HklModeAutoInfo info
= {
224 HKL_MODE_AUTO_INFO("lifting detector phi", axes_r
, axes_w
, functions
),
227 return hkl_mode_auto_new(&info
,
228 &hkl_full_mode_operations
,
232 /**********************/
233 /* pseudo axis engine */
234 /**********************/
236 static HklEngine
*hkl_engine_petra3_p09_eh2_hkl_new(HklEngineList
*engines
)
239 HklMode
*default_mode
;
241 self
= hkl_engine_hkl_new(engines
);
243 default_mode
= zaxis_alpha_fixed();
244 hkl_engine_add_mode(self
, default_mode
);
245 hkl_engine_mode_set(self
, default_mode
);
247 hkl_engine_add_mode(self
, zaxis_beta_fixed());
248 hkl_engine_add_mode(self
, zaxis_alpha_eq_beta());
249 hkl_engine_add_mode(self
, fourc_bissector_horizontal());
250 hkl_engine_add_mode(self
, fourc_constant_omega_horizontal());
251 hkl_engine_add_mode(self
, fourc_constant_chi_horizontal());
252 hkl_engine_add_mode(self
, fourc_constant_phi_horizontal());
253 hkl_engine_add_mode(self
, lifting_detector_mu());
254 hkl_engine_add_mode(self
, lifting_detector_omega());
255 hkl_engine_add_mode(self
, lifting_detector_chi());
256 hkl_engine_add_mode(self
, lifting_detector_phi());
265 #define HKL_GEOMETRY_TYPE_PETRA3_P09_EH2_DESCRIPTION \
266 "+ xrays source fix allong the :math:`\\vec{x}` direction (1, 0, 0)\n" \
267 "+ 4 axes for the sample\n" \
269 " + **" MU "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
270 " + **" OMEGA "** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
271 " + **" CHI "** : rotating around the :math:`\\vec{x}` direction (1, 0, 0)\n" \
272 " + **" PHI "** : rotating around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
274 "+ 3 axis for the detector\n" \
276 " + **" MU "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
277 " + **" DELTA "** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
278 " + **" GAMMA "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n"
280 static const char* hkl_geometry_petra3_p09_eh2_axes
[] = {MU
, OMEGA
, CHI
, PHI
, DELTA
, GAMMA
};
282 static HklGeometry
*hkl_geometry_new_petra3_p09_eh2(const HklFactory
*factory
)
284 HklGeometry
*self
= hkl_geometry_new(factory
);
287 h
= hkl_geometry_add_holder(self
);
288 hkl_holder_add_rotation_axis(h
, MU
, 0, -1, 0);
289 hkl_holder_add_rotation_axis(h
, OMEGA
, 0, 0, 1);
290 hkl_holder_add_rotation_axis(h
, CHI
, 1, 0, 0);
291 hkl_holder_add_rotation_axis(h
, PHI
, 0, 0, 1);
293 h
= hkl_geometry_add_holder(self
);
294 hkl_holder_add_rotation_axis(h
, MU
, 0, -1, 0);
295 hkl_holder_add_rotation_axis(h
, DELTA
, 0, 0, 1);
296 hkl_holder_add_rotation_axis(h
, GAMMA
, 0, -1, 0);
301 static HklEngineList
*hkl_engine_list_new_petra3_p09_eh2(const HklFactory
*factory
)
303 HklEngineList
*self
= hkl_engine_list_new();
305 hkl_engine_petra3_p09_eh2_hkl_new(self
);
310 REGISTER_DIFFRACTOMETER(petra3_p09_eh2
, "PETRA3 P09 EH2", HKL_GEOMETRY_TYPE_PETRA3_P09_EH2_DESCRIPTION
);