Changeset a5bcd61 in sasmodels


Ignore:
Timestamp:
Sep 28, 2018 11:25:32 AM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
1058bf8, d321747
Parents:
da7b26b (diff), ca77fc1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Butler <butlerpd@…> (09/28/18 11:25:32)
git-committer:
GitHub <noreply@…> (09/28/18 11:25:32)
Message:

Merge pull request #82 from SasView?/ticket-1155BE_PolyElectrolyte

Fix docs and code for be_polyelectrolyte.py

Closes #1155
Will open a new ticket that validation is still required.

Location:
sasmodels/models
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/be_polyelectrolyte.py

    ref07e95 rca77fc1  
    11r""" 
     2.. note:: Please read the Validation section below. 
     3 
    24Definition 
    35---------- 
     
    1113 
    1214    I(q) = K\frac{q^2+k^2}{4\pi L_b\alpha ^2} 
    13     \frac{1}{1+r_{0}^2(q^2+k^2)(q^2-12hC_a/b^2)} + background 
     15    \frac{1}{1+r_{0}^4(q^2+k^2)(q^2-12hC_a/b^2)} + background 
    1416 
    1517    k^2 = 4\pi L_b(2C_s + \alpha C_a) 
    1618 
    17     r_{0}^2 = \frac{1}{\alpha \sqrt{C_a} \left( b/\sqrt{48\pi L_b}\right)} 
     19    r_{0}^2 = \frac{b}{\alpha \sqrt{C_a 48\pi L_b}} 
    1820 
    1921where 
    2022 
    2123$K$ is the contrast factor for the polymer which is defined differently than in 
    22 other models and is given in barns where $1 barn = 10^{-24} cm^2$.  $K$ is 
     24other models and is given in barns where 1 $barn = 10^{-24}$ $cm^2$.  $K$ is 
    2325defined as: 
    2426 
     
    2931    a = b_p - (v_p/v_s) b_s 
    3032 
    31 where $b_p$ and $b_s$ are sum of the scattering lengths of the atoms 
    32 constituting the monomer of the polymer and the sum of the scattering lengths 
    33 of the atoms constituting the solvent molecules respectively, and $v_p$ and 
    34 $v_s$ are the partial molar volume of the polymer and the solvent respectively 
    35  
    36 $L_b$ is the Bjerrum length(|Ang|) - **Note:** This parameter needs to be 
    37 kept constant for a given solvent and temperature! 
    38  
    39 $h$ is the virial parameter (|Ang^3|/mol) - **Note:** See [#Borue]_ for the 
    40 correct interpretation of this parameter.  It incorporates second and third 
    41 virial coefficients and can be Negative. 
    42  
    43 $b$ is the monomer length(|Ang|), $C_s$ is the concentration of monovalent 
    44 salt(mol/L), $\alpha$ is the ionization degree (ionization degree : ratio of 
    45 charged monomers  to total number of monomers), $C_a$ is the polymer molar 
    46 concentration(mol/L), and $background$ is the incoherent background. 
     33where: 
     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 
     50- $C_s$ is the concentration of monovalent salt(1/|Ang^3| - internally converted from mol/L). 
     51 
     52- $\alpha$ is the degree of ionization (the ratio of charged monomers to the total  
     53  number of monomers) 
     54 
     55- $C_a$ is the polymer molar concentration (1/|Ang^3| - internally converted from mol/L) 
     56 
     57- $background$ is the incoherent background. 
    4758 
    4859For 2D data the scattering intensity is calculated in the same way as 1D, 
     
    5263 
    5364    q = \sqrt{q_x^2 + q_y^2} 
     65 
     66Validation 
     67---------- 
     68 
     69As of the last revision, this code is believed to be correct.  However it 
     70needs further validation and should be used with caution at this time.  The 
     71history of this code goes back to a 1998 implementation. It was recently noted 
     72that in that implementation, while both the polymer concentration and salt 
     73concentration were converted from experimental units of mol/L to more 
     74dimensionally useful units of 1/|Ang^3|, only the converted version of the 
     75polymer concentration was actually being used in the calculation while the 
     76unconverted salt concentration (still in apparent units of mol/L) was being  
     77used.  This was carried through to Sasmodels as used for SasView 4.1 (though  
     78the line of code converting the salt concentration to the new units was removed  
     79somewhere along the line). Simple dimensional analysis of the calculation shows  
     80that the converted salt concentration should be used, which the original code  
     81suggests was the intention, so this has now been corrected (for SasView 4.2).  
     82Once better validation has been performed this note will be removed. 
    5483 
    5584References 
     
    6695 
    6796* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    68 * **Last Modified by:** Paul Kienzle **Date:** July 24, 2016 
    69 * **Last Reviewed by:** Paul Butler and Richard Heenan **Date:** October 07, 2016 
     97* **Last Modified by:** Paul Butler **Date:** September 25, 2018 
     98* **Last Reviewed by:** Paul Butler **Date:** September 25, 2018 
    7099""" 
    71100 
     
    92121    ["contrast_factor",       "barns",   10.0,  [-inf, inf], "", "Contrast factor of the polymer"], 
    93122    ["bjerrum_length",        "Ang",      7.1,  [0, inf],    "", "Bjerrum length"], 
    94     ["virial_param",          "Ang^3/mol", 12.0,  [-inf, inf], "", "Virial parameter"], 
     123    ["virial_param",          "Ang^3", 12.0,  [-inf, inf], "", "Virial parameter"], 
    95124    ["monomer_length",        "Ang",     10.0,  [0, inf],    "", "Monomer length"], 
    96125    ["salt_concentration",    "mol/L",    0.0,  [-inf, inf], "", "Concentration of monovalent salt"], 
     
    102131 
    103132def Iq(q, 
    104        contrast_factor=10.0, 
    105        bjerrum_length=7.1, 
    106        virial_param=12.0, 
    107        monomer_length=10.0, 
    108        salt_concentration=0.0, 
    109        ionization_degree=0.05, 
    110        polymer_concentration=0.7): 
     133       contrast_factor, 
     134       bjerrum_length, 
     135       virial_param, 
     136       monomer_length, 
     137       salt_concentration, 
     138       ionization_degree, 
     139       polymer_concentration): 
    111140    """ 
    112     :param q:                     Input q-value 
    113     :param contrast_factor:       Contrast factor of the polymer 
    114     :param bjerrum_length:        Bjerrum length 
    115     :param virial_param:          Virial parameter 
    116     :param monomer_length:        Monomer length 
    117     :param salt_concentration:    Concentration of monovalent salt 
    118     :param ionization_degree:     Degree of ionization 
    119     :param polymer_concentration: Polymer molar concentration 
    120     :return:                      1-D intensity 
     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 
    121147    """ 
    122148 
    123     concentration = polymer_concentration * 6.022136e-4 
    124  
    125     k_square = 4.0 * pi * bjerrum_length * (2*salt_concentration + 
    126                                             ionization_degree * concentration) 
    127  
    128     r0_square = 1.0/ionization_degree/sqrt(concentration) * \ 
     149    concentration_pol = polymer_concentration * 6.022136e-4 
     150    concentration_salt = salt_concentration * 6.022136e-4 
     151 
     152    k_square = 4.0 * pi * bjerrum_length * (2*concentration_salt + 
     153                                            ionization_degree * concentration_pol) 
     154 
     155    r0_square = 1.0/ionization_degree/sqrt(concentration_pol) * \ 
    129156                (monomer_length/sqrt((48.0*pi*bjerrum_length))) 
    130157 
     
    133160 
    134161    term2 = 1.0 + r0_square**2 * (q**2 + k_square) * \ 
    135         (q**2 - (12.0 * virial_param * concentration/(monomer_length**2))) 
     162        (q**2 - (12.0 * virial_param * concentration_pol/(monomer_length**2))) 
    136163 
    137164    return term1/term2 
     
    174201 
    175202    # Accuracy tests based on content in test/utest_other_models.py 
     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 
    176208    [{'contrast_factor':       10.0, 
    177209      'bjerrum_length':         7.1, 
     
    184216     }, 0.001, 0.0948379], 
    185217 
    186     # Additional tests with larger range of parameters 
    187218    [{'contrast_factor':       10.0, 
    188219      'bjerrum_length':       100.0, 
    189220      'virial_param':           3.0, 
    190       'monomer_length':         1.0, 
    191       'salt_concentration':    10.0, 
    192       'ionization_degree':      2.0, 
    193       'polymer_concentration': 10.0, 
     221      'monomer_length':         5.0, 
     222      'salt_concentration':     1.0, 
     223      'ionization_degree':      0.1, 
     224      'polymer_concentration':  1.0, 
    194225      'background':             0.0, 
    195      }, 0.1, -3.75693800588], 
     226     }, 0.1, 0.253469484], 
    196227 
    197228    [{'contrast_factor':       10.0, 
    198229      'bjerrum_length':       100.0, 
    199230      'virial_param':           3.0, 
    200       'monomer_length':         1.0, 
    201       'salt_concentration':    10.0, 
    202       'ionization_degree':      2.0, 
    203       'polymer_concentration': 10.0, 
    204       'background':           100.0 
    205      }, 5.0, 100.029142149], 
     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], 
    206237 
    207238    [{'contrast_factor':     100.0, 
    208239      'bjerrum_length':       10.0, 
    209       'virial_param':        180.0, 
    210       'monomer_length':        1.0, 
     240      'virial_param':         12.0, 
     241      'monomer_length':       10.0, 
    211242      'salt_concentration':    0.1, 
    212243      'ionization_degree':     0.5, 
    213244      'polymer_concentration': 0.1, 
    214       'background':             0.0, 
    215      }, 200., 1.80664667511e-06], 
     245      'background':           0.01, 
     246     }, 0.5, 0.012881893], 
    216247    ] 
  • sasmodels/models/bcc_paracrystal.py

    r2d81cfe rda7b26b  
    11r""" 
     2.. warning:: This model and this model description are under review following  
     3             concerns raised by SasView users. If you need to use this model,  
     4             please email help@sasview.org for the latest situation. *The  
     5             SasView Developers. September 2018.* 
     6 
    27Definition 
    38---------- 
     
    1318 
    1419    I(q) = \frac{\text{scale}}{V_p} V_\text{lattice} P(q) Z(q) 
    15  
    1620 
    1721where *scale* is the volume fraction of spheres, $V_p$ is the volume of the 
     
    97101 
    98102Authorship and Verification 
    99 ---------------------------- 
     103--------------------------- 
    100104 
    101105* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
  • sasmodels/models/fcc_paracrystal.py

    r2d81cfe rda7b26b  
    33#note - calculation requires double precision 
    44r""" 
     5.. warning:: This model and this model description are under review following  
     6             concerns raised by SasView users. If you need to use this model,  
     7             please email help@sasview.org for the latest situation. *The  
     8             SasView Developers. September 2018.* 
     9 
     10Definition 
     11---------- 
     12 
    513Calculates the scattering from a **face-centered cubic lattice** with 
    614paracrystalline distortion. Thermal vibrations are considered to be 
     
    816Paracrystalline distortion is assumed to be isotropic and characterized by 
    917a Gaussian distribution. 
    10  
    11 Definition 
    12 ---------- 
    1318 
    1419The scattering intensity $I(q)$ is calculated as 
     
    2328is the paracrystalline structure factor for a face-centered cubic structure. 
    2429 
    25 Equation (1) of the 1990 reference is used to calculate $Z(q)$, using 
    26 equations (23)-(25) from the 1987 paper for $Z1$, $Z2$, and $Z3$. 
     30Equation (1) of the 1990 reference\ [#CIT1990]_ is used to calculate $Z(q)$, 
     31using equations (23)-(25) from the 1987 paper\ [#CIT1987]_ for $Z1$, $Z2$, and 
     32$Z3$. 
    2733 
    2834The lattice correction (the occupied volume of the lattice) for a 
     
    8894---------- 
    8995 
    90 Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 
    91 (Original Paper) 
     96.. [#CIT1987] Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 
     97   (Original Paper) 
     98.. [#CIT1990] Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856 
     99   (Corrections to FCC and BCC lattice structure calculation) 
    92100 
    93 Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856 
    94 (Corrections to FCC and BCC lattice structure calculation) 
     101Authorship and Verification 
     102--------------------------- 
     103 
     104* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
     105* **Last Modified by:** Paul Butler **Date:** September 29, 2016 
     106* **Last Reviewed by:** Richard Heenan **Date:** March 21, 2016 
    95107""" 
    96108 
  • sasmodels/models/sc_paracrystal.py

    r2d81cfe rda7b26b  
    11r""" 
     2.. warning:: This model and this model description are under review following  
     3             concerns raised by SasView users. If you need to use this model,  
     4             please email help@sasview.org for the latest situation. *The  
     5             SasView Developers. September 2018.* 
     6              
     7Definition 
     8---------- 
     9 
    210Calculates the scattering from a **simple cubic lattice** with 
    311paracrystalline distortion. Thermal vibrations are considered to be 
     
    513Paracrystalline distortion is assumed to be isotropic and characterized 
    614by a Gaussian distribution. 
    7  
    8 Definition 
    9 ---------- 
    1015 
    1116The scattering intensity $I(q)$ is calculated as 
     
    2025$Z(q)$ is the paracrystalline structure factor for a simple cubic structure. 
    2126 
    22 Equation (16) of the 1987 reference is used to calculate $Z(q)$, using 
    23 equations (13)-(15) from the 1987 paper for Z1, Z2, and Z3. 
     27Equation (16) of the 1987 reference\ [#CIT1987]_ is used to calculate $Z(q)$, 
     28using equations (13)-(15) from the 1987 paper\ [#CIT1987]_ for $Z1$, $Z2$, and 
     29$Z3$. 
    2430 
    2531The lattice correction (the occupied volume of the lattice) for a simple cubic 
     
    9197Reference 
    9298--------- 
    93 Hideki Matsuoka et. al. *Physical Review B,* 36 (1987) 1754-1765 
    94 (Original Paper) 
    9599 
    96 Hideki Matsuoka et. al. *Physical Review B,* 41 (1990) 3854 -3856 
    97 (Corrections to FCC and BCC lattice structure calculation) 
     100.. [#CIT1987] Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 
     101   (Original Paper) 
     102.. [#CIT1990] Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856 
     103   (Corrections to FCC and BCC lattice structure calculation) 
     104 
     105Authorship and Verification 
     106--------------------------- 
     107 
     108* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
     109* **Last Modified by:** Paul Butler **Date:** September 29, 2016 
     110* **Last Reviewed by:** Richard Heenan **Date:** March 21, 2016 
    98111""" 
    99112 
Note: See TracChangeset for help on using the changeset viewer.