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-2010 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_math.h>
23 #include <gsl/gsl_vector.h>
25 #include <ccan/array_size/array_size.h>
27 #include "hkl-pseudoaxis-auto-private.h"
28 #include "hkl-pseudoaxis-common-hkl-private.h"
32 /***********************/
33 /* numerical functions */
34 /***********************/
36 static int _reflectivity_func(const gsl_vector
*x
, void *params
, gsl_vector
*f
)
38 const double mu
= x
->data
[0];
39 const double gamma
= x
->data
[3];
41 CHECK_NAN(x
->data
, x
->size
);
43 RUBh_minus_Q(x
->data
, params
, f
->data
);
44 f
->data
[3] = mu
- gamma
;
49 static const HklFunction reflectivity_func
= {
50 .function
= _reflectivity_func
,
58 static HklMode
* zaxis()
60 static const char* axes
[] = {"omega", "delta", "gamma"};
61 static const HklFunction
*functions
[] = {&RUBh_minus_Q_func
};
62 static const HklModeAutoInfo info
= {
63 INFO_AUTO(__func__
, axes
, functions
),
66 return hkl_mode_auto_new(&info
,
67 &hkl_full_mode_operations
);
70 static HklMode
* reflectivity()
72 static const char* axes
[] = {"mu", "omega", "delta", "gamma"};
73 static const HklFunction
*functions
[] = {&reflectivity_func
};
74 static const HklModeAutoInfo info
= {
75 INFO_AUTO(__func__
, axes
, functions
),
78 return hkl_mode_auto_new(&info
,
79 &hkl_full_mode_operations
);
82 /**********************/
83 /* pseudo axis engine */
84 /**********************/
86 HklEngine
*hkl_engine_zaxis_hkl_new(void)
89 HklMode
*default_mode
;
91 self
= hkl_engine_hkl_new();
93 default_mode
= zaxis();
94 hkl_engine_add_mode(self
, default_mode
);
95 hkl_engine_select_mode(self
, default_mode
);
97 hkl_engine_add_mode(self
, reflectivity());