source: sasview/src/sas/models/c_extension/c_models/SquareWell.cpp @ 4adf48e

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 4adf48e 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.8 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/**
16 * Scattering model classes
17 * The classes use the IGOR library found in
18 *   sansmodels/src/libigor
19 *
20 */
21
22#include <math.h>
23#include "parameters.hh"
24#include <stdio.h>
25using namespace std;
26#include "SquareWell.h"
27
28extern "C" {
29#include "libStructureFactor.h"
30}
31
32SquareWellStructure :: SquareWellStructure() {
33  effect_radius      = Parameter(50.0, true);
34  effect_radius.set_min(0.0);
35  volfraction = Parameter(0.04, true);
36  volfraction.set_min(0.0);
37  welldepth   = Parameter(1.50);
38  wellwidth  = Parameter(1.20);
39}
40
41/**
42 * Function to evaluate 1D scattering function
43 * The NIST IGOR library is used for the actual calculation.
44 * @param q: q-value
45 * @return: function value
46 */
47double SquareWellStructure :: operator()(double q) {
48  double dp[4];
49
50  // Fill parameter array for IGOR library
51  // Add the background after averaging
52  dp[0] = effect_radius();
53  dp[1] = volfraction();
54  dp[2] = welldepth();
55  dp[3] = wellwidth();
56
57  // Get the dispersion points for the radius
58  vector<WeightPoint> weights_rad;
59  effect_radius.get_weights(weights_rad);
60
61  // Perform the computation, with all weight points
62  double sum = 0.0;
63  double norm = 0.0;
64
65  // Loop over radius weight points
66  for(size_t i=0; i<weights_rad.size(); i++) {
67    dp[0] = weights_rad[i].value;
68
69    sum += weights_rad[i].weight
70        * SquareWellStruct(dp, q);
71    norm += weights_rad[i].weight;
72  }
73  return sum/norm ;
74}
75
76/**
77 * Function to evaluate 2D scattering function
78 * @param q_x: value of Q along x
79 * @param q_y: value of Q along y
80 * @return: function value
81 */
82double SquareWellStructure :: operator()(double qx, double qy) {
83  double q = sqrt(qx*qx + qy*qy);
84  return (*this).operator()(q);
85}
86
87/**
88 * Function to evaluate 2D scattering function
89 * @param pars: parameters of the cylinder
90 * @param q: q-value
91 * @param phi: angle phi
92 * @return: function value
93 */
94double SquareWellStructure :: evaluate_rphi(double q, double phi) {
95  double qx = q*cos(phi);
96  double qy = q*sin(phi);
97  return (*this).operator()(qx, qy);
98}
99/**
100 * Function to calculate effective radius
101 * @return: effective radius value
102 */
103double SquareWellStructure :: calculate_ER() {
104  //NOT implemented yet!!!
105  return 0.0;
106}
107double SquareWellStructure :: calculate_VR() {
108  return 1.0;
109}
Note: See TracBrowser for help on using the repository browser.