source: sasmodels/sasmodels/models/pringle.c @ 3f8584a2

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 3f8584a2 was 2c74c11, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

implicit Iqxy; fix divide by 0 for q=0

  • Property mode set to 100644
File size: 4.2 KB
Line 
1double form_volume(double radius,
2          double thickness);
3
4double Iq(double q,
5          double radius,
6          double thickness,
7          double alpha,
8          double beta,
9          double sld_pringle,
10          double sld_solvent);
11
12static
13double pringleC(double radius,
14                double alpha,
15                double beta,
16                double q,
17                double phi,
18                double n) {
19
20    double va, vb;
21    double bessargs, cosarg, bessargcb;
22    double r, retval, yyy;
23
24
25    va = 0;
26    vb = radius;
27
28    // evaluate at Gauss points
29    // remember to index from 0,size-1
30
31    double summ = 0.0;          // initialize integral
32    int ii = 0;
33    do {
34        // Using 76 Gauss points
35        r = (Gauss76Z[ii] * (vb - va) + vb + va) / 2.0;
36
37        bessargs = q*r*sin(phi);
38        cosarg = q*r*r*alpha*cos(phi);
39        bessargcb = q*r*r*beta*cos(phi);
40
41        yyy = Gauss76Wt[ii]*r*cos(cosarg)
42                *sas_JN(n, bessargcb)
43                *sas_JN(2*n, bessargs);
44        summ += yyy;
45
46        ii += 1;
47    } while (ii < N_POINTS_76);                 // end of loop over quadrature points
48    //
49    // calculate value of integral to return
50
51    retval = (vb - va) / 2.0 * summ;
52    retval = retval / pow(r, 2.0);
53
54    return retval;
55}
56
57static
58double pringleS(double radius,
59                double alpha,
60                double beta,
61                double q,
62                double phi,
63                double n) {
64
65    double va, vb, summ;
66    double bessargs, sinarg, bessargcb;
67    double r, retval, yyy;
68    // set up the integration
69    // end points and weights
70
71    va = 0;
72    vb = radius;
73
74    // evaluate at Gauss points
75    // remember to index from 0,size-1
76
77    summ = 0.0;         // initialize integral
78    int ii = 0;
79    do {
80        // Using 76 Gauss points
81        r = (Gauss76Z[ii] * (vb - va) + vb + va) / 2.0;
82
83        bessargs = q*r*sin(phi);
84        sinarg = q*r*r*alpha*cos(phi);
85        bessargcb = q*r*r*beta*cos(phi);
86
87        yyy = Gauss76Wt[ii]*r*sin(sinarg)
88                    *sas_JN(n, bessargcb)
89                    *sas_JN(2*n, bessargs);
90        summ += yyy;
91
92        ii += 1;
93    } while (ii < N_POINTS_76);
94
95    // end of loop over quadrature points
96    //
97    // calculate value of integral to return
98
99    retval = (vb-va)/2.0*summ;
100    retval = retval/pow(r, 2.0);
101
102    return retval;
103}
104
105static
106double _kernel(double thickness,
107               double radius,
108               double alpha,
109               double beta,
110               double q,
111               double phi) {
112
113    const double sincarg = q * thickness * cos(phi) / 2.0;
114    const double sincterm = pow(sin(sincarg) / sincarg, 2.0);
115
116    //calculate sum term from n = -3 to 3
117    double sumterm = 0.0;
118    for (int nn = -3; nn <= 3; nn++) {
119        double powc = pringleC(radius, alpha, beta, q, phi, nn);
120        double pows = pringleS(radius, alpha, beta, q, phi, nn);
121        sumterm += pow(powc, 2.0) + pow(pows, 2.0);
122    }
123    double retval = 4.0 * sin(phi) * sumterm * sincterm;
124
125    return retval;
126
127}
128
129static double pringles_kernel(double q,
130          double radius,
131          double thickness,
132          double alpha,
133          double beta,
134          double sld_pringle,
135          double sld_solvent)
136{
137
138    //upper and lower integration limits
139    const double lolim = 0.0;
140    const double uplim = M_PI / 2.0;
141
142    double summ = 0.0;                  //initialize integral
143
144    double delrho = sld_pringle - sld_solvent; //make contrast term
145
146    for (int i = 0; i < N_POINTS_76; i++) {
147        double phi = (Gauss76Z[i] * (uplim - lolim) + uplim + lolim) / 2.0;
148        summ += Gauss76Wt[i] * _kernel(thickness, radius, alpha, beta, q, phi);
149    }
150
151    double answer = (uplim - lolim) / 2.0 * summ;
152    answer *= delrho*delrho;
153
154    return answer;
155}
156
157double form_volume(double radius,
158        double thickness){
159
160        return 1.0;
161}
162
163double Iq(double q,
164          double radius,
165          double thickness,
166          double alpha,
167          double beta,
168          double sld_pringle,
169          double sld_solvent)
170{
171    const double form = pringles_kernel(q,
172                  radius,
173                  thickness,
174                  alpha,
175                  beta,
176                  sld_pringle,
177                  sld_solvent);
178
179    return 1.0e-4*form*M_PI*radius*radius*thickness;
180}
Note: See TracBrowser for help on using the repository browser.