# source:sasmodels/sasmodels/models/hardsphere.py@301e096

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 301e096 was 301e096, checked in by richardh, 10 years ago

adding hard sphere S(Q)

• Property mode set to 100644
File size: 3.0 KB
Line
1# Note: model title and parameter table are inserted automatically
2r"""This calculates the interparticle structure factor for monodisperse spherical particles interacting through hard
3sphere (excluded volume) interactions.
4
5The calculation uses the Percus-Yevick closure where the interparticle potential is
6
7.. image:: img/HardSphere_223.PNG
8
9where *r* is the distance from the center of the sphere of a radius *R*.
10
11For a 2D plot, the wave transfer is defined as
12
13.. math::
14
15    Q = \sqrt{Q_x^2 + Q_y^2}
16
17
18==============  ========  =============
19Parameter name  Units     Default value
20==============  ========  =============
22volfraction     None      0.2
23==============  ========  =============
24
25.. image:: img/HardSphere_224.jpg
26
27*Figure. 1D plot using the default values (in linear scale).*
28
29REFERENCE
30
31J K Percus, J Yevick, *J. Phys. Rev.*, 110, (1958) 1
32"""
33
34from numpy import pi, inf
35
36name = "hardsphere"
37title = "Hard sphere structure factor, with Percus-Yevick closure"
38description = """\
39        [Hard sphere structure factor, with Percus-Yevick closure]
40        Interparticle S(Q) for random, non-interacting spheres.
41                May be a reasonable approximation for other shapes of
42                particles that freely rotate, and for moderately polydisperse
43        systems. Though strictly the maths needs to be modified -
44                which sasview does not do yet.
45                effect_radius is the hard sphere radius
46                volfraction is the volume fraction occupied by the spheres.
47"""
48
49parameters = [
50#   [ "name", "units", default, [lower, upper], "type",
51#     "description" ],
52    [ "effect_radius", "Ang",  50.0, [0, inf], "volume",
53      "effective radius of hard sphere" ],
54    [ "volfraction", "",  0.2, [0, 0.74], "",
55      "volume fraction of hard spheres" ],
56     ]
57
58# No volume normalization despite having a volume parameter
59# This should perhaps be volume normalized?
60form_volume = """
61    return 1.0;
62    """
63
64Iq = """
65        double denom,dnum,alpha,beta,gamm,a,asq,ath,afor,rca,rsa;
66        double calp,cbeta,cgam,prefac,c,vstruc;
67        double struc;
68
69        //  compute constants
70        denom = pow((1.0-volfraction),4);
71        dnum = pow((1.0 + 2.0*volfraction),2);
72        alpha = dnum/denom;
73        beta = -6.0*volfraction*pow((1.0 + volfraction/2.0),2)/denom;
74        gamm = 0.50*volfraction*dnum/denom;
75        //
76        //  calculate the structure factor
77        //
78        a = 2.0*q*effect_radius;
79        asq = a*a;
80        ath = asq*a;
81        afor = ath*a;
82        SINCOS(a,rsa,rca);
83        //rca = cos(a);
84        //rsa = sin(a);
85        calp = alpha*(rsa/asq - rca/a);
86        cbeta = beta*(2.0*rsa/asq - (asq - 2.0)*rca/ath - 2.0/ath);
87        cgam = gamm*(-rca/a + (4.0/a)*((3.0*asq - 6.0)*rca/afor + (asq - 6.0)*rsa/ath + 6.0/afor));
88        prefac = -24.0*volfraction/a;
89        c = prefac*(calp + cbeta + cgam);
90        vstruc = 1.0/(1.0-c);
91        struc = vstruc;
92
93        return(struc);
94   """
95
96Iqxy = """
97    // never called since no orientation or magnetic parameters.
98    return -1.0;
99    """
100
101# ER defaults to 0.0
102# VR defaults to 1.0
103
104demo = dict(effect_radius = 200,volfraction = 0.2,effect_radius_pd = 0.1,effect_radius_pd_n = 40)
105oldname = 'HardsphereStructure'
106oldpars = dict()
107
Note: See TracBrowser for help on using the repository browser.