source: sasview/sansmodels/src/sans/models/c_models/StickyHS.cpp @ f82fe3c

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 f82fe3c was 770bab1, checked in by Jae Cho <jhjcho@…>, 14 years ago

removed some c functions

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