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

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

fix compiler warnings for CUDA

  • Property mode set to 100644
File size: 3.1 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
16radius_from_volume(double radius, double thickness, double length)
17{
18    const double volume_outer_cyl = M_PI*square(radius + thickness)*length;
[6d5601c]19    return cbrt(volume_outer_cyl/M_4PI_3);
[d277229]20}
21
22static double
23radius_from_diagonal(double radius, double thickness, double length)
24{
25    return sqrt(square(radius + thickness) + 0.25*square(length));
26}
27
28static double
29effective_radius(int mode, double radius, double thickness, double length)
30{
[ee60aa7]31    switch (mode) {
[d42dd4a]32    default:
[ee60aa7]33    case 1: // equivalent sphere
[d277229]34        return radius_from_volume(radius, thickness, length);
[ee60aa7]35    case 2: // outer radius
[d277229]36        return radius + thickness;
[ee60aa7]37    case 3: // half length
[d277229]38        return 0.5*length;
[ee60aa7]39    case 4: // half outer min dimension
[d277229]40        return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length);
[ee60aa7]41    case 5: // half outer max dimension
[d277229]42        return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length);
[ee60aa7]43    case 6: // half outer diagonal
[d277229]44        return radius_from_diagonal(radius,thickness,length);
45    }
46}
[aea2e2a]47
[e44432d]48static double
49_fq(double qab, double qc,
50    double radius, double thickness, double length)
51{
52    const double lam1 = sas_2J1x_x((radius+thickness)*qab);
53    const double lam2 = sas_2J1x_x(radius*qab);
54    const double gamma_sq = square(radius/(radius+thickness));
55    //Note: lim_{thickness -> 0} psi = sas_J0(radius*qab)
56    //Note: lim_{radius -> 0} psi = sas_2J1x_x(thickness*qab)
57    const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq);    //SRK 10/19/00
58    const double t2 = sas_sinx_x(0.5*length*qc);
59    return psi*t2;
60}
61
[71b751d]62static void
63Fq(double q, double *F1, double *F2, double radius, double thickness, double length,
[aea2e2a]64    double sld, double solvent_sld)
65{
[5bddd89]66    const double lower = 0.0;
[2a0b2b1]67    const double upper = 1.0;        //limits of numerical integral
[5bddd89]68
[71b751d]69    double total_F1 = 0.0;            //initialize intergral
70    double total_F2 = 0.0;
[74768cb]71    for (int i=0;i<GAUSS_N;i++) {
72        const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper );
[2a0b2b1]73        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
74        const double form = _fq(q*sin_theta, q*cos_theta,
75                                radius, thickness, length);
[71b751d]76        total_F1 += GAUSS_W[i] * form;
77        total_F2 += GAUSS_W[i] * form * form;
[aea2e2a]78    }
[71b751d]79    total_F1 *= 0.5*(upper-lower);
80    total_F2 *= 0.5*(upper-lower);
[e44432d]81    const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length);
[71b751d]82    *F1 = 1e-2 * s * total_F1;
83    *F2 = 1e-4 * s*s * total_F2;
[5bddd89]84}
[aea2e2a]85
[71b751d]86
[becded3]87static double
[108e70e]88Iqac(double qab, double qc,
[5bddd89]89    double radius, double thickness, double length,
[becded3]90    double sld, double solvent_sld)
[5bddd89]91{
[2a0b2b1]92    const double form = _fq(qab, qc, radius, thickness, length);
[e44432d]93    const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length);
[71b751d]94    return 1.0e-4*square(s * form);
[aea2e2a]95}
Note: See TracBrowser for help on using the repository browser.