[34c3020] | 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; |
---|
[82c11d3] | 26 | #include "lamellar.h" |
---|
[34c3020] | 27 | |
---|
[82c11d3] | 28 | /* LamellarFFX : calculates the form factor of a lamellar structure - no S(q) effects included |
---|
| 29 | -NO polydispersion included |
---|
| 30 | */ |
---|
| 31 | static double lamellar_kernel(double dp[], double q){ |
---|
| 32 | double scale,del,sld_bi,sld_sol,contr,bkg; //local variables of coefficient wave |
---|
| 33 | double inten, qval,Pq; |
---|
| 34 | double Pi; |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | Pi = 4.0*atan(1.0); |
---|
| 38 | scale = dp[0]; |
---|
| 39 | del = dp[1]; |
---|
| 40 | sld_bi = dp[2]; |
---|
| 41 | sld_sol = dp[3]; |
---|
| 42 | bkg = dp[4]; |
---|
| 43 | qval = q; |
---|
| 44 | contr = sld_bi -sld_sol; |
---|
| 45 | |
---|
| 46 | Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)); |
---|
| 47 | |
---|
| 48 | inten = 2.0*Pi*scale*Pq/(qval*qval); //this is now dimensionless... |
---|
| 49 | |
---|
| 50 | inten /= del; //normalize by the thickness (in A) |
---|
| 51 | |
---|
| 52 | inten *= 1.0e8; // 1/A to 1/cm |
---|
| 53 | |
---|
| 54 | return(inten+bkg); |
---|
[34c3020] | 55 | } |
---|
| 56 | |
---|
| 57 | LamellarModel :: LamellarModel() { |
---|
| 58 | scale = Parameter(1.0); |
---|
[975ec8e] | 59 | bi_thick = Parameter(50.0, true); |
---|
| 60 | bi_thick.set_min(0.0); |
---|
| 61 | sld_bi = Parameter(1.0e-6); |
---|
| 62 | sld_sol = Parameter(6.3e-6); |
---|
[34c3020] | 63 | background = Parameter(0.0); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Function to evaluate 1D scattering function |
---|
| 68 | * The NIST IGOR library is used for the actual calculation. |
---|
| 69 | * @param q: q-value |
---|
| 70 | * @return: function value |
---|
| 71 | */ |
---|
| 72 | double LamellarModel :: operator()(double q) { |
---|
| 73 | double dp[5]; |
---|
| 74 | |
---|
| 75 | // Fill parameter array for IGOR library |
---|
| 76 | // Add the background after averaging |
---|
| 77 | dp[0] = scale(); |
---|
[975ec8e] | 78 | dp[1] = bi_thick(); |
---|
| 79 | dp[2] = sld_bi(); |
---|
| 80 | dp[3] = sld_sol(); |
---|
| 81 | dp[4] = 0.0; |
---|
[34c3020] | 82 | |
---|
[975ec8e] | 83 | // Get the dispersion points for the bi_thick |
---|
| 84 | vector<WeightPoint> weights_bi_thick; |
---|
| 85 | bi_thick.get_weights(weights_bi_thick); |
---|
| 86 | // Perform the computation, with all weight points |
---|
| 87 | double sum = 0.0; |
---|
| 88 | double norm = 0.0; |
---|
| 89 | |
---|
| 90 | // Loop over short_edgeA weight points |
---|
| 91 | for(int i=0; i< (int)weights_bi_thick.size(); i++) { |
---|
| 92 | dp[1] = weights_bi_thick[i].value; |
---|
| 93 | |
---|
| 94 | sum += weights_bi_thick[i].weight * lamellar_kernel(dp, q); |
---|
| 95 | norm += weights_bi_thick[i].weight; |
---|
| 96 | |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | return sum/norm + background(); |
---|
[34c3020] | 100 | } |
---|
| 101 | |
---|
| 102 | /** |
---|
| 103 | * Function to evaluate 2D scattering function |
---|
| 104 | * @param q_x: value of Q along x |
---|
| 105 | * @param q_y: value of Q along y |
---|
| 106 | * @return: function value |
---|
| 107 | */ |
---|
| 108 | |
---|
| 109 | double LamellarModel :: operator()(double qx, double qy) { |
---|
[42f193a] | 110 | double q = sqrt(qx*qx + qy*qy); |
---|
| 111 | return (*this).operator()(q); |
---|
[34c3020] | 112 | } |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * Function to evaluate 2D scattering function |
---|
| 116 | * @param pars: parameters of the lamellar |
---|
| 117 | * @param q: q-value |
---|
| 118 | * @param phi: angle phi |
---|
| 119 | * @return: function value |
---|
| 120 | */ |
---|
| 121 | double LamellarModel :: evaluate_rphi(double q, double phi) { |
---|
[42f193a] | 122 | return (*this).operator()(q); |
---|
[34c3020] | 123 | } |
---|
[5eb9154] | 124 | /** |
---|
| 125 | * Function to calculate effective radius |
---|
| 126 | * @return: effective radius value |
---|
| 127 | */ |
---|
| 128 | double LamellarModel :: calculate_ER() { |
---|
| 129 | //NOT implemented yet!!! |
---|
[34c2649] | 130 | return 0.0; |
---|
[5eb9154] | 131 | } |
---|
[e08bd5b] | 132 | double LamellarModel :: calculate_VR() { |
---|
| 133 | return 1.0; |
---|
| 134 | } |
---|