source: sasmodels/sasmodels/models/be_polyelectrolyte.py @ 168052c

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

pylint prettification

  • Property mode set to 100644
File size: 6.3 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,
47*J. Journal de Physique II France*, 3 (1993) 573
48
49E Raphael, J F Joanny, *Europhysics Letters*, 11 (1990) 179
50
51"""
52
53from numpy import inf, pi, sqrt
54
55name = "be_polyelectrolyte"
56title = "Polyelectrolyte with the RPA expression derived by Borue and Erukhimovich"
57description = """
58            Evaluate
59            F(x) = K 1/(4 pi Lb (alpha)^(2)) (q^(2)+k2)/(1+(r02)^(2))
60                 (q^(2)+k2) (q^(2)-(12 h C/b^(2)))
61
62            has 3 internal parameters :
63                   The inverse Debye Length: K2 = 4 pi Lb (2 Cs+alpha C)
64                   r02 =1/alpha/Ca^(0.5) (B/(48 pi Lb)^(0.5))
65                   Ca = 6.022136e-4 C
66            """
67category = "shape-independent"
68
69# pylint: disable=bad-whitespace, line-too-long
70#   ["name", "units", default, [lower, upper], "type", "description"],
71parameters = [
72    ["contrast_factor",       "barns",   10.0,  [-inf, inf], "", "Contrast factor of the polymer"],
73    ["bjerrum_length",        "Ang",      7.1,  [0, inf],    "", "Bjerrum length"],
74    ["virial_param",          "1/Ang^2", 12.0,  [-inf, inf], "", "Virial parameter"],
75    ["monomer_length",        "Ang",     10.0,  [0, inf],    "", "Monomer length"],
76    ["salt_concentration",    "mol/L",    0.0,  [-inf, inf], "", "Concentration of monovalent salt"],
77    ["ionization_degree",     "",         0.05, [0, inf],    "", "Degree of ionization"],
78    ["polymer_concentration", "mol/L",    0.7,  [0, inf],    "", "Polymer molar concentration"],
79    ]
80# pylint: enable=bad-whitespace, line-too-long
81
82
83def Iq(q,
84       contrast_factor=10.0,
85       bjerrum_length=7.1,
86       virial_param=12.0,
87       monomer_length=10.0,
88       salt_concentration=0.0,
89       ionization_degree=0.05,
90       polymer_concentration=0.7):
91    """
92    :param q:                     Input q-value
93    :param contrast_factor:       Contrast factor of the polymer
94    :param bjerrum_length:        Bjerrum length
95    :param virial_param:          Virial parameter
96    :param monomer_length:        Monomer length
97    :param salt_concentration:    Concentration of monovalent salt
98    :param ionization_degree:     Degree of ionization
99    :param polymer_concentration: Polymer molar concentration
100    :return:                      1-D intensity
101    """
102
103    concentration = polymer_concentration * 6.022136e-4
104
105    k_square = 4.0 * pi * bjerrum_length * (2*salt_concentration +
106                                            ionization_degree * concentration)
107
108    r0_square = 1.0/ionization_degree/sqrt(concentration) * \
109                (monomer_length/sqrt((48.0*pi*bjerrum_length)))
110
111    term1 = contrast_factor/(4.0 * pi * bjerrum_length *
112                             ionization_degree**2) * (q**2 + k_square)
113
114    term2 = 1.0 + r0_square**2 * (q**2 + k_square) * \
115        (q**2 - (12.0 * virial_param * concentration/(monomer_length**2)))
116
117    return term1/term2
118
119Iq.vectorized = True  # Iq accepts an array of q values
120
121
122def Iqxy(qx, qy, *args):
123    """
124    :param qx:   Input q_x-value
125    :param qy:   Input q_y-value
126    :param args: Remaining arguments
127    :return:     2D-Intensity
128    """
129    iq = Iq(sqrt(qx**2 + qy**2), *args)
130    return iq
131
132Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values
133
134
135demo = dict(scale=1, background=0.1,
136            contrast_factor=10.0,
137            bjerrum_length=7.1,
138            virial_param=12.0,
139            monomer_length=10.0,
140            salt_concentration=0.0,
141            ionization_degree=0.05,
142            polymer_concentration=0.7)
143
144oldname = "BEPolyelectrolyte"
145
146oldpars = dict(background='background',
147               contrast_factor='k',
148               bjerrum_length='lb',
149               virial_param='h',
150               monomer_length='b',
151               salt_concentration='cs',
152               ionization_degree='alpha',
153               polymer_concentration='c')
154
155tests = [
156
157    # Accuracy tests based on content in test/utest_other_models.py
158    [{'contrast_factor':       10.0,
159      'bjerrum_length':         7.1,
160      'virial_param':          12.0,
161      'monomer_length':        10.0,
162      'salt_concentration':     0.0,
163      'ionization_degree':      0.05,
164      'polymer_concentration':  0.7,
165      'background':             0.001,
166     }, 0.001, 0.0948379],
167
168    # Additional tests with larger range of parameters
169    [{'contrast_factor':       10.0,
170      'bjerrum_length':       100.0,
171      'virial_param':           3.0,
172      'monomer_length':         1.0,
173      'salt_concentration':    10.0,
174      'ionization_degree':      2.0,
175      'polymer_concentration': 10.0,
176     }, 0.1, -3.75693800588],
177
178    [{'contrast_factor':       10.0,
179      'bjerrum_length':       100.0,
180      'virial_param':           3.0,
181      'monomer_length':         1.0,
182      'salt_concentration':    10.0,
183      'ionization_degree':      2.0,
184      'polymer_concentration': 10.0,
185      'background':           100.0
186     }, 5.0, 100.029142149],
187
188    [{'contrast_factor':     100.0,
189      'bjerrum_length':       10.0,
190      'virial_param':        180.0,
191      'monomer_length':        1.0,
192      'salt_concentration':    0.1,
193      'ionization_degree':     0.5,
194      'polymer_concentration': 0.1,
195     }, 200., 1.80664667511e-06],
196    ]
Note: See TracBrowser for help on using the repository browser.