Changeset 3a8d205 in sasmodels
- Timestamp:
- Oct 6, 2016 10:47:23 AM (8 years ago)
- Parents:
- 8b10fdf (diff), aea2e2a (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:
-
- 1 added
- 15 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r41e7f2e rbb2d187 312 312 name = name.split('*')[0] 313 313 314 if name == 'capped_cylinder' and pars[' cap_radius'] < pars['radius']:315 pars['radius'], pars[' cap_radius'] = pars['cap_radius'], pars['radius']316 if name == 'barbell' and pars[' bell_radius'] < pars['radius']:317 pars['radius'], pars[' bell_radius'] = pars['bell_radius'], pars['radius']314 if name == 'capped_cylinder' and pars['radius_cap'] < pars['radius']: 315 pars['radius'], pars['radius_cap'] = pars['radius_cap'], pars['radius'] 316 if name == 'barbell' and pars['radius_bell'] < pars['radius']: 317 pars['radius'], pars['radius_bell'] = pars['radius_bell'], pars['radius'] 318 318 319 319 # Limit guinier to an Rg such that Iq > 1e-30 (single precision cutoff) -
sasmodels/models/adsorbed_layer.py
r52ec91e rb0c4271 1 #adsorbed_layer model 2 #conversion of Core2ndMomentModel.py 3 #converted by Steve King, Mar 2016 1 r""" 2 Definition 3 ---------- 4 4 5 r"""6 5 This model describes the scattering from a layer of surfactant or polymer 7 6 adsorbed on large, smooth, notionally spherical particles under the conditions … … 19 18 the mean of the density distribution (ie, the distance of the centre-of-mass 20 19 of the distribution from the interface), $\sigma = \sqrt{t^2/12}$. 21 22 Definition23 ----------24 20 25 21 .. math:: … … 44 40 calculation is exact). 45 41 42 The code for this model is based originally on a a fortran implementation by 43 Steve King at ISIS in the SANDRA package c. 1990. 44 46 45 References 47 46 ---------- 48 47 49 S King, P Griffiths, J Hone, and T Cosgrove, 50 *SANS from Adsorbed Polymer Layers*, *Macromol. Symp.*, 190 (2002) 33-42. 48 .. [#] S King, P Griffiths, J Hone, and T Cosgrove, *SANS from Adsorbed Polymer 49 Layers*, *Macromol. Symp.*, 190 (2002) 33-42. 50 51 Authorship and Verification 52 ---------------------------- 53 54 * **Author:** Jae-Hi Cho **Date:** pre 2010 55 * **Last Modified by:** Paul Kienzle **Date:** April 14, 2016 56 * **Last Reviewed by:** Steve King **Date:** March 18, 2016 51 57 """ 52 58 … … 80 86 def Iq(q, second_moment, adsorbed_amount, density_shell, radius, 81 87 volfraction, sld_shell, sld_solvent): 82 # pylint: disable = missing-docstring83 #deltarhosqrd = (sld_shell - sld_solvent) * (sld_shell - sld_solvent)84 #numerator = 6.0 * pi * volfraction * (adsorbed_amount * adsorbed_amount)85 #denominator = (q * q) * (density_shell * density_shell) * radius86 #eterm = exp(-1.0 * (q * q) * (second_moment * second_moment))87 ##scale by 10^-2 for units conversion to cm^-188 #inten = 1.0e-02 * deltarhosqrd * ((numerator / denominator) * eterm)89 88 with errstate(divide='ignore'): 90 89 aa = ((sld_shell - sld_solvent)/density_shell * adsorbed_amount) / q -
sasmodels/models/barbell.py
r2222134 rb0c4271 1 #barbell model2 # Note: model title and parameter table are inserted automatically3 1 r""" 2 Definition 3 ---------- 4 4 5 Calculates the scattering from a barbell-shaped cylinder. Like 5 6 :ref:`capped-cylinder`, this is a sphereocylinder with spherical end … … 7 8 of the end cap radius lying outside of the cylinder. See the diagram for 8 9 the details of the geometry and restrictions on parameter values. 9 10 Definition11 ----------12 10 13 11 .. figure:: img/barbell_geometry.jpg … … 75 73 76 74 .. figure:: img/cylinder_angle_projection.jpg 75 :width: 600px 77 76 78 77 Examples of the angles for oriented pp against the detector plane. … … 81 80 ---------- 82 81 83 H Kaya, *J. Appl. Cryst.*, 37 (2004) 37 223-230 82 .. [#] H Kaya, *J. Appl. Cryst.*, 37 (2004) 37 223-230 83 .. [#] H Kaya and N R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda 84 and errata) 84 85 85 H Kaya and N R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata) 86 Authorship and Verification 87 ---------------------------- 88 89 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 90 * **Last Modified by:** Paul Butler **Date:** March 20, 2016 91 * **Last Reviewed by:** Paul Butler **Date:** March 20, 2016 86 92 """ 87 93 from numpy import inf -
sasmodels/models/bcc_paracrystal.py
r0bef47b rb0c4271 1 #bcc paracrystal model2 #note model title and parameter table are automatically inserted3 #note - calculation requires double precision4 1 r""" 2 Definition 3 ---------- 4 5 5 Calculates the scattering from a **body-centered cubic lattice** with 6 6 paracrystalline distortion. Thermal vibrations are considered to be negligible, 7 7 and the size of the paracrystal is infinitely large. Paracrystalline distortion 8 8 is assumed to be isotropic and characterized by a Gaussian distribution. 9 10 Definition11 ----------12 9 13 10 The scattering intensity $I(q)$ is calculated as … … 23 20 is the paracrystalline structure factor for a body-centered cubic structure. 24 21 25 Equation (1) of the 1990 reference is used to calculate $Z(q)$, using 26 equations (29)-(31) from the 1987 paper for $Z1$, $Z2$, and $Z3$. 22 Equation (1) of the 1990 reference\ [#CIT1990]_ is used to calculate $Z(q)$, 23 using equations (29)-(31) from the 1987 paper\ [#CIT1987]_ for $Z1$, $Z2$, and 24 $Z3$. 27 25 28 26 The lattice correction (the occupied volume of the lattice) for a … … 79 77 The 2D (Anisotropic model) is based on the reference below where $I(q)$ is 80 78 approximated for 1d scattering. Thus the scattering pattern for 2D may not 81 be accurate. Note that we are not responsible for any incorrectness of the 2D 82 model computation. 79 be accurate. 83 80 84 81 .. figure:: img/bcc_angle_definition.png … … 89 86 ---------- 90 87 91 Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 92 (Original Paper) 88 .. [#CIT1987] Hideki Matsuoka et. al. *Physical Review B*, 36 (1987) 1754-1765 89 (Original Paper) 90 .. [#CIT1990] Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856 91 (Corrections to FCC and BCC lattice structure calculation) 93 92 94 Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856 95 (Corrections to FCC and BCC lattice structure calculation) 93 Authorship and Verification 94 ---------------------------- 95 96 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 97 * **Last Modified by:** Paul Butler **Date:** September 29, 2016 98 * **Last Reviewed by:** Richard Heenan **Date:** March 21, 2016 96 99 """ 97 100 … … 109 112 category = "shape:paracrystal" 110 113 114 #note - calculation requires double precision 111 115 single = False 112 116 -
sasmodels/models/be_polyelectrolyte.py
r2c74c11 rb0c4271 1 1 r""" 2 This model calculates the structure factor of a polyelectrolyte solution with3 the RPA expression derived by Borue and Erukhimovich.4 5 2 Definition 6 3 ---------- 7 8 The scattering intensity $I(q)$ is calculated as 4 This model calculates the structure factor of a polyelectrolyte solution with 5 the RPA expression derived by Borue and Erukhimovich\ [#Borue]_. The scattering intensity 6 $I(q)$ is calculated as 9 7 10 8 .. math:: … … 36 34 ---------- 37 35 38 V Y Borue, I Y Erukhimovich, *Macromolecules*, 21 (1988) 3240 36 .. [#Borue] V Y Borue, I Y Erukhimovich, *Macromolecules*, 21 (1988) 3240 37 .. [#] J F Joanny, L Leibler, *Journal de Physique*, 51 (1990) 545 38 .. [#] A Moussaid, F Schosseler, J P Munch, S Candau, *J. Journal de Physique 39 II France*, 3 (1993) 573 40 .. [#] E Raphael, J F Joanny, *Europhysics Letters*, 11 (1990) 179 39 41 40 J F Joanny, L Leibler, *Journal de Physique*, 51 (1990) 545 42 Authorship and Verification 43 ---------------------------- 41 44 42 A Moussaid, F Schosseler, J P Munch, S Candau, 43 *J. Journal de Physique II France*, 3 (1993) 573 44 45 E Raphael, J F Joanny, *Europhysics Letters*, 11 (1990) 179 46 45 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 46 * **Last Modified by:** Paul Kienzle **Date:** July 24, 2016 47 * **Last Reviewed by:** Piotr rozyczko **Date:** January 27, 2016 47 48 """ 48 49 -
sasmodels/models/binary_hard_sphere.py
r63c6a08 rb0c4271 1 1 r""" 2 3 2 Definition 4 3 ---------- 4 5 5 The binary hard sphere model provides the scattering intensity, for binary 6 6 mixture of hard spheres including hard sphere interaction between those … … 61 61 ---------- 62 62 63 N W Ashcroft and D C Langreth, *Physical Review*, 156 (1967) 685-692 64 [Errata found in *Phys. Rev.* 166 (1968) 934] 63 .. [#] N W Ashcroft and D C Langreth, *Physical Review*, 156 (1967) 685-692 64 [Errata found in *Phys. Rev.* 166 (1968) 934] 65 .. [#] S R Kline, *J Appl. Cryst.*, 39 (2006) 895 65 66 66 S R Kline, *J Appl. Cryst.*, 39 (2006) 895 67 Authorship and Verification 68 ---------------------------- 67 69 68 **Author:** NIST IGOR/DANSE **on:** pre 2010 69 70 **Last Modified by:** Paul Butler **on:** March 20, 2016 71 72 **Last Reviewed by:** Paul Butler **on:** March 20, 2016 70 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 71 * **Last Modified by:** Paul Butler **Date:** March 20, 2016 72 * **Last Reviewed by:** Paul Butler **Date:** March 20, 2016 73 73 """ 74 74 -
sasmodels/models/broad_peak.py
r40a87fa rb0c4271 1 1 r""" 2 Definition 3 ---------- 4 2 5 This model calculates an empirical functional form for SAS data characterized 3 6 by a broad scattering peak. Many SAS spectra are characterized by a broad peak … … 9 12 between the scattering inhomogeneities (such as in lamellar, cylindrical, or 10 13 spherical morphologies, or for bicontinuous structures). 11 12 Definition13 ----------14 14 15 15 The scattering intensity $I(q)$ is calculated as … … 33 33 None. 34 34 35 *2013/09/09 - Description reviewed by King, S and Parker, P.* 35 Authorship and Verification 36 ---------------------------- 37 38 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 39 * **Last Modified by:** Paul kienle **Date:** July 24, 2016 40 * **Last Reviewed by:** Richard Heenan **Date:** March 21, 2016 36 41 """ 37 42 -
sasmodels/models/capped_cylinder.py
r2222134 rb0c4271 1 1 r""" 2 Definitions 3 ----------- 4 2 5 Calculates the scattering from a cylinder with spherical section end-caps. 3 6 Like :ref:`barbell`, this is a sphereocylinder with end caps that have a … … 6 9 lens when the length of the cylinder $L=0$. See the diagram for the details 7 10 of the geometry and restrictions on parameter values. 8 9 Definitions10 -----------11 11 12 12 .. figure:: img/capped_cylinder_geometry.jpg … … 76 76 77 77 .. figure:: img/cylinder_angle_projection.jpg 78 :width: 600px 78 79 79 80 Examples of the angles for oriented 2D cylinders against the detector plane. … … 82 83 ---------- 83 84 84 H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230 85 .. [#] H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230 86 .. [#] H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda 87 and errata) 85 88 86 H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata) 89 Authorship and Verification 90 ---------------------------- 91 92 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 93 * **Last Modified by:** Paul Butler **Date:** September 30, 2016 94 * **Last Reviewed by:** Richard Heenan **Date:** March 19, 2016 87 95 """ 88 96 from numpy import inf -
sasmodels/models/core_multi_shell.py
r7b68dc5 rb0c4271 33 33 References 34 34 ---------- 35 See the :ref:`core-shell-sphere` model documentation.36 35 37 L A Feigin and D I Svergun, 38 *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*,39 Plenum Press, New York, 1987.36 .. [#] See the :ref:`core-shell-sphere` model documentation. 37 .. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and Neutron Scattering*, 38 Plenum Press, New York, 1987. 40 39 41 **Author:** NIST IGOR/DANSE **on:** pre 2010 40 Authorship and Verification 41 ---------------------------- 42 42 43 * *Last Modified by:** in progress **on:** March 20, 201644 45 * *Last Reviewed by:** in progress **on:** March 20, 201643 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 44 * **Last Modified by:** Paul Kienzle **Date:** September 12, 2016 45 * **Last Reviewed by:** Under Review **Date:** as of October 5, 2016 46 46 """ 47 47 -
sasmodels/models/core_shell_bicelle.py
r2222134 rb0c4271 1 1 r""" 2 3 2 Definition 4 3 ---------- … … 13 12 .. figure:: img/core_shell_bicelle_geometry.png 14 13 15 (Graphic from DOI: 10.1039/C0NP00002G, note however that the model here16 calculates for rectangular, not curved, rims.)14 Core shell geometry (Graphic from ref [#Matusmori]_). 15 Note however that the model here calculates for rectangular, not curved, rims. 17 16 18 17 The output of the 1D scattering intensity function for randomly oriented … … 28 27 29 28 .. figure:: img/cylinder_angle_projection.jpg 29 :width: 600px 30 30 31 31 Examples of the angles for oriented pp against the detector plane. … … 34 34 ---------- 35 35 36 L A Feigin and D I Svergun, 37 *Structure Analysis by Small-Angle X-Ray and Neutron Scattering,* 38 Plenum Press, New York, (1987) 36 .. [#Matusmori] `N Matsumori and M Murata <http://dx.doi.org/10.1039/C0NP0000 37 2G>`_, *Nat. Prod. Rep.* 27 (2010) 1480-1492 38 .. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 39 Neutron Scattering,* Plenum Press, New York, (1987) 40 41 Authorship and Verification 42 ---------------------------- 43 44 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 45 * **Last Modified by:** Paul Butler **Date:** Septmber 30, 2016 46 * **Last Reviewed by:** Under Review **Date:** October 5, 2016 39 47 40 48 """ -
sasmodels/models/hollow_cylinder.c
ra807206 raea2e2a 1 double form_volume(double radius, double radius_core, double length);1 double form_volume(double radius, double thickness, double length); 2 2 3 double Iq(double q, double radius, double radius_core, double length, double sld,3 double Iq(double q, double radius, double thickness, double length, double sld, 4 4 double solvent_sld); 5 double Iqxy(double qx, double qy, double radius, double radius_core, double length, double sld,5 double Iqxy(double qx, double qy, double radius, double thickness, double length, double sld, 6 6 double solvent_sld, double theta, double phi); 7 7 8 #define INVALID(v) (v.radius_core >= v.radius)8 //#define INVALID(v) (v.radius_core >= v.radius) 9 9 10 10 // From Igor library … … 27 27 28 28 static double _hollow_cylinder_kernel( 29 double q, double radius _core, double radius, double length, double dum)29 double q, double radius, double thickness, double length, double dum) 30 30 { 31 31 const double qs = q*sqrt(1.0-dum*dum); 32 const double lam1 = sas_J1c( radius*qs);33 const double lam2 = sas_J1c(radius _core*qs);34 const double gamma_sq = square(radius _core/radius);32 const double lam1 = sas_J1c((radius+thickness)*qs); 33 const double lam2 = sas_J1c(radius*qs); 34 const double gamma_sq = square(radius/(radius+thickness)); 35 35 //Note: lim_{r -> r_c} psi = J0(radius_core*qs) 36 36 const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 … … 41 41 42 42 static double hollow_cylinder_analytical_2D_scaled( 43 double q, double q_x, double q_y, double radius, double radius_core,43 double q, double q_x, double q_y, double radius, double thickness, 44 44 double length, double sld, double solvent_sld, double theta, double phi) 45 45 { … … 65 65 cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 66 66 67 answer = _hollow_cylinder_kernel(q, radius _core, radius, length, cos_val);67 answer = _hollow_cylinder_kernel(q, radius, thickness, length, cos_val); 68 68 69 vol = form_volume(radius, radius_core, length);69 vol = form_volume(radius, thickness, length); 70 70 answer = hollow_cylinder_scaling(answer, delrho, vol); 71 71 … … 74 74 75 75 76 double form_volume(double radius, double radius_core, double length)76 double form_volume(double radius, double thickness, double length) 77 77 { 78 double v_shell = M_PI*length*( radius*radius-radius_core*radius_core);78 double v_shell = M_PI*length*((radius+thickness)*(radius+thickness)-radius*radius); 79 79 return(v_shell); 80 80 } 81 81 82 82 83 double Iq(double q, double radius, double radius_core, double length,83 double Iq(double q, double radius, double thickness, double length, 84 84 double sld, double solvent_sld) 85 85 { … … 95 95 for (i=0;i<76;i++) { 96 96 zi = ( Gauss76Z[i] * (upper-lower) + lower + upper )/2.0; 97 inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, radius _core, radius, length, zi);97 inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, radius, thickness, length, zi); 98 98 summ += inter; 99 99 } 100 100 101 101 norm = summ*(upper-lower)/2.0; 102 volume = form_volume(radius, radius_core, length);102 volume = form_volume(radius, thickness, length); 103 103 delrho = solvent_sld - sld; 104 104 answer = hollow_cylinder_scaling(norm, delrho, volume); … … 108 108 109 109 110 double Iqxy(double qx, double qy, double radius, double radius_core,110 double Iqxy(double qx, double qy, double radius, double thickness, 111 111 double length, double sld, double solvent_sld, double theta, double phi) 112 112 { 113 113 const double q = sqrt(qx*qx+qy*qy); 114 return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, radius_core, length, sld, solvent_sld, theta, phi);114 return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, thickness, length, sld, solvent_sld, theta, phi); 115 115 } -
sasmodels/models/hollow_cylinder.py
ra807206 raea2e2a 1 1 r""" 2 2 This model provides the form factor, $P(q)$, for a monodisperse hollow right 3 angle circular cylinder ( tube) where the form factor is normalized by the4 volume of the tube 3 angle circular cylinder (rigid tube) where the form factor is normalized by the 4 volume of the tube (i.e. not by the external volume). 5 5 6 6 .. math:: … … 21 21 P(q) &= (\text{scale})V_\text{shell}\Delta\rho^2 22 22 \int_0^{1}\Psi^2 23 \left[q_z, R_\text{ shell}(1-x^2)^{1/2},23 \left[q_z, R_\text{outer}(1-x^2)^{1/2}, 24 24 R_\text{core}(1-x^2)^{1/2}\right] 25 25 \left[\frac{\sin(qHx)}{qHx}\right]^2 dx \\ … … 27 27 \left[ \Lambda(qy) - \gamma^2\Lambda(qz) \right] \\ 28 28 \Lambda(a) &= 2 J_1(a) / a \\ 29 \gamma &= R_\text{core} / R_\text{ shell} \\30 V_\text{shell} &= \pi \left(R_\text{ shell}^2 - R_\text{core}^2 \right)L \\29 \gamma &= R_\text{core} / R_\text{outer} \\ 30 V_\text{shell} &= \pi \left(R_\text{outer}^2 - R_\text{core}^2 \right)L \\ 31 31 J_1(x) &= (\sin(x)-x\cdot \cos(x)) / x^2 32 32 … … 35 35 36 36 **NB**: The 2nd virial coefficient of the cylinder is calculated 37 based on the radius and 2 length values, and used asthe effective radius38 for $S(q)$ when $P(q) \cdot S(q)$ is applied.37 based on the outer radius and full length, which give an the effective radius 38 for structure factor $S(q)$ when $P(q) \cdot S(q)$ is applied. 39 39 40 In the parameters, the contrast represents SLD :sub:`shell` - SLD :sub:`solvent` 41 and the *radius* is $R_\text{shell}$ while *radius_core* is $R_\text{core}$. 40 In the parameters,the *radius* is $R_\text{core}$ while *thickness* is $R_\text{outer} - R_\text{core}$. 42 41 43 42 To provide easy access to the orientation of the core-shell cylinder, we define … … 50 49 L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 51 50 Neutron Scattering*, Plenum Press, New York, (1987) 51 52 Authorship and Verification 53 ---------------------------- 54 55 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 56 * **Last Modified by:** Richard Heenan **Date:** October 06, 2016 57 (reparametrised to use thickness, not outer radius) 58 * **Last Reviewed by:** Richard Heenan **Date:** October 06, 2016 59 52 60 """ 53 61 … … 58 66 description = """ 59 67 P(q) = scale*<f*f>/Vol + background, where f is the scattering amplitude. 60 radius _core= the radius of core61 radius = the radius of shell68 radius = the radius of core 69 thickness = the thickness of shell 62 70 length = the total length of the cylinder 63 71 sld = SLD of the shell … … 69 77 # ["name", "units", default, [lower, upper], "type","description"], 70 78 parameters = [ 71 ["radius", "Ang", 30.0, [0, inf], "volume", "Cylinderradius"],72 [" radius_core", "Ang", 20.0, [0, inf], "volume", "Hollow core radius"],73 ["length", "Ang", 400.0, [0, inf], "volume", "Cylinder length"],79 ["radius", "Ang", 20.0, [0, inf], "volume", "Cylinder core radius"], 80 ["thickness", "Ang", 10.0, [0, inf], "volume", "Cylinder wall thickness"], 81 ["length", "Ang", 400.0, [0, inf], "volume", "Cylinder total length"], 74 82 ["sld", "1/Ang^2", 6.3, [-inf, inf], "sld", "Cylinder sld"], 75 83 ["sld_solvent", "1/Ang^2", 1, [-inf, inf], "sld", "Solvent sld"], … … 82 90 83 91 # pylint: disable=W0613 84 def ER(radius, radius_core, length):92 def ER(radius, thickness, length): 85 93 """ 86 :param radius: Cylinder radius87 :param radius_core: Hollow core radius, UNUSED94 :param radius: Cylinder core radius 95 :param thickness: Cylinder wall thickness 88 96 :param length: Cylinder length 89 97 :return: Effective radius 90 98 """ 91 if radius == 0 or length == 0: 99 router = radius + thickness 100 if router == 0 or length == 0: 92 101 return 0.0 93 len1 = r adius102 len1 = router 94 103 len2 = length/2.0 95 104 term1 = len1*len1*2.0*len2/2.0 … … 99 108 return diam 100 109 101 def VR(radius, radius_core, length):110 def VR(radius, thickness, length): 102 111 """ 103 112 :param radius: Cylinder radius 104 :param radius_core: Hollow core radius113 :param thickness: Cylinder wall thickness 105 114 :param length: Cylinder length 106 115 :return: Volf ratio for P(q)*S(q) 107 116 """ 108 vol_core = pi*radius_core*radius_core*length 109 vol_total = pi*radius*radius*length 117 router = radius + thickness 118 vol_core = pi*radius*radius*length 119 vol_total = pi*router*router*length 110 120 vol_shell = vol_total - vol_core 111 121 return vol_shell, vol_total 112 122 113 123 # parameters for demo 114 demo = dict(scale=1.0, background=0.0, length=400.0, radius=30.0, 115 radius_core=20.0, sld=6.3, sld_solvent=1, theta=90, phi=0, 124 demo = dict(scale=1.0, background=0.0, length=400.0, radius=20.0, 125 thickness=10, sld=6.3, sld_solvent=1, theta=90, phi=0, 126 thickness_pd=0.2, thickness_pd_n=9, 127 length_pd=.2, length_pd_n=10, 116 128 radius_pd=.2, radius_pd_n=9, 117 length_pd=.2, length_pd_n=10,118 radius_core_pd=.2, radius_core_pd_n=9,119 129 theta_pd=10, theta_pd_n=5, 120 130 ) … … 122 132 # Parameters for unit tests 123 133 tests = [ 124 [{ "radius": 30.0}, 0.00005, 1764.926],134 [{}, 0.00005, 1764.926], 125 135 [{}, 'VR', 1.8], 126 136 [{}, 0.001, 1756.76] -
doc/ref/gpu_computations.rst
r1875f4e r0c1e5a9 1 1 .. _models-complitation: 2 2 3 **************** **4 Models Compliation 5 **************** **3 **************** 4 GPU Computations 5 **************** 6 6 SasView model evaluations can run on your graphics card (GPU) or they can run 7 7 on the processor (CPU). 8 8 9 9 To run on the GPU, your computer must have OpenCL drivers installed. 10 11 ... give details on how to identify graphics cards, how to tell if OpenCL 12 is already installed and where to get drivers if it is not ... 13 14 Note that Intel provides an OpenCL drivers for Intel processors. 15 This can sometimes make use of special vector instructions across multiple 16 processors, so it is worth installing if the GPU does not support double 17 precision. 18 You can install this driver alongside the GPU driver for NVIDIA or AMD. 10 For information about OpenCL installation see the 11 :ref:`opencl-installation` documentation 19 12 20 13 Where the model is evaluated is a little bit complicated. -
doc/ref/index.rst
r1875f4e r0c1e5a9 9 9 intro.rst 10 10 refs.rst 11 compilation.rst11 gpu_computations.rst 12 12 magnetism/magnetism.rst -
sasmodels/kerneldll.py
r3764ec1 r8b10fdf 73 73 import tempfile 74 74 import ctypes as ct # type: ignore 75 from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float # type: ignore 75 import _ctypes as _ct 76 76 import logging 77 77 … … 111 111 compiler = "unix" 112 112 113 ARCH = "" if ct.sizeof(c _void_p) > 4 else "x86" # 4 byte pointers on x86113 ARCH = "" if ct.sizeof(ct.c_void_p) > 4 else "x86" # 4 byte pointers on x86 114 114 if compiler == "unix": 115 115 # Generic unix compile … … 241 241 if not os.path.exists(dll): 242 242 need_recompile = True 243 elif getattr(sys, 'frozen', None) is not None:244 # TODO: don't suppress time stamp245 # Currently suppressing recompile when running in a frozen environment246 need_recompile = False247 243 else: 248 244 dll_time = os.path.getmtime(dll) … … 301 297 def _load_dll(self): 302 298 # type: () -> None 303 #print("dll", self.dllpath)304 299 try: 305 300 self._dll = ct.CDLL(self.dllpath) … … 308 303 raise 309 304 310 float_type = (c _float if self.dtype == generate.F32311 else c _double if self.dtype == generate.F64312 else c _longdouble)305 float_type = (ct.c_float if self.dtype == generate.F32 306 else ct.c_double if self.dtype == generate.F64 307 else ct.c_longdouble) 313 308 314 309 # int, int, int, int*, double*, double*, double*, double*, double 315 argtypes = [c _int32]*3 + [c_void_p]*4 + [float_type]310 argtypes = [ct.c_int32]*3 + [ct.c_void_p]*4 + [float_type] 316 311 names = [generate.kernel_name(self.info, variant) 317 312 for variant in ("Iq", "Iqxy", "Imagnetic")] … … 344 339 Release any resources associated with the model. 345 340 """ 341 dll_handle = self._dll._handle 346 342 if os.name == 'nt': 347 #dll = ct.cdll.LoadLibrary(self.dllpath)348 dll = ct.CDLL(self.dllpath)349 dll_handle = dll._handle350 #dll_handle = ct.c_void_p(dll._handle)351 del dll, self._dll352 self._dll = None353 343 ct.windll.kernel32.FreeLibrary(dll_handle) 354 344 else: 355 pass 356 345 _ct.dlclose(dll_handle) 346 del self._dll 347 self._dll = None 357 348 358 349 class DllKernel(Kernel): … … 411 402 #print("returned",self.q_input.q, self.result) 412 403 pd_norm = self.result[self.q_input.nq] 413 scale = values[0]/(pd_norm if pd_norm !=0.0 else 1.0)404 scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 414 405 background = values[1] 415 406 #print("scale",scale,background) -
sasmodels/sasview_model.py
r9c1a59c r9acbd37 575 575 magnetic=is_magnetic) 576 576 calculator.release() 577 self._model.release() 577 578 return result 578 579
Note: See TracChangeset
for help on using the changeset viewer.