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 | BinaryHSPSF11Model :: BinaryHSPSF11Model() { |
---|
33 | |
---|
34 | l_radius = Parameter(160.0, true); |
---|
35 | l_radius.set_min(0.0); |
---|
36 | s_radius = Parameter(25.0, true); |
---|
37 | s_radius.set_min(0.0); |
---|
38 | vol_frac_ls = Parameter(0.2); |
---|
39 | vol_frac_ss = Parameter(0.1); |
---|
40 | ls_sld = Parameter(3.5e-6); |
---|
41 | ss_sld = Parameter(5e-7); |
---|
42 | solvent_sld = Parameter(6.36e-6); |
---|
43 | background = Parameter(0.0); |
---|
44 | } |
---|
45 | |
---|
46 | /** |
---|
47 | * Function to evaluate 1D scattering function |
---|
48 | * The NIST IGOR library is used for the actual calculation. |
---|
49 | * @param q: q-value |
---|
50 | * @return: function value |
---|
51 | */ |
---|
52 | double BinaryHSPSF11Model :: operator()(double q) { |
---|
53 | double dp[8]; |
---|
54 | |
---|
55 | // Fill parameter array for IGOR library |
---|
56 | // Add the background after averaging |
---|
57 | dp[0] = l_radius(); |
---|
58 | dp[1] = s_radius(); |
---|
59 | dp[2] = vol_frac_ls(); |
---|
60 | dp[3] = vol_frac_ss(); |
---|
61 | dp[4] = ls_sld(); |
---|
62 | dp[5] = ss_sld(); |
---|
63 | dp[6] = solvent_sld(); |
---|
64 | dp[7] = 0.0; |
---|
65 | |
---|
66 | |
---|
67 | // Get the dispersion points for the large radius |
---|
68 | vector<WeightPoint> weights_l_radius; |
---|
69 | l_radius.get_weights(weights_l_radius); |
---|
70 | |
---|
71 | // Get the dispersion points for the small radius |
---|
72 | vector<WeightPoint> weights_s_radius; |
---|
73 | s_radius.get_weights(weights_s_radius); |
---|
74 | |
---|
75 | // Perform the computation, with all weight points |
---|
76 | double sum = 0.0; |
---|
77 | double norm = 0.0; |
---|
78 | |
---|
79 | // Loop over larger radius weight points |
---|
80 | for(int i=0; i< (int)weights_l_radius.size(); i++) { |
---|
81 | dp[0] = weights_l_radius[i].value; |
---|
82 | |
---|
83 | // Loop over small radius weight points |
---|
84 | for(int j=0; j< (int)weights_s_radius.size(); j++) { |
---|
85 | dp[1] = weights_s_radius[j].value; |
---|
86 | |
---|
87 | |
---|
88 | sum += weights_l_radius[i].weight *weights_s_radius[j].weight * BinaryHS_PSF11(dp, q); |
---|
89 | norm += weights_l_radius[i].weight *weights_s_radius[j].weight; |
---|
90 | } |
---|
91 | } |
---|
92 | return sum/norm + background(); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * Function to evaluate 2D scattering function |
---|
97 | * @param q_x: value of Q along x |
---|
98 | * @param q_y: value of Q along y |
---|
99 | * @return: function value |
---|
100 | */ |
---|
101 | double BinaryHSPSF11Model :: operator()(double qx, double qy) { |
---|
102 | double q = sqrt(qx*qx + qy*qy); |
---|
103 | return (*this).operator()(q); |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * Function to evaluate 2D scattering function |
---|
108 | * @param pars: parameters of the vesicle |
---|
109 | * @param q: q-value |
---|
110 | * @param phi: angle phi |
---|
111 | * @return: function value |
---|
112 | */ |
---|
113 | double BinaryHSPSF11Model :: evaluate_rphi(double q, double phi) { |
---|
114 | return (*this).operator()(q); |
---|
115 | } |
---|