source: sasmodels/sasmodels/models/hollow_cylinder.c @ 99658f6

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 99658f6 was 99658f6, checked in by grethevj, 10 months ago

updated ER functions including cylinder excluded volume, to match 4.x

  • Property mode set to 100644
File size: 3.5 KB
Line 
1//#define INVALID(v) (v.radius_core >= v.radius)
2
3static double
4shell_volume(double radius, double thickness, double length)
5{
6    return M_PI*length*(square(radius+thickness) - radius*radius);
7}
8
9static double
10form_volume(double radius, double thickness, double length)
11{
12    return M_PI*length*square(radius+thickness);
13}
14
15static double
16radius_from_excluded_volume(double radius, double thickness, double length)
17{
18    const double radius_tot = radius + thickness;
19    return 0.5*cbrt(0.75*radius_tot*(2.0*radius_tot*length + (radius_tot + length)*(M_PI*radius_tot + length)));
20}
21
22static double
23radius_from_volume(double radius, double thickness, double length)
24{
25    const double volume_outer_cyl = M_PI*square(radius + thickness)*length;
26    return cbrt(volume_outer_cyl/M_4PI_3);
27}
28
29static double
30radius_from_diagonal(double radius, double thickness, double length)
31{
32    return sqrt(square(radius + thickness) + 0.25*square(length));
33}
34
35static double
36effective_radius(int mode, double radius, double thickness, double length)
37{
38    switch (mode) {
39    default:
40    case 1: // excluded volume
41        return radius_from_excluded_volume(radius, thickness, length);
42    case 2: // equivalent volume sphere
43        return radius_from_volume(radius, thickness, length);
44    case 3: // outer radius
45        return radius + thickness;
46    case 4: // half length
47        return 0.5*length;
48    case 5: // half outer min dimension
49        return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length);
50    case 6: // half outer max dimension
51        return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length);
52    case 7: // half outer diagonal
53        return radius_from_diagonal(radius,thickness,length);
54    }
55}
56
57static double
58_fq(double qab, double qc,
59    double radius, double thickness, double length)
60{
61    const double lam1 = sas_2J1x_x((radius+thickness)*qab);
62    const double lam2 = sas_2J1x_x(radius*qab);
63    const double gamma_sq = square(radius/(radius+thickness));
64    //Note: lim_{thickness -> 0} psi = sas_J0(radius*qab)
65    //Note: lim_{radius -> 0} psi = sas_2J1x_x(thickness*qab)
66    const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq);    //SRK 10/19/00
67    const double t2 = sas_sinx_x(0.5*length*qc);
68    return psi*t2;
69}
70
71static void
72Fq(double q, double *F1, double *F2, double radius, double thickness, double length,
73    double sld, double solvent_sld)
74{
75    const double lower = 0.0;
76    const double upper = 1.0;        //limits of numerical integral
77
78    double total_F1 = 0.0;            //initialize intergral
79    double total_F2 = 0.0;
80    for (int i=0;i<GAUSS_N;i++) {
81        const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper );
82        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
83        const double form = _fq(q*sin_theta, q*cos_theta,
84                                radius, thickness, length);
85        total_F1 += GAUSS_W[i] * form;
86        total_F2 += GAUSS_W[i] * form * form;
87    }
88    total_F1 *= 0.5*(upper-lower);
89    total_F2 *= 0.5*(upper-lower);
90    const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length);
91    *F1 = 1e-2 * s * total_F1;
92    *F2 = 1e-4 * s*s * total_F2;
93}
94
95
96static double
97Iqac(double qab, double qc,
98    double radius, double thickness, double length,
99    double sld, double solvent_sld)
100{
101    const double form = _fq(qab, qc, radius, thickness, length);
102    const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length);
103    return 1.0e-4*square(s * form);
104}
Note: See TracBrowser for help on using the repository browser.