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 | * TODO: refactor so that we pull in the old sansmodels.c_extensions |
---|
21 | */ |
---|
22 | |
---|
23 | #include <math.h> |
---|
24 | #include "models.hh" |
---|
25 | #include "parameters.hh" |
---|
26 | #include <stdio.h> |
---|
27 | using namespace std; |
---|
28 | |
---|
29 | extern "C" { |
---|
30 | #include "libCylinder.h" |
---|
31 | #include "lamellar.h" |
---|
32 | } |
---|
33 | |
---|
34 | LamellarModel :: LamellarModel() { |
---|
35 | scale = Parameter(1.0); |
---|
36 | bi_thick = Parameter(50.0, true); |
---|
37 | bi_thick.set_min(0.0); |
---|
38 | sld_bi = Parameter(1.0e-6); |
---|
39 | sld_sol = Parameter(6.3e-6); |
---|
40 | background = Parameter(0.0); |
---|
41 | |
---|
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 LamellarModel :: operator()(double q) { |
---|
51 | double dp[5]; |
---|
52 | |
---|
53 | // Fill parameter array for IGOR library |
---|
54 | // Add the background after averaging |
---|
55 | dp[0] = scale(); |
---|
56 | dp[1] = bi_thick(); |
---|
57 | dp[2] = sld_bi(); |
---|
58 | dp[3] = sld_sol(); |
---|
59 | dp[4] = 0.0; |
---|
60 | |
---|
61 | // Get the dispersion points for the bi_thick |
---|
62 | vector<WeightPoint> weights_bi_thick; |
---|
63 | bi_thick.get_weights(weights_bi_thick); |
---|
64 | // Perform the computation, with all weight points |
---|
65 | double sum = 0.0; |
---|
66 | double norm = 0.0; |
---|
67 | |
---|
68 | // Loop over short_edgeA weight points |
---|
69 | for(int i=0; i< (int)weights_bi_thick.size(); i++) { |
---|
70 | dp[1] = weights_bi_thick[i].value; |
---|
71 | |
---|
72 | sum += weights_bi_thick[i].weight * lamellar_kernel(dp, q); |
---|
73 | norm += weights_bi_thick[i].weight; |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | return sum/norm + background(); |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * Function to evaluate 2D scattering function |
---|
82 | * @param q_x: value of Q along x |
---|
83 | * @param q_y: value of Q along y |
---|
84 | * @return: function value |
---|
85 | */ |
---|
86 | |
---|
87 | double LamellarModel :: operator()(double qx, double qy) { |
---|
88 | double q = sqrt(qx*qx + qy*qy); |
---|
89 | return (*this).operator()(q); |
---|
90 | } |
---|
91 | |
---|
92 | /** |
---|
93 | * Function to evaluate 2D scattering function |
---|
94 | * @param pars: parameters of the lamellar |
---|
95 | * @param q: q-value |
---|
96 | * @param phi: angle phi |
---|
97 | * @return: function value |
---|
98 | */ |
---|
99 | double LamellarModel :: evaluate_rphi(double q, double phi) { |
---|
100 | return (*this).operator()(q); |
---|
101 | } |
---|