Changeset 6abd46f in sasmodels
- Timestamp:
- Feb 18, 2016 7:13:00 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
- Parents:
- a0632d9 (diff), 16bb433 (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. - Files:
-
- 22 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/HayterMSAsq.py
r13ed84c rec2ca99 52 52 [Hayter-Penfold MSA charged sphere interparticle S(Q) structure factor] 53 53 Interparticle structure factor S(Q)for a charged hard spheres. 54 Routine takes absolute value of charge, use HardSphere if charge goes to zero. 54 Routine takes absolute value of charge, use HardSphere if charge 55 goes to zero. 55 56 In sasview the effective radius will be calculated from the 56 57 parameters used in P(Q). 57 58 """ 58 59 single = False # double precision only for now 60 61 # pylint: disable=bad-whitespace, line-too-long 59 62 # [ "name", "units", default, [lower, upper], "type", "description" ], 60 parameters = [["effect_radius", "Ang", 20.75, [0, inf], "volume", 61 "effective radius of hard sphere"], 62 ["charge", "e", 19.0, [0, inf], "", 63 "charge on sphere (in electrons)"], 64 ["volfraction", "", 0.0192, [0, 0.74], "", 65 "volume fraction of spheres"], 66 ["temperature", "K", 318.16, [0, inf], "", 67 "temperature, in Kelvin, for Debye length calculation"], 68 ["saltconc", "M", 0.0, [-inf, inf], "", 69 "conc of salt, 1:1 electolyte, for Debye length"], 70 ["dielectconst", "", 71.08, [-inf, inf], "", 71 "dielectric constant of solvent (default water), for Debye length"], 72 ] 63 parameters = [ 64 ["effect_radius", "Ang", 20.75, [0, inf], "volume", "effective radius of hard sphere"], 65 ["charge", "e", 19.0, [0, inf], "", "charge on sphere (in electrons)"], 66 ["volfraction", "", 0.0192, [0, 0.74], "", "volume fraction of spheres"], 67 ["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"], 70 ] 71 # pylint: enable=bad-whitespace, line-too-long 73 72 category = "structure-factor" 74 73 … … 88 87 oldpars = dict() 89 88 # default parameter set, use compare.sh -midQ -linear 90 # note the calculation varies in different limiting cases so a wide range of parameters will be required for a thorough test! 89 # note the calculation varies in different limiting cases so a wide range of 90 # parameters will be required for a thorough test! 91 91 # odd that the default st has saltconc zero 92 demo = dict(effect_radius = 20.75,charge=19.0,volfraction = 0.0192,temperature=318.16,saltconc=0.05,dielectconst=71.08,effect_radius_pd = 0.1,effect_radius_pd_n = 40) 92 demo = dict(effect_radius=20.75, 93 charge=19.0, 94 volfraction=0.0192, 95 temperature=318.16, 96 saltconc=0.05, 97 dielectconst=71.08, 98 effect_radius_pd=0.1, 99 effect_radius_pd_n=40) 93 100 # 94 101 # attempt to use same values as old sasview unit test 95 102 tests = [ 96 [ {'scale': 1.0, 'background' : 0.0, 'effect_radius' : 20.75, 'charge' : 19.0, 'volfraction' : 0.0192, 'temperature' : 298.0, 97 'saltconc' : 0,'dielectconst' : 78.0, 'effect_radius_pd' : 0}, [0.0010], [0.0712928]] 98 ] 103 [{'scale': 1.0, 104 'background': 0.0, 105 'effect_radius': 20.75, 106 'charge': 19.0, 107 'volfraction': 0.0192, 108 'temperature': 298.0, 109 'saltconc': 0, 110 'dielectconst': 78.0, 111 'effect_radius_pd': 0}, 112 [0.0010], [0.0712928]] 113 ] 99 114 -
sasmodels/models/bcc.c
r7ed702f r9aac25d 40 40 } 41 41 42 double _sphereform(double q, double radius, double sld, double solvent_sld){43 const double qr = q*radius;44 double sn, cn;45 SINCOS(qr, sn, cn);46 const double bes = (qr == 0.0 ? 1.0 : 3.0*(sn-qr*cn)/(qr*qr*qr));47 const double fq = bes * (sld - solvent_sld)*form_volume(radius);48 return 1.0e-4*fq*fq;49 }50 42 51 43 double form_volume(double radius){ … … 87 79 88 80 answer = (vb-va)/2.0*summ; 89 answer = answer* _sphereform(q,radius,sld,solvent_sld)*latticescale;81 answer = answer*sphere_form(q,radius,sld,solvent_sld)*latticescale; 90 82 91 83 return answer; … … 174 166 175 167 // Use SphereForm directly from libigor 176 answer = _sphereform(q,radius,sld,solvent_sld)*Zq*latticescale;168 answer = sphere_form(q,radius,sld,solvent_sld)*Zq*latticescale; 177 169 178 170 return answer; -
sasmodels/models/bcc.py
r13ed84c r9aac25d 132 132 # pylint: enable=bad-whitespace, line-too-long 133 133 134 source = ["lib/J1.c", "lib/gauss150.c", " bcc.c"]134 source = ["lib/J1.c", "lib/gauss150.c", "lib/sphere_form.c", "bcc.c"] 135 135 136 136 # parameters for demo -
sasmodels/models/fcc.c
reeb8bac r9aac25d 7 7 double _FCC_Integrand(double q, double dnn, double d_factor, double theta, double phi); 8 8 double _FCCeval(double Theta, double Phi, double temp1, double temp3); 9 double _sphereform(double q, double radius, double sld, double solvent_sld);10 9 11 10 … … 39 38 40 39 return (result); 41 }42 43 double _sphereform(double q, double radius, double sld, double solvent_sld){44 const double qr = q*radius;45 double sn, cn;46 SINCOS(qr, sn, cn);47 const double bes = (qr == 0.0 ? 1.0 : 3.0*(sn-qr*cn)/(qr*qr*qr));48 const double fq = bes * (sld - solvent_sld)*form_volume(radius);49 return 1.0e-4*fq*fq;50 40 } 51 41 … … 88 78 89 79 answer = (vb-va)/2.0*summ; 90 answer = answer* _sphereform(q,radius,sld,solvent_sld)*latticescale;80 answer = answer*sphere_form(q,radius,sld,solvent_sld)*latticescale; 91 81 92 82 return answer; … … 175 165 176 166 // Use SphereForm directly from libigor 177 answer = _sphereform(q,radius,sld,solvent_sld)*Zq*latticescale;167 answer = sphere_form(q,radius,sld,solvent_sld)*Zq*latticescale; 178 168 179 169 return answer; -
sasmodels/models/fcc.py
r13ed84c r9aac25d 125 125 ] 126 126 127 source = ["lib/J1.c", "lib/gauss150.c", " fcc.c"]127 source = ["lib/J1.c", "lib/gauss150.c", "lib/sphere_form.c", "fcc.c"] 128 128 129 129 # parameters for demo -
sasmodels/models/hardsphere.py
r13ed84c r093f754 35 35 from numpy import inf 36 36 37 name = "hardsphere "38 title = "Hard sphere structure factor , with Percus-Yevick closure"37 name = "hardsphere_fish" 38 title = "Hard sphere structure factor from FISH, with Percus-Yevick closure" 39 39 description = """\ 40 40 [Hard sphere structure factor, with Percus-Yevick closure] … … 55 55 "volume fraction of hard spheres"], 56 56 ] 57 single = False58 57 59 58 # No volume normalization despite having a volume parameter … … 64 63 65 64 Iq = """ 66 double denom,dnum,alpha,beta,gamm,a,asq,ath,afor,rca,rsa; 67 double calp,cbeta,cgam,prefac,c,vstruc; 68 double struc; 65 double D,A,B,G,X,X2,X4,S,C,FF,HARDSPH; 69 66 70 // compute constants 71 denom = pow((1.0-volfraction),4); 72 dnum = pow((1.0 + 2.0*volfraction),2); 73 alpha = dnum/denom; 74 beta = -6.0*volfraction*pow((1.0 + volfraction/2.0),2)/denom; 75 gamm = 0.50*volfraction*dnum/denom; 76 // 77 // calculate the structure factor 78 // 79 a = 2.0*q*effect_radius; 80 asq = a*a; 81 ath = asq*a; 82 afor = ath*a; 83 SINCOS(a,rsa,rca); 84 //rca = cos(a); 85 //rsa = sin(a); 86 calp = alpha*(rsa/asq - rca/a); 87 cbeta = beta*(2.0*rsa/asq - (asq - 2.0)*rca/ath - 2.0/ath); 88 cgam = gamm*(-rca/a + (4.0/a)*((3.0*asq - 6.0)*rca/afor + (asq - 6.0)*rsa/ath + 6.0/afor)); 89 prefac = -24.0*volfraction/a; 90 c = prefac*(calp + cbeta + cgam); 91 vstruc = 1.0/(1.0-c); 92 struc = vstruc; 67 if(fabs(effect_radius) < 1.E-12) { 68 HARDSPH=1.0; 69 return(HARDSPH); 70 } 71 D=pow((1.-volfraction),2); 72 A=pow((1.+2.*volfraction)/D, 2); 73 X=fabs(q*effect_radius*2.0); 93 74 94 return(struc); 75 if(X < 5.E-06) { 76 HARDSPH=1./A; 77 return(HARDSPH); 78 } 79 X2=pow(X,2); 80 X4=pow(X2,2); 81 B=-6.*volfraction* pow((1.+0.5*volfraction)/D ,2); 82 G=0.5*volfraction*A; 83 84 if(X < 0.2) { 85 // use Taylor series expansion for small X, IT IS VERY PICKY ABOUT THE X CUT OFF VALUE, ought to be lower in double. 86 // No obvious way to rearrange the equations to avoid needing a very high number of significant figures. 87 // Series expansion found using Mathematica software. Numerical test in .xls showed terms to X^2 are sufficient 88 // for 5 or 6 significant figures but I put the X^4 one in anyway 89 FF = 8*A +6*B + 4*G - (0.8*A +2.0*B/3.0 +0.5*G)*X2 +(A/35. +B/40. +G/50.)*X4; 90 // combining the terms makes things worse at smallest Q in single precision 91 //FF = (8-0.8*X2)*A +(3.0-X2/3.)*2*B + (4+0.5*X2)*G +(A/35. +B/40. +G/50.)*X4; 92 // note that G = -volfraction*A/2, combining this makes no further difference at smallest Q 93 //FF = (8 +2.*volfraction + ( volfraction/4. -0.8 +(volfraction/100. -1./35.)*X2 )*X2 )*A + (3.0 -X2/3. +X4/40)*2*B; 94 HARDSPH= 1./(1. + volfraction*FF ); 95 return(HARDSPH); 96 } 97 SINCOS(X,S,C); 98 99 // RKH Feb 2016, use version from FISH code as it is better than original sasview one at small Q in single precision 100 FF=A*(S-X*C)/X + B*(2.*X*S -(X2-2.)*C -2.)/X2 + G*( (4.*X2*X -24.*X)*S -(X4 -12.*X2 +24.)*C +24. )/X4; 101 HARDSPH= 1./(1. + 24.*volfraction*FF/X2 ); 102 103 // rearrange the terms, is now about same as sasmodels 104 // FF=A*(S/X-C) + B*(2.*S/X - C +2.0*(C-1.0)/X2) + G*( (4./X -24./X3)*S -(1.0 -12./X2 +24./X4)*C +24./X4 ); 105 // HARDSPH= 1./(1. + 24.*volfraction*FF/X2 ); 106 // remove 1/X2 from final line, take more powers of X inside the brackets, stil bad 107 // FF=A*(S/X3-C/X2) + B*(2.*S/X3 - C/X2 +2.0*(C-1.0)/X4) + G*( (4./X -24./X3)*S -(1.0 -12./X2 +24./X4)*C +24./X4 )/X2; 108 // HARDSPH= 1./(1. + 24.*volfraction*FF ); 109 return(HARDSPH); 95 110 """ 96 111 … … 106 121 oldname = 'HardsphereStructure' 107 122 oldpars = dict() 108 123 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 109 124 tests = [ 110 125 [ {'scale': 1.0, 'background' : 0.0, 'effect_radius' : 50.0, 'volfraction' : 0.2, 111 'effect_radius_pd' : 0}, [0.001 ], [0.209128]]126 'effect_radius_pd' : 0}, [0.001,0.1], [0.209128,0.930587]] 112 127 ] 113 128 -
sasmodels/models/hollow_cylinder.py
r0420af7 rec2ca99 78 78 """ 79 79 category = "shape:cylinder" 80 81 # 80 # pylint: disable=bad-whitespace, line-too-long 81 # ["name", "units", default, [lower, upper], "type","description"], 82 82 parameters = [ 83 ["radius", "Ang", 30.0, [0, inf], "volume", "Cylinder radius"], 84 ["core_radius", "Ang", 20.0, [0, inf], "volume", "Hollow core radius"], 85 ["length", "Ang", 400.0, [0, inf], "volume", "Cylinder length"], 86 ["sld", "1/Ang^2", 6.3, [-inf, inf], "", "Cylinder sld"], 87 ["solvent_sld", "1/Ang^2", 1, [-inf, inf], "", "Solvent sld"], 88 ["theta", "degrees", 90, [-360, 360], "orientation", "Theta angle"], 89 ["phi", "degrees", 0, [-360, 360], "orientation", "Phi angle"], 90 ] 83 ["radius", "Ang", 30.0, [0, inf], "volume", "Cylinder radius"], 84 ["core_radius", "Ang", 20.0, [0, inf], "volume", "Hollow core radius"], 85 ["length", "Ang", 400.0, [0, inf], "volume", "Cylinder length"], 86 ["sld", "1/Ang^2", 6.3, [-inf, inf], "", "Cylinder sld"], 87 ["solvent_sld", "1/Ang^2", 1, [-inf, inf], "", "Solvent sld"], 88 ["theta", "degrees", 90, [-360, 360], "orientation", "Theta angle"], 89 ["phi", "degrees", 0, [-360, 360], "orientation", "Phi angle"], 90 ] 91 # pylint: enable=bad-whitespace, line-too-long 91 92 92 93 source = ["lib/J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 93 94 94 95 def ER(radius, core_radius, length): 96 """ 97 :param radius: Cylinder radius 98 :param core_radius: Hollow core radius, UNUSED 99 :param length: Cylinder length 100 :return: Effective radius 101 """ 95 102 if radius == 0 or length == 0: 96 103 return 0.0 … … 104 111 105 112 def VR(radius, core_radius, length): 113 """ 114 :param radius: Cylinder radius 115 :param core_radius: Hollow core radius 116 :param length: Cylinder length 117 :return: Volf ratio for P(q)*S(q) 118 """ 106 119 vol_core = pi*core_radius*core_radius*length 107 120 vol_total = pi*radius*radius*length … … 110 123 111 124 # parameters for demo 112 demo = dict(scale=1.0, background=0.0,length=400.0,radius=30.0,core_radius=20.0,113 sld=6.3,solvent_sld=1,theta=90,phi=0,125 demo = dict(scale=1.0, background=0.0, length=400.0, radius=30.0, 126 core_radius=20.0, sld=6.3, solvent_sld=1, theta=90, phi=0, 114 127 radius_pd=.2, radius_pd_n=9, 115 128 length_pd=.2, length_pd_n=10, 116 129 core_radius_pd=.2, core_radius_pd_n=9, 117 130 theta_pd=10, theta_pd_n=5, 118 131 ) 119 132 120 133 # For testing against the old sasview models, include the converted parameter 121 134 # names and the target sasview model name. 122 135 oldname = 'HollowCylinderModel' 123 oldpars = dict(scale='scale', background='background',radius='radius',124 core_radius='core_radius', sld='sldCyl',length='length',125 solvent_sld='sldSolv', phi='axis_phi',theta='axis_theta')136 oldpars = dict(scale='scale', background='background', radius='radius', 137 core_radius='core_radius', sld='sldCyl', length='length', 138 solvent_sld='sldSolv', phi='axis_phi', theta='axis_theta') 126 139 127 140 # Parameters for unit tests 128 141 tests = [ 129 [{"radius" : 30.0},0.00005,1764.926],130 [{},'VR',1.8],131 [{},0.001,1756.76]132 142 [{"radius": 30.0}, 0.00005, 1764.926], 143 [{}, 'VR', 1.8], 144 [{}, 0.001, 1756.76] 145 ] -
sasmodels/models/lamellarCaille.py
r13ed84c rec2ca99 1 # Note: model title and parameter table are inserted automatically2 1 r""" 3 2 This model provides the scattering intensity, $I(q) = P(q) S(q)$, for a … … 77 76 title = "Random lamellar sheet with Caille structure factor" 78 77 description = """\ 79 80 81 82 83 84 85 78 [Random lamellar phase with Caille structure factor] 79 randomly oriented stacks of infinite sheets 80 with Caille S(Q), having polydisperse spacing. 81 sld = sheet scattering length density 82 sld_solvent = solvent scattering length density 83 background = incoherent background 84 scale = scale factor 86 85 """ 87 86 category = "shape:lamellae" 88 87 89 88 single = False 90 89 # pylint: disable=bad-whitespace, line-too-long 91 90 # ["name", "units", default, [lower, upper], "type","description"], 92 parameters = [ ["thickness", "Ang", 30.0, [0, inf], "volume", "sheet thickness"],93 ["Nlayers", "", 20, [0, inf], "", "Number of layers"],94 ["spacing", "Ang", 400., [0.0,inf], "volume", "d-spacing of Caille S(Q)"],95 ["Caille_parameter", "1/Ang^2", 0.1, [0.0,0.8], "", "Caille parameter"],96 ["sld", "1e-6/Ang^2", 6.3, [-inf,inf], "",97 98 ["solvent_sld", "1e-6/Ang^2", 1.0, [-inf,inf], "",99 "Solvent scattering length density"],100 ] 91 parameters = [ 92 ["thickness", "Ang", 30.0, [0, inf], "volume", "sheet thickness"], 93 ["Nlayers", "", 20, [0, inf], "", "Number of layers"], 94 ["spacing", "Ang", 400., [0.0,inf], "volume", "d-spacing of Caille S(Q)"], 95 ["Caille_parameter", "1/Ang^2", 0.1, [0.0,0.8], "", "Caille parameter"], 96 ["sld", "1e-6/Ang^2", 6.3, [-inf,inf], "", "layer scattering length density"], 97 ["solvent_sld", "1e-6/Ang^2", 1.0, [-inf,inf], "", "Solvent scattering length density"], 98 ] 99 # pylint: enable=bad-whitespace, line-too-long 101 100 102 101 source = ["lamellarCaille_kernel.c"] … … 116 115 117 116 demo = dict(scale=1, background=0, 118 thickness=67., Nlayers=3.75,spacing=200.,119 Caille_parameter=0.268, sld=1.0, solvent_sld=6.34,120 thickness_pd= 121 spacing_pd= 117 thickness=67., Nlayers=3.75, spacing=200., 118 Caille_parameter=0.268, sld=1.0, solvent_sld=6.34, 119 thickness_pd=0.1, thickness_pd_n=100, 120 spacing_pd=0.05, spacing_pd_n=40) 122 121 123 122 oldname = 'LamellarPSModel' 124 oldpars = dict(thickness='delta', Nlayers='N_plates', Caille_parameter='caille', 125 sld='sld_bi',solvent_sld='sld_sol') 123 oldpars = dict(thickness='delta', Nlayers='N_plates', 124 Caille_parameter='caille', 125 sld='sld_bi', solvent_sld='sld_sol') 126 126 # 127 127 tests = [ 128 [ {'scale': 1.0, 'background' : 0.0, 'thickness' : 30.,'Nlayers' : 20.0, 'spacing' : 400., 129 'Caille_parameter' : 0.1, 'sld' : 6.3, 'solvent_sld' : 1.0, 130 'thickness_pd' : 0.0, 'spacing_pd' : 0.0 }, [0.001], [28895.13397]] 131 ] 128 [{'scale': 1.0, 'background': 0.0, 'thickness': 30., 'Nlayers': 20.0, 129 'spacing': 400., 'Caille_parameter': 0.1, 'sld': 6.3, 130 'solvent_sld': 1.0, 'thickness_pd': 0.0, 'spacing_pd': 0.0}, 131 [0.001], [28895.13397]] 132 ] -
.gitignore
r66ebdd6 r4a82d4d 1 1 /build/ 2 2 /dist/ 3 /logs/ 3 4 /*.csv 4 5 *.pyc … … 16 17 /.project 17 18 /.pydevproject 19 /.idea 20 /sasmodels.egg-info/ -
doc/rst_prolog
r19dcb933 r0a4628d 60 60 .. |g/cm^3| replace:: g\ |cdot|\ cm\ :sup:`-3` 61 61 .. |fm^2| replace:: fm\ :sup:`2` 62 .. |Ang*cm^-1| replace:: |Ang|\ |cdot|\ cm\ :sup:`-1` -
multi_compare.sh
r5753e4e r0a4628d 1 #!/bin/ sh1 #!/bin/bash 2 2 3 3 sasview=( ../sasview/build/lib.* ) -
sasmodels/convert.py
r3964f92 r34d6cab 10 10 'broad_peak', 11 11 'two_lorentzian', 12 "two_power_law", 12 13 'gel_fit', 13 14 'gauss_lorentz_gel', … … 151 152 pars['string_thickness_pd_n'] = 0 152 153 pars['number_of_pearls_pd_n'] = 0 154 elif name == 'line': 155 pars['scale'] = 1 156 pars['background'] = 0 153 157 elif name == 'rpa': 154 158 pars['case_num'] = int(pars['case_num']) -
sasmodels/generate.py
reafc9fa r0a4628d 233 233 "degrees": "degree", 234 234 "1/cm": "|cm^-1|", 235 "Ang/cm": "|Ang*cm^-1|", 235 236 "": "None", 236 237 } -
setup.py
r040575f r3eb3312 11 11 version = "1.0.0a", 12 12 description = "sasmodels package", 13 long_description=open('README. rst').read(),13 long_description=open('README.md').read(), 14 14 author = "SasView Collaboration", 15 15 author_email = "management@sasview.org",
Note: See TracChangeset
for help on using the changeset viewer.