[230f479] | 1 | |
---|
| 2 | /* |
---|
| 3 | This software was developed by the University of Tennessee as part of the |
---|
| 4 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 5 | project funded by the US National Science Foundation. |
---|
| 6 | |
---|
| 7 | If you use DANSE applications to do scientific research that leads to |
---|
| 8 | publication, we ask that you acknowledge the use of the software with the |
---|
| 9 | following sentence: |
---|
| 10 | |
---|
| 11 | "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
| 12 | |
---|
| 13 | copyright 2008, University of Tennessee |
---|
| 14 | |
---|
| 15 | SHIBAYAMA-GEISSLER TWO-LENGTH SCALE SCATTERING FUNCTION FOR GELS |
---|
| 16 | |
---|
| 17 | See Sibayama, Tanaka & Han, J Chem Phys, (1992), 97(9), 6829-6841 |
---|
| 18 | or Mallam, Horkay, Hecht, Rennie & Geissler, Macromol, (1991), 24, 543 |
---|
| 19 | |
---|
| 20 | Ported to C++ from Fortran by Robert Whitley (2012) |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | #include <math.h> |
---|
| 24 | #include "parameters.hh" |
---|
| 25 | #include <stdio.h> |
---|
| 26 | using namespace std; |
---|
| 27 | #include "GelFit.h" |
---|
| 28 | |
---|
| 29 | GelFitModel::GelFitModel() |
---|
| 30 | { |
---|
| 31 | lScale = Parameter(3.5); |
---|
| 32 | gScale = Parameter(1.7); |
---|
| 33 | zeta = Parameter(16.0); |
---|
| 34 | radius = Parameter(104.0,true); |
---|
| 35 | radius.set_min(2.0); |
---|
[1d115ef] | 36 | FractalExp = Parameter(2.0,true); |
---|
[230f479] | 37 | background = Parameter(0.01); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | double GelFitModel::operator()(double q) |
---|
| 41 | { |
---|
| 42 | double dp[3]; |
---|
| 43 | dp[0] = zeta(); |
---|
| 44 | dp[1] = radius(); |
---|
[1d115ef] | 45 | dp[2] = FractalExp(); |
---|
[230f479] | 46 | |
---|
| 47 | if (dp[2] <= 0) |
---|
| 48 | { |
---|
| 49 | //cout << "\n\nThe Scaling Exponent must be > 0"; |
---|
| 50 | //cout << "\nWill set to 2.0"; |
---|
| 51 | dp[2] = 2.0; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | // Lorentzian Term |
---|
| 55 | ////////////////////////double a(x[i]*x[i]*zeta*zeta); |
---|
| 56 | double a(q*q*dp[0]*dp[0]); |
---|
| 57 | double b(1.0 + (((dp[2] + 1.0)/3.0)*a) ); |
---|
| 58 | double c(pow(b, (dp[2]/2.0) ) ); |
---|
| 59 | |
---|
| 60 | // Exponential Term |
---|
| 61 | ////////////////////////double d(x[i]*x[i]*rg*rg); |
---|
| 62 | double d(q*q*dp[1]*dp[1]); |
---|
| 63 | double e(-1.0*(d/3.0) ); |
---|
| 64 | double f(exp(e)); |
---|
| 65 | |
---|
| 66 | // Scattering Law |
---|
| 67 | double result((lScale()/c) + (gScale()*f) + background()); |
---|
| 68 | return result; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Function to evaluate 2D scattering function |
---|
| 74 | * @param q_x: value of Q along x |
---|
| 75 | * @param q_y: value of Q along y |
---|
| 76 | * @return: function value |
---|
| 77 | */ |
---|
| 78 | double GelFitModel::operator()(double qx, double qy) |
---|
| 79 | { |
---|
| 80 | double q = sqrt(qx*qx + qy*qy); |
---|
| 81 | return (*this).operator()(q); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * Function to evaluate 2D scattering function |
---|
| 86 | * @param pars: parameters of the cylinder |
---|
| 87 | * @param q: q-value |
---|
| 88 | * @param phi: angle phi |
---|
| 89 | * @return: function value |
---|
| 90 | */ |
---|
| 91 | double GelFitModel::evaluate_rphi(double q, double phi) |
---|
| 92 | { |
---|
| 93 | double qx = q*cos(phi); |
---|
| 94 | double qy = q*sin(phi); |
---|
| 95 | return (*this).operator()(qx, qy); |
---|
| 96 | } |
---|
| 97 | /** |
---|
| 98 | * Function to calculate effective radius |
---|
| 99 | * @return: effective radius value |
---|
| 100 | */ |
---|
| 101 | double GelFitModel::calculate_ER() |
---|
| 102 | { |
---|
| 103 | //NOT implemented yet!!! |
---|
| 104 | return 0.0; |
---|
| 105 | } |
---|
| 106 | double GelFitModel::calculate_VR() |
---|
| 107 | { |
---|
| 108 | return 1.0; |
---|
| 109 | } |
---|