source: sasview/src/sas/models/c_extension/c_models/GelFit.cpp @ 7bcbeb7

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 7bcbeb7 was 1d115ef, checked in by butler, 9 years ago

fix parameter name - was scale now is FractalExp? as it should be. This
model has two scale parameters: one for the Guinier term and one for the
Lorentz term. The fractal exponent D (used in the Lorentz term) was
cofusingly labeled scale in the gui.

  • Property mode set to 100644
File size: 2.8 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
29GelFitModel::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);
36    FractalExp = Parameter(2.0,true);
37    background = Parameter(0.01);
38}
39
40double GelFitModel::operator()(double q) 
41{
42    double dp[3];
43    dp[0] = zeta();
44    dp[1] = radius();
45    dp[2] = FractalExp();
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 */
78double 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 */
91double 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 */
101double GelFitModel::calculate_ER() 
102{
103  //NOT implemented yet!!!
104  return 0.0;
105}
106double GelFitModel::calculate_VR() 
107{
108  return 1.0;
109}
Note: See TracBrowser for help on using the repository browser.