source: sasview/src/sas/models/c_extension/c_models/DiamCyl.cpp @ 06dfd39

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