Changeset d529d93 in sasmodels
- Timestamp:
- Mar 17, 2016 8:16:55 AM (9 years ago)
- 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
- Location:
- sasmodels/models
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/hardsphere.py
r8e45182 rd529d93 3 3 spherical particles interacting through hard sphere (excluded volume) 4 4 interactions. 5 May be a reasonable approximation for other shapes of particles that 6 freely rotate, and for moderately polydisperse systems. Though strictly 7 the maths needs to be modified (no \Beta(Q) correction yet in sasview). 5 8 6 The calculation uses the Percus-Yevick closure where the interparticle 9 radius_effective is the effective hard sphere radius. 10 volfraction is the volume fraction occupied by the spheres. 11 12 In sasview the effective radius may be calculated from the parameters 13 used in the form factor $P(q)$ that this $S(q)$ is combined with. 14 15 For numerical stability the computation uses a Taylor series expansion 16 at very small $qR$, there may be a very minor glitch at the transition point 17 in some circumstances. 18 19 The S(Q) uses the Percus-Yevick closure where the interparticle 7 20 potential is 8 21 … … 44 57 systems. Though strictly the maths needs to be modified - 45 58 which sasview does not do yet. 46 effect_radiusis the hard sphere radius59 radius_effective is the hard sphere radius 47 60 volfraction is the volume fraction occupied by the spheres. 48 61 """ … … 51 64 52 65 # ["name", "units", default, [lower, upper], "type","description"], 53 parameters = [[" effect_radius", "Ang", 50.0, [0, inf], "volume",66 parameters = [["radius_effective", "Ang", 50.0, [0, inf], "volume", 54 67 "effective radius of hard sphere"], 55 68 ["volfraction", "", 0.2, [0, 0.74], "", … … 66 79 double D,A,B,G,X,X2,X4,S,C,FF,HARDSPH; 67 80 68 if(fabs( effect_radius) < 1.E-12) {81 if(fabs(radius_effective) < 1.E-12) { 69 82 HARDSPH=1.0; 70 83 return(HARDSPH); … … 75 88 A= (1.+2.*volfraction)*D; 76 89 A *=A; 77 X=fabs(q* effect_radius*2.0);90 X=fabs(q*radius_effective*2.0); 78 91 79 92 if(X < 5.E-06) { … … 138 151 # VR defaults to 1.0 139 152 140 demo = dict( effect_radius=200, volfraction=0.2, effect_radius_pd=0.1, effect_radius_pd_n=40)153 demo = dict(radius_effective=200, volfraction=0.2, radius_effective_pd=0.1, radius_effective_pd_n=40) 141 154 oldname = 'HardsphereStructure' 142 oldpars = dict( )155 oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 143 156 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 144 157 tests = [ 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]] 147 160 ] 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 9 9 10 10 **This routine only works for charged particles**. If the charge is set to 11 zero the routine willself-destruct! For non-charged particles use a hard11 zero the routine may self-destruct! For non-charged particles use a hard 12 12 sphere potential. 13 13 … … 15 15 which in turn is used to compute the Debye screening length. At present 16 16 there 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. 17 of any multivalent salts, though it should be possible to simulate the effect 18 of this by increasing the salt concentration. The counterions are also assumed to 19 be monovalent. 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 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 26 in the transition region under some circumstances. 18 27 19 28 For 2D data, the scattering intensity is calculated in the same way as 1D, … … 24 33 q = \sqrt{q_x^2 + q_y^2} 25 34 26 .. figure:: img/HayterMSAsq_227.jpg27 28 1D plot using the default values (in linear scale).29 35 30 36 References … … 35 41 J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 36 42 """ 43 from numpy import inf 37 44 38 # dp[0] = 2.0*effect_radius(); 45 category = "structure-factor" 46 structure_factor = True 47 single = False # double precision only! 48 49 # dp[0] = 2.0*radius_effective(); 39 50 # dp[1] = fabs(charge()); 40 51 # dp[2] = volfraction(); … … 43 54 # dp[5] = dielectconst(); 44 55 45 from numpy import inf46 56 47 source = ["hayter_msa_kernel.c"] 57 48 58 49 59 name = "hayter_msa" 50 title = "Hayter-Penfold MSA charged sphereinterparticle S(Q) structure factor"60 title = "Hayter-Penfold rescaled MSA, charged sphere, interparticle S(Q) structure factor" 51 61 description = """\ 52 [Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor]62 [Hayter-Penfold RMSA charged sphere interparticle S(Q) structure factor] 53 63 Interparticle structure factor S(Q)for a charged hard spheres. 54 64 Routine takes absolute value of charge, use HardSphere if charge 55 65 goes to zero. 56 In sasview the effective radius will be calculated from the57 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). 58 68 """ 59 single = False # double precision only! 69 60 70 61 71 # pylint: disable=bad-whitespace, line-too-long 62 72 # [ "name", "units", default, [lower, upper], "type", "description" ], 63 73 parameters = [ 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"], 65 75 ["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"], 67 77 ["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"] 70 80 ] 71 81 # pylint: enable=bad-whitespace, line-too-long 72 category = "structure-factor"73 82 83 source = ["hayter_msa_kernel.c"] 74 84 # No volume normalization despite having a volume parameter 75 85 # This should perhaps be volume normalized? … … 85 95 86 96 oldname = '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") 98 oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 99 #oldpars = dict( ) 88 100 # default parameter set, use compare.sh -midQ -linear 89 101 # note the calculation varies in different limiting cases so a wide range of 90 102 # parameters will be required for a thorough test! 91 103 # odd that the default st has saltconc zero 92 demo = dict( effect_radius=20.75,104 demo = dict(radius_effective=20.75, 93 105 charge=19.0, 94 106 volfraction=0.0192, … … 96 108 saltconc=0.05, 97 109 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) 100 112 # 101 113 # attempt to use same values as old sasview unit test at Q=.001 was 0.0712928, … … 104 116 [{'scale': 1.0, 105 117 'background': 0.0, 106 ' effect_radius': 20.75,118 'radius_effective': 20.75, 107 119 'charge': 19.0, 108 120 'volfraction': 0.0192, … … 110 122 'saltconc': 0, 111 123 'dielectconst': 78.0, 112 ' effect_radius_pd': 0},124 'radius_effective_pd': 0}, 113 125 [0.00001,0.0010,0.01,0.075], [0.0711646,0.0712928,0.0847006,1.07150]], 114 126 [{'scale': 1.0, 115 127 'background': 0.0, 116 ' effect_radius': 20.75,128 'radius_effective': 20.75, 117 129 'charge': 19.0, 118 130 'volfraction': 0.0192, … … 120 132 'saltconc': 0.05, 121 133 '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}, 124 136 [0.00001,0.0010,0.01,0.075], [0.450272,0.450420,0.465116,1.039625]] 125 137 ] 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 3 3 // C99 needs declarations of routines here 4 4 double 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); 6 6 int 7 7 sqcoef(int ir, double gMSAWave[]); … … 14 14 15 15 double 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) 17 17 { 18 18 double gMSAWave[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; … … 28 28 pi = M_PI; 29 29 30 diam=2* effect_radius; //in A30 diam=2*radius_effective; //in A 31 31 32 32 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
sasmodels/models/squarewell.py
r5111921 rd529d93 8 8 Positive well depths correspond to an attractive potential well. Negative well depths correspond to a potential 9 9 "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.10 some circumstances. Computed values may behave badly at extremely small $qR$. 11 11 12 The well width ( *l*\) is defined as multiples of the particle diameter (2\*\ *R*\ )12 The well width (|lambda| ) is defined as multiples of the particle diameter (2\*\ *R*\ ) 13 13 14 14 The interaction potential is: … … 22 22 U(r) = \begin{cases} 23 23 \infty & r < 2R \\ 24 -\epsilon , 2R \leq < 2R\lambda25 0 & r \geq 2R 24 -\epsilon & 2R \leq r < 2R\lambda \\ 25 0 & r \geq 2R\lambda 26 26 \end{cases} 27 27 28 28 where $r$ is the distance from the center of the sphere of a radius $R$. 29 29 30 In sasview the effective radius may be calculated from the parameters 31 used in the form factor $P(q)$ that this $S(q)$ is combined with. 30 32 31 33 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as … … 35 37 q = \sqrt{q_x^2 + q_y^2} 36 38 37 .. comment::38 39 .. figure:: img/squarewell_226.jpg40 41 1D plot using the default values (in linear scale).*42 39 43 40 REFERENCE … … 59 56 """ 60 57 category = "structure-factor" 58 structure_factor = True 61 59 62 60 #single = False … … 65 63 # [ "name", "units", default, [lower, upper], "type", 66 64 # "description" ], 67 [" effect_radius", "Ang", 50.0, [0, inf], "volume",65 ["radius_effective", "Ang", 50.0, [0, inf], "volume", 68 66 "effective radius of hard sphere"], 69 67 ["volfraction", "", 0.04, [0, 0.08], "", … … 71 69 ["welldepth", "kT", 1.5, [0.0, 1.5], "", 72 70 "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"], 75 73 ] 76 74 … … 89 87 x= q; 90 88 91 req = effect_radius;89 req = radius_effective; 92 90 phis = volfraction; 93 91 edibkb = welldepth; … … 134 132 135 133 oldname = '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)134 oldpars = dict(radius_effective="effect_radius",radius_effective_pd="effect_radius_pd",radius_effective_pd_n="effect_radius_pd_n") 135 demo = dict(radius_effective=50, volfraction=0.04, welldepth=1.5, 136 wellwidth=1.2, radius_effective_pd=0, radius_effective_pd_n=0) 139 137 # 140 138 tests = [ 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]] 143 141 ] 144 # ADDED by: converting from sasview RKH ON: 16Mar2016 - in progress142 # ADDED by: converting from sasview RKH ON: 16Mar2016 145 143 -
sasmodels/models/stickyhardsphere.py
r8e45182 rd529d93 49 49 the optimization does not hit the constraints. 50 50 51 In sasview the effective radius willbe calculated from the parameters51 In sasview the effective radius may be calculated from the parameters 52 52 used in the form factor $P(q)$ that this $S(q)$ is combined with. 53 53
Note: See TracChangeset
for help on using the changeset viewer.