[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 "lamellarFF_HG.h" |
---|
[34c3020] | 27 | |
---|
| 28 | extern "C" { |
---|
[82c11d3] | 29 | #include "libCylinder.h" |
---|
[34c3020] | 30 | } |
---|
| 31 | |
---|
| 32 | LamellarFFHGModel :: LamellarFFHGModel() { |
---|
[82c11d3] | 33 | scale = Parameter(1.0); |
---|
| 34 | t_length = Parameter(15.0, true); |
---|
| 35 | t_length.set_min(0.0); |
---|
| 36 | h_thickness = Parameter(10.0, true); |
---|
| 37 | h_thickness.set_min(0.0); |
---|
| 38 | sld_tail = Parameter(4e-7); |
---|
| 39 | sld_head = Parameter(3e-6); |
---|
| 40 | sld_solvent = Parameter(6e-6); |
---|
| 41 | background = Parameter(0.0); |
---|
[34c3020] | 42 | |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * Function to evaluate 1D scattering function |
---|
| 47 | * The NIST IGOR library is used for the actual calculation. |
---|
| 48 | * @param q: q-value |
---|
| 49 | * @return: function value |
---|
| 50 | */ |
---|
| 51 | double LamellarFFHGModel :: operator()(double q) { |
---|
[82c11d3] | 52 | double dp[7]; |
---|
| 53 | |
---|
| 54 | // Fill parameter array for IGOR library |
---|
| 55 | // Add the background after averaging |
---|
| 56 | dp[0] = scale(); |
---|
| 57 | dp[1] = t_length(); |
---|
| 58 | dp[2] = h_thickness(); |
---|
| 59 | dp[3] = sld_tail(); |
---|
| 60 | dp[4] = sld_head(); |
---|
| 61 | dp[5] = sld_solvent(); |
---|
| 62 | dp[6] = 0.0; |
---|
| 63 | |
---|
| 64 | // Get the dispersion points for the tail length |
---|
| 65 | vector<WeightPoint> weights_t_length; |
---|
| 66 | t_length.get_weights(weights_t_length); |
---|
| 67 | |
---|
| 68 | // Get the dispersion points for the head thickness |
---|
| 69 | vector<WeightPoint> weights_h_thickness; |
---|
| 70 | h_thickness.get_weights(weights_h_thickness); |
---|
| 71 | |
---|
| 72 | // Perform the computation, with all weight points |
---|
| 73 | double sum = 0.0; |
---|
| 74 | double norm = 0.0; |
---|
| 75 | |
---|
| 76 | // Loop over semi axis A weight points |
---|
| 77 | for(int i=0; i< (int)weights_t_length.size(); i++) { |
---|
| 78 | dp[1] = weights_t_length[i].value; |
---|
| 79 | |
---|
| 80 | for (int j=0; j< (int)weights_h_thickness.size(); j++){ |
---|
| 81 | dp[2] = weights_h_thickness[j].value; |
---|
| 82 | |
---|
| 83 | sum += weights_t_length[i].weight* weights_h_thickness[j].weight*LamellarFF_HG(dp, q); |
---|
| 84 | norm += weights_t_length[i].weight* weights_h_thickness[j].weight; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | return sum/norm + background(); |
---|
[34c3020] | 89 | } |
---|
| 90 | |
---|
| 91 | /** |
---|
| 92 | * Function to evaluate 2D scattering function |
---|
| 93 | * @param q_x: value of Q along x |
---|
| 94 | * @param q_y: value of Q along y |
---|
| 95 | * @return: function value |
---|
| 96 | */ |
---|
| 97 | |
---|
| 98 | double LamellarFFHGModel :: operator()(double qx, double qy) { |
---|
[82c11d3] | 99 | double q = sqrt(qx*qx + qy*qy); |
---|
| 100 | return (*this).operator()(q); |
---|
[34c3020] | 101 | } |
---|
| 102 | |
---|
| 103 | /** |
---|
| 104 | * Function to evaluate 2D scattering function |
---|
| 105 | * @param pars: parameters of the lamellar |
---|
| 106 | * @param q: q-value |
---|
| 107 | * @param phi: angle phi |
---|
| 108 | * @return: function value |
---|
| 109 | */ |
---|
| 110 | double LamellarFFHGModel :: evaluate_rphi(double q, double phi) { |
---|
[82c11d3] | 111 | return (*this).operator()(q); |
---|
[34c3020] | 112 | } |
---|
[5eb9154] | 113 | /** |
---|
| 114 | * Function to calculate effective radius |
---|
| 115 | * @return: effective radius value |
---|
| 116 | */ |
---|
| 117 | double LamellarFFHGModel :: calculate_ER() { |
---|
[82c11d3] | 118 | //NOT implemented yet!!! |
---|
| 119 | return 0.0; |
---|
[5eb9154] | 120 | } |
---|