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 | #include <math.h> |
---|
16 | #include "parameters.hh" |
---|
17 | #include <stdio.h> |
---|
18 | using namespace std; |
---|
19 | #include "schulz.h" |
---|
20 | |
---|
21 | #if defined(_MSC_VER) |
---|
22 | #include "gamma_win.h" |
---|
23 | #endif |
---|
24 | |
---|
25 | Schulz :: Schulz() { |
---|
26 | scale = Parameter(1.0, true); |
---|
27 | sigma = Parameter(1.0, true); |
---|
28 | center = Parameter(0.0, true); |
---|
29 | } |
---|
30 | |
---|
31 | /** |
---|
32 | * Function to evaluate 1D scattering function |
---|
33 | /** |
---|
34 | * Function to evaluate 1D Schulz function. |
---|
35 | * The function is normalized to the 'scale' parameter. |
---|
36 | * |
---|
37 | * f(x)=scale * math.pow(z+1, z+1)*math.pow((R), z)* |
---|
38 | * math.exp(-R*(z+1))/(center*gamma(z+1) |
---|
39 | * z= math.pow[(1/(sigma/center),2]-1 |
---|
40 | * R= x/center |
---|
41 | * |
---|
42 | * @param q: q-value |
---|
43 | * @return: function value |
---|
44 | */ |
---|
45 | double Schulz :: operator()(double q) { |
---|
46 | double z = pow(center()/ sigma(), 2)-1; |
---|
47 | double R= q/center(); |
---|
48 | double zz= z+1; |
---|
49 | double expo; |
---|
50 | expo = log(scale())+zz*log(zz)+z*log(R)-R*zz-log(center())-lgamma(zz); |
---|
51 | |
---|
52 | return exp(expo);//scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((center) * tgamma(zz)) ; |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * Function to evaluate 2D schulz function |
---|
57 | * The function is normalized to the 'scale' parameter. |
---|
58 | * |
---|
59 | * f(x,y) = Schulz(x) * Schulz(y) |
---|
60 | * |
---|
61 | * where both Shulzs share the same parameters. |
---|
62 | * @param q_x: value of Q along x |
---|
63 | * @param q_y: value of Q along y |
---|
64 | * @return: function value |
---|
65 | */ |
---|
66 | double Schulz :: operator()(double qx, double qy) { |
---|
67 | return (*this).operator()(qx) * (*this).operator()(qy); |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * Function to evaluate 2D schulz function |
---|
72 | * The function is normalized to the 'scale' parameter. |
---|
73 | * |
---|
74 | * f(x,y) = Schulz(x) * Schulz(y) |
---|
75 | * |
---|
76 | * where both Shulzs share the same parameters. |
---|
77 | * @param pars: parameters of the cylinder |
---|
78 | * @param q: q-value |
---|
79 | * @param phi: angle phi |
---|
80 | * @return: function value |
---|
81 | */ |
---|
82 | double Schulz :: evaluate_rphi(double q, double phi) { |
---|
83 | double qx = q*cos(phi); |
---|
84 | double qy = q*sin(phi); |
---|
85 | return (*this).operator()(qx, qy); |
---|
86 | } |
---|
87 | /** |
---|
88 | * Function to calculate effective radius |
---|
89 | * @return: effective radius value |
---|
90 | */ |
---|
91 | double Schulz :: calculate_ER() { |
---|
92 | //NOT implemented yet!!! |
---|
93 | return 0.0; |
---|
94 | } |
---|