[3330bb4] | 1 | r""" |
---|
[c78d677] | 2 | .. note:: Please read the Validation section below. |
---|
| 3 | |
---|
[3330bb4] | 4 | Definition |
---|
| 5 | ---------- |
---|
| 6 | This model calculates the structure factor of a polyelectrolyte solution with |
---|
| 7 | the RPA expression derived by Borue and Erukhimovich\ [#Borue]_. Note however |
---|
| 8 | that the fitting procedure here does not follow the notation in that reference |
---|
| 9 | as 's' and 't' are **not** decoupled. Instead the scattering intensity $I(q)$ |
---|
| 10 | is calculated as |
---|
| 11 | |
---|
| 12 | .. math:: |
---|
| 13 | |
---|
| 14 | I(q) = K\frac{q^2+k^2}{4\pi L_b\alpha ^2} |
---|
[284bdd4] | 15 | \frac{1}{1+r_{0}^4(q^2+k^2)(q^2-12hC_a/b^2)} + background |
---|
[3330bb4] | 16 | |
---|
| 17 | k^2 = 4\pi L_b(2C_s + \alpha C_a) |
---|
| 18 | |
---|
[284bdd4] | 19 | r_{0}^2 = \frac{b}{\alpha \sqrt{C_a 48\pi L_b}} |
---|
[3330bb4] | 20 | |
---|
[a151caa] | 21 | where |
---|
[3330bb4] | 22 | |
---|
| 23 | $K$ is the contrast factor for the polymer which is defined differently than in |
---|
[c78d677] | 24 | other models and is given in barns where 1 $barn = 10^{-24}$ $cm^2$. $K$ is |
---|
[3330bb4] | 25 | defined as: |
---|
| 26 | |
---|
| 27 | .. math:: |
---|
| 28 | |
---|
| 29 | K = a^2 |
---|
| 30 | |
---|
| 31 | a = b_p - (v_p/v_s) b_s |
---|
[a151caa] | 32 | |
---|
[c78d677] | 33 | where: |
---|
| 34 | |
---|
| 35 | - $b_p$ and $b_s$ are **sum of the scattering lengths of the atoms** |
---|
| 36 | constituting the polymer monomer and the solvent molecules, respectively. |
---|
| 37 | |
---|
| 38 | - $v_p$ and $v_s$ are the partial molar volume of the polymer and the |
---|
| 39 | solvent, respectively. |
---|
| 40 | |
---|
| 41 | - $L_b$ is the Bjerrum length (|Ang|) - **Note:** This parameter needs to be |
---|
| 42 | kept constant for a given solvent and temperature! |
---|
| 43 | |
---|
| 44 | - $h$ is the virial parameter (|Ang^3|) - **Note:** See [#Borue]_ for the |
---|
| 45 | correct interpretation of this parameter. It incorporates second and third |
---|
| 46 | virial coefficients and can be *negative*. |
---|
| 47 | |
---|
| 48 | - $b$ is the monomer length (|Ang|). |
---|
| 49 | |
---|
[c351383] | 50 | - $C_s$ is the concentration of monovalent salt(1/|Ang^3| - converted from mol/L). |
---|
[3330bb4] | 51 | |
---|
[c78d677] | 52 | - $\alpha$ is the degree of ionization (the ratio of charged monomers to the total |
---|
| 53 | number of monomers) |
---|
[3330bb4] | 54 | |
---|
[c351383] | 55 | - $C_a$ is the polymer molar concentration (1/|Ang^3| - converted from mol/L) |
---|
[3330bb4] | 56 | |
---|
[c78d677] | 57 | - $background$ is the incoherent background. |
---|
[3330bb4] | 58 | |
---|
| 59 | For 2D data the scattering intensity is calculated in the same way as 1D, |
---|
| 60 | where the $\vec q$ vector is defined as |
---|
| 61 | |
---|
| 62 | .. math:: |
---|
| 63 | |
---|
| 64 | q = \sqrt{q_x^2 + q_y^2} |
---|
| 65 | |
---|
[284bdd4] | 66 | Validation |
---|
| 67 | ---------- |
---|
| 68 | |
---|
| 69 | As of the last revision, this code is believed to be correct. However it |
---|
| 70 | needs further validation and should be used with caution at this time. The |
---|
| 71 | history of this code goes back to a 1998 implementation. It was recently noted |
---|
| 72 | that in that implementation, while both the polymer concentration and salt |
---|
[d8b4c5a] | 73 | concentration were converted from experimental units of mol/L to more |
---|
[c78d677] | 74 | dimensionally useful units of 1/|Ang^3|, only the converted version of the |
---|
[d8b4c5a] | 75 | polymer concentration was actually being used in the calculation while the |
---|
[c78d677] | 76 | unconverted salt concentration (still in apparent units of mol/L) was being |
---|
| 77 | used. This was carried through to Sasmodels as used for SasView 4.1 (though |
---|
| 78 | the line of code converting the salt concentration to the new units was removed |
---|
| 79 | somewhere along the line). Simple dimensional analysis of the calculation shows |
---|
| 80 | that the converted salt concentration should be used, which the original code |
---|
| 81 | suggests was the intention, so this has now been corrected (for SasView 4.2). |
---|
| 82 | Once better validation has been performed this note will be removed. |
---|
[284bdd4] | 83 | |
---|
[3330bb4] | 84 | References |
---|
| 85 | ---------- |
---|
| 86 | |
---|
| 87 | .. [#Borue] V Y Borue, I Y Erukhimovich, *Macromolecules*, 21 (1988) 3240 |
---|
| 88 | .. [#] J F Joanny, L Leibler, *Journal de Physique*, 51 (1990) 545 |
---|
| 89 | .. [#] A Moussaid, F Schosseler, J P Munch, S Candau, *J. Journal de Physique |
---|
| 90 | II France*, 3 (1993) 573 |
---|
| 91 | .. [#] E Raphael, J F Joanny, *Europhysics Letters*, 11 (1990) 179 |
---|
| 92 | |
---|
| 93 | Authorship and Verification |
---|
| 94 | ---------------------------- |
---|
| 95 | |
---|
| 96 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
[284bdd4] | 97 | * **Last Modified by:** Paul Butler **Date:** September 25, 2018 |
---|
| 98 | * **Last Reviewed by:** Paul Butler **Date:** September 25, 2018 |
---|
[3330bb4] | 99 | """ |
---|
| 100 | |
---|
[2d81cfe] | 101 | import numpy as np |
---|
[3330bb4] | 102 | from numpy import inf, pi, sqrt |
---|
| 103 | |
---|
| 104 | name = "be_polyelectrolyte" |
---|
| 105 | title = "Polyelectrolyte with the RPA expression derived by Borue and Erukhimovich" |
---|
| 106 | description = """ |
---|
| 107 | Evaluate |
---|
| 108 | F(x) = K 1/(4 pi Lb (alpha)^(2)) (q^(2)+k2)/(1+(r02)^(2)) |
---|
| 109 | (q^(2)+k2) (q^(2)-(12 h C/b^(2))) |
---|
| 110 | |
---|
| 111 | has 3 internal parameters : |
---|
| 112 | The inverse Debye Length: K2 = 4 pi Lb (2 Cs+alpha C) |
---|
| 113 | r02 =1/alpha/Ca^(0.5) (B/(48 pi Lb)^(0.5)) |
---|
| 114 | Ca = 6.022136e-4 C |
---|
| 115 | """ |
---|
| 116 | category = "shape-independent" |
---|
| 117 | |
---|
| 118 | # pylint: disable=bad-whitespace, line-too-long |
---|
| 119 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
| 120 | parameters = [ |
---|
| 121 | ["contrast_factor", "barns", 10.0, [-inf, inf], "", "Contrast factor of the polymer"], |
---|
| 122 | ["bjerrum_length", "Ang", 7.1, [0, inf], "", "Bjerrum length"], |
---|
[284bdd4] | 123 | ["virial_param", "Ang^3", 12.0, [-inf, inf], "", "Virial parameter"], |
---|
[3330bb4] | 124 | ["monomer_length", "Ang", 10.0, [0, inf], "", "Monomer length"], |
---|
| 125 | ["salt_concentration", "mol/L", 0.0, [-inf, inf], "", "Concentration of monovalent salt"], |
---|
| 126 | ["ionization_degree", "", 0.05, [0, inf], "", "Degree of ionization"], |
---|
| 127 | ["polymer_concentration", "mol/L", 0.7, [0, inf], "", "Polymer molar concentration"], |
---|
| 128 | ] |
---|
| 129 | # pylint: enable=bad-whitespace, line-too-long |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | def Iq(q, |
---|
[d8b4c5a] | 133 | contrast_factor, |
---|
| 134 | bjerrum_length, |
---|
| 135 | virial_param, |
---|
| 136 | monomer_length, |
---|
| 137 | salt_concentration, |
---|
| 138 | ionization_degree, |
---|
| 139 | polymer_concentration): |
---|
[3330bb4] | 140 | """ |
---|
[d8b4c5a] | 141 | :params: see parameter table |
---|
| 142 | :return: 1-D form factor for polyelectrolytes in low salt |
---|
| 143 | |
---|
| 144 | parameter names, units, default values, and behavior (volume, sld etc) are |
---|
| 145 | defined in the parameter table. The concentrations are converted from |
---|
| 146 | experimental mol/L to dimensionaly useful 1/A3 in first two lines |
---|
[3330bb4] | 147 | """ |
---|
| 148 | |
---|
[284bdd4] | 149 | concentration_pol = polymer_concentration * 6.022136e-4 |
---|
| 150 | concentration_salt = salt_concentration * 6.022136e-4 |
---|
[3330bb4] | 151 | |
---|
[284bdd4] | 152 | k_square = 4.0 * pi * bjerrum_length * (2*concentration_salt + |
---|
| 153 | ionization_degree * concentration_pol) |
---|
[3330bb4] | 154 | |
---|
[284bdd4] | 155 | r0_square = 1.0/ionization_degree/sqrt(concentration_pol) * \ |
---|
[3330bb4] | 156 | (monomer_length/sqrt((48.0*pi*bjerrum_length))) |
---|
| 157 | |
---|
| 158 | term1 = contrast_factor/(4.0 * pi * bjerrum_length * |
---|
| 159 | ionization_degree**2) * (q**2 + k_square) |
---|
| 160 | |
---|
| 161 | term2 = 1.0 + r0_square**2 * (q**2 + k_square) * \ |
---|
[284bdd4] | 162 | (q**2 - (12.0 * virial_param * concentration_pol/(monomer_length**2))) |
---|
[3330bb4] | 163 | |
---|
| 164 | return term1/term2 |
---|
| 165 | |
---|
| 166 | Iq.vectorized = True # Iq accepts an array of q values |
---|
| 167 | |
---|
[a151caa] | 168 | def random(): |
---|
[8f04da4] | 169 | # TODO: review random be_polyelectrolyte model generation |
---|
[a151caa] | 170 | pars = dict( |
---|
| 171 | scale=10000, #background=0, |
---|
| 172 | #polymer_concentration=0.7, |
---|
| 173 | polymer_concentration=np.random.beta(5, 3), # around 70% |
---|
| 174 | #salt_concentration=0.0, |
---|
| 175 | # keep salt concentration extremely low |
---|
| 176 | # and use explicit molar to match polymer concentration |
---|
| 177 | salt_concentration=np.random.beta(1, 100)*6.022136e-4, |
---|
| 178 | #contrast_factor=10.0, |
---|
| 179 | contrast_fact=np.random.uniform(1, 100), |
---|
| 180 | #bjerrum_length=7.1, |
---|
| 181 | bjerrum_length=np.random.uniform(1, 10), |
---|
| 182 | #virial_param=12.0, |
---|
| 183 | virial_param=np.random.uniform(-1000, 30), |
---|
| 184 | #monomer_length=10.0, |
---|
| 185 | monomer_length=10.0**(4*np.random.beta(1.5, 3)), |
---|
| 186 | #ionization_degree=0.05, |
---|
| 187 | ionization_degree=np.random.beta(1.5, 4), |
---|
| 188 | ) |
---|
| 189 | return pars |
---|
[3330bb4] | 190 | |
---|
| 191 | demo = dict(scale=1, background=0.1, |
---|
| 192 | contrast_factor=10.0, |
---|
| 193 | bjerrum_length=7.1, |
---|
| 194 | virial_param=12.0, |
---|
| 195 | monomer_length=10.0, |
---|
| 196 | salt_concentration=0.0, |
---|
| 197 | ionization_degree=0.05, |
---|
| 198 | polymer_concentration=0.7) |
---|
| 199 | |
---|
| 200 | tests = [ |
---|
| 201 | |
---|
| 202 | # Accuracy tests based on content in test/utest_other_models.py |
---|
[d8b4c5a] | 203 | # Note that these should some day be validated beyond this self validation |
---|
| 204 | # (circular reasoning). -- i.e. the "good value," at least for those with |
---|
| 205 | # non zero salt concentrations, were obtained by running the current |
---|
| 206 | # model in SasView and copying the appropriate result here. |
---|
| 207 | # PDB -- Sep 26, 2018 |
---|
[3330bb4] | 208 | [{'contrast_factor': 10.0, |
---|
| 209 | 'bjerrum_length': 7.1, |
---|
| 210 | 'virial_param': 12.0, |
---|
| 211 | 'monomer_length': 10.0, |
---|
| 212 | 'salt_concentration': 0.0, |
---|
| 213 | 'ionization_degree': 0.05, |
---|
| 214 | 'polymer_concentration': 0.7, |
---|
| 215 | 'background': 0.001, |
---|
| 216 | }, 0.001, 0.0948379], |
---|
| 217 | |
---|
[d8b4c5a] | 218 | [{'contrast_factor': 10.0, |
---|
| 219 | 'bjerrum_length': 100.0, |
---|
| 220 | 'virial_param': 3.0, |
---|
| 221 | 'monomer_length': 5.0, |
---|
| 222 | 'salt_concentration': 1.0, |
---|
| 223 | 'ionization_degree': 0.1, |
---|
| 224 | 'polymer_concentration': 1.0, |
---|
| 225 | 'background': 0.0, |
---|
| 226 | }, 0.1, 0.253469484], |
---|
| 227 | |
---|
| 228 | [{'contrast_factor': 10.0, |
---|
| 229 | 'bjerrum_length': 100.0, |
---|
| 230 | 'virial_param': 3.0, |
---|
| 231 | 'monomer_length': 5.0, |
---|
| 232 | 'salt_concentration': 1.0, |
---|
| 233 | 'ionization_degree': 0.1, |
---|
| 234 | 'polymer_concentration': 1.0, |
---|
| 235 | 'background': 1.0, |
---|
| 236 | }, 0.05, 1.738358122], |
---|
| 237 | |
---|
| 238 | [{'contrast_factor': 100.0, |
---|
| 239 | 'bjerrum_length': 10.0, |
---|
| 240 | 'virial_param': 12.0, |
---|
| 241 | 'monomer_length': 10.0, |
---|
| 242 | 'salt_concentration': 0.1, |
---|
| 243 | 'ionization_degree': 0.5, |
---|
| 244 | 'polymer_concentration': 0.1, |
---|
| 245 | 'background': 0.01, |
---|
| 246 | }, 0.5, 0.012881893], |
---|
[3330bb4] | 247 | ] |
---|