Changeset 3a8d205 in sasmodels


Ignore:
Timestamp:
Oct 6, 2016 10:47:23 AM (5 years ago)
Author:
wojciech
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.
Message:

Merging with master before pull request

Files:
1 added
15 edited
1 moved

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    r41e7f2e rbb2d187  
    312312        name = name.split('*')[0] 
    313313 
    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'] 
    318318 
    319319    # 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 
     1r""" 
     2Definition 
     3---------- 
    44 
    5 r""" 
    65This model describes the scattering from a layer of surfactant or polymer 
    76adsorbed on large, smooth, notionally spherical particles under the conditions 
     
    1918the mean of the density distribution (ie, the distance of the centre-of-mass 
    2019of the distribution from the interface), $\sigma = \sqrt{t^2/12}$. 
    21  
    22 Definition 
    23 ---------- 
    2420 
    2521.. math:: 
     
    4440calculation is exact). 
    4541 
     42The code for this model is based originally on a a fortran implementation by 
     43Steve King at ISIS in the SANDRA package c. 1990. 
     44 
    4645References 
    4746---------- 
    4847 
    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 
     51Authorship 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 
    5157""" 
    5258 
     
    8086def Iq(q, second_moment, adsorbed_amount, density_shell, radius, 
    8187       volfraction, sld_shell, sld_solvent): 
    82     # pylint: disable = missing-docstring 
    83     #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) * radius 
    86     #eterm =  exp(-1.0 * (q * q) * (second_moment * second_moment)) 
    87     ##scale by 10^-2 for units conversion to cm^-1 
    88     #inten =  1.0e-02 * deltarhosqrd * ((numerator / denominator) * eterm) 
    8988    with errstate(divide='ignore'): 
    9089        aa = ((sld_shell - sld_solvent)/density_shell * adsorbed_amount) / q 
  • sasmodels/models/barbell.py

    r2222134 rb0c4271  
    1 #barbell model 
    2 # Note: model title and parameter table are inserted automatically 
    31r""" 
     2Definition 
     3---------- 
     4 
    45Calculates the scattering from a barbell-shaped cylinder.  Like 
    56:ref:`capped-cylinder`, this is a sphereocylinder with spherical end 
     
    78of the end cap radius lying outside of the cylinder. See the diagram for 
    89the details of the geometry and restrictions on parameter values. 
    9  
    10 Definition 
    11 ---------- 
    1210 
    1311.. figure:: img/barbell_geometry.jpg 
     
    7573 
    7674.. figure:: img/cylinder_angle_projection.jpg 
     75    :width: 600px 
    7776 
    7877    Examples of the angles for oriented pp against the detector plane. 
     
    8180---------- 
    8281 
    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) 
    8485 
    85 H Kaya and N R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata) 
     86Authorship 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 
    8692""" 
    8793from numpy import inf 
  • sasmodels/models/bcc_paracrystal.py

    r0bef47b rb0c4271  
    1 #bcc paracrystal model 
    2 #note model title and parameter table are automatically inserted 
    3 #note - calculation requires double precision 
    41r""" 
     2Definition 
     3---------- 
     4 
    55Calculates the scattering from a **body-centered cubic lattice** with 
    66paracrystalline distortion. Thermal vibrations are considered to be negligible, 
    77and the size of the paracrystal is infinitely large. Paracrystalline distortion 
    88is assumed to be isotropic and characterized by a Gaussian distribution. 
    9  
    10 Definition 
    11 ---------- 
    129 
    1310The scattering intensity $I(q)$ is calculated as 
     
    2320is the paracrystalline structure factor for a body-centered cubic structure. 
    2421 
    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$. 
     22Equation (1) of the 1990 reference\ [#CIT1990]_ is used to calculate $Z(q)$, 
     23using equations (29)-(31) from the 1987 paper\ [#CIT1987]_ for $Z1$, $Z2$, and 
     24$Z3$. 
    2725 
    2826The lattice correction (the occupied volume of the lattice) for a 
     
    7977The 2D (Anisotropic model) is based on the reference below where $I(q)$ is 
    8078approximated 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. 
     79be accurate. 
    8380 
    8481.. figure:: img/bcc_angle_definition.png 
     
    8986---------- 
    9087 
    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) 
    9392 
    94 Hideki Matsuoka et. al. *Physical Review B*, 41 (1990) 3854 -3856 
    95 (Corrections to FCC and BCC lattice structure calculation) 
     93Authorship 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 
    9699""" 
    97100 
     
    109112category = "shape:paracrystal" 
    110113 
     114#note - calculation requires double precision 
    111115single = False 
    112116 
  • sasmodels/models/be_polyelectrolyte.py

    r2c74c11 rb0c4271  
    11r""" 
    2 This model calculates the structure factor of a polyelectrolyte solution with 
    3 the RPA expression derived by Borue and Erukhimovich. 
    4  
    52Definition 
    63---------- 
    7  
    8 The scattering intensity $I(q)$ is calculated as 
     4This model calculates the structure factor of a polyelectrolyte solution with 
     5the RPA expression derived by Borue and Erukhimovich\ [#Borue]_.  The scattering intensity 
     6$I(q)$ is calculated as 
    97 
    108.. math:: 
     
    3634---------- 
    3735 
    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 
    3941 
    40 J F Joanny, L Leibler, *Journal de Physique*, 51 (1990) 545 
     42Authorship and Verification 
     43---------------------------- 
    4144 
    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 
    4748""" 
    4849 
  • sasmodels/models/binary_hard_sphere.py

    r63c6a08 rb0c4271  
    11r""" 
    2  
    32Definition 
    43---------- 
     4 
    55The binary hard sphere model provides the scattering intensity, for binary 
    66mixture of hard spheres including hard sphere interaction between those 
     
    6161---------- 
    6262 
    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 
    6566 
    66 S R Kline, *J Appl. Cryst.*, 39 (2006) 895 
     67Authorship and Verification 
     68---------------------------- 
    6769 
    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 
    7373""" 
    7474 
  • sasmodels/models/broad_peak.py

    r40a87fa rb0c4271  
    11r""" 
     2Definition 
     3---------- 
     4 
    25This model calculates an empirical functional form for SAS data characterized 
    36by a broad scattering peak. Many SAS spectra are characterized by a broad peak 
     
    912between the scattering inhomogeneities (such as in lamellar, cylindrical, or 
    1013spherical morphologies, or for bicontinuous structures). 
    11  
    12 Definition 
    13 ---------- 
    1414 
    1515The scattering intensity $I(q)$ is calculated as 
     
    3333None. 
    3434 
    35 *2013/09/09 - Description reviewed by King, S and Parker, P.* 
     35Authorship 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 
    3641""" 
    3742 
  • sasmodels/models/capped_cylinder.py

    r2222134 rb0c4271  
    11r""" 
     2Definitions 
     3----------- 
     4 
    25Calculates the scattering from a cylinder with spherical section end-caps. 
    36Like :ref:`barbell`, this is a sphereocylinder with end caps that have a 
     
    69lens when the length of the cylinder $L=0$. See the diagram for the details 
    710of the geometry and restrictions on parameter values. 
    8  
    9 Definitions 
    10 ----------- 
    1111 
    1212.. figure:: img/capped_cylinder_geometry.jpg 
     
    7676 
    7777.. figure:: img/cylinder_angle_projection.jpg 
     78    :width: 600px 
    7879 
    7980    Examples of the angles for oriented 2D cylinders against the detector plane. 
     
    8283---------- 
    8384 
    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) 
    8588 
    86 H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata) 
     89Authorship 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 
    8795""" 
    8896from numpy import inf 
  • sasmodels/models/core_multi_shell.py

    r7b68dc5 rb0c4271  
    3333References 
    3434---------- 
    35 See the :ref:`core-shell-sphere` model documentation. 
    3635 
    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. 
    4039 
    41 **Author:** NIST IGOR/DANSE **on:** pre 2010 
     40Authorship and Verification 
     41---------------------------- 
    4242 
    43 **Last Modified by:** in progress **on:** March 20, 2016 
    44  
    45 **Last Reviewed by:** in progress **on:** March 20, 2016 
     43* **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 
    4646""" 
    4747 
  • sasmodels/models/core_shell_bicelle.py

    r2222134 rb0c4271  
    11r""" 
    2  
    32Definition 
    43---------- 
     
    1312.. figure:: img/core_shell_bicelle_geometry.png 
    1413 
    15     (Graphic from DOI: 10.1039/C0NP00002G, note however that the model here 
    16     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. 
    1716 
    1817The output of the 1D scattering intensity function for randomly oriented 
     
    2827 
    2928.. figure:: img/cylinder_angle_projection.jpg 
     29    :width: 600px 
    3030 
    3131    Examples of the angles for oriented pp against the detector plane. 
     
    3434---------- 
    3535 
    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 
     41Authorship 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 
    3947 
    4048""" 
  • sasmodels/models/hollow_cylinder.c

    ra807206 raea2e2a  
    1 double form_volume(double radius, double radius_core, double length); 
     1double form_volume(double radius, double thickness, double length); 
    22 
    3 double Iq(double q, double radius, double radius_core, double length, double sld, 
     3double Iq(double q, double radius, double thickness, double length, double sld, 
    44        double solvent_sld); 
    5 double Iqxy(double qx, double qy, double radius, double radius_core, double length, double sld, 
     5double Iqxy(double qx, double qy, double radius, double thickness, double length, double sld, 
    66        double solvent_sld, double theta, double phi); 
    77 
    8 #define INVALID(v) (v.radius_core >= v.radius) 
     8//#define INVALID(v) (v.radius_core >= v.radius) 
    99 
    1010// From Igor library 
     
    2727 
    2828static 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) 
    3030{ 
    3131    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)); 
    3535    //Note: lim_{r -> r_c} psi = J0(radius_core*qs) 
    3636    const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 
     
    4141 
    4242static 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, 
    4444    double length, double sld, double solvent_sld, double theta, double phi) 
    4545{ 
     
    6565    cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 
    6666 
    67     answer = _hollow_cylinder_kernel(q, radius_core, radius, length, cos_val); 
     67    answer = _hollow_cylinder_kernel(q, radius, thickness, length, cos_val); 
    6868 
    69     vol = form_volume(radius, radius_core, length); 
     69    vol = form_volume(radius, thickness, length); 
    7070    answer = hollow_cylinder_scaling(answer, delrho, vol); 
    7171 
     
    7474 
    7575 
    76 double form_volume(double radius, double radius_core, double length) 
     76double form_volume(double radius, double thickness, double length) 
    7777{ 
    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); 
    7979    return(v_shell); 
    8080} 
    8181 
    8282 
    83 double Iq(double q, double radius, double radius_core, double length, 
     83double Iq(double q, double radius, double thickness, double length, 
    8484    double sld, double solvent_sld) 
    8585{ 
     
    9595    for (i=0;i<76;i++) { 
    9696        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); 
    9898        summ += inter; 
    9999    } 
    100100 
    101101    norm = summ*(upper-lower)/2.0; 
    102     volume = form_volume(radius, radius_core, length); 
     102    volume = form_volume(radius, thickness, length); 
    103103    delrho = solvent_sld - sld; 
    104104    answer = hollow_cylinder_scaling(norm, delrho, volume); 
     
    108108 
    109109 
    110 double Iqxy(double qx, double qy, double radius, double radius_core, 
     110double Iqxy(double qx, double qy, double radius, double thickness, 
    111111    double length, double sld, double solvent_sld, double theta, double phi) 
    112112{ 
    113113    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); 
    115115} 
  • sasmodels/models/hollow_cylinder.py

    ra807206 raea2e2a  
    11r""" 
    22This model provides the form factor, $P(q)$, for a monodisperse hollow right 
    3 angle circular cylinder (tube) where the form factor is normalized by the 
    4 volume of the tube 
     3angle circular cylinder (rigid tube) where the form factor is normalized by the 
     4volume of the tube (i.e. not by the external volume). 
    55 
    66.. math:: 
     
    2121    P(q)           &= (\text{scale})V_\text{shell}\Delta\rho^2 
    2222            \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}, 
    2424                       R_\text{core}(1-x^2)^{1/2}\right] 
    2525            \left[\frac{\sin(qHx)}{qHx}\right]^2 dx \\ 
     
    2727            \left[ \Lambda(qy) - \gamma^2\Lambda(qz) \right] \\ 
    2828    \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 \\ 
    3131    J_1(x)         &= (\sin(x)-x\cdot \cos(x)) / x^2 
    3232 
     
    3535 
    3636**NB**: The 2nd virial coefficient of the cylinder is calculated 
    37 based on the radius and 2 length values, and used as the effective radius 
    38 for $S(q)$ when $P(q) \cdot S(q)$ is applied. 
     37based on the outer radius and full length, which give an the effective radius 
     38for structure factor $S(q)$ when $P(q) \cdot S(q)$ is applied. 
    3939 
    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}$. 
     40In the parameters,the *radius* is $R_\text{core}$ while *thickness* is $R_\text{outer} - R_\text{core}$. 
    4241 
    4342To provide easy access to the orientation of the core-shell cylinder, we define 
     
    5049L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
    5150Neutron Scattering*, Plenum Press, New York, (1987) 
     51 
     52Authorship 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 
    5260""" 
    5361 
     
    5866description = """ 
    5967P(q) = scale*<f*f>/Vol + background, where f is the scattering amplitude. 
    60 radius_core = the radius of core 
    61 radius = the radius of shell 
     68radius = the radius of core 
     69thickness = the thickness of shell 
    6270length = the total length of the cylinder 
    6371sld = SLD of the shell 
     
    6977#   ["name", "units", default, [lower, upper], "type","description"], 
    7078parameters = [ 
    71     ["radius",      "Ang",     30.0, [0, inf],    "volume",      "Cylinder radius"], 
    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"], 
    7482    ["sld",         "1/Ang^2",  6.3, [-inf, inf], "sld",         "Cylinder sld"], 
    7583    ["sld_solvent", "1/Ang^2",  1,   [-inf, inf], "sld",         "Solvent sld"], 
     
    8290 
    8391# pylint: disable=W0613 
    84 def ER(radius, radius_core, length): 
     92def ER(radius, thickness, length): 
    8593    """ 
    86     :param radius:      Cylinder radius 
    87     :param radius_core: Hollow core radius, UNUSED 
     94    :param radius:      Cylinder core radius 
     95    :param thickness:   Cylinder wall thickness 
    8896    :param length:      Cylinder length 
    8997    :return:            Effective radius 
    9098    """ 
    91     if radius == 0 or length == 0: 
     99    router = radius + thickness 
     100    if router == 0 or length == 0: 
    92101        return 0.0 
    93     len1 = radius 
     102    len1 = router 
    94103    len2 = length/2.0 
    95104    term1 = len1*len1*2.0*len2/2.0 
     
    99108    return diam 
    100109 
    101 def VR(radius, radius_core, length): 
     110def VR(radius, thickness, length): 
    102111    """ 
    103112    :param radius:      Cylinder radius 
    104     :param radius_core: Hollow core radius 
     113    :param thickness:   Cylinder wall thickness 
    105114    :param length:      Cylinder length 
    106115    :return:            Volf ratio for P(q)*S(q) 
    107116    """ 
    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 
    110120    vol_shell = vol_total - vol_core 
    111121    return vol_shell, vol_total 
    112122 
    113123# 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, 
     124demo = 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, 
    116128            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, 
    119129            theta_pd=10, theta_pd_n=5, 
    120130           ) 
     
    122132# Parameters for unit tests 
    123133tests = [ 
    124     [{"radius": 30.0}, 0.00005, 1764.926], 
     134    [{}, 0.00005, 1764.926], 
    125135    [{}, 'VR', 1.8], 
    126136    [{}, 0.001, 1756.76] 
  • doc/ref/gpu_computations.rst

    r1875f4e r0c1e5a9  
    11.. _models-complitation: 
    22 
    3 ****************** 
    4 Models Compliation 
    5 ****************** 
     3**************** 
     4GPU Computations 
     5**************** 
    66SasView model evaluations can run on your graphics card (GPU) or they can run 
    77on the processor (CPU). 
    88 
    99To 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. 
     10For information about OpenCL installation see the 
     11:ref:`opencl-installation` documentation 
    1912 
    2013Where the model is evaluated is a little bit complicated. 
  • doc/ref/index.rst

    r1875f4e r0c1e5a9  
    99   intro.rst 
    1010   refs.rst 
    11    compilation.rst 
     11   gpu_computations.rst 
    1212   magnetism/magnetism.rst 
  • sasmodels/kerneldll.py

    r3764ec1 r8b10fdf  
    7373import tempfile 
    7474import ctypes as ct  # type: ignore 
    75 from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float  # type: ignore 
     75import _ctypes as _ct 
    7676import logging 
    7777 
     
    111111    compiler = "unix" 
    112112 
    113 ARCH = "" if ct.sizeof(c_void_p) > 4 else "x86"  # 4 byte pointers on x86 
     113ARCH = "" if ct.sizeof(ct.c_void_p) > 4 else "x86"  # 4 byte pointers on x86 
    114114if compiler == "unix": 
    115115    # Generic unix compile 
     
    241241    if not os.path.exists(dll): 
    242242        need_recompile = True 
    243     elif getattr(sys, 'frozen', None) is not None: 
    244         # TODO: don't suppress time stamp 
    245         # Currently suppressing recompile when running in a frozen environment 
    246         need_recompile = False 
    247243    else: 
    248244        dll_time = os.path.getmtime(dll) 
     
    301297    def _load_dll(self): 
    302298        # type: () -> None 
    303         #print("dll", self.dllpath) 
    304299        try: 
    305300            self._dll = ct.CDLL(self.dllpath) 
     
    308303            raise 
    309304 
    310         float_type = (c_float if self.dtype == generate.F32 
    311                       else c_double if self.dtype == generate.F64 
    312                       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) 
    313308 
    314309        # 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] 
    316311        names = [generate.kernel_name(self.info, variant) 
    317312                 for variant in ("Iq", "Iqxy", "Imagnetic")] 
     
    344339        Release any resources associated with the model. 
    345340        """ 
     341        dll_handle = self._dll._handle 
    346342        if os.name == 'nt': 
    347             #dll = ct.cdll.LoadLibrary(self.dllpath) 
    348             dll = ct.CDLL(self.dllpath) 
    349             dll_handle = dll._handle 
    350             #dll_handle = ct.c_void_p(dll._handle) 
    351             del dll, self._dll 
    352             self._dll = None 
    353343            ct.windll.kernel32.FreeLibrary(dll_handle) 
    354344        else: 
    355             pass 
    356  
     345            _ct.dlclose(dll_handle) 
     346        del self._dll 
     347        self._dll = None 
    357348 
    358349class DllKernel(Kernel): 
     
    411402        #print("returned",self.q_input.q, self.result) 
    412403        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) 
    414405        background = values[1] 
    415406        #print("scale",scale,background) 
  • sasmodels/sasview_model.py

    r9c1a59c r9acbd37  
    575575                            magnetic=is_magnetic) 
    576576        calculator.release() 
     577        self._model.release() 
    577578        return result 
    578579 
Note: See TracChangeset for help on using the changeset viewer.