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