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