source: sasmodels/sasmodels/models/squarewell.py @ a84a0ca

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since a84a0ca was a84a0ca, checked in by smk78, 8 years ago

Index file snot being tracked for some reason

  • Property mode set to 100644
File size: 4.8 KB
Line 
1# Note: model title and parameter table are inserted automatically
2r"""
3This calculates the interparticle structure factor for a square well fluid spherical particles. The mean spherical
4approximation (MSA) closure was used for this calculation, and is not the most appropriate closure for an attractive
5interparticle potential. This solution has been compared to Monte Carlo simulations for a square well fluid, showing
6this calculation to be limited in applicability to well depths |epsilon| < 1.5 kT and volume fractions |phi| < 0.08.
7
8Positive well depths correspond to an attractive potential well. Negative well depths correspond to a potential
9"shoulder", which may or may not be physically reasonable. The stickyhardsphere model may be a better choice in
10some circumstances. Computed values may behave badly at extremely small $qR$.
11
12The well width (|lambda| ) is defined as multiples of the particle diameter (2\*\ *R*\ )
13
14The interaction potential is:
15
16.. comment::
17
18  .. image:: img/image225.PNG
19
20.. math::
21
22    U(r) = \begin{cases}
23    \infty & r < 2R \\
24    -\epsilon & 2R \leq r < 2R\lambda \\
25    0 & r \geq 2R\lambda
26    \end{cases}
27
28where $r$ is the distance from the center of the sphere of a radius $R$.
29
30In sasview the effective radius may be calculated from the parameters
31used in the form factor $P(q)$ that this $S(q)$ is combined with.
32
33For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as
34
35.. math::
36
37    q = \sqrt{q_x^2 + q_y^2}
38
39
40REFERENCE
41
42R V Sharma, K C Sharma, *Physica*, 89A (1977) 213
43
44"""
45from numpy import inf
46
47name = "squarewell"
48title = "Square well structure factor, with MSA closure"
49description = """\
50    [Square well structure factor, with MSA closure]
51        Interparticle structure factor S(Q)for a hard sphere fluid with
52        a narrow attractive well. Fits are prone to deliver non-physical
53        parameters, use with care and read the references in the full manual.
54        In sasview the effective radius will be calculated from the
55        parameters used in P(Q).
56"""
57category = "structure-factor"
58structure_factor = True
59
60#single = False
61#             ["name", "units", default, [lower, upper], "type","description"],
62parameters = [
63    #   [ "name", "units", default, [lower, upper], "type",
64    #     "description" ],
65    ["radius_effective", "Ang", 50.0, [0, inf], "volume",
66     "effective radius of hard sphere"],
67    ["volfraction", "", 0.04, [0, 0.08], "",
68     "volume fraction of spheres"],
69    ["welldepth", "kT", 1.5, [0.0, 1.5], "",
70     "depth of well, epsilon"],
71    ["wellwidth", "diameters", 1.2, [1.0, inf], "",
72     "width of well in diameters (=2R) units, must be > 1"],
73    ]
74
75# No volume normalization despite having a volume parameter
76# This should perhaps be volume normalized?
77form_volume = """
78    return 1.0;
79    """
80
81Iq = """
82// single precision is very poor at extreme small Q, would need a Taylor series
83        double req,phis,edibkb,lambda,struc;
84        double sigma,eta,eta2,eta3,eta4,etam1,etam14,alpha,beta,gamm;
85        double x,sk,sk2,sk3,sk4,t1,t2,t3,t4,ck;
86        double S,C,SL,CL;
87        x= q;
88       
89        req = radius_effective;
90        phis = volfraction;
91        edibkb = welldepth;
92        lambda = wellwidth;
93       
94        sigma = req*2.;
95        eta = phis;
96        eta2 = eta*eta;
97        eta3 = eta*eta2;
98        eta4 = eta*eta3;
99        etam1 = 1. - eta;
100        etam14 = etam1*etam1*etam1*etam1;
101        // temp borrow sk for an intermediate calc
102        sk = 1.0 +2.0*eta;
103        sk *= sk;
104        alpha = (  sk + eta3*( eta-4.0 )  )/etam14;
105        beta = -(eta/3.0) * ( 18. + 20.*eta - 12.*eta2 + eta4 )/etam14;
106        gamm = 0.5*eta*( sk + eta3*(eta-4.) )/etam14;
107       
108        //  calculate the structure factor
109       
110        sk = x*sigma;
111        sk2 = sk*sk;
112        sk3 = sk*sk2;
113        sk4 = sk3*sk;
114        SINCOS(sk,S,C);
115        SINCOS(lambda*sk,SL,CL);
116        t1 = alpha * sk3 * ( S - sk * C );
117        t2 = beta * sk2 * 2.0*( sk*S - (0.5*sk2 - 1.)*C - 1.0 );
118        t3 = gamm*( ( 4.0*sk3 - 24.*sk ) * S - ( sk4 - 12.0*sk2 + 24.0 )*C + 24.0 );
119        t4 = -edibkb*sk3*(SL +sk*(C - lambda*CL) - S );
120        ck =  -24.0*eta*( t1 + t2 + t3 + t4 )/sk3/sk3;
121        struc  = 1./(1.-ck);
122       
123        return(struc);
124"""
125
126Iqxy = """
127    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
128    """
129
130# ER defaults to 0.0
131# VR defaults to 1.0
132
133oldname = 'SquareWellStructure'
134oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n")
135demo = dict(radius_effective=50, volfraction=0.04, welldepth=1.5,
136            wellwidth=1.2, radius_effective_pd=0, radius_effective_pd_n=0)
137#
138tests = [
139        [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2, 
140           'radius_effective_pd' : 0}, [0.001], [0.97665742]]
141        ]
142# ADDED by: converting from sasview RKH  ON: 16Mar2016
143
Note: See TracBrowser for help on using the repository browser.