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 | * TODO: refactor so that we pull in the old sansmodels.c_extensions |
---|
21 | */ |
---|
22 | |
---|
23 | #include <math.h> |
---|
24 | #include "models.hh" |
---|
25 | #include "parameters.hh" |
---|
26 | #include <stdio.h> |
---|
27 | using namespace std; |
---|
28 | |
---|
29 | extern "C" { |
---|
30 | #include "libCylinder.h" |
---|
31 | #include "lamellar.h" |
---|
32 | } |
---|
33 | |
---|
34 | LamellarModel :: LamellarModel() { |
---|
35 | scale = Parameter(1.0); |
---|
36 | delta = Parameter(50.0); |
---|
37 | delta.set_min(0.0); |
---|
38 | sigma = Parameter(0.15); |
---|
39 | sigma.set_min(0.0); |
---|
40 | contrast = Parameter(5.3e-6); |
---|
41 | background = Parameter(0.0); |
---|
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 LamellarModel :: operator()(double q) { |
---|
52 | double dp[5]; |
---|
53 | |
---|
54 | // Fill parameter array for IGOR library |
---|
55 | // Add the background after averaging |
---|
56 | dp[0] = scale(); |
---|
57 | dp[1] = delta(); |
---|
58 | dp[2] = sigma(); |
---|
59 | dp[3] = contrast(); |
---|
60 | dp[4] = background(); |
---|
61 | |
---|
62 | return LamellarFF(dp, q); |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * Function to evaluate 2D scattering function |
---|
67 | * @param q_x: value of Q along x |
---|
68 | * @param q_y: value of Q along y |
---|
69 | * @return: function value |
---|
70 | */ |
---|
71 | |
---|
72 | double LamellarModel :: operator()(double qx, double qy) { |
---|
73 | double q = sqrt(qx*qx + qy*qy); |
---|
74 | return (*this).operator()(q); |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * Function to evaluate 2D scattering function |
---|
79 | * @param pars: parameters of the lamellar |
---|
80 | * @param q: q-value |
---|
81 | * @param phi: angle phi |
---|
82 | * @return: function value |
---|
83 | */ |
---|
84 | double LamellarModel :: evaluate_rphi(double q, double phi) { |
---|
85 | return (*this).operator()(q); |
---|
86 | } |
---|