source: sasmodels/sasmodels/models/be_polyelectrolyte.py @ 6cefbc9

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

implicit Iqxy; fix divide by 0 for q=0

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