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-2015 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" // for RUBh_minus_Q, etc
25 #include "hkl-pseudoaxis-common-q-private.h" // for hkl_engine_q2_new, etc
26 #include "hkl-pseudoaxis-common-tth-private.h" // for hkl_engine_tth2_new, etc
30 static HklMode
* _zaxis()
32 static const char *axes_r
[] = {"mu", "omega", "delta", "gamma"};
33 static const char *axes_w
[] = {"omega", "delta", "gamma"};
34 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
35 static const HklModeAutoInfo info
= {
36 HKL_MODE_AUTO_INFO("zaxis", axes_r
, axes_w
, functions
),
39 return hkl_mode_auto_new(&info
,
40 &hkl_full_mode_operations
,
46 static int _reflectivity_func(const gsl_vector
*x
, void *params
, gsl_vector
*f
)
48 const double mu
= x
->data
[0];
49 const double gamma
= x
->data
[3];
51 CHECK_NAN(x
->data
, x
->size
);
53 RUBh_minus_Q(x
->data
, params
, f
->data
);
54 f
->data
[3] = mu
- gamma
;
59 static const HklFunction reflectivity_func
= {
60 .function
= _reflectivity_func
,
64 static HklMode
* reflectivity()
66 static const char* axes
[] = {"mu", "omega", "delta", "gamma"};
67 static const HklFunction
*functions
[] = {&reflectivity_func
};
68 static const HklModeAutoInfo info
= {
69 HKL_MODE_AUTO_INFO(__func__
, axes
, axes
, functions
),
72 return hkl_mode_auto_new(&info
,
73 &hkl_full_mode_operations
,
77 /**********************/
78 /* pseudo axis engine */
79 /**********************/
81 static HklEngine
*hkl_engine_zaxis_hkl_new(HklEngineList
*engines
)
84 HklMode
*default_mode
;
86 self
= hkl_engine_hkl_new(engines
);
88 default_mode
= _zaxis();
89 hkl_engine_add_mode(self
, default_mode
);
90 hkl_engine_mode_set(self
, default_mode
);
92 hkl_engine_add_mode(self
, reflectivity());
101 #define HKL_GEOMETRY_TYPE_ZAXIS_DESCRIPTION \
102 "For this geometry the **mu** axis is common to the sample and the detector.\n" \
104 "+ xrays source fix allong the :math:`\\vec{x}` direction (1, 0, 0)\n" \
105 "+ 2 axes for the sample\n" \
107 " + **mu** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
108 " + **omega** : rotating around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
110 "+ 3 axis for the detector\n" \
112 " + **mu** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n" \
113 " + **delta** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
114 " + **gamma** : rotation around the :math:`\\vec{z}` direction (0, 0, 1)\n"
116 static const char* hkl_geometry_zaxis_axes
[] = {"mu", "omega", "delta", "gamma"};
118 static HklGeometry
*hkl_geometry_new_zaxis(const HklFactory
*factory
)
120 HklGeometry
*self
= hkl_geometry_new(factory
);
123 h
= hkl_geometry_add_holder(self
);
124 hkl_holder_add_rotation_axis(h
, "mu", 0, 0, 1);
125 hkl_holder_add_rotation_axis(h
, "omega", 0, -1, 0);
127 h
= hkl_geometry_add_holder(self
);
128 hkl_holder_add_rotation_axis(h
, "mu", 0, 0, 1);
129 hkl_holder_add_rotation_axis(h
, "delta", 0, -1, 0);
130 hkl_holder_add_rotation_axis(h
, "gamma", 0, 0, 1);
135 static HklEngineList
*hkl_engine_list_new_zaxis(const HklFactory
*factory
)
137 HklEngineList
*self
= hkl_engine_list_new();
139 hkl_engine_list_add(self
, hkl_engine_zaxis_hkl_new(self
));
140 hkl_engine_list_add(self
, hkl_engine_q2_new(self
));
141 hkl_engine_list_add(self
, hkl_engine_qper_qpar_new(self
));
142 hkl_engine_list_add(self
, hkl_engine_tth2_new(self
));
147 REGISTER_DIFFRACTOMETER(zaxis
, "ZAXIS", HKL_GEOMETRY_TYPE_ZAXIS_DESCRIPTION
);