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