1 | /** |
---|
2 | This software was developed by the University of Tennessee as part of the |
---|
3 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
4 | project funded by the US National Science Foundation. |
---|
5 | |
---|
6 | If you use DANSE applications to do scientific research that leads to |
---|
7 | publication, we ask that you acknowledge the use of the software with the |
---|
8 | following sentence: |
---|
9 | |
---|
10 | "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
11 | |
---|
12 | copyright 2008, University of Tennessee |
---|
13 | */ |
---|
14 | |
---|
15 | /** |
---|
16 | * Scattering model classes |
---|
17 | * The classes use the IGOR library found in |
---|
18 | * sansmodels/src/libigor |
---|
19 | * |
---|
20 | */ |
---|
21 | |
---|
22 | #include <math.h> |
---|
23 | #include "models.hh" |
---|
24 | #include "parameters.hh" |
---|
25 | #include <stdio.h> |
---|
26 | using namespace std; |
---|
27 | |
---|
28 | extern "C" { |
---|
29 | #include "libSphere.h" |
---|
30 | } |
---|
31 | |
---|
32 | MultiShellModel :: MultiShellModel() { |
---|
33 | scale = Parameter(1.0); |
---|
34 | core_radius = Parameter(60.0, true); |
---|
35 | core_radius.set_min(0.0); |
---|
36 | s_thickness = Parameter(10.0); |
---|
37 | w_thickness = Parameter(10.0); |
---|
38 | core_sld = Parameter(6.4e-6); |
---|
39 | shell_sld = Parameter(4.0e-7); |
---|
40 | n_pairs = Parameter(2); |
---|
41 | background = Parameter(0.0); |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * Function to evaluate 1D scattering function |
---|
46 | * The NIST IGOR library is used for the actual calculation. |
---|
47 | * @param q: q-value |
---|
48 | * @return: function value |
---|
49 | */ |
---|
50 | double MultiShellModel :: operator()(double q) { |
---|
51 | double dp[8]; |
---|
52 | |
---|
53 | // Fill parameter array for IGOR library |
---|
54 | // Add the background after averaging |
---|
55 | dp[0] = scale(); |
---|
56 | dp[1] = core_radius(); |
---|
57 | dp[2] = s_thickness(); |
---|
58 | dp[3] = w_thickness(); |
---|
59 | dp[4] = core_sld(); |
---|
60 | dp[5] = shell_sld(); |
---|
61 | dp[6] = n_pairs(); |
---|
62 | dp[7] = background(); |
---|
63 | |
---|
64 | // Get the dispersion points for the core radius |
---|
65 | vector<WeightPoint> weights_core_radius; |
---|
66 | core_radius.get_weights(weights_core_radius); |
---|
67 | |
---|
68 | // Perform the computation, with all weight points |
---|
69 | double sum = 0.0; |
---|
70 | double norm = 0.0; |
---|
71 | |
---|
72 | // Loop over radius weight points |
---|
73 | for(int i=0; i< (int)weights_core_radius.size(); i++) { |
---|
74 | dp[1] = weights_core_radius[i].value; |
---|
75 | |
---|
76 | sum += weights_core_radius[i].weight |
---|
77 | * MultiShell(dp, q); |
---|
78 | norm += weights_core_radius[i].weight; |
---|
79 | } |
---|
80 | return sum/norm + background(); |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * Function to evaluate 2D scattering function |
---|
85 | * @param q_x: value of Q along x |
---|
86 | * @param q_y: value of Q along y |
---|
87 | * @return: function value |
---|
88 | */ |
---|
89 | double MultiShellModel :: operator()(double qx, double qy) { |
---|
90 | double q = sqrt(qx*qx + qy*qy); |
---|
91 | return (*this).operator()(q); |
---|
92 | } |
---|
93 | |
---|
94 | /** |
---|
95 | * Function to evaluate 2D scattering function |
---|
96 | * @param pars: parameters of the multishell |
---|
97 | * @param q: q-value |
---|
98 | * @param phi: angle phi |
---|
99 | * @return: function value |
---|
100 | */ |
---|
101 | double MultiShellModel :: evaluate_rphi(double q, double phi) { |
---|
102 | return (*this).operator()(q); |
---|
103 | } |
---|