source: sasview/sansmodels/src/sans/models/c_models/Hardsphere.cpp @ ec658c85

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 ec658c85 was f9bf661, checked in by Jae Cho <jhjcho@…>, 15 years ago

updated documents

  • Property mode set to 100644
File size: 3.4 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 *      TODO: refactor so that we pull in the old sansmodels.c_extensions
21 */
22
23#include <math.h>
24#include "models.hh"
25#include "parameters.hh"
26#include <stdio.h>
27using namespace std;
28
29extern "C" {
30        #include "libStructureFactor.h"
31        #include "Hardsphere.h"
32}
33
34HardsphereStructure :: HardsphereStructure() {
35        effect_radius      = Parameter(50.0, true);
36        effect_radius.set_min(0.0);
37        volfraction = Parameter(0.20, true);
38        volfraction.set_min(0.0);
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 HardsphereStructure :: operator()(double q) {
48        double dp[2];
49
50        // Fill parameter array for IGOR library
51        // Add the background after averaging
52        dp[0] = effect_radius();
53        dp[1] = volfraction();
54
55        // Get the dispersion points for the radius
56        vector<WeightPoint> weights_rad;
57        effect_radius.get_weights(weights_rad);
58
59        // Perform the computation, with all weight points
60        double sum = 0.0;
61        double norm = 0.0;
62
63        // Loop over radius weight points
64        for(int i=0; i<weights_rad.size(); i++) {
65                dp[0] = weights_rad[i].value;
66
67                sum += weights_rad[i].weight
68                                * HardSphereStruct(dp, q);
69                norm += weights_rad[i].weight;
70        }
71        return sum/norm ;
72}
73
74/**
75 * Function to evaluate 2D scattering function
76 * @param q_x: value of Q along x
77 * @param q_y: value of Q along y
78 * @return: function value
79 */
80double HardsphereStructure :: operator()(double qx, double qy) {
81        HardsphereParameters dp;
82        // Fill parameter array
83        dp.effect_radius      = effect_radius();
84        dp.volfraction = volfraction();
85
86        // Get the dispersion points for the radius
87        vector<WeightPoint> weights_rad;
88        effect_radius.get_weights(weights_rad);
89
90        // Perform the computation, with all weight points
91        double sum = 0.0;
92        double norm = 0.0;
93
94        // Loop over radius weight points
95        for(int i=0; i<weights_rad.size(); i++) {
96                dp.effect_radius = weights_rad[i].value;
97
98                                        double _ptvalue = weights_rad[i].weight
99                                                * Hardsphere_analytical_2DXY(&dp, qx, qy);
100                                        sum += _ptvalue;
101
102                                        norm += weights_rad[i].weight;
103        }
104        // Averaging in theta needs an extra normalization
105        // factor to account for the sin(theta) term in the
106        // integration (see documentation).
107        return sum/norm;
108}
109
110/**
111 * Function to evaluate 2D scattering function
112 * @param pars: parameters of the cylinder
113 * @param q: q-value
114 * @param phi: angle phi
115 * @return: function value
116 */
117double HardsphereStructure :: evaluate_rphi(double q, double phi) {
118        double qx = q*cos(phi);
119        double qy = q*sin(phi);
120        return (*this).operator()(qx, qy);
121}
122/**
123 * Function to calculate effective radius
124 * @return: effective radius value
125 */
126double HardsphereStructure :: calculate_ER() {
127//NOT implemented yet!!!
128}
Note: See TracBrowser for help on using the repository browser.