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