Changeset d529d93 in sasmodels


Ignore:
Timestamp:
Mar 17, 2016 8:16:55 AM (9 years ago)
Author:
richardh
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a45c2c, 0784c18
Parents:
c5dadbb
Message:

updated docs for several S(Q)

Location:
sasmodels/models
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hardsphere.py

    r8e45182 rd529d93  
    33spherical particles interacting through hard sphere (excluded volume) 
    44interactions. 
     5May be a reasonable approximation for other shapes of particles that  
     6freely rotate, and for moderately polydisperse systems. Though strictly  
     7the maths needs to be modified (no \Beta(Q) correction yet in sasview). 
    58 
    6 The calculation uses the Percus-Yevick closure where the interparticle 
     9radius_effective is the effective hard sphere radius. 
     10volfraction is the volume fraction occupied by the spheres. 
     11 
     12In sasview the effective radius may be calculated from the parameters 
     13used in the form factor $P(q)$ that this $S(q)$ is combined with. 
     14 
     15For numerical stability the computation uses a Taylor series expansion  
     16at very small $qR$, there may be a very minor glitch at the transition point 
     17in some circumstances. 
     18 
     19The S(Q) uses the Percus-Yevick closure where the interparticle 
    720potential is 
    821 
     
    4457        systems. Though strictly the maths needs to be modified - 
    4558    which sasview does not do yet. 
    46     effect_radius is the hard sphere radius 
     59    radius_effective is the hard sphere radius 
    4760    volfraction is the volume fraction occupied by the spheres. 
    4861""" 
     
    5164 
    5265#             ["name", "units", default, [lower, upper], "type","description"], 
    53 parameters = [["effect_radius", "Ang", 50.0, [0, inf], "volume", 
     66parameters = [["radius_effective", "Ang", 50.0, [0, inf], "volume", 
    5467               "effective radius of hard sphere"], 
    5568              ["volfraction", "", 0.2, [0, 0.74], "", 
     
    6679      double D,A,B,G,X,X2,X4,S,C,FF,HARDSPH; 
    6780 
    68       if(fabs(effect_radius) < 1.E-12) { 
     81      if(fabs(radius_effective) < 1.E-12) { 
    6982               HARDSPH=1.0; 
    7083               return(HARDSPH); 
     
    7588      A= (1.+2.*volfraction)*D; 
    7689      A *=A; 
    77       X=fabs(q*effect_radius*2.0); 
     90      X=fabs(q*radius_effective*2.0); 
    7891 
    7992      if(X < 5.E-06) { 
     
    138151# VR defaults to 1.0 
    139152 
    140 demo = dict(effect_radius=200, volfraction=0.2, effect_radius_pd=0.1, effect_radius_pd_n=40) 
     153demo = dict(radius_effective=200, volfraction=0.2, radius_effective_pd=0.1, radius_effective_pd_n=40) 
    141154oldname = 'HardsphereStructure' 
    142 oldpars = dict() 
     155oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 
    143156# Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 
    144157tests = [ 
    145         [ {'scale': 1.0, 'background' : 0.0, 'effect_radius' : 50.0, 'volfraction' : 0.2, 
    146            'effect_radius_pd' : 0}, [0.001,0.1], [0.209128,0.930587]] 
     158        [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.2, 
     159           'radius_effective_pd' : 0}, [0.001,0.1], [0.209128,0.930587]] 
    147160        ] 
    148  
     161# ADDED by: RKH  ON: 16Mar2016  using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q,  
  • sasmodels/models/hayter_msa.py

    r348557a rd529d93  
    99 
    1010**This routine only works for charged particles**. If the charge is set to 
    11 zero the routine will self-destruct! For non-charged particles use a hard 
     11zero the routine may self-destruct! For non-charged particles use a hard 
    1212sphere potential. 
    1313 
     
    1515which in turn is used to compute the Debye screening length. At present 
    1616there is no provision for entering the ionic strength directly nor for use 
    17 of any multivalent salts. The counterions are also assumed to be monovalent. 
     17of any multivalent salts, though it should be possible to simulate the effect 
     18of this by increasing the salt concentration. The counterions are also assumed to  
     19be monovalent. 
     20 
     21In sasview the effective radius may be calculated from the parameters 
     22used in the form factor $P(q)$ that this $S(q)$ is combined with. 
     23 
     24The computation uses a Taylor series expansion at very small rescaled $qR$, to  
     25avoid some serious rounding error issues, this may result in a minor artefact  
     26in the transition region under some circumstances. 
    1827 
    1928For 2D data, the scattering intensity is calculated in the same way as 1D, 
     
    2433    q = \sqrt{q_x^2 + q_y^2} 
    2534 
    26 .. figure:: img/HayterMSAsq_227.jpg 
    27  
    28     1D plot using the default values (in linear scale). 
    2935 
    3036References 
     
    3541J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 
    3642""" 
     43from numpy import inf 
    3744 
    38 #  dp[0] = 2.0*effect_radius(); 
     45category = "structure-factor" 
     46structure_factor = True 
     47single = False  # double precision only! 
     48 
     49#  dp[0] = 2.0*radius_effective(); 
    3950#  dp[1] = fabs(charge()); 
    4051#  dp[2] = volfraction(); 
     
    4354#  dp[5] = dielectconst(); 
    4455 
    45 from numpy import inf 
    4656 
    47 source = ["hayter_msa_kernel.c"] 
     57 
    4858 
    4959name = "hayter_msa" 
    50 title = "Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor" 
     60title = "Hayter-Penfold rescaled MSA, charged sphere, interparticle S(Q) structure factor" 
    5161description = """\ 
    52     [Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor] 
     62    [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor] 
    5363        Interparticle structure factor S(Q)for a charged hard spheres. 
    5464        Routine takes absolute value of charge, use HardSphere if charge 
    5565        goes to zero. 
    56         In sasview the effective radius will be calculated from the 
    57         parameters used in P(Q). 
     66        In sasview the effective radius and volume fraction may be calculated  
     67        from the parameters used in P(Q). 
    5868""" 
    59 single = False  # double precision only! 
     69 
    6070 
    6171# pylint: disable=bad-whitespace, line-too-long 
    6272#             [ "name", "units", default, [lower, upper], "type", "description" ], 
    6373parameters = [ 
    64     ["effect_radius", "Ang", 20.75,   [0, inf],    "volume", "effective radius of hard sphere"], 
     74    ["radius_effective", "Ang", 20.75,   [0, inf],    "volume", "effective radius of charged sphere"], 
    6575    ["charge",        "e",   19.0,    [0, inf],    "", "charge on sphere (in electrons)"], 
    66     ["volfraction",   "",     0.0192, [0, 0.74],   "", "volume fraction of spheres"], 
     76    ["volfraction",   "None",     0.0192, [0, 0.74],   "", "volume fraction of spheres"], 
    6777    ["temperature",   "K",  318.16,   [0, inf],    "", "temperature, in Kelvin, for Debye length calculation"], 
    68     ["saltconc",      "M",    0.0,    [-inf, inf], "", "conc of salt, 1:1 electolyte, for Debye length"], 
    69     ["dielectconst",  "",    71.08,   [-inf, inf], "", "dielectric constant of solvent (default water), for Debye length"], 
     78    ["saltconc",      "M",    0.0,    [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 
     79    ["dielectconst",  "None",    71.08,   [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] 
    7080    ] 
    7181# pylint: enable=bad-whitespace, line-too-long 
    72 category = "structure-factor" 
    7382 
     83source = ["hayter_msa_kernel.c"] 
    7484# No volume normalization despite having a volume parameter 
    7585# This should perhaps be volume normalized? 
     
    8595 
    8696oldname = 'HayterMSAStructure' 
    87 oldpars = dict() 
     97#oldpars = dict(effect_radius="radius_effective",effect_radius_pd="radius_effective_pd",effect_radius_pd_n="radius_effective_pd_n") 
     98oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 
     99#oldpars = dict( ) 
    88100# default parameter set,  use  compare.sh -midQ -linear 
    89101# note the calculation varies in different limiting cases so a wide range of 
    90102# parameters will be required for a thorough test! 
    91103# odd that the default st has saltconc zero 
    92 demo = dict(effect_radius=20.75, 
     104demo = dict(radius_effective=20.75, 
    93105            charge=19.0, 
    94106            volfraction=0.0192, 
     
    96108            saltconc=0.05, 
    97109            dielectconst=71.08, 
    98             effect_radius_pd=0.1, 
    99             effect_radius_pd_n=40) 
     110            radius_effective_pd=0.1, 
     111            radius_effective_pd_n=40) 
    100112# 
    101113# attempt to use same values as old sasview unit test at Q=.001 was 0.0712928,  
     
    104116    [{'scale': 1.0, 
    105117      'background': 0.0, 
    106       'effect_radius': 20.75, 
     118      'radius_effective': 20.75, 
    107119      'charge': 19.0, 
    108120      'volfraction': 0.0192, 
     
    110122      'saltconc': 0, 
    111123      'dielectconst': 78.0, 
    112       'effect_radius_pd': 0}, 
     124      'radius_effective_pd': 0}, 
    113125     [0.00001,0.0010,0.01,0.075], [0.0711646,0.0712928,0.0847006,1.07150]], 
    114126    [{'scale': 1.0, 
    115127      'background': 0.0, 
    116       'effect_radius': 20.75, 
     128      'radius_effective': 20.75, 
    117129      'charge': 19.0, 
    118130      'volfraction': 0.0192, 
     
    120132      'saltconc': 0.05, 
    121133      'dielectconst': 78.0, 
    122       'effect_radius_pd': 0.1, 
    123       'effect_radius_pd_n': 40}, 
     134      'radius_effective_pd': 0.1, 
     135      'radius_effective_pd_n': 40}, 
    124136     [0.00001,0.0010,0.01,0.075], [0.450272,0.450420,0.465116,1.039625]] 
    125137    ] 
    126  
     138# ADDED by:  RKH  ON: 16Mar2016 converted from sasview, new Taylor expansion at smallest rescaled Q 
  • sasmodels/models/hayter_msa_kernel.c

    r348557a rd529d93  
    33// C99 needs declarations of routines here 
    44double Iq(double QQ, 
    5       double effect_radius, double zz, double VolFrac, double Temp, double csalt, double dialec); 
     5      double radius_effective, double zz, double VolFrac, double Temp, double csalt, double dialec); 
    66int 
    77sqcoef(int ir, double gMSAWave[]); 
     
    1414   
    1515double Iq(double QQ, 
    16       double effect_radius, double zz, double VolFrac, double Temp, double csalt, double dialec)   
     16      double radius_effective, double zz, double VolFrac, double Temp, double csalt, double dialec)   
    1717{ 
    1818    double gMSAWave[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; 
     
    2828        pi = M_PI; 
    2929 
    30         diam=2*effect_radius;           //in A 
     30        diam=2*radius_effective;                //in A 
    3131 
    3232                                                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
  • sasmodels/models/squarewell.py

    r5111921 rd529d93  
    88Positive well depths correspond to an attractive potential well. Negative well depths correspond to a potential 
    99"shoulder", which may or may not be physically reasonable. The stickyhardsphere model may be a better choice in 
    10 some circumstances. Computed values may behave badly at extremely small Q. 
     10some circumstances. Computed values may behave badly at extremely small $qR$. 
    1111 
    12 The well width (*l*\ ) is defined as multiples of the particle diameter (2\*\ *R*\ ) 
     12The well width (|lambda| ) is defined as multiples of the particle diameter (2\*\ *R*\ ) 
    1313 
    1414The interaction potential is: 
     
    2222    U(r) = \begin{cases} 
    2323    \infty & r < 2R \\ 
    24     -\epsilon , 2R \leq < 2R\lambda 
    25     0 & r \geq 2R 
     24    -\epsilon & 2R \leq r < 2R\lambda \\ 
     25    0 & r \geq 2R\lambda 
    2626    \end{cases} 
    2727 
    2828where $r$ is the distance from the center of the sphere of a radius $R$. 
    2929 
     30In sasview the effective radius may be calculated from the parameters 
     31used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    3032 
    3133For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as 
     
    3537    q = \sqrt{q_x^2 + q_y^2} 
    3638 
    37 .. comment:: 
    38  
    39   .. figure:: img/squarewell_226.jpg 
    40  
    41     1D plot using the default values (in linear scale).* 
    4239 
    4340REFERENCE 
     
    5956""" 
    6057category = "structure-factor" 
     58structure_factor = True 
    6159 
    6260#single = False 
     
    6563    #   [ "name", "units", default, [lower, upper], "type", 
    6664    #     "description" ], 
    67     ["effect_radius", "Ang", 50.0, [0, inf], "volume", 
     65    ["radius_effective", "Ang", 50.0, [0, inf], "volume", 
    6866     "effective radius of hard sphere"], 
    6967    ["volfraction", "", 0.04, [0, 0.08], "", 
     
    7169    ["welldepth", "kT", 1.5, [0.0, 1.5], "", 
    7270     "depth of well, epsilon"], 
    73     ["wellwidth", "diameters", 1.2, [0, inf], "", 
    74      "width of well in diameters (=2R) units"], 
     71    ["wellwidth", "diameters", 1.2, [1.0, inf], "", 
     72     "width of well in diameters (=2R) units, must be > 1"], 
    7573    ] 
    7674 
     
    8987        x= q; 
    9088         
    91         req = effect_radius; 
     89        req = radius_effective; 
    9290        phis = volfraction; 
    9391        edibkb = welldepth; 
     
    134132 
    135133oldname = 'SquareWellStructure' 
    136 oldpars = dict() 
    137 demo = dict(effect_radius=50, volfraction=0.04, welldepth=1.5, 
    138             wellwidth=1.2, effect_radius_pd=0, effect_radius_pd_n=0) 
     134oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 
     135demo = dict(radius_effective=50, volfraction=0.04, welldepth=1.5, 
     136            wellwidth=1.2, radius_effective_pd=0, radius_effective_pd_n=0) 
    139137# 
    140138tests = [ 
    141         [ {'scale': 1.0, 'background' : 0.0, 'effect_radius' : 50.0, 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2,  
    142            'effect_radius_pd' : 0}, [0.001], [0.97665742]] 
     139        [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2,  
     140           'radius_effective_pd' : 0}, [0.001], [0.97665742]] 
    143141        ] 
    144 # ADDED by: converting from sasview RKH  ON: 16Mar2016 - in progress 
     142# ADDED by: converting from sasview RKH  ON: 16Mar2016 
    145143 
  • sasmodels/models/stickyhardsphere.py

    r8e45182 rd529d93  
    4949the optimization does not hit the constraints. 
    5050 
    51 In sasview the effective radius will be calculated from the parameters 
     51In sasview the effective radius may be calculated from the parameters 
    5252used in the form factor $P(q)$ that this $S(q)$ is combined with. 
    5353 
Note: See TracChangeset for help on using the changeset viewer.