source: sasview/src/sas/models/c_extension/c_models/schulz.cpp @ db46d13

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 db46d13 was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

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