source: sasmodels/sasmodels/models/be_polyelectrolyte.py @ 97cb037

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 97cb037 was 97cb037, checked in by piotr, 8 years ago

Converted BEPolyelectrolyte

  • Property mode set to 100644
File size: 5.2 KB
Line 
1r"""
2This model calculates the structure factor of a polyelectrolyte solution with
3the RPA expression derived by Borue and Erukhimovich.
4
5Definition
6----------
7
8The scattering intensity $I(q)$ is calculated as
9
10.. math::
11
12    I(q) = K\frac{q^2+k^2}{4\pi L\alpha ^2}
13    \frac{1}{1+r_{0}^2(q^2+k^2)(q^2-12hC_a/b^2)} + background
14
15    k^2 = 4\pi L(2C_s + \alpha C_a)
16
17    r_{0}^2 = \frac{1}{\alpha \sqrt{C_a} \left( b/\sqrt{48\pi L_b}\right)}
18
19where $K$ is the contrast factor for the polymer, $L_b$ is the Bjerrum length,
20$h$ is the virial parameter, $b$ is the monomer length,
21$C_s$ is the concentration of monovalent salt, $\alpha$ is the ionization
22degree, $C_a$ is the polymer molar concentration, and $background$ is the
23incoherent background.
24
25For 2D data the scattering intensity is calculated in the same way as 1D,
26where the $q$ vector is defined as
27
28.. math::
29
30    q = \sqrt{q_x^2 + q_y^2}
31
32
33.. figure:: img/be_polyelectrolyte_1d.jpg
34
35    1D plot using the default values (w/500 data point).
36
37NB: $1 barn = 10^{-24} cm^2$
38
39References
40----------
41
42V Y Borue, I Y Erukhimovich, *Macromolecules*, 21 (1988) 3240
43
44J F Joanny, L Leibler, *Journal de Physique*, 51 (1990) 545
45
46A Moussaid, F Schosseler, J P Munch, S Candau, *J. Journal de Physique II France*, 3 (1993) 573
47
48E Raphael, J F Joanny, *Europhysics Letters*, 11 (1990) 179
49
50"""
51
52from numpy import inf, power, pi, sqrt
53
54name = "be_polyelectrolyte"
55title = "Polyelectrolyte with the RPA expression derived by Borue and Erukhimovich"
56description = """
57            Evaluate
58            F(x) = K 1/(4 pi Lb (alpha)^(2)) (q^(2)+k2)/(1+(r02)^(2))
59                 (q^(2)+k2) (q^(2)-(12 h C/b^(2)))
60
61            has 3 internal parameters :
62                   The inverse Debye Length: K2 = 4 pi Lb (2 Cs+alpha C)
63                   r02 =1/alpha/Ca^(0.5) (B/(48 pi Lb)^(0.5))
64                   Ca = 6.022136e-4 C
65            """
66category = "shape-independent"
67
68#            ["name", "units", default, [lower, upper], "type", "description"],
69parameters = [["contrast_factor",       "barns",   10.0,  [-inf, inf], "", "Contrast factor of the polymer"],
70              ["bjerrum_length",        "Ang",      7.1,  [0, inf],    "", "Bjerrum length"],
71              ["virial_param",          "1/Ang^2", 12.0,  [-inf, inf], "", "Virial parameter"],
72              ["monomer_length",        "Ang",     10.0,  [0, inf],    "", "Monomer length"],
73              ["salt_concentration",    "mol/L",    0.0,  [-inf, inf], "", "Concentration of monovalent salt"],
74              ["ionization_degree",     "",         0.05, [0, inf],    "", "Degree of ionization"],
75              ["polymer_concentration", "mol/L",    0.7,  [0, inf],    "", "Polymer molar concentration"],
76              ]
77
78
79def Iq(q,
80       contrast_factor,
81       bjerrum_length,
82       virial_param,
83       monomer_length,
84       salt_concentration,
85       ionization_degree,
86       polymer_concentration):
87
88    concentration = polymer_concentration * 6.022136e-4
89
90    k_square = 4.0 * pi * bjerrum_length * (2*salt_concentration +
91            ionization_degree * concentration)
92
93    r0_square = 1.0/ionization_degree/sqrt(concentration) * \
94            (monomer_length/sqrt((48.0*pi*bjerrum_length)))
95
96    term1 = contrast_factor/(4.0 * pi * bjerrum_length *
97        ionization_degree**2) * (q**2 + k_square)
98
99    term2 = 1.0 + r0_square**2 * (q**2 + k_square) * \
100        (q**2 - (12.0 * virial_param * concentration/(monomer_length**2)))
101
102    return term1/term2
103
104Iq.vectorized = True  # Iq accepts an array of q values
105
106
107def Iqxy(qx, qy, *args):
108        iq = Iq(sqrt(qx**2 + qy**2), *args)
109
110        return iq
111
112Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values
113
114
115demo = dict(scale=1, background=0.1,
116            contrast_factor=10.0,
117            bjerrum_length=7.1,
118            virial_param=12.0,
119            monomer_length=10.0,
120            salt_concentration=0.0,
121            ionization_degree=0.05,
122            polymer_concentration=0.7)
123
124oldname = "BEPolyelectrolyte"
125
126oldpars = dict(background='background',
127               contrast_factor='k',
128               bjerrum_length='lb',
129               virial_param='h',
130               monomer_length='b',
131               salt_concentration='cs',
132               ionization_degree='alpha',
133               polymer_concentration='c')
134
135tests = [[{'contrast_factor':       10.0,
136           'bjerrum_length':       100.0,
137           'virial_param':           3.0,
138           'monomer_length':         1.0,
139           'salt_concentration':    10.0,
140           'ionization_degree':      2.0,
141           'polymer_concentration': 10.0,
142           }, 0.1, -3.75693800588],
143
144         [{'contrast_factor':       10.0,
145           'bjerrum_length':       100.0,
146           'virial_param':           3.0,
147           'monomer_length':         1.0,
148           'salt_concentration':    10.0,
149           'ionization_degree':      2.0,
150           'polymer_concentration': 10.0,
151           'background':           100.0
152           }, 5.0, 100.029142149],
153
154         [{'contrast_factor':     100.0,
155           'bjerrum_length':       10.0,
156           'virial_param':        180.0,
157           'monomer_length':        1.0,
158           'salt_concentration':    0.1,
159           'ionization_degree':     0.5,
160           'polymer_concentration': 0.1,
161           }, 200., 1.80664667511e-06],
162         ]
Note: See TracBrowser for help on using the repository browser.