source: sasmodels/sasmodels/models/hollow_cylinder.c @ d277229

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since d277229 was d277229, checked in by grethevj, 6 years ago

Models updated to include choices for effective interaction radii

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