source: sasview/src/sas/models/c_extension/c_models/sld_cal.cpp @ cd06a5f

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since cd06a5f was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * Scattering model classes
3 * The classes use the IGOR library found in
4 *   sansmodels/c_extensions/libmultifunc/librefl.h
5 */
6
7#include <math.h>
8#include "parameters.hh"
9#include <stdio.h>
10using namespace std;
11#include "sld_cal.h"
12
13extern "C" {
14#include "libmultifunc/librefl.h"
15}
16
17// Convenience structure
18typedef struct {
19    double fun_type;
20    double npts_inter;
21    double shell_num;
22    double nu_inter;
23    double sld_left;
24    double sld_right;
25} SLDCalParameters;
26
27/**
28 * Function to calculate sld
29 * @param pars: parameters
30 * @param x: independent param-value
31 * @return: sld value
32 */
33static double sld_cal_analytical_1D(SLDCalParameters *pars, double x) {
34  double fun, nsl, n_s, fun_coef, sld_l, sld_r, sld_out;
35  int fun_type;
36
37  fun = pars->fun_type;
38  nsl = pars->npts_inter;
39  n_s = pars->shell_num;
40  fun_coef = pars->nu_inter;
41  sld_l = pars-> sld_left;
42  sld_r = pars-> sld_right;
43
44  fun_type = floor(fun);
45
46  sld_out = intersldfunc(fun_type, nsl, n_s, fun_coef, sld_l, sld_r);
47
48  return sld_out;
49}
50
51SLDCalFunc :: SLDCalFunc() {
52        fun_type     = Parameter(0);
53        npts_inter   = Parameter(21);
54        shell_num        = Parameter(1);
55        nu_inter         = Parameter(2.5);
56        sld_left         = Parameter(1.0e-06);
57        sld_right        = Parameter(2.0e-06);
58}
59
60/**
61 * Function to evaluate 1D scattering function
62 * @param q: q-value
63 * @return: function value
64 */
65double SLDCalFunc :: operator()(double q) {
66        SLDCalParameters dp;
67
68        dp.fun_type = fun_type();
69        dp.npts_inter = npts_inter();
70        dp.shell_num = shell_num();
71        dp.nu_inter = nu_inter();
72        dp.sld_left = sld_left();
73        dp.sld_right = sld_right();
74
75        return sld_cal_analytical_1D(&dp, q);
76}
77
78/**
79 * Function to evaluate 2D scattering function
80 * @param q_x: value of Q along x
81 * @param q_y: value of Q along y
82 * @return: function value
83 */
84double SLDCalFunc :: operator()(double qx, double qy) {
85        double q = sqrt(qx*qx + qy*qy);
86                return (*this).operator()(q);
87}
88
89/**
90 * Function to evaluate 2D scattering function
91 * @param pars: parameters of the cylinder
92 * @param q: q-value
93 * @param phi: angle phi
94 * @return: function value
95 */
96double SLDCalFunc :: evaluate_rphi(double q, double phi) {
97        return (*this).operator()(q);
98}
99/**
100 * Function to calculate effective radius
101 * @return: effective radius value
102 */
103double SLDCalFunc :: calculate_ER() {
104//NOT implemented yet!!!
105        return 0.0;
106}
107double SLDCalFunc :: calculate_VR() {
108  return 1.0;
109}
Note: See TracBrowser for help on using the repository browser.