source: sasmodels/sasmodels/models/stickyhardsphere.py @ bfb195e

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since bfb195e was bfb195e, checked in by Paul Kienzle <pkienzle@…>, 9 years ago

fake 2D patterns for pure 1D models using Iqq

  • Property mode set to 100644
File size: 5.7 KB
Line 
1# Note: model title and parameter table are inserted automatically
2r"""This calculates the interparticle structure factor for a hard sphere fluid with a narrow attractive well. A perturbative
3solution of the Percus-Yevick closure is used. The strength of the attractive well is described in terms of "stickiness"
4as defined below. The returned value is a dimensionless structure factor, *S(q)*.
5
6The perturb (perturbation parameter), |epsilon|, should be held between 0.01 and 0.1. It is best to hold the
7perturbation parameter fixed and let the "stickiness" vary to adjust the interaction strength. The stickiness, |tau|,
8is defined in the equation below and is a function of both the perturbation parameter and the interaction strength.
9|tau| and |epsilon| are defined in terms of the hard sphere diameter (|sigma| = 2\*\ *R*\ ), the width of the square
10well, |bigdelta| (same units as *R*), and the depth of the well, *Uo*, in units of kT. From the definition, it is clear
11that smaller |tau| means stronger attraction.
12
13.. image:: img/stickyhardsphere_228.PNG
14
15where the interaction potential is
16
17.. image:: img/stickyhardsphere_229.PNG
18
19The Percus-Yevick (PY) closure was used for this calculation, and is an adequate closure for an attractive interparticle
20potential. This solution has been compared to Monte Carlo simulations for a square well fluid, with good agreement.
21
22The true particle volume fraction, |phi|, is not equal to *h*, which appears in most of the reference. The two are
23related in equation (24) of the reference. The reference also describes the relationship between this perturbation
24solution and the original sticky hard sphere (or adhesive sphere) model by Baxter.
25
26NB: The calculation can go haywire for certain combinations of the input parameters, producing unphysical solutions - in
27this case errors are reported to the command window and the *S(q)* is set to -1 (so it will disappear on a log-log
28plot). Use tight bounds to keep the parameters to values that you know are physical (test them) and keep nudging them
29until the optimization does not hit the constraints.
30
31In sasview the effective radius will be calculated from the parameters used in the form factor P(Q) that this
32S(Q) is combined with.
33
34For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as
35
36.. math::
37
38    Q = \sqrt{Q_x^2 + Q_y^2}
39
40==============  ========  =============
41Parameter name  Units     Default value
42==============  ========  =============
43effect_radius   |Ang|     50
44perturb         None      0.05
45volfraction     None      0.1
46stickiness      K         0.2
47==============  ========  =============
48
49.. image:: img/stickyhardsphere_230.jpg
50
51*Figure. 1D plot using the default values (in linear scale).*
52
53REFERENCE
54
55S V G Menon, C Manohar, and K S Rao, *J. Chem. Phys.*, 95(12) (1991) 9186-9190
56"""
57
58# TODO: refactor so that we pull in the old sansmodels.c_extensions
59 
60from numpy import pi, inf
61
62name = "stickyhardsphere"
63title = "Sticky hard sphere structure factor, with Percus-Yevick closure"
64description = """\
65        [Sticky hard sphere structure factor, with Percus-Yevick closure]
66        Interparticle structure factor S(Q)for a hard sphere fluid with
67                a narrow attractive well. Fits are prone to deliver non-physical
68                parameters, use with care and read the references in the full manual.
69                In sasview the effective radius will be calculated from the
70                parameters used in P(Q).
71"""
72category = "structure-factor"
73
74parameters = [
75#   [ "name", "units", default, [lower, upper], "type",
76#     "description" ],
77    [ "effect_radius", "Ang",  50.0, [0, inf], "volume",
78      "effective radius of hard sphere" ],
79    [ "volfraction", "",  0.2, [0, 0.74], "",
80      "volume fraction of hard spheres" ],
81    [ "perturb", "",  0.05, [0.01, 0.1], "",
82      "perturbation parameter, epsilon" ],
83    [ "stickiness", "",  0.20, [-inf,inf], "",
84      "stickiness, tau" ],
85    ]
86       
87# No volume normalization despite having a volume parameter
88# This should perhaps be volume normalized?
89form_volume = """
90    return 1.0;
91    """
92
93Iq = """
94        double onemineps,eta;
95        double sig,aa,etam1,etam1sq,qa,qb,qc,radic;
96        double lam,lam2,test,mu,alpha,beta;
97        double kk,k2,k3,ds,dc,aq1,aq2,aq3,aq,bq1,bq2,bq3,bq,sq;
98       
99        onemineps = 1.0-perturb;
100        eta = volfraction/onemineps/onemineps/onemineps;
101       
102        sig = 2.0 * effect_radius;
103        aa = sig/onemineps;
104        etam1 = 1.0 - eta;
105        etam1sq=etam1*etam1;
106        //C
107        //C  SOLVE QUADRATIC FOR LAMBDA
108        //C
109        qa = eta/12.0;
110        qb = -1.0*(stickiness + eta/etam1);
111        qc = (1.0 + eta/2.0)/etam1sq;
112        radic = qb*qb - 4.0*qa*qc;
113        if(radic<0) {
114                //if(x>0.01 && x<0.015)
115                //      Print "Lambda unphysical - both roots imaginary"
116                //endif
117                return(-1.0);
118        }
119        //C   KEEP THE SMALLER ROOT, THE LARGER ONE IS UNPHYSICAL
120        lam = (-1.0*qb-sqrt(radic))/(2.0*qa);
121        lam2 = (-1.0*qb+sqrt(radic))/(2.0*qa);
122        if(lam2<lam) {
123                lam = lam2;
124        }
125        test = 1.0 + 2.0*eta;
126        mu = lam*eta*etam1;
127        if(mu>test) {
128                //if(x>0.01 && x<0.015)
129                // Print "Lambda unphysical mu>test"
130                //endif
131                return(-1.0);
132        }
133        alpha = (1.0 + 2.0*eta - mu)/etam1sq;
134        beta = (mu - 3.0*eta)/(2.0*etam1sq);
135        //C
136        //C   CALCULATE THE STRUCTURE FACTOR
137        //C
138        kk = q*aa;
139        k2 = kk*kk;
140        k3 = kk*k2;
141        SINCOS(kk,ds,dc);
142        //ds = sin(kk);
143        //dc = cos(kk);
144        aq1 = ((ds - kk*dc)*alpha)/k3;
145        aq2 = (beta*(1.0-dc))/k2;
146        aq3 = (lam*ds)/(12.0*kk);
147        aq = 1.0 + 12.0*eta*(aq1+aq2-aq3);
148        //
149        bq1 = alpha*(0.5/kk - ds/k2 + (1.0 - dc)/k3);
150        bq2 = beta*(1.0/kk - ds/k2);
151        bq3 = (lam/12.0)*((1.0 - dc)/kk);
152        bq = 12.0*eta*(bq1+bq2-bq3);
153        //
154        sq = 1.0/(aq*aq +bq*bq);
155       
156        return(sq);
157"""
158
159Iqxy = """
160    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
161    """
162
163# ER defaults to 0.0
164# VR defaults to 1.0
165
166oldname = 'StickyHSStructure'
167oldpars = dict()
168demo = dict(effect_radius = 200,volfraction = 0.2,perturb=0.05,stickiness=0.2,effect_radius_pd = 0.1,effect_radius_pd_n = 40)
169
170
171
Note: See TracBrowser for help on using the repository browser.