upgrading copyright year from 2015 to 2016
[hkl.git] / hkl / hkl-engine-petra3-p09-eh2.c
blobd4a90c13d28a7e3a1fd594e415d11886f5215283
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-2016 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"
26 #define MU "mu"
27 #define OMEGA "omega"
28 #define CHI "chi"
29 #define PHI "phi"
30 #define DELTA "delta"
31 #define GAMMA "gamma"
33 /********/
34 /* mode */
35 /********/
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,
48 TRUE);
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,
62 TRUE);
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;
77 return GSL_SUCCESS;
80 static const HklFunction reflectivity = {
81 .function = _reflectivity,
82 .size = 4,
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,
97 TRUE);
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);
112 return GSL_SUCCESS;
115 static const HklFunction bissector_horizontal = {
116 .function = _bissector_horizontal,
117 .size = 4,
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,
131 TRUE);
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,
145 TRUE);
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,
159 TRUE);
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,
173 TRUE);
176 /**********************/
177 /* pseudo axis engine */
178 /**********************/
180 static HklEngine *hkl_engine_petra3_p09_eh2_hkl_new(HklEngineList *engines)
182 HklEngine *self;
183 HklMode *default_mode;
185 self = hkl_engine_hkl_new(engines);
187 default_mode = zaxis_alpha_fixed();
188 hkl_engine_add_mode(self, default_mode);
189 hkl_engine_mode_set(self, default_mode);
191 hkl_engine_add_mode(self, zaxis_beta_fixed());
192 hkl_engine_add_mode(self, zaxis_alpha_eq_beta());
193 hkl_engine_add_mode(self, fourc_bissector_horizontal());
194 hkl_engine_add_mode(self, fourc_constant_omega_horizontal());
195 hkl_engine_add_mode(self, fourc_constant_chi_horizontal());
196 hkl_engine_add_mode(self, fourc_constant_phi_horizontal());
198 return self;
201 /******************/
202 /* PETRA3 P09 EH2 */
203 /******************/
205 #define HKL_GEOMETRY_TYPE_PETRA3_P09_EH2_DESCRIPTION \
206 "+ xrays source fix allong the :math:`\\vec{x}` direction (1, 0, 0)\n" \
207 "+ 4 axes for the sample\n" \
208 "\n" \
209 " + **" MU "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
210 " + **" OMEGA "** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
211 " + **" CHI "** : rotating around the :math:`\\vec{x}` direction (1, 0, 0)\n" \
212 " + **" PHI "** : rotating around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
213 "\n" \
214 "+ 3 axis for the detector\n" \
215 "\n" \
216 " + **" MU "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
217 " + **" DELTA "** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
218 " + **" GAMMA "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n"
220 static const char* hkl_geometry_petra3_p09_eh2_axes[] = {MU, OMEGA, CHI, PHI, DELTA, GAMMA};
222 static HklGeometry *hkl_geometry_new_petra3_p09_eh2(const HklFactory *factory)
224 HklGeometry *self = hkl_geometry_new(factory);
225 HklHolder *h;
227 h = hkl_geometry_add_holder(self);
228 hkl_holder_add_rotation_axis(h, MU, 0, -1, 0);
229 hkl_holder_add_rotation_axis(h, OMEGA, 0, 0, 1);
230 hkl_holder_add_rotation_axis(h, CHI, 1, 0, 0);
231 hkl_holder_add_rotation_axis(h, PHI, 0, 0, 1);
233 h = hkl_geometry_add_holder(self);
234 hkl_holder_add_rotation_axis(h, MU, 0, -1, 0);
235 hkl_holder_add_rotation_axis(h, DELTA, 0, 0, 1);
236 hkl_holder_add_rotation_axis(h, GAMMA, 0, -1, 0);
238 return self;
241 static HklEngineList *hkl_engine_list_new_petra3_p09_eh2(const HklFactory *factory)
243 HklEngineList *self = hkl_engine_list_new();
245 hkl_engine_petra3_p09_eh2_hkl_new(self);
247 return self;
250 REGISTER_DIFFRACTOMETER(petra3_p09_eh2, "PETRA3 P09 EH2", HKL_GEOMETRY_TYPE_PETRA3_P09_EH2_DESCRIPTION);