Changeset 352494a in sasmodels


Ignore:
Timestamp:
Mar 31, 2017 5:18:05 AM (2 years ago)
Author:
wojciech
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
0cd9158, 956960a
Parents:
37c7d5e (diff), cb0dc22 (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:

Merge branch 'master' of https://github.com/SasView/sasmodels

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • doc/ref/index.rst

    rc34a31f r9f12fbe  
    1010   refs.rst 
    1111   gpu/gpu_computations.rst 
     12   gpu/opencl_installation.rst 
    1213   magnetism/magnetism.rst 
    1314   sesans/sans_to_sesans.rst 
  • sasmodels/models/core_shell_parallelepiped.py

    r797a8e3 rcb0dc22  
    44 
    55Calculates the form factor for a rectangular solid with a core-shell structure. 
    6 **The thickness and the scattering length density of the shell or "rim" 
    7 can be different on all three (pairs) of faces.** 
     6The thickness and the scattering length density of the shell or  
     7"rim" can be different on each (pair) of faces. However at this time 
     8the model does **NOT** actually calculate a c face rim despite the presence of 
     9the parameter. 
     10 
     11.. note:: 
     12   This model was originally ported from NIST IGOR macros. However,t is not 
     13   yet fully understood by the SasView developers and is currently review. 
    814 
    915The form factor is normalized by the particle volume $V$ such that 
     
    3541    V = ABC + 2t_ABC + 2t_BAC + 2t_CAB 
    3642 
    37 **meaning that there are "gaps" at the corners of the solid.** 
     43**meaning that there are "gaps" at the corners of the solid.**  Again note that 
     44$t_C = 0$ currently.  
    3845 
    3946The intensity calculated follows the :ref:`parallelepiped` model, with the 
     
    4148amplitudes of the core and shell, in the same manner as a core-shell model. 
    4249 
    43 .. math:: 
    44  
    45     F_{a}(Q,\alpha,\beta)= 
    46     \Bigg(\frac{sin(Q(L_A+2t_A)/2sin\alpha sin\beta)}{Q(L_A+2t_A)/2sin\alpha 
    47     sin\beta)} 
    48     - \frac{sin(QL_A/2sin\alpha sin\beta)}{QL_A/2sin\alpha sin\beta)} \Bigg) 
    49     + \frac{sin(QL_B/2sin\alpha sin\beta)}{QL_B/2sin\alpha sin\beta)} 
    50     + \frac{sin(QL_C/2sin\alpha sin\beta)}{QL_C/2sin\alpha sin\beta)} 
    5150 
    5251.. note:: 
     
    9392    detector plane. 
    9493 
    95 Validation 
    96 ---------- 
    97  
    98 The model uses the form factor calculations implemented in a c-library provided 
    99 by the NIST Center for Neutron Research (Kline, 2006). 
    100  
    10194References 
    10295---------- 
     
    113106 
    114107* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    115 * **Last Modified by:** Paul Butler **Date:** September 30, 2016 
    116 * **Last Reviewed by:** Miguel Gonzales **Date:** March 21, 2016 
     108* **Converted to sasmodels by:** Miguel Gonzales **Date:** February 26, 2016 
     109* **Last Modified by:** Wojciech Potrzebowski **Date:** January 11, 2017 
     110* **Currently Under review by:** Paul Butler 
    117111""" 
    118112 
  • sasmodels/models/fractal.c

    r925ad6e r4788822  
    11#define INVALID(p) (p.fractal_dim < 0.0) 
     2 
     3 static double 
     4 form_volume(double radius) 
     5 { 
     6     return M_4PI_3 * cube(radius); 
     7 } 
    28 
    39static double 
     
    1319 
    1420    //calculate P(q) for the spherical subunits 
    15     const double V = M_4PI_3*cube(radius); 
    16     const double pq = V * square((sld_block-sld_solvent)*sas_3j1x_x(q*radius)); 
     21    const double pq = square(form_volume(radius) * (sld_block-sld_solvent) 
     22                      *sas_3j1x_x(q*radius)); 
    1723 
    1824    // scale to units cm-1 sr-1 (assuming data on absolute scale) 
  • sasmodels/models/fractal.py

    r925ad6e rdf89d77  
    2020.. math:: 
    2121 
    22     P(q)&= F(qR_0)^2 
    23  
    24     F(q)&= \frac{3 (\sin x - x \cos x)}{x^3} 
    25  
    26     V_\text{particle} &= \frac{4}{3}\ \pi R_0 
    27  
     22    P(q)&= F(qR_0)^2 \\ 
     23    F(q)&= \frac{3 (\sin x - x \cos x)}{x^3} \\ 
     24    V_\text{particle} &= \frac{4}{3}\ \pi R_0 \\ 
    2825    S(q) &= 1 + \frac{D_f\  \Gamma\!(D_f-1)}{[1+1/(q \xi)^2\  ]^{(D_f -1)/2}} 
    2926    \frac{\sin[(D_f-1) \tan^{-1}(q \xi) ]}{(q R_0)^{D_f}} 
     
    3229is the fractal dimension, representing the self similarity of the structure.  
    3330Note that S(q) here goes negative if $D_f$ is too large, and the Gamma function  
    34 diverges at $D_f$=0 and $D_f$=1.   
     31diverges at $D_f=0$ and $D_f=1$. 
    3532 
    3633**Polydispersity on the radius is provided for.** 
     
    4744---------- 
    4845 
    49 J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785 
     46.. [#] J Teixeira, *J. Appl. Cryst.*, 21 (1988) 781-785 
    5047 
    51 **Author:** NIST IGOR/DANSE **on:** pre 2010 
     48Authorship and Verification 
     49---------------------------- 
    5250 
    53 **Last Modified by:** Paul Butler **on:** March 20, 2016 
    54  
    55 **Last Reviewed by:** Paul Butler **on:** March 20, 2016 
     51* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
     52* **Converted to sasmodels by:** Paul Butler **Date:** March 19, 2016 
     53* **Last Modified by:** Paul Butler **Date:** March 12, 2017 
     54* **Last Reviewed by:** Paul Butler **Date:** March 12, 2017 
    5655 
    5756""" 
     
    8483parameters = [["volfraction", "", 0.05, [0.0, 1], "", 
    8584               "volume fraction of blocks"], 
    86               ["radius",    "Ang",  5.0, [0.0, inf], "", 
     85              ["radius",    "Ang",  5.0, [0.0, inf], "volume", 
    8786               "radius of particles"], 
    8887              ["fractal_dim",      "",  2.0, [0.0, 6.0], "", 
  • sasmodels/resolution.py

    r2b3a1bd rb32caab  
    1717 
    1818MINIMUM_RESOLUTION = 1e-8 
    19  
    20  
    21 # When extrapolating to -q, what is the minimum positive q relative to q_min 
    22 # that we wish to calculate? 
    23 MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION = 0.01 
     19MINIMUM_ABSOLUTE_Q = 0.02  # relative to the minimum q in the data 
    2420 
    2521class Resolution(object): 
     
    8278        self.q_calc = (pinhole_extend_q(q, q_width, nsigma=nsigma) 
    8379                       if q_calc is None else np.sort(q_calc)) 
     80 
     81        # Protect against models which are not defined for very low q.  Limit 
     82        # the smallest q value evaluated (in absolute) to 0.02*min 
     83        cutoff = MINIMUM_ABSOLUTE_Q*np.min(self.q) 
     84        self.q_calc = self.q_calc[abs(self.q_calc) >= cutoff] 
     85 
     86        # Build weight matrix from calculated q values 
    8487        self.weight_matrix = pinhole_resolution(self.q_calc, self.q, 
    8588                                np.maximum(q_width, MINIMUM_RESOLUTION)) 
     89        self.q_calc = abs(self.q_calc) 
    8690 
    8791    def apply(self, theory): 
     
    123127        self.q_calc = slit_extend_q(q, qx_width, qy_width) \ 
    124128            if q_calc is None else np.sort(q_calc) 
     129 
     130        # Protect against models which are not defined for very low q.  Limit 
     131        # the smallest q value evaluated (in absolute) to 0.02*min 
     132        cutoff = MINIMUM_ABSOLUTE_Q*np.min(self.q) 
     133        self.q_calc = self.q_calc[abs(self.q_calc) >= cutoff] 
     134 
     135        # Build weight matrix from calculated q values 
    125136        self.weight_matrix = \ 
    126137            slit_resolution(self.q_calc, self.q, qx_width, qy_width) 
     138        self.q_calc = abs(self.q_calc) 
    127139 
    128140    def apply(self, theory): 
     
    153165    # neither trapezoid nor Simpson's rule improved the accuracy. 
    154166    edges = bin_edges(q_calc) 
    155     edges[edges < 0.0] = 0.0 # clip edges below zero 
     167    #edges[edges < 0.0] = 0.0 # clip edges below zero 
    156168    cdf = erf((edges[:, None] - q[None, :]) / (sqrt(2.0)*q_width)[None, :]) 
    157169    weights = cdf[1:] - cdf[:-1] 
     
    286298    # The current algorithm is a midpoint rectangle rule. 
    287299    q_edges = bin_edges(q_calc) # Note: requires q > 0 
    288     q_edges[q_edges < 0.0] = 0.0 # clip edges below zero 
     300    #q_edges[q_edges < 0.0] = 0.0 # clip edges below zero 
    289301    weights = np.zeros((len(q), len(q_calc)), 'd') 
    290302 
     
    392404    interval. 
    393405 
    394     if *q_min* is zero or less then *q[0]/10* is used instead. 
     406    Note that extrapolated values may be negative. 
    395407    """ 
    396408    q = np.sort(q) 
    397409    if q_min + 2*MINIMUM_RESOLUTION < q[0]: 
    398         if q_min <= 0: q_min = q_min*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 
    399410        n_low = np.ceil((q[0]-q_min) / (q[1]-q[0])) if q[1] > q[0] else 15 
    400411        q_low = np.linspace(q_min, q[0], n_low+1)[:-1] 
     
    448459        log_delta_q = log(10.) / points_per_decade 
    449460    if q_min < q[0]: 
    450         if q_min < 0: q_min = q[0]*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 
     461        if q_min < 0: q_min = q[0]*MINIMUM_ABSOLUTE_Q 
    451462        n_low = log_delta_q * (log(q[0])-log(q_min)) 
    452463        q_low = np.logspace(log10(q_min), log10(q[0]), np.ceil(n_low)+1)[:-1] 
  • doc/ref/gpu/gpu_computations.rst

    r3f5a566 r7e74ed5  
    3131from available OpenCL platforms. 
    3232 
     33OpenCL devices can be set from OpenCL options dialog in Fitting menu or as 
     34enviromental variables. 
     35 
     36**If you don't want to use OpenCL, you can select "No OpenCL" option from** 
     37**GUI dialog or set *SAS_OPENCL=None* in your environment settings** 
     38**This will only use normal programs.** 
     39 
    3340SasView prefers AMD or NVIDIA drivers for GPU, and prefers Intel or 
    3441Apple drivers for CPU. Both GPU and CPU are included on the assumption that CPU  
     
    3946chose to run the model. 
    4047 
    41 **If you don't want to use OpenCL, you can set** *SAS_OPENCL=None* 
    42 **in your environment settings, and it will only use normal programs.** 
    43  
    44 If you want to use one of the other devices, you can run the following 
    45 from the python console in SasView:: 
     48If you want to use one of the other devices, you can select it from OpenCL 
     49options dialog (accessible from Fitting menu) or run the following from 
     50the python console in SasView:: 
    4651 
    4752    import pyopencl as cl 
Note: See TracChangeset for help on using the changeset viewer.