fix all the references
[hkl.git] / hkl / hkl-engine-zaxis.c
blob513451c883372bed0c63ab69e55ca64002652fba
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-2014 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-q-private.h" // for hkl_engine_q2_new, etc
25 #include "hkl-pseudoaxis-common-hkl-private.h" // for RUBh_minus_Q, etc
27 /* #define DEBUG */
29 static HklMode* _zaxis()
31 static const char *axes_r[] = {"mu", "omega", "delta", "gamma"};
32 static const char *axes_w[] = {"omega", "delta", "gamma"};
33 static const HklFunction *functions[] = {&RUBh_minus_Q_func};
34 static const HklModeAutoInfo info = {
35 HKL_MODE_AUTO_INFO("zaxis", axes_r, axes_w, functions),
38 return hkl_mode_auto_new(&info,
39 &hkl_full_mode_operations,
40 TRUE);
43 /* reflectivity */
45 static int _reflectivity_func(const gsl_vector *x, void *params, gsl_vector *f)
47 const double mu = x->data[0];
48 const double gamma = x->data[3];
50 CHECK_NAN(x->data, x->size);
52 RUBh_minus_Q(x->data, params, f->data);
53 f->data[3] = mu - gamma;
55 return GSL_SUCCESS;
58 static const HklFunction reflectivity_func = {
59 .function = _reflectivity_func,
60 .size = 4,
63 static HklMode* reflectivity()
65 static const char* axes[] = {"mu", "omega", "delta", "gamma"};
66 static const HklFunction *functions[] = {&reflectivity_func};
67 static const HklModeAutoInfo info = {
68 HKL_MODE_AUTO_INFO(__func__, axes, axes, functions),
71 return hkl_mode_auto_new(&info,
72 &hkl_full_mode_operations,
73 TRUE);
76 /**********************/
77 /* pseudo axis engine */
78 /**********************/
80 static HklEngine *hkl_engine_zaxis_hkl_new(void)
82 HklEngine *self;
83 HklMode *default_mode;
85 self = hkl_engine_hkl_new();
87 default_mode = _zaxis();
88 hkl_engine_add_mode(self, default_mode);
89 hkl_engine_mode_set(self, default_mode);
91 hkl_engine_add_mode(self, reflectivity());
93 return self;
96 /*********/
97 /* ZAXIS */
98 /*********/
100 #define HKL_GEOMETRY_TYPE_ZAXIS_DESCRIPTION \
101 "For this geometry the **mu** axis is common to the sample and the detector.\n" \
102 "\n" \
103 "+ xrays source fix allong the :math:`\\vec{x}` direction (1, 0, 0)\n" \
104 "+ 2 axes for the sample\n" \
105 "\n" \
106 " + **mu** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
107 " + **omega** : rotating around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
108 "\n" \
109 "+ 3 axis for the detector\n" \
110 "\n" \
111 " + **mu** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
112 " + **delta** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
113 " + **gamma** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n"
115 static const char* hkl_geometry_zaxis_axes[] = {"mu", "omega", "delta", "gamma"};
117 static HklGeometry *hkl_geometry_new_zaxis(const HklFactory *factory)
119 HklGeometry *self = hkl_geometry_new(factory);
120 HklHolder *h;
122 h = hkl_geometry_add_holder(self);
123 hkl_holder_add_rotation_axis(h, "mu", 0, 0, 1);
124 hkl_holder_add_rotation_axis(h, "omega", 0, -1, 0);
126 h = hkl_geometry_add_holder(self);
127 hkl_holder_add_rotation_axis(h, "mu", 0, 0, 1);
128 hkl_holder_add_rotation_axis(h, "delta", 0, -1, 0);
129 hkl_holder_add_rotation_axis(h, "gamma", 0, 0, 1);
131 return self;
134 static HklEngineList *hkl_engine_list_new_zaxis(const HklFactory *factory)
136 HklEngineList *self = hkl_engine_list_new();
138 hkl_engine_list_add(self, hkl_engine_zaxis_hkl_new());
139 hkl_engine_list_add(self, hkl_engine_q2_new());
140 hkl_engine_list_add(self, hkl_engine_qper_qpar_new());
142 return self;
145 REGISTER_DIFFRACTOMETER(zaxis, "ZAXIS", HKL_GEOMETRY_TYPE_ZAXIS_DESCRIPTION);