source: sasmodels/sasmodels/models/hardsphere.py @ d1fe925

gh-pages
Last change on this file since d1fe925 was d1fe925, checked in by ajj, 8 years ago

Creating gh_pages branch for docs

  • Property mode set to 100644
File size: 3.0 KB
Line 
1# Note: model title and parameter table are inserted automatically
2r"""Calculate the interparticle structure factor for monodisperse
3spherical particles interacting through hard sphere (excluded volume)
4interactions.
5
6The calculation uses the Percus-Yevick closure where the interparticle
7potential is
8
9.. math:
10
11    U(r) = \begin{cases}
12    \infty & r < 2R \\
13    0 & r \geq 2R
14    \end{cases}
15
16where *r* is the distance from the center of the sphere of a radius *R*.
17
18For a 2D plot, the wave transfer is defined as
19
20.. math::
21
22    q = \sqrt{q_x^2 + q_y^2}
23
24
25.. image:: img/HardSphere_1d.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 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"""
48category = "structure-factor"
49
50#             ["name", "units", default, [lower, upper], "type","description"],
51parameters = [["effect_radius", "Ang", 50.0, [0, inf], "volume",
52               "effective radius of hard sphere"],
53              ["volfraction", "", 0.2, [0, 0.74], "",
54               "volume fraction of hard spheres"],
55             ]
56
57# No volume normalization despite having a volume parameter
58# This should perhaps be volume normalized?
59form_volume = """
60    return 1.0;
61    """
62
63Iq = """
64    double denom,dnum,alpha,beta,gamm,a,asq,ath,afor,rca,rsa;
65    double calp,cbeta,cgam,prefac,c,vstruc;
66    double struc;
67
68    //  compute constants
69    denom = pow((1.0-volfraction),4);
70    dnum = pow((1.0 + 2.0*volfraction),2);
71    alpha = dnum/denom;
72    beta = -6.0*volfraction*pow((1.0 + volfraction/2.0),2)/denom;
73    gamm = 0.50*volfraction*dnum/denom;
74    //
75    //  calculate the structure factor
76    //
77    a = 2.0*q*effect_radius;
78    asq = a*a;
79    ath = asq*a;
80    afor = ath*a;
81    SINCOS(a,rsa,rca);
82    //rca = cos(a);
83    //rsa = sin(a);
84    calp = alpha*(rsa/asq - rca/a);
85    cbeta = beta*(2.0*rsa/asq - (asq - 2.0)*rca/ath - 2.0/ath);
86    cgam = gamm*(-rca/a + (4.0/a)*((3.0*asq - 6.0)*rca/afor + (asq - 6.0)*rsa/ath + 6.0/afor));
87    prefac = -24.0*volfraction/a;
88    c = prefac*(calp + cbeta + cgam);
89    vstruc = 1.0/(1.0-c);
90    struc = vstruc;
91
92    return(struc);
93   """
94
95Iqxy = """
96    // never called since no orientation or magnetic parameters.
97    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
98    """
99
100# ER defaults to 0.0
101# VR defaults to 1.0
102
103demo = dict(effect_radius=200, volfraction=0.2, effect_radius_pd=0.1, effect_radius_pd_n=40)
104oldname = 'HardsphereStructure'
105oldpars = dict()
106
Note: See TracBrowser for help on using the repository browser.