source: sasmodels/sasmodels/models/core_shell_ellipsoid.c @ 81dd619

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 81dd619 was 81dd619, checked in by piotr, 8 years ago

Converted CoreShellEllipsoid?

  • Property mode set to 100644
File size: 4.3 KB
Line 
1double form_volume(double equat_core,
2                   double polar_core,
3                   double equat_shell,
4                   double polar_shell);
5double Iq(double q,
6          double equat_core,
7          double polar_core,
8          double equat_shell,
9          double polar_shell,
10          double core_sld,
11          double shell_sld,
12          double solvent_sld);
13
14
15double Iqxy(double qx, double qy,
16          double equat_core,
17          double polar_core,
18          double equat_shell,
19          double polar_shell,
20          double core_sld,
21          double shell_sld,
22          double solvent_sld,
23          double theta,
24          double phi);
25
26
27double form_volume(double equat_core,
28                   double polar_core,
29                   double equat_shell,
30                   double polar_shell)
31{
32    double vol = 4.0*M_PI/3.0*equat_shell*equat_shell*polar_shell;
33    return vol;
34}
35
36static double
37core_shell_ellipsoid_kernel(double q,
38          double equat_core,
39          double polar_core,
40          double equat_shell,
41          double polar_shell,
42          double core_sld,
43          double shell_sld,
44          double solvent_sld)
45{
46        double delpc,delps;
47        double uplim,lolim;             //upper and lower integration limits
48        double summ,zi,yyy,answer; //running tally of integration
49
50        lolim = 0.0;
51        uplim = 1.0;
52
53        summ = 0.0;      //initialize intergral
54
55        delpc = core_sld - shell_sld; //core - shell
56        delps = shell_sld - solvent_sld; //shell - solvent
57
58        for(int i=0;i<76;i++) {
59                zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
60                yyy = Gauss76Wt[i] * gfn4(zi,
61                                          equat_core,
62                                          polar_core,
63                                          equat_shell,
64                                          polar_shell,
65                                          delpc,
66                                          delps,
67                                          q);
68                summ += yyy;
69        }
70
71        answer = (uplim-lolim)/2.0*summ;
72
73        //convert to [cm-1]
74        answer *= 1.0e-4;
75
76        return answer;
77}
78
79static double
80core_shell_ellipsoid_kernel_2d(double q, double q_x, double q_y,
81          double equat_core,
82          double polar_core,
83          double equat_shell,
84          double polar_shell,
85          double core_sld,
86          double shell_sld,
87          double solvent_sld,
88          double theta,
89          double phi)
90{
91    double cyl_x, cyl_y;
92    double cos_val;
93    double answer;
94    double sldcs,sldss;
95
96    //convert angle degree to radian
97    theta = theta * M_PI/180.0;
98    phi = phi * M_PI/180.0;
99
100
101    // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis.
102    cyl_x = cos(theta) * cos(phi);
103    cyl_y = sin(theta);
104
105    sldcs = core_sld - shell_sld;
106    sldss = shell_sld- solvent_sld;
107
108    // Compute the angle btw vector q and the
109    // axis of the cylinder
110    cos_val = cyl_x*q_x + cyl_y*q_y;
111
112    // Call the IGOR library function to get the kernel: MUST use gfn4 not gf2 because of the def of params.
113    answer = gfn4(cos_val,
114                  equat_core,
115                  polar_core,
116                  equat_shell,
117                  polar_shell,
118                  sldcs,
119                  sldss,
120                  q);
121
122    //convert to [cm-1]
123    answer *= 1.0e-4;
124
125    return answer;
126}
127
128double Iq(double q,
129          double equat_core,
130          double polar_core,
131          double equat_shell,
132          double polar_shell,
133          double core_sld,
134          double shell_sld,
135          double solvent_sld)
136{
137    double intensity = core_shell_ellipsoid_kernel(q,
138           equat_core,
139           polar_core,
140           equat_shell,
141           polar_shell,
142           core_sld,
143           shell_sld,
144           solvent_sld);
145
146    return intensity;
147}
148
149
150double Iqxy(double qx, double qy,
151          double equat_core,
152          double polar_core,
153          double equat_shell,
154          double polar_shell,
155          double core_sld,
156          double shell_sld,
157          double solvent_sld,
158          double theta,
159          double phi)
160{
161    double q;
162    q = sqrt(qx*qx+qy*qy);
163    double intensity = core_shell_ellipsoid_kernel_2d(q, qx/q, qy/q,
164                       equat_core,
165                       polar_core,
166                       equat_shell,
167                       polar_shell,
168                       core_sld,
169                       shell_sld,
170                       solvent_sld,
171                       theta,
172                       phi);
173
174    return intensity;
175}
Note: See TracBrowser for help on using the repository browser.