source: sasview/src/sas/models/c_extension/c_models/micelleSphCore.cpp @ 79492222

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 79492222 was 79492222, checked in by krzywon, 9 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 4.7 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>
25#include <iostream>
26using namespace std;
27#include "micelleSphCore.h"
28
29extern "C" {
30#include "libSphere.h"
31}
32
33
34MicelleSphCoreModel :: MicelleSphCoreModel() {
35    scale      = Parameter(1.0);
36    ndensity   = Parameter(8.94e15);
37    ndensity.set_min(0.0);
38    v_core     = Parameter(62624.0);
39    v_core.set_min(0.0);
40    v_corona   = Parameter(61940.0);
41    v_corona.set_min(0.0);
42    rho_solv   = Parameter(6.4e-6);
43    rho_core   = Parameter(3.4e-7);
44    rho_corona = Parameter(8.0e-7);
45    radius_core = Parameter(45.0, true);
46    radius_core.set_min(0.0);
47    radius_gyr = Parameter(20.0, true);
48    radius_gyr.set_min(0.0);
49    d_penetration = Parameter(1.0);
50    d_penetration.set_min(0.0);
51    n_aggreg = Parameter(6.0);
52    n_aggreg.set_min(1.0);
53    background = Parameter(0.0);
54}
55
56
57/**
58 * Function to evaluate 1D scattering function
59 * @param q: q-value
60 * @return: function value
61 */
62double MicelleSphCoreModel :: operator()(double q) {
63        double dp[12];
64       
65        // Fill parameter array
66        // Add the background after averaging
67        dp[0] = scale();
68        dp[1] = ndensity();
69        dp[2] = v_core();
70        dp[3] = v_corona();
71        dp[4] = rho_solv();
72        dp[5] = rho_core();
73        dp[6] = rho_corona();
74        dp[7] = radius_core();
75        dp[8] = radius_gyr();
76        dp[9] = d_penetration();
77        dp[10] = n_aggreg();
78        dp[11] = 0.0;
79
80
81        // Get the dispersion points for the core radius
82        vector<WeightPoint> weights_rcore;
83        radius_core.get_weights(weights_rcore);
84
85         // Get the dispersion points for the gyration radius
86        vector<WeightPoint> weights_rgyr;
87        radius_gyr.get_weights(weights_rgyr);
88
89       // Perform the computation, with all weight points
90        double sum = 0.0;
91        double norm = 0.0;
92        double vol = 0.0;
93        double vol_micelle = 0.0;
94
95        // Loop over core radius weight points
96        for(int i=0; i< (int)weights_rcore.size(); i++) {
97
98            dp[7] = weights_rcore[i].value;
99
100            // Loop over gyration radius weight points
101            for(int j=0; j< (int)weights_rgyr.size(); j++) {
102
103                dp[8] = weights_rgyr[j].value;
104               
105                //cout << "\n loop i,j = " << i << "  " << j;
106                //cout << "\n radius_core: value weight = " << weights_rcore[i].value << "  " << weights_rcore[i].weight;
107                //cout << "\n radius_gyr:  value weight = " << weights_rgyr[j].value << "  " << weights_rgyr[j].weight;
108                //cout << "\n";
109
110                vol_micelle = pow(weights_rcore[i].value+weights_rgyr[j].value,3);
111
112                //Un-normalize SphereForm by volume
113                sum += weights_rcore[i].weight *  weights_rgyr[j].weight *
114                       MicelleSphericalCore(dp, q) *
115                       vol_micelle;
116     
117                //Find average volume
118                vol += weights_rcore[i].weight * weights_rgyr[j].weight * vol_micelle;
119
120                norm += weights_rcore[i].weight * weights_rgyr[j].weight;
121            }   
122
123        }
124
125        if (vol != 0.0 && norm != 0.0) {
126             //Re-normalize by avg volume
127             sum = sum/(vol/norm);}
128             
129        return sum/norm + background();
130
131}
132
133
134/**
135 * Function to evaluate 2D scattering function
136 * @param q_x: value of Q along x
137 * @param q_y: value of Q along y
138 * @return: function value
139 */
140double MicelleSphCoreModel :: operator()(double qx, double qy) {
141        double q = sqrt(qx*qx + qy*qy);
142        return (*this).operator()(q);
143}
144
145
146/**
147 * Function to evaluate 2D scattering function
148 * @param pars: parameters of the model
149 * @param q: q-value
150 * @param phi: angle phi
151 * @return: function value
152 */
153double MicelleSphCoreModel :: evaluate_rphi(double q, double phi) {
154        return (*this).operator()(q);
155}
156
157
158/**
159 * Function to calculate effective radius
160 * @return: effective radius value
161 */
162double MicelleSphCoreModel :: calculate_ER() {
163        return 1.0;
164}
165
166
167/**
168 * Function to calculate particle volume/total volume for shape models:
169 *      Most case returns 1 but for example for the vesicle model it is
170 *      (total volume - core volume)/total volume
171 *      (< 1 depending on the thickness).
172 * @return: effective radius value
173 */
174double MicelleSphCoreModel :: calculate_VR() {
175  return 1.0;
176}
Note: See TracBrowser for help on using the repository browser.