source: sasview/src/sas/models/c_extension/c_models/RectangularHollowPrismInfThinWalls.cpp @ 573e7034

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 573e7034 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: 4.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: add 2D function
21 */
22
23#include <math.h>
24#include "parameters.hh"
25#include <stdio.h>
26#include <iostream>
27using namespace std;
28
29extern "C" {
30    #include "libCylinder.h"
31    #include "libStructureFactor.h"
32    #include "libmultifunc/libfunc.h"
33}
34#include "RectangularHollowPrismInfThinWalls.h"
35
36// Convenience parameter structure
37typedef struct {
38    double scale;
39    double short_side;
40    double b2a_ratio;
41    double c2a_ratio;
42    double sldPipe;
43    double sldSolv;
44    double background;
45} RectangularHollowPrismInfThinWallsParameters;
46
47
48RectangularHollowPrismInfThinWallsModel :: RectangularHollowPrismInfThinWallsModel() {
49    scale      = Parameter(1.0);
50    short_side = Parameter(35.0, true);
51    short_side.set_min(1.0);
52    b2a_ratio   = Parameter(1.0, true);
53    b2a_ratio.set_min(1.0);
54    c2a_ratio   = Parameter(1.0, true);
55    c2a_ratio.set_min(1.0);
56    sldPipe   = Parameter(6.3e-6);
57    sldSolv   = Parameter(1.0e-6);
58    background = Parameter(0.0);
59}
60
61/**
62 * Function to evaluate 1D scattering function
63 * @param q: q-value
64 * @return: function value
65 */
66double RectangularHollowPrismInfThinWallsModel :: operator()(double q) {
67
68    double dp[7];
69
70    // Fill parameter array for IGOR library
71    // Add the background after averaging
72    dp[0] = scale();
73    dp[1] = short_side();
74    dp[2] = b2a_ratio();
75    dp[3] = c2a_ratio();
76    dp[4] = sldPipe();
77    dp[5] = sldSolv();
78    dp[6] = 0.0;
79
80    // Get the dispersion points for a
81    vector<WeightPoint> weights_short_side;
82    short_side.get_weights(weights_short_side);
83
84    // Get the dispersion points for b/a ratio
85    vector<WeightPoint> weights_b2a_ratio;
86    b2a_ratio.get_weights(weights_b2a_ratio);
87
88    // Get the dispersion points for c/a ratio
89    vector<WeightPoint> weights_c2a_ratio;
90    c2a_ratio.get_weights(weights_c2a_ratio);
91
92    // Perform the computation, with all weight points
93    double sum = 0.0;
94    double norm = 0.0;
95    double vol = 0.0;
96
97    // Loop over short_side weight points
98    for (int i=0; i < (int)weights_short_side.size(); i++) {
99
100        dp[1] = weights_short_side[i].value;
101
102        // Loop over b/a ratios
103        for (int j=0; j < (int)weights_b2a_ratio.size(); j++) {
104
105            dp[2] = weights_b2a_ratio[j].value;
106
107            // Loop over c/a ratios
108            for (int k=0; k < (int)weights_c2a_ratio.size(); k++) {
109
110                dp[3] = weights_c2a_ratio[k].value;
111
112                    // Un-normalize  by volume = 2*a*b + 2*a*c + 2*b*c
113
114                    double a = dp[1];
115                    double b = dp[1] * dp[2];
116                    double c = dp[1] * dp[3];
117                double vol_i = (2.0*a*b) + (2.0*a*c) + (2.0*b*c);
118
119                    sum += weights_short_side[i].weight *
120                           weights_b2a_ratio[j].weight *
121                           weights_c2a_ratio[k].weight *
122                           RectangularHollowPrismInfThinWalls(dp, q) *
123                       vol_i;
124
125                    //Find average volume (ABC)
126
127                    vol += weights_short_side[i].weight *
128                           weights_b2a_ratio[j].weight *
129                           weights_c2a_ratio[k].weight *
130                       vol_i;
131
132                    norm += weights_short_side[i].weight *
133                            weights_b2a_ratio[j].weight *
134                            weights_c2a_ratio[k].weight;
135            }
136        }                   
137    }
138
139    if (vol != 0.0 && norm != 0.0) {
140        //Re-normalize by avg volume
141        sum = sum/(vol/norm);}
142
143    return sum/norm + background();
144   
145}
146
147/**
148 * Function to evaluate 2D scattering function
149 * @param q_x: value of Q along x
150 * @param q_y: value of Q along y
151 * @return: function value
152 */
153double RectangularHollowPrismInfThinWallsModel :: operator()(double qx, double qy) {
154    return 1.0;
155}
156
157
158/**
159 * Function to evaluate 2D scattering function
160 * @param pars: parameters of the cylinder
161 * @param q: q-value
162 * @param phi: angle phi
163 * @return: function value
164 */
165double RectangularHollowPrismInfThinWallsModel :: evaluate_rphi(double q, double phi) {
166    double qx = q*cos(phi);
167    double qy = q*sin(phi);
168    return (*this).operator()(qx, qy);
169}
170
171/**
172 * Function to calculate effective radius
173 * @return: effective radius value
174 */
175double RectangularHollowPrismInfThinWallsModel :: calculate_ER() {
176    return 1.0;
177
178}
179double RectangularHollowPrismInfThinWallsModel :: calculate_VR() {
180  return 1.0;
181}
Note: See TracBrowser for help on using the repository browser.