source: sasmodels/sasmodels/models/core_shell_ellipsoid.c @ 0a3d9b2

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0a3d9b2 was 0a3d9b2, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

code cleanup

  • Property mode set to 100644
File size: 4.4 KB
Line 
1double form_volume(double radius_equat_core,
2                   double polar_core,
3                   double equat_shell,
4                   double polar_shell);
5double Iq(double q,
6          double radius_equat_core,
7          double x_core,
8          double thick_shell,
9          double x_polar_shell,
10          double core_sld,
11          double shell_sld,
12          double solvent_sld);
13
14
15double Iqxy(double qx, double qy,
16          double radius_equat_core,
17          double x_core,
18          double thick_shell,
19          double x_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 radius_equat_core,
28                   double x_core,
29                   double thick_shell,
30                   double x_polar_shell)
31{
32    const double equat_shell = radius_equat_core + thick_shell;
33    const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell;
34    double vol = M_4PI_3*equat_shell*equat_shell*polar_shell;
35    return vol;
36}
37
38static double
39core_shell_ellipsoid_xt_kernel(double q,
40          double radius_equat_core,
41          double x_core,
42          double thick_shell,
43          double x_polar_shell,
44          double core_sld,
45          double shell_sld,
46          double solvent_sld)
47{
48    const double lolim = 0.0;
49    const double uplim = 1.0;
50
51
52    const double delpc = core_sld - shell_sld; //core - shell
53    const double delps = shell_sld - solvent_sld; //shell - solvent
54
55
56    const double polar_core = radius_equat_core*x_core;
57    const double equat_shell = radius_equat_core + thick_shell;
58    const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell;
59
60    double summ = 0.0;   //initialize intergral
61    for(int i=0;i<76;i++) {
62        double zi = 0.5*( Gauss76Z[i]*(uplim-lolim) + uplim + lolim );
63        double yyy = gfn4(zi, radius_equat_core, polar_core, equat_shell,
64                          polar_shell, delpc, delps, q);
65        summ += Gauss76Wt[i] * yyy;
66    }
67    summ *= 0.5*(uplim-lolim);
68
69    // convert to [cm-1]
70    return 1.0e-4 * summ;
71}
72
73static double
74core_shell_ellipsoid_xt_kernel_2d(double qx, double qy,
75          double radius_equat_core,
76          double x_core,
77          double thick_shell,
78          double x_polar_shell,
79          double core_sld,
80          double shell_sld,
81          double solvent_sld,
82          double theta,
83          double phi)
84{
85    double q, sin_alpha, cos_alpha;
86    ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha);
87
88    const double sldcs = core_sld - shell_sld;
89    const double sldss = shell_sld- solvent_sld;
90
91    const double polar_core = radius_equat_core*x_core;
92    const double equat_shell = radius_equat_core + thick_shell;
93    const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell;
94
95    // Call the IGOR library function to get the kernel:
96    // MUST use gfn4 not gf2 because of the def of params.
97    double answer = gfn4(cos_alpha,
98                  radius_equat_core,
99                  polar_core,
100                  equat_shell,
101                  polar_shell,
102                  sldcs,
103                  sldss,
104                  q);
105
106    //convert to [cm-1]
107    answer *= 1.0e-4;
108
109    return answer;
110}
111
112double Iq(double q,
113          double radius_equat_core,
114          double x_core,
115          double thick_shell,
116          double x_polar_shell,
117          double core_sld,
118          double shell_sld,
119          double solvent_sld)
120{
121    double intensity = core_shell_ellipsoid_xt_kernel(q,
122           radius_equat_core,
123           x_core,
124           thick_shell,
125           x_polar_shell,
126           core_sld,
127           shell_sld,
128           solvent_sld);
129
130    return intensity;
131}
132
133
134double Iqxy(double qx, double qy,
135          double radius_equat_core,
136          double x_core,
137          double thick_shell,
138          double x_polar_shell,
139          double core_sld,
140          double shell_sld,
141          double solvent_sld,
142          double theta,
143          double phi)
144{
145    double intensity = core_shell_ellipsoid_xt_kernel_2d(qx, qy,
146                       radius_equat_core,
147                       x_core,
148                       thick_shell,
149                       x_polar_shell,
150                       core_sld,
151                       shell_sld,
152                       solvent_sld,
153                       theta,
154                       phi);
155
156    return intensity;
157}
Note: See TracBrowser for help on using the repository browser.