[d60b433] | 1 | # Note: model title and parameter table are inserted automatically |
---|
| 2 | r""" |
---|
[eb69cce] | 3 | This calculates the structure factor (the Fourier transform of the pair |
---|
| 4 | correlation function $g(r)$) for a system of charged, spheroidal objects |
---|
| 5 | in a dielectric medium. When combined with an appropriate form factor |
---|
| 6 | (such as sphere, core+shell, ellipsoid, etc), this allows for inclusion |
---|
| 7 | of the interparticle interference effects due to screened coulomb repulsion |
---|
| 8 | between charged particles. |
---|
[d60b433] | 9 | |
---|
[eb69cce] | 10 | **This routine only works for charged particles**. If the charge is set to |
---|
[d529d93] | 11 | zero the routine may self-destruct! For non-charged particles use a hard |
---|
[eb69cce] | 12 | sphere potential. |
---|
[d60b433] | 13 | |
---|
[eb69cce] | 14 | The salt concentration is used to compute the ionic strength of the solution |
---|
| 15 | which in turn is used to compute the Debye screening length. At present |
---|
| 16 | there is no provision for entering the ionic strength directly nor for use |
---|
[d529d93] | 17 | of any multivalent salts, though it should be possible to simulate the effect |
---|
[40a87fa] | 18 | of this by increasing the salt concentration. The counterions are also |
---|
| 19 | assumed to be monovalent. |
---|
[d529d93] | 20 | |
---|
| 21 | In sasview the effective radius may be calculated from the parameters |
---|
| 22 | used in the form factor $P(q)$ that this $S(q)$ is combined with. |
---|
| 23 | |
---|
[40a87fa] | 24 | The computation uses a Taylor series expansion at very small rescaled $qR$, to |
---|
| 25 | avoid some serious rounding error issues, this may result in a minor artefact |
---|
[d529d93] | 26 | in the transition region under some circumstances. |
---|
[d60b433] | 27 | |
---|
[eb69cce] | 28 | For 2D data, the scattering intensity is calculated in the same way as 1D, |
---|
| 29 | where the $q$ vector is defined as |
---|
[d60b433] | 30 | |
---|
| 31 | .. math:: |
---|
| 32 | |
---|
[eb69cce] | 33 | q = \sqrt{q_x^2 + q_y^2} |
---|
[d60b433] | 34 | |
---|
| 35 | |
---|
[eb69cce] | 36 | References |
---|
| 37 | ---------- |
---|
[d60b433] | 38 | |
---|
[0507e09] | 39 | .. [#] J B Hayter and J Penfold, *Molecular Physics*, 42 (1981) 109-118 |
---|
| 40 | .. [#] J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 |
---|
[d60b433] | 41 | |
---|
[0507e09] | 42 | Source |
---|
| 43 | ------ |
---|
| 44 | |
---|
| 45 | `hayter_msa.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/hayter_msa.py>`_ |
---|
| 46 | |
---|
| 47 | `hayter_msa.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/hayter_msa.c>`_ |
---|
| 48 | |
---|
| 49 | Authorship and Verification |
---|
| 50 | ---------------------------- |
---|
| 51 | |
---|
| 52 | * **Author:** |
---|
| 53 | * **Last Modified by:** |
---|
| 54 | * **Last Reviewed by:** |
---|
| 55 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
[d60b433] | 56 | """ |
---|
[2d81cfe] | 57 | |
---|
| 58 | import numpy as np |
---|
[d529d93] | 59 | from numpy import inf |
---|
[d60b433] | 60 | |
---|
[d529d93] | 61 | category = "structure-factor" |
---|
| 62 | structure_factor = True |
---|
| 63 | single = False # double precision only! |
---|
| 64 | |
---|
| 65 | # dp[0] = 2.0*radius_effective(); |
---|
[d60b433] | 66 | # dp[1] = fabs(charge()); |
---|
| 67 | # dp[2] = volfraction(); |
---|
| 68 | # dp[3] = temperature(); |
---|
[a807206] | 69 | # dp[4] = concentration_salt(); |
---|
[d60b433] | 70 | # dp[5] = dielectconst(); |
---|
| 71 | |
---|
| 72 | |
---|
[d529d93] | 73 | |
---|
[d60b433] | 74 | |
---|
[348557a] | 75 | name = "hayter_msa" |
---|
[d529d93] | 76 | title = "Hayter-Penfold rescaled MSA, charged sphere, interparticle S(Q) structure factor" |
---|
[d60b433] | 77 | description = """\ |
---|
[d529d93] | 78 | [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor] |
---|
[d60b433] | 79 | Interparticle structure factor S(Q)for a charged hard spheres. |
---|
[ec2ca99] | 80 | Routine takes absolute value of charge, use HardSphere if charge |
---|
| 81 | goes to zero. |
---|
[8f04da4] | 82 | In sasview the effective radius and volume fraction may be calculated |
---|
[d529d93] | 83 | from the parameters used in P(Q). |
---|
[d60b433] | 84 | """ |
---|
[d529d93] | 85 | |
---|
[ec2ca99] | 86 | |
---|
| 87 | # pylint: disable=bad-whitespace, line-too-long |
---|
[b7d432f] | 88 | # [ "name", "units", default, [lower, upper], "type", "description" ], |
---|
[ec2ca99] | 89 | parameters = [ |
---|
[d529d93] | 90 | ["radius_effective", "Ang", 20.75, [0, inf], "volume", "effective radius of charged sphere"], |
---|
| 91 | ["volfraction", "None", 0.0192, [0, 0.74], "", "volume fraction of spheres"], |
---|
[5702f52] | 92 | ["charge", "e", 19.0, [0, 200], "", "charge on sphere (in electrons)"], |
---|
[3ad7978] | 93 | ["temperature", "K", 318.16, [0, 450], "", "temperature, in Kelvin, for Debye length calculation"], |
---|
[5702f52] | 94 | ["concentration_salt", "M", 0.0, [0, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], |
---|
[d529d93] | 95 | ["dielectconst", "None", 71.08, [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] |
---|
[ec2ca99] | 96 | ] |
---|
| 97 | # pylint: enable=bad-whitespace, line-too-long |
---|
[d60b433] | 98 | |
---|
[0bef47b] | 99 | source = ["hayter_msa.c"] |
---|
[d60b433] | 100 | # No volume normalization despite having a volume parameter |
---|
| 101 | # This should perhaps be volume normalized? |
---|
| 102 | form_volume = """ |
---|
| 103 | return 1.0; |
---|
| 104 | """ |
---|
| 105 | |
---|
[8f04da4] | 106 | def random(): |
---|
[b297ba9] | 107 | """Return a random parameter set for the model.""" |
---|
[8f04da4] | 108 | # TODO: too many failures for random hayter_msa parameters |
---|
| 109 | pars = dict( |
---|
| 110 | scale=1, background=0, |
---|
| 111 | radius_effective=10**np.random.uniform(1, 4.7), |
---|
| 112 | volfraction=10**np.random.uniform(-2, 0), # high volume fraction |
---|
| 113 | charge=min(int(10**np.random.uniform(0, 1.3)+0.5), 200), |
---|
| 114 | temperature=10**np.random.uniform(0, np.log10(450)), # max T = 450 |
---|
| 115 | #concentration_salt=10**np.random.uniform(-3, 1), |
---|
| 116 | dialectconst=10**np.random.uniform(0, 6), |
---|
| 117 | #charge=10, |
---|
| 118 | #temperature=318.16, |
---|
| 119 | concentration_salt=0.0, |
---|
| 120 | #dielectconst=71.08, |
---|
| 121 | ) |
---|
| 122 | return pars |
---|
| 123 | |
---|
[ab87a12] | 124 | # default parameter set, use compare.sh -midQ -linear |
---|
[ec2ca99] | 125 | # note the calculation varies in different limiting cases so a wide range of |
---|
| 126 | # parameters will be required for a thorough test! |
---|
[a807206] | 127 | # odd that the default st has concentration_salt zero |
---|
[d529d93] | 128 | demo = dict(radius_effective=20.75, |
---|
[ec2ca99] | 129 | charge=19.0, |
---|
| 130 | volfraction=0.0192, |
---|
| 131 | temperature=318.16, |
---|
[a807206] | 132 | concentration_salt=0.05, |
---|
[ec2ca99] | 133 | dielectconst=71.08, |
---|
[d529d93] | 134 | radius_effective_pd=0.1, |
---|
| 135 | radius_effective_pd_n=40) |
---|
[7f47777] | 136 | # |
---|
[40a87fa] | 137 | # attempt to use same values as old sasview unit test at Q=.001 was 0.0712928, |
---|
| 138 | # then add lots new ones assuming values from new model are OK, need some |
---|
| 139 | # low Q values to test the small Q Taylor expansion |
---|
[7f47777] | 140 | tests = [ |
---|
[ec2ca99] | 141 | [{'scale': 1.0, |
---|
| 142 | 'background': 0.0, |
---|
[d529d93] | 143 | 'radius_effective': 20.75, |
---|
[ec2ca99] | 144 | 'charge': 19.0, |
---|
| 145 | 'volfraction': 0.0192, |
---|
| 146 | 'temperature': 298.0, |
---|
[a807206] | 147 | 'concentration_salt': 0, |
---|
[ec2ca99] | 148 | 'dielectconst': 78.0, |
---|
[d529d93] | 149 | 'radius_effective_pd': 0}, |
---|
[40a87fa] | 150 | [0.00001, 0.0010, 0.01, 0.075], [0.0711646, 0.0712928, 0.0847006, 1.07150]], |
---|
[348557a] | 151 | [{'scale': 1.0, |
---|
| 152 | 'background': 0.0, |
---|
[d529d93] | 153 | 'radius_effective': 20.75, |
---|
[348557a] | 154 | 'charge': 19.0, |
---|
| 155 | 'volfraction': 0.0192, |
---|
| 156 | 'temperature': 298.0, |
---|
[a807206] | 157 | 'concentration_salt': 0.05, |
---|
[348557a] | 158 | 'dielectconst': 78.0, |
---|
[d529d93] | 159 | 'radius_effective_pd': 0.1, |
---|
| 160 | 'radius_effective_pd_n': 40}, |
---|
[40a87fa] | 161 | [0.00001, 0.0010, 0.01, 0.075], [0.450272, 0.450420, 0.465116, 1.039625]] |
---|
[ec2ca99] | 162 | ] |
---|
[d529d93] | 163 | # ADDED by: RKH ON: 16Mar2016 converted from sasview, new Taylor expansion at smallest rescaled Q |
---|