source: sasview/src/sans/models/c_extension/c_models/StickyHS.cpp @ 79d5b6c

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 79d5b6c was 230f479, checked in by Mathieu Doucet <doucetm@…>, 11 years ago

Rename C source dir for models (minor updates)

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