source: sasmodels/sasmodels/models/squarewell.py @ 5111921

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

replace gifs so that we can build pdf

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