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>
21 * Maria-Teresa Nunez-Pardo-de-Verra <tnunez@mail.desy.de>
23 #include <gsl/gsl_vector_double.h> // for gsl_vector
24 #include "hkl-pseudoaxis-auto-private.h"
25 #include "hkl-pseudoaxis-private.h" // for HklModeOperations, etc
26 #include "hkl.h" // for HklEngine, HklDetector, etc
28 typedef struct _HklEngineHkl HklEngineHkl
;
29 struct _HklEngineHkl
{
36 extern int _RUBh_minus_Q_func(const gsl_vector
*x
, void *params
, gsl_vector
*f
);
37 extern int _double_diffraction_func(const gsl_vector
*x
, void *params
, gsl_vector
*f
);
38 extern int _psi_constant_vertical_func(const gsl_vector
*x
, void *params
, gsl_vector
*f
);
40 extern int RUBh_minus_Q(double const x
[], void *params
, double f
[]);
41 extern int _double_diffraction(double const x
[], void *params
, double f
[]);
43 extern int hkl_mode_get_hkl_real(HklMode
*self
,
45 HklGeometry
*geometry
,
46 HklDetector
*detector
,
50 extern int hkl_mode_set_hkl_real(HklMode
*self
,
52 HklGeometry
*geometry
,
53 HklDetector
*detector
,
57 extern int hkl_mode_initialized_set_psi_constant_vertical_real(HklMode
*base
,
59 HklGeometry
*geometry
,
60 HklDetector
*detector
,
65 extern HklEngine
*hkl_engine_hkl_new(HklEngineList
*engines
);
67 #define HKL_MODE_OPERATIONS_HKL_DEFAULTS \
68 HKL_MODE_OPERATIONS_AUTO_DEFAULTS, \
69 .get = hkl_mode_get_hkl_real
71 static const HklModeOperations hkl_mode_operations
= {
72 HKL_MODE_OPERATIONS_HKL_DEFAULTS
,
75 static const HklModeOperations hkl_full_mode_operations
= {
76 HKL_MODE_OPERATIONS_HKL_DEFAULTS
,
77 .set
= hkl_mode_set_hkl_real
,
80 static const HklModeOperations psi_constant_vertical_mode_operations
= {
81 HKL_MODE_OPERATIONS_HKL_DEFAULTS
,
82 .capabilities
= HKL_ENGINE_CAPABILITIES_READABLE
| HKL_ENGINE_CAPABILITIES_WRITABLE
| HKL_ENGINE_CAPABILITIES_INITIALIZABLE
,
83 .initialized_set
= hkl_mode_initialized_set_psi_constant_vertical_real
,
84 .set
= hkl_mode_set_hkl_real
,
87 static const HklModeOperations constant_incidence_mode_operations
= {
88 HKL_MODE_OPERATIONS_AUTO_WITH_INIT_DEFAULTS
,
89 .get
= hkl_mode_get_hkl_real
,
90 .set
= hkl_mode_set_hkl_real
93 static const HklFunction RUBh_minus_Q_func
= {
94 .function
= _RUBh_minus_Q_func
,
98 static const HklFunction double_diffraction_func
= {
99 .function
= _double_diffraction_func
,
103 static const HklFunction psi_constant_vertical_func
= {
104 .function
= _psi_constant_vertical_func
,
108 /* mode parameters */
110 #define CONSTANT_PARAMETER(_name) \
112 HKL_PARAMETER_DEFAULTS_ANGLE, .name = #_name, \
113 .description = "the freezed value", \
116 #define PSI_CONSTANT_PARAMETERS(_h2, _k2, _l2, _psi) \
118 HKL_PARAMETER_DEFAULTS, .name = "h2", ._value = _h2, \
119 .description = "h coordinate of the reference plan", \
120 .range = { .min=-1, .max=1 }, \
123 HKL_PARAMETER_DEFAULTS, .name = "k2", ._value = _k2, \
124 .description = "k coordinate of the reference plan", \
125 .range = { .min=-1, .max=1 }, \
128 HKL_PARAMETER_DEFAULTS, .name = "l2", ._value = _l2, \
129 .description = "l coordinate of the reference plan", \
130 .range = { .min=-1, .max=1 }, \
133 HKL_PARAMETER_DEFAULTS_ANGLE, .name = "psi", ._value = _psi, \
134 .description = "expected angle between the reference and the diffraction plans", \
137 static const HklParameter constant_omega_parameters
[] = { CONSTANT_PARAMETER(omega
) };
138 static const HklParameter constant_chi_parameters
[] = { CONSTANT_PARAMETER(chi
) };
139 static const HklParameter constant_phi_parameters
[] = { CONSTANT_PARAMETER(phi
) };
141 /* outside the mode because used in more than one mode */
142 static const HklParameter double_diffraction_parameters
[] = {
144 HKL_PARAMETER_DEFAULTS
, .name
= "h2", ._value
= 1,
145 .description
= "h coordinate of the second diffracting plan",
146 .range
= {.min
=-1, .max
=1},
149 HKL_PARAMETER_DEFAULTS
, .name
= "k2", ._value
= 1,
150 .description
= "k coordinate of the second diffracting plan",
151 .range
= {.min
=-1, .max
=1},
154 HKL_PARAMETER_DEFAULTS
, .name
= "l2", ._value
= 1,
155 .description
= "l coordinate of the second diffracting plan",
156 .range
= {.min
=-1, .max
=1},
160 static const HklParameter psi_constant_parameters
[] = { PSI_CONSTANT_PARAMETERS(1, 1, 1, 0) };
162 static const HklParameter constant_incidence_parameters
[] = {
164 HKL_PARAMETER_DEFAULTS
, .name
= "x", ._value
= 1,
165 .description
= "the x coordinate of the surface $\\vec{n}$",
166 .range
= { .min
=-1, .max
=1 },
169 HKL_PARAMETER_DEFAULTS
, .name
= "y", ._value
= 1,
170 .description
= "the y coordinate of the surface $\\vec{n}$",
171 .range
= { .min
=-1, .max
=1 },
174 HKL_PARAMETER_DEFAULTS
, .name
= "z", ._value
= 1,
175 .description
= "the z coordinate of the surface $\\vec{n}$",
176 .range
= { .min
=-1, .max
=1 },
179 HKL_PARAMETER_DEFAULTS_ANGLE
, .name
= "incidence",
180 .description
= "expected incidence of the incoming beam $\\vec{k_i}$ on the surface."
183 HKL_PARAMETER_DEFAULTS_ANGLE
, .name
= "azimuth", ._value
= M_PI_2
,
184 .description
= "expected azimuth",