source: sasview/sansmodels/src/c_models/GelFit.cpp @ 0da4eba

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 0da4eba was 0da4eba, checked in by Robert Whitley <robert.whitley@…>, 12 years ago

Refs #84. Add Gel Fit model.

  • Property mode set to 100644
File size: 2.9 KB
Line 
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>
26using namespace std;
27#include "GelFit.h"
28
29typedef struct {
30  double lScale;
31  double gScale;
32  double zeta;
33  double radius;
34  double scale;
35  double background;
36}
37
38GelFitModel :: GelFitModel()
39{
40    lScale = Parameter(3.5);
41    gScale = Parameter(1.7);
42    zeta = Parameter(16.0);
43    radius = Parameter(104.0,true);
44    radius.set_min(2.0);
45    scale = Parameter(2.0,true);
46    background = Parameter(0.01);
47}
48
49double GelFitModel :: operator()(double q) 
50{
51    double dp[3];
52    dp[0] = zeta();
53    dp[1] = radius();
54    dp[2] = scale();
55   
56    if (dp[2] <= 0)
57    {
58        //cout << "\n\nThe Scaling Exponent must be > 0";
59        //cout << "\nWill set to 2.0";
60        dp[2] = 2.0;
61    }
62
63    // Lorentzian Term
64    ////////////////////////double a(x[i]*x[i]*zeta*zeta);
65    double a(q*q*dp[0]*dp[0]);
66    double b(1.0 + (((dp[2] + 1.0)/3.0)*a) );
67    double c(pow(b, (dp[2]/2.0) ) );
68   
69    // Exponential Term
70    ////////////////////////double d(x[i]*x[i]*rg*rg);
71    double d(q*q*dp[1]*dp[1]);
72    double e(-1.0*(d/3.0) );
73    double f(exp(e));
74       
75        // Scattering Law
76        ///////////////////////////////ycal[j] = ((lScale/c) + (gScale*f) + bkgd);
77    return ((lScale()/c) + (gScale()*f) + background());
78}
79
80
81/**
82 * Function to evaluate 2D scattering function
83 * @param q_x: value of Q along x
84 * @param q_y: value of Q along y
85 * @return: function value
86 */
87double GelFitModel :: operator()(double qx, double qy) 
88{
89  double q = sqrt(qx*qx + qy*qy);
90  return (*this).operator()(q);
91}
92
93/**
94 * Function to evaluate 2D scattering function
95 * @param pars: parameters of the cylinder
96 * @param q: q-value
97 * @param phi: angle phi
98 * @return: function value
99 */
100double GelFitModel :: evaluate_rphi(double q, double phi) 
101{
102  double qx = q*cos(phi);
103  double qy = q*sin(phi);
104  return (*this).operator()(qx, qy);
105}
106/**
107 * Function to calculate effective radius
108 * @return: effective radius value
109 */
110double GelFitModel :: calculate_ER() 
111{
112  //NOT implemented yet!!!
113  return 0.0;
114}
115double GelFitModel :: calculate_VR() 
116{
117  return 1.0;
118}
Note: See TracBrowser for help on using the repository browser.