[3330bb4] | 1 | # Note: model title and parameter table are inserted automatically |
---|
| 2 | r""" |
---|
[c1e44e5] | 3 | Calculates the interparticle structure factor for a hard sphere fluid |
---|
| 4 | with a narrow, attractive, square well potential. **The Mean Spherical |
---|
| 5 | Approximation (MSA) closure relationship is used, but it is not the most |
---|
| 6 | appropriate closure for an attractive interparticle potential.** However, |
---|
| 7 | the solution has been compared to Monte Carlo simulations for a square |
---|
| 8 | well fluid and these show the MSA calculation to be limited to well |
---|
[5f3c534] | 9 | depths $\epsilon < 1.5$ kT and volume fractions $\phi < 0.08$. |
---|
[3330bb4] | 10 | |
---|
| 11 | Positive well depths correspond to an attractive potential well. Negative |
---|
| 12 | well depths correspond to a potential "shoulder", which may or may not be |
---|
[c1e44e5] | 13 | physically reasonable. The :ref:`stickyhardsphere` model may be a better |
---|
[5f3c534] | 14 | choice in some circumstances. |
---|
| 15 | |
---|
| 16 | Computed values may behave badly at extremely small $qR$. |
---|
| 17 | |
---|
| 18 | .. note:: |
---|
| 19 | |
---|
[c1e44e5] | 20 | Earlier versions of SasView did not incorporate the so-called |
---|
| 21 | $\beta(q)$ ("beta") correction [2] for polydispersity and non-sphericity. |
---|
[5f3c534] | 22 | This is only available in SasView versions 4.2.2 and higher. |
---|
[3330bb4] | 23 | |
---|
| 24 | The well width $(\lambda)$ is defined as multiples of the particle diameter |
---|
| 25 | $(2 R)$. |
---|
| 26 | |
---|
| 27 | The interaction potential is: |
---|
| 28 | |
---|
| 29 | .. math:: |
---|
| 30 | |
---|
| 31 | U(r) = \begin{cases} |
---|
| 32 | \infty & r < 2R \\ |
---|
| 33 | -\epsilon & 2R \leq r < 2R\lambda \\ |
---|
| 34 | 0 & r \geq 2R\lambda |
---|
| 35 | \end{cases} |
---|
| 36 | |
---|
[5f3c534] | 37 | where $r$ is the distance from the center of a sphere of a radius $R$. |
---|
[3330bb4] | 38 | |
---|
[5f3c534] | 39 | In SasView the effective radius may be calculated from the parameters |
---|
[3330bb4] | 40 | used in the form factor $P(q)$ that this $S(q)$ is combined with. |
---|
| 41 | |
---|
| 42 | For 2D data: The 2D scattering intensity is calculated in the same way as 1D, |
---|
| 43 | where the $q$ vector is defined as |
---|
| 44 | |
---|
| 45 | .. math:: |
---|
| 46 | |
---|
| 47 | q = \sqrt{q_x^2 + q_y^2} |
---|
| 48 | |
---|
| 49 | References |
---|
| 50 | ---------- |
---|
| 51 | |
---|
[0507e09] | 52 | .. [#] R V Sharma, K C Sharma, *Physica*, 89A (1977) 213 |
---|
| 53 | |
---|
[5f3c534] | 54 | .. [#] M Kotlarchyk and S-H Chen, *J. Chem. Phys.*, 79 (1983) 2461-2469 |
---|
| 55 | |
---|
[0507e09] | 56 | Authorship and Verification |
---|
| 57 | ---------------------------- |
---|
| 58 | |
---|
[c1e44e5] | 59 | * **Author:** |
---|
| 60 | * **Last Modified by:** |
---|
[5f3c534] | 61 | * **Last Reviewed by:** Steve King **Date:** March 27, 2019 |
---|
[3330bb4] | 62 | """ |
---|
[2d81cfe] | 63 | |
---|
| 64 | import numpy as np |
---|
[3330bb4] | 65 | from numpy import inf |
---|
| 66 | |
---|
| 67 | name = "squarewell" |
---|
[5f3c534] | 68 | title = "Square well structure factor with Mean Spherical Approximation closure" |
---|
[3330bb4] | 69 | description = """\ |
---|
| 70 | [Square well structure factor, with MSA closure] |
---|
[c1e44e5] | 71 | Interparticle structure factor S(Q) for a hard sphere fluid |
---|
[5f3c534] | 72 | with a narrow attractive well. Fits are prone to deliver non- |
---|
[c1e44e5] | 73 | physical parameters; use with care and read the references in |
---|
| 74 | the model documentation.The "beta(q)" correction is available |
---|
[5f3c534] | 75 | in versions 4.2.2 and higher. |
---|
[3330bb4] | 76 | """ |
---|
| 77 | category = "structure-factor" |
---|
| 78 | structure_factor = True |
---|
| 79 | single = False |
---|
| 80 | |
---|
| 81 | #single = False |
---|
| 82 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
| 83 | parameters = [ |
---|
| 84 | # [ "name", "units", default, [lower, upper], "type", |
---|
| 85 | # "description" ], |
---|
| 86 | ["radius_effective", "Ang", 50.0, [0, inf], "volume", |
---|
| 87 | "effective radius of hard sphere"], |
---|
| 88 | ["volfraction", "", 0.04, [0, 0.08], "", |
---|
| 89 | "volume fraction of spheres"], |
---|
| 90 | ["welldepth", "kT", 1.5, [0.0, 1.5], "", |
---|
| 91 | "depth of well, epsilon"], |
---|
| 92 | ["wellwidth", "diameters", 1.2, [1.0, inf], "", |
---|
| 93 | "width of well in diameters (=2R) units, must be > 1"], |
---|
| 94 | ] |
---|
| 95 | |
---|
| 96 | # No volume normalization despite having a volume parameter |
---|
| 97 | # This should perhaps be volume normalized? |
---|
| 98 | form_volume = """ |
---|
| 99 | return 1.0; |
---|
| 100 | """ |
---|
| 101 | |
---|
| 102 | Iq = """ |
---|
| 103 | // single precision is very poor at extreme small Q, would need a Taylor series |
---|
| 104 | double req,phis,edibkb,lambda,struc; |
---|
| 105 | double sigma,eta,eta2,eta3,eta4,etam1,etam14,alpha,beta,gamm; |
---|
| 106 | double x,sk,sk2,sk3,sk4,t1,t2,t3,t4,ck; |
---|
| 107 | double S,C,SL,CL; |
---|
| 108 | x= q; |
---|
[8f04da4] | 109 | |
---|
[3330bb4] | 110 | req = radius_effective; |
---|
| 111 | phis = volfraction; |
---|
| 112 | edibkb = welldepth; |
---|
| 113 | lambda = wellwidth; |
---|
[8f04da4] | 114 | |
---|
[3330bb4] | 115 | sigma = req*2.; |
---|
| 116 | eta = phis; |
---|
| 117 | eta2 = eta*eta; |
---|
| 118 | eta3 = eta*eta2; |
---|
| 119 | eta4 = eta*eta3; |
---|
| 120 | etam1 = 1. - eta; |
---|
| 121 | etam14 = etam1*etam1*etam1*etam1; |
---|
| 122 | // temp borrow sk for an intermediate calc |
---|
| 123 | sk = 1.0 +2.0*eta; |
---|
| 124 | sk *= sk; |
---|
| 125 | alpha = ( sk + eta3*( eta-4.0 ) )/etam14; |
---|
| 126 | beta = -(eta/3.0) * ( 18. + 20.*eta - 12.*eta2 + eta4 )/etam14; |
---|
| 127 | gamm = 0.5*eta*( sk + eta3*(eta-4.) )/etam14; |
---|
[8f04da4] | 128 | |
---|
[3330bb4] | 129 | // calculate the structure factor |
---|
[8f04da4] | 130 | |
---|
[3330bb4] | 131 | sk = x*sigma; |
---|
| 132 | sk2 = sk*sk; |
---|
| 133 | sk3 = sk*sk2; |
---|
| 134 | sk4 = sk3*sk; |
---|
| 135 | SINCOS(sk,S,C); |
---|
| 136 | SINCOS(lambda*sk,SL,CL); |
---|
| 137 | t1 = alpha * sk3 * ( S - sk * C ); |
---|
| 138 | t2 = beta * sk2 * 2.0*( sk*S - (0.5*sk2 - 1.)*C - 1.0 ); |
---|
| 139 | t3 = gamm*( ( 4.0*sk3 - 24.*sk ) * S - ( sk4 - 12.0*sk2 + 24.0 )*C + 24.0 ); |
---|
| 140 | t4 = -edibkb*sk3*(SL +sk*(C - lambda*CL) - S ); |
---|
| 141 | ck = -24.0*eta*( t1 + t2 + t3 + t4 )/sk3/sk3; |
---|
| 142 | struc = 1./(1.-ck); |
---|
[8f04da4] | 143 | |
---|
[3330bb4] | 144 | return(struc); |
---|
| 145 | """ |
---|
| 146 | |
---|
[8f04da4] | 147 | def random(): |
---|
[b297ba9] | 148 | """Return a random parameter set for the model.""" |
---|
[8f04da4] | 149 | pars = dict( |
---|
| 150 | scale=1, background=0, |
---|
| 151 | radius_effective=10**np.random.uniform(1, 4.7), |
---|
| 152 | volfraction=np.random.uniform(0.00001, 0.08), |
---|
| 153 | welldepth=np.random.uniform(0, 1.5), |
---|
| 154 | wellwidth=np.random.uniform(1, 1.2), |
---|
| 155 | ) |
---|
| 156 | return pars |
---|
| 157 | |
---|
[3330bb4] | 158 | demo = dict(radius_effective=50, volfraction=0.04, welldepth=1.5, |
---|
| 159 | wellwidth=1.2, radius_effective_pd=0, radius_effective_pd_n=0) |
---|
| 160 | # |
---|
| 161 | tests = [ |
---|
[8f04da4] | 162 | [{'scale': 1.0, 'background': 0.0, 'radius_effective': 50.0, |
---|
[2d81cfe] | 163 | 'volfraction': 0.04, 'welldepth': 1.5, 'wellwidth': 1.2, |
---|
[8f04da4] | 164 | 'radius_effective_pd': 0}, [0.001], [0.97665742]], |
---|
[3330bb4] | 165 | ] |
---|
| 166 | # ADDED by: converting from sasview RKH ON: 16Mar2016 |
---|