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