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, 5 years ago

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

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[aea2e2a]1//#define INVALID(v) (v.radius_core >= v.radius)
2
[5bddd89]3static double
[e44432d]4shell_volume(double radius, double thickness, double length)
[ee60aa7]5{
[e44432d]6    return M_PI*length*(square(radius+thickness) - radius*radius);
[ee60aa7]7}
8
[becded3]9static double
[5bddd89]10form_volume(double radius, double thickness, double length)
[aea2e2a]11{
[e44432d]12    return M_PI*length*square(radius+thickness);
[aea2e2a]13}
14
[d277229]15static double
[99658f6]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
[d277229]23radius_from_volume(double radius, double thickness, double length)
24{
25    const double volume_outer_cyl = M_PI*square(radius + thickness)*length;
[6d5601c]26    return cbrt(volume_outer_cyl/M_4PI_3);
[d277229]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{
[ee60aa7]38    switch (mode) {
[d42dd4a]39    default:
[99658f6]40    case 1: // excluded volume
41        return radius_from_excluded_volume(radius, thickness, length);
42    case 2: // equivalent volume sphere
[d277229]43        return radius_from_volume(radius, thickness, length);
[99658f6]44    case 3: // outer radius
[d277229]45        return radius + thickness;
[99658f6]46    case 4: // half length
[d277229]47        return 0.5*length;
[99658f6]48    case 5: // half outer min dimension
[d277229]49        return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length);
[99658f6]50    case 6: // half outer max dimension
[d277229]51        return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length);
[99658f6]52    case 7: // half outer diagonal
[d277229]53        return radius_from_diagonal(radius,thickness,length);
54    }
55}
[aea2e2a]56
[e44432d]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
[71b751d]71static void
72Fq(double q, double *F1, double *F2, double radius, double thickness, double length,
[aea2e2a]73    double sld, double solvent_sld)
74{
[5bddd89]75    const double lower = 0.0;
[2a0b2b1]76    const double upper = 1.0;        //limits of numerical integral
[5bddd89]77
[71b751d]78    double total_F1 = 0.0;            //initialize intergral
79    double total_F2 = 0.0;
[74768cb]80    for (int i=0;i<GAUSS_N;i++) {
81        const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper );
[2a0b2b1]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);
[71b751d]85        total_F1 += GAUSS_W[i] * form;
86        total_F2 += GAUSS_W[i] * form * form;
[aea2e2a]87    }
[71b751d]88    total_F1 *= 0.5*(upper-lower);
89    total_F2 *= 0.5*(upper-lower);
[e44432d]90    const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length);
[71b751d]91    *F1 = 1e-2 * s * total_F1;
92    *F2 = 1e-4 * s*s * total_F2;
[5bddd89]93}
[aea2e2a]94
[71b751d]95
[becded3]96static double
[108e70e]97Iqac(double qab, double qc,
[5bddd89]98    double radius, double thickness, double length,
[becded3]99    double sld, double solvent_sld)
[5bddd89]100{
[2a0b2b1]101    const double form = _fq(qab, qc, radius, thickness, length);
[e44432d]102    const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length);
[71b751d]103    return 1.0e-4*square(s * form);
[aea2e2a]104}
Note: See TracBrowser for help on using the repository browser.