Changeset 0b499f0 in sasmodels
- Timestamp:
- Mar 20, 2016 4:44: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:
- 0495db8
- Parents:
- d554bd7 (diff), e796fcb (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:
-
- 11 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/conf.py
r9404dd3 r4a21670c 231 231 with open('rst_prolog') as fid: 232 232 rst_prolog = fid.read() 233 234 numfig = True -
sasmodels/models/_bessel.py
r275b98e5 r0f910a7 1 1 r""" 2 For information about polarised and magnetic scattering, click here_. 3 4 .. _here: polar_mag_help.html 2 This is a test function! 5 3 6 4 Definition 7 5 ---------- 8 6 9 The 1D scattering intensity is calculated in the following way (Guinier, 1955) 10 11 .. math:: 12 13 I(q) = \frac{\text{scale}}{V} \cdot \left[ 14 3V(\Delta\rho) \cdot \frac{\sin(qr) - qr\cos(qr))}{(qr)^3} 15 \right]^2 + \text{background} 16 17 where *scale* is a volume fraction, $V$ is the volume of the scatterer, 18 $r$ is the radius of the sphere, *background* is the background level and 19 *sld* and *solvent_sld* are the scattering length densities (SLDs) of the 20 scatterer and the solvent respectively. 21 22 Note that if your data is in absolute scale, the *scale* should represent 23 the volume fraction (which is unitless) if you have a good fit. If not, 24 it should represent the volume fraction times a factor (by which your data 25 might need to be rescaled). 26 27 The 2D scattering intensity is the same as above, regardless of the 28 orientation of $\vec q$. 29 30 Validation 31 ---------- 32 33 Validation of our code was done by comparing the output of the 1D model 34 to the output of the software provided by the NIST (Kline, 2006). 35 Figure :numref:`figure #sphere-comparison` shows a comparison of the output 36 of our model and the output of the NIST software. 37 38 .. _sphere-comparison: 39 40 .. figure:: img/sphere_comparison.jpg 41 42 Comparison of the DANSE scattering intensity for a sphere with the 43 output of the NIST SANS analysis software. The parameters were set to: 44 *scale* = 1.0, *radius* = 60 |Ang|, *contrast* = 1e-6 |Ang^-2|, and 45 *background* = 0.01 |cm^-1|. 46 7 Calculates a bessel function. Maybe... 47 8 48 9 References 49 10 ---------- 50 11 51 A Guinier and G. Fournet, *Small-Angle Scattering of X-Rays*, 52 John Wiley and Sons, New York, (1955) 53 54 *2013/09/09 and 2014/01/06 - Description reviewed by S King and P Parker.* 12 None 55 13 """ 56 14 … … 60 18 title = "Bessel function testing" 61 19 description = """\ 62 Lev raging current infrastracture to test Bessel function performance on20 Leveraging current infrastructure to test Bessel function performance on 63 21 """ 64 category = "special_fu cntions:bessel"22 category = "special_functions:bessel" 65 23 66 24 # ["name", "units", default, [lower, upper], "type","description"], -
sasmodels/models/core_shell_ellipsoid_xt.py
r29172aa r3556ad7 89 89 parameters = [ 90 90 ["equat_core", "Ang", 20, [0, inf], "volume", "Equatorial radius of core"], 91 ["x_core", "None", 3, [0, inf], "volume", " Polar radius of core"],92 ["t_shell", "Ang", 30, [0, inf], "volume", " Equatorial radius of shell"],93 ["x_polar_shell", "", 1, [0, inf], "volume", " Polar radius of shell"],91 ["x_core", "None", 3, [0, inf], "volume", "axial ratio of core, X = r_polar/r_equatorial"], 92 ["t_shell", "Ang", 30, [0, inf], "volume", "thickness of shell at equator"], 93 ["x_polar_shell", "", 1, [0, inf], "volume", "ratio of thickness of shell at pole to that at equator"], 94 94 ["sld_core", "1e-6/Ang^2", 2, [-inf, inf], "", "Core scattering length density"], 95 95 ["sld_shell", "1e-6/Ang^2", 1, [-inf, inf], "", "Shell scattering length density"], -
sasmodels/models/core_shell_sphere.py
raa2edb2 r3556ad7 19 19 V_s(\rho_s-\rho_{solv})\frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right] 20 20 21 where $V_s$ is the volume of the outer shell, $V_c$ is22 the volume of the core, $r_s$ is the radius of the shell, $r_c$ is the radius of the21 where $V_s$ is the volume of the whole particle, $V_c$ is 22 the volume of the core, $r_s$ = $radius$ + $thickness$ is the radius of the particle, $r_c$ is the radius of the 23 23 core, $\rho_c$ is the scattering length density of the core, $\rho_s$ is the scattering length 24 24 density of the shell, $\rho_{solv}$ is the scattering length density of the solvent. … … 30 30 effective radius for $S(Q)$ when $P(Q) \cdot S(Q)$ is applied. 31 31 32 Reference 33 --------- 32 References 33 ---------- 34 34 35 35 A Guinier and G Fournet, *Small-Angle Scattering of X-Rays*, John Wiley and Sons, New York, (1955) … … 49 49 title = "Form factor for a monodisperse spherical particle with particle with a core-shell structure." 50 50 description = """ 51 F^2(q) = 3/V_s [V_c ( core_sld-shell_sld) (sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^352 + V_s (s hell_sld-solvent_sld) (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3]51 F^2(q) = 3/V_s [V_c (sld_core-sld_shell) (sin(q*radius)-q*radius*cos(q*radius))/(q*radius)^3 52 + V_s (sld_shell-sld_solvent) (sin(q*r_s)-q*r_s*cos(q*r_s))/(q*r_s)^3] 53 53 54 54 V_s: Volume of the sphere shell … … 62 62 parameters = [["radius", "Ang", 60.0, [0, inf], "volume", "Sphere core radius"], 63 63 ["thickness", "Ang", 10.0, [0, inf], "volume", "Sphere shell thickness"], 64 [" core_sld", "1e-6/Ang^2", 1.0, [-inf, inf], "", "Spherecore scattering length density"],65 ["s hell_sld", "1e-6/Ang^2", 2.0, [-inf, inf], "", "Sphereshell scattering length density"],66 ["s olvent_sld", "1e-6/Ang^2", 3.0, [-inf, inf], "", "Solvent scattering length density"]]64 ["sld_core", "1e-6/Ang^2", 1.0, [-inf, inf], "", "core scattering length density"], 65 ["sld_shell", "1e-6/Ang^2", 2.0, [-inf, inf], "", "shell scattering length density"], 66 ["sld_solvent", "1e-6/Ang^2", 3.0, [-inf, inf], "", "Solvent scattering length density"]] 67 67 # pylint: enable=bad-whitespace, line-too-long 68 68 … … 70 70 71 71 demo = dict(scale=1, background=0, radius=60, thickness=10, 72 core_sld=1.0, shell_sld=2.0, solvent_sld=0.0)72 sld_core=1.0, sld_shell=2.0, sld_solvent=0.0) 73 73 74 74 oldname = 'CoreShellModel' 75 oldpars = {} 75 oldpars = dict( sld_core='core_sld', 76 sld_shell='shell_sld', 77 sld_solvent='solvent_sld') 76 78 77 79 def ER(radius, thickness): … … 99 101 [{'radius': 60.0, 100 102 'thickness': 10.0, 101 ' core_sld': 1.0,102 's hell_sld':2.0,103 's olvent_sld':3.0,103 'sld_core': 1.0, 104 'sld_shell':2.0, 105 'sld_solvent':3.0, 104 106 'background':0.0 105 107 }, 0.4, 0.000698838]] -
sasmodels/models/cylinder.py
r2f63032 r5933c7f 31 31 To provide easy access to the orientation of the cylinder, we define the 32 32 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 33 are defined in :numref:`figure # cylinder-angle-definition`.33 are defined in :numref:`figure #<cylinder-angle-definition>`. 34 34 35 35 .. _cylinder-angle-definition: -
sasmodels/models/ellipsoid.py
rcedad32 r3556ad7 2 2 # Note: model title and parameter table are inserted automatically 3 3 r""" 4 The form factor is normalized by the particle volume .4 The form factor is normalized by the particle volume 5 5 6 6 Definition … … 31 31 32 32 $\alpha$ is the angle between the axis of the ellipsoid and $\vec q$, 33 $V $ is the volume of the ellipsoid, $R_p$ is the polar radius along the33 $V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the polar radius along the 34 34 rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular 35 35 to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the … … 41 41 :ref:`cylinder orientation figure <cylinder-angle-definition>`. 42 42 For the ellipsoid, $\theta$ is the angle between the rotational axis 43 and the $z$ -axis.43 and the $z$ -axis. 44 44 45 45 NB: The 2nd virial coefficient of the solid ellipsoid is calculated based … … 54 54 .. figure:: img/ellipsoid_angle_projection.jpg 55 55 56 The angles for oriented ellipsoid .56 The angles for oriented ellipsoid, shown here as oblate, $a$ = $R_p$ and $b$ = $R_e$ 57 57 58 58 Validation … … 74 74 calculated from our 2D model and the intensity from the NIST SANS 75 75 analysis software. The parameters used were: *scale* = 1.0, 76 *r polar* = 20 |Ang|, *requatorial* = 400 |Ang|,76 *r_polar* = 20 |Ang|, *r_equatorial* = 400 |Ang|, 77 77 *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. 78 78 … … 102 102 description = """\ 103 103 P(q.alpha)= scale*f(q)^2 + background, where f(q)= 3*(sld 104 - s olvent_sld)*V*[sin(q*r(Rp,Re,alpha))104 - sld_solvent)*V*[sin(q*r(Rp,Re,alpha)) 105 105 -q*r*cos(qr(Rp,Re,alpha))] 106 106 /[qr(Rp,Re,alpha)]^3" … … 110 110 111 111 sld: SLD of the ellipsoid 112 s olvent_sld: SLD of the solvent112 sld_solvent: SLD of the solvent 113 113 V: volume of the ellipsoid 114 114 Rp: polar radius of the ellipsoid … … 120 120 parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "", 121 121 "Ellipsoid scattering length density"], 122 ["s olvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "",122 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "", 123 123 "Solvent scattering length density"], 124 ["r polar", "Ang", 20, [0, inf], "volume",124 ["r_polar", "Ang", 20, [0, inf], "volume", 125 125 "Polar radius"], 126 ["r equatorial", "Ang", 400, [0, inf], "volume",126 ["r_equatorial", "Ang", 400, [0, inf], "volume", 127 127 "Equatorial radius"], 128 128 ["theta", "degrees", 60, [-inf, inf], "orientation", … … 134 134 source = ["lib/sph_j1c.c", "lib/gauss76.c", "ellipsoid.c"] 135 135 136 def ER(r polar, requatorial):136 def ER(r_polar, r_equatorial): 137 137 import numpy as np 138 138 139 ee = np.empty_like(r polar)140 idx = r polar > requatorial141 ee[idx] = (r polar[idx] ** 2 - requatorial[idx] ** 2) / rpolar[idx] ** 2142 idx = r polar < requatorial143 ee[idx] = (r equatorial[idx] ** 2 - rpolar[idx] ** 2) / requatorial[idx] ** 2144 idx = r polar == requatorial145 ee[idx] = 2 * r polar[idx]146 valid = (r polar * requatorial != 0)139 ee = np.empty_like(r_polar) 140 idx = r_polar > r_equatorial 141 ee[idx] = (r_polar[idx] ** 2 - r_equatorial[idx] ** 2) / r_polar[idx] ** 2 142 idx = r_polar < r_equatorial 143 ee[idx] = (r_equatorial[idx] ** 2 - r_polar[idx] ** 2) / r_equatorial[idx] ** 2 144 idx = r_polar == r_equatorial 145 ee[idx] = 2 * r_polar[idx] 146 valid = (r_polar * r_equatorial != 0) 147 147 bd = 1.0 - ee[valid] 148 148 e1 = np.sqrt(ee[valid]) … … 152 152 delta = 0.75 * b1 * b2 153 153 154 ddd = np.zeros_like(r polar)155 ddd[valid] = 2.0 * (delta + 1.0) * r polar * requatorial ** 2154 ddd = np.zeros_like(r_polar) 155 ddd[valid] = 2.0 * (delta + 1.0) * r_polar * r_equatorial ** 2 156 156 return 0.5 * ddd ** (1.0 / 3.0) 157 157 158 158 159 159 demo = dict(scale=1, background=0, 160 sld=6, s olvent_sld=1,161 r polar=50, requatorial=30,160 sld=6, sld_solvent=1, 161 r_polar=50, r_equatorial=30, 162 162 theta=30, phi=15, 163 r polar_pd=.2, rpolar_pd_n=15,164 r equatorial_pd=.2, requatorial_pd_n=15,163 r_polar_pd=.2, r_polar_pd_n=15, 164 r_equatorial_pd=.2, r_equatorial_pd_n=15, 165 165 theta_pd=15, theta_pd_n=45, 166 166 phi_pd=15, phi_pd_n=1) 167 167 oldname = 'EllipsoidModel' 168 168 oldpars = dict(theta='axis_theta', phi='axis_phi', 169 sld='sldEll', s olvent_sld='sldSolv',170 r polar='radius_a', requatorial='radius_b')169 sld='sldEll', sld_solvent='sldSolv', 170 r_polar='radius_a', r_equatorial='radius_b') -
sasmodels/models/elliptical_cylinder.py
raa24114 r74fd96f 12 12 .. figure:: img/elliptical_cylinder_geometry.png 13 13 14 Elliptical cylinder geometry $a$ = $r_{minor}$ and \nu = $ r_{ratio}$ = $r_{major} / r_{minor}$14 Elliptical cylinder geometry $a$ = $r_{minor}$ and \nu = $axis\_ratio$ = $r_{major} / r_{minor}$ 15 15 16 16 The function calculated is … … 57 57 Examples of the angles for oriented elliptical cylinders against the detector plane. 58 58 59 NB: The 2nd virial coefficient of the cylinder is calculated based on the averaged radius (= sqrt(*r_minor*\ :sup:`2` \* * r_ratio*))59 NB: The 2nd virial coefficient of the cylinder is calculated based on the averaged radius (= sqrt(*r_minor*\ :sup:`2` \* *axis_ratio*)) 60 60 and length values, and used as the effective radius for *S(Q)* when *P(Q)* \* *S(Q)* is applied. 61 61 … … 95 95 # ["name", "units", default, [lower, upper], "type","description"], 96 96 parameters = [["r_minor", "Ang", 20.0, [0, inf], "volume", "Ellipse minor radius"], 97 [" r_ratio", "", 1.5, [1, inf], "volume", "Ratio of major radius over minor radius"],97 ["axis_ratio", "", 1.5, [1, inf], "volume", "Ratio of major radius over minor radius"], 98 98 ["length", "Ang", 400.0, [1, inf], "volume", "Length of the cylinder"], 99 99 ["sld", "1e-6/Ang^2", 4.0, [-inf, inf], "", "Cylinder scattering length density"], … … 107 107 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/gauss20.c", "elliptical_cylinder.c"] 108 108 109 demo = dict(scale=1, background=0, r_minor=100, r_ratio=1.5, length=400.0,109 demo = dict(scale=1, background=0, r_minor=100, axis_ratio=1.5, length=400.0, 110 110 sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, theta_pd=10, phi_pd=2, psi_pd=3) 111 111 112 112 oldname = 'EllipticalCylinderModel' 113 oldpars = dict( theta='cyl_theta', phi='cyl_phi', psi='cyl_psi', sld='sldCyl', sld_solvent='sldSolv')113 oldpars = dict(axis_ratio="r_ratio",theta='cyl_theta', phi='cyl_phi', psi='cyl_psi', sld='sldCyl', sld_solvent='sldSolv') 114 114 115 def ER(r_minor, r_ratio, length):115 def ER(r_minor, axis_ratio, length): 116 116 """ 117 117 Equivalent radius 118 118 @param r_minor: Ellipse minor radius 119 @param r_ratio: Ratio of major radius over minor radius119 @param axis_ratio: Ratio of major radius over minor radius 120 120 @param length: Length of the cylinder 121 121 """ 122 radius = math.sqrt(r_minor * r_minor * r_ratio)122 radius = math.sqrt(r_minor * r_minor * axis_ratio) 123 123 ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) 124 124 return 0.5 * (ddd) ** (1. / 3.) 125 125 126 tests = [[{'r_minor': 20.0, ' r_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024],127 [{'r_minor': 20.0, ' r_ratio': 1.2, 'length':300.0}, 'VR', 1],126 tests = [[{'r_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 127 [{'r_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 128 128 129 129 # The SasView test result was 0.00169, with a background of 0.001 130 130 [{'r_minor': 20.0, 131 ' r_ratio': 1.5,131 'axis_ratio': 1.5, 132 132 'sld': 4.0, 133 133 'length':400.0, -
sasmodels/models/flexible_cylinder_elliptical.py
rce8bed9 rb66d38e 102 102 ["length", "Ang", 1000.0, [0, inf], "volume", "Length of the flexible cylinder"], 103 103 ["kuhn_length", "Ang", 100.0, [0, inf], "volume", "Kuhn length of the flexible cylinder"], 104 ["radius", "Ang", 20.0, [ 0, inf], "volume", "Radius of the flexible cylinder"],104 ["radius", "Ang", 20.0, [1, inf], "volume", "Radius of the flexible cylinder"], 105 105 ["axis_ratio", "", 1.5, [0, inf], "", "Axis_ratio (major_radius/minor_radius"], 106 106 ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "", "Cylinder scattering length density"], … … 109 109 # pylint: enable=bad-whitespace, line-too-long 110 110 111 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/wrc_cyl.c", "flexible_cylinder_e x.c"]111 source = ["lib/polevl.c","lib/sas_J1.c", "lib/gauss76.c", "lib/wrc_cyl.c", "flexible_cylinder_elliptical.c"] 112 112 113 113 demo = dict(scale=1.0, background=0.0001, -
sasmodels/models/fractal.py
r12dbc90 rdff1088 48 48 **Author:** N/A **on:** 49 49 50 ** Modified by:** Paul Butler **on:** March 18, 201650 **Last Modified by:** Paul Butler **on:** March 20, 2016 51 51 52 ** Reviewed by:** Paul Butler **on:** March 18, 201652 **Last Reviewed by:** Paul Butler **on:** March 20, 2016 53 53 54 54 """ … … 96 96 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "fractal.c"] 97 97 98 demo = dict(scale=1, background=0, 99 volfraction=0.05, 98 demo = dict(volfraction=0.05, 100 99 radius=5.0, 101 100 fractal_dim=2.0, … … 115 114 # NOTE: test results taken from values returned by SasView 3.1.2 116 115 tests = [ 117 [{}, 0.234959183673, 0.0910228716283], 118 [{}, 0.5, 0.016235799134], 116 [{}, 0.0005, 40.4980069872], 117 [{}, 0.234734468938, 0.0947143166058], 118 [{}, 0.5, 0.0176878183458], 119 119 ] -
sasmodels/models/parallelepiped.py
r2f63032 r5933c7f 7 7 ---------- 8 8 9 | This model calculates the scattering from a rectangular parallelepiped (:numref:`Figure # parallelepiped-image`).9 | This model calculates the scattering from a rectangular parallelepiped (:numref:`Figure #<parallelepiped-image>`). 10 10 | If you need to apply polydispersity, see also :ref:`rectangular-prism`. 11 11 -
sasmodels/models/triaxial_ellipsoid.py
r2f63032 r5933c7f 36 36 we define the axis of the cylinder using the angles $\theta$, $\phi$ 37 37 and $\psi$. These angles are defined on 38 :numref:`figure # triaxial-ellipsoid-angles`.38 :numref:`figure #<triaxial-ellipsoid-angles>`. 39 39 The angle $\psi$ is the rotational angle around its own $c$ axis 40 40 against the $q$ plane. For example, $\psi = 0$ when the -
sasmodels/sesans.py
rd459d4e rd554bd7 27 27 """ 28 28 q_min = dq = 0.1 * 2*pi / Rmax 29 return np.arange(q_min, q_max , dq)29 return np.arange(q_min, q_max[0], dq) 30 30 31 31 def make_all_q(data):
Note: See TracChangeset
for help on using the changeset viewer.