Changeset b6f3bbe in sasmodels for sasmodels


Ignore:
Timestamp:
Sep 2, 2016 9:30:49 AM (8 years ago)
Author:
wojciech
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:
fe77343
Parents:
f49675c (diff), e822c97 (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:

Merged with master

Location:
sasmodels
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/__init__.py

    r40a87fa rb2377b0  
    1414defining new models. 
    1515""" 
    16 __version__ = "0.9" 
     16__version__ = "0.93" 
    1717 
    1818def data_files(): 
  • sasmodels/convert.py

    r6dc78e4 r51241113  
    334334            pars['n_shells'] = math.ceil(pars['n_shells']) 
    335335            pars['n_steps'] = math.ceil(pars['n_steps']) 
    336             for k in range(1, 12): 
     336            for k in range(1, 11): 
    337337                pars['shape%d'%k] = math.trunc(pars['shape%d'%k]+0.5) 
    338             for k in range(2, 12): 
     338            for k in range(2, 11): 
    339339                pars['thickness%d_pd_n'%k] = 0 
    340340                pars['interface%d_pd_n'%k] = 0 
  • sasmodels/kernelcl.py

    r0dc34c3 r14a15a3  
    568568            if v is not None: v.release() 
    569569 
    570         scale = values[0]/self.result[self.q_input.nq] 
     570        pd_norm = self.result[self.q_input.nq] 
     571        scale = values[0]/(pd_norm if pd_norm!=0.0 else 1.0) 
    571572        background = values[1] 
    572         #print("scale",scale,values[0],self.result[self.q_input.nq]) 
     573        #print("scale",scale,values[0],self.result[self.q_input.nq],background) 
    573574        return scale*self.result[:self.q_input.nq] + background 
    574575        # return self.result[:self.q_input.nq] 
  • sasmodels/kerneldll.py

    r0dc34c3 r14a15a3  
    389389 
    390390        #print("returned",self.q_input.q, self.result) 
    391         scale = values[0]/self.result[self.q_input.nq] 
     391        pd_norm = self.result[self.q_input.nq] 
     392        scale = values[0]/(pd_norm if pd_norm!=0.0 else 1.0) 
    392393        background = values[1] 
    393394        #print("scale",scale,background) 
  • sasmodels/kernelpy.py

    rbde38b5 r14a15a3  
    187187    n_pars = len(parameters) 
    188188    parameters[:] = values[2:n_pars+2] 
    189     scale, background = values[0], values[1] 
    190189    if call_details.num_active == 0: 
    191         norm = float(form_volume()) 
    192         if norm > 0.0: 
    193             return (scale/norm)*form() + background 
    194         else: 
    195             return np.ones(nq, 'd')*background 
     190        pd_norm = float(form_volume()) 
     191        scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 
     192        background = values[1] 
     193        return scale*form() + background 
    196194 
    197195    pd_value = values[2+n_pars:2+n_pars + call_details.num_weights] 
     
    245243            pd_norm += weight * form_volume() 
    246244 
    247     if pd_norm > 0.0: 
    248         return (scale/pd_norm)*total + background 
    249     else: 
    250         return np.ones(nq, 'd')*background 
     245    scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 
     246    background = values[1] 
     247    return scale*total + background 
    251248 
    252249 
  • sasmodels/models/core_multi_shell.py

    r9a4811a r8c6fbbc  
    116116 
    117117    # add in the shells 
    118     for k in range(n): 
     118    for k in range(int(n)): 
    119119        # Left side of each shells 
    120120        z.append(z[-1]) 
  • sasmodels/models/onion.py

    r40a87fa r3cd1001  
    337337 
    338338    # add in the shells 
    339     for k in range(n_shells): 
     339    for k in range(int(n_shells)): 
    340340        # Left side of each shells 
    341341        z_current = z[-1] 
  • sasmodels/models/unified_power_Rg.py

    r40a87fa reb574d7  
    88has been added which simply calculates 
    99 
    10 .. math: 
     10.. math:: 
    1111 
    1212    I(q) = \text{scale} / q + \text{background} 
     
    1616(Debye equation), ellipsoidal particles, etc. 
    1717 
    18 The empirical fit function is (eq 9'): 
     18The empirical fit function is: 
    1919 
    20 .. math: 
     20.. math:: 
    2121 
    2222    I(q) = \text{background} 
    23     + \Sum_{i=1}^N \left[ 
    24         G_i \exp\left(-\frac{q^2R_{gi}^2}{3}\right) 
    25        + B_i \exp\left(-\frac{q^2R_{g(i+1)}^2}{3}\right) 
    26              \left(\frac{1}{q_i^*}\right)^{P_i} 
     23    + \sum_{i=1}^N \Bigl[ 
     24        G_i \exp\Bigl(-\frac{q^2R_{gi}^2}{3}\Bigr) 
     25       + B_i \exp\Bigl(-\frac{q^2R_{g(i+1)}^2}{3}\Bigr) 
     26             \Bigl(\frac{1}{q_i^*}\Bigr)^{P_i} \Bigr] 
    2727 
    2828where 
    2929 
    30 .. math: 
     30.. math:: 
    3131 
    3232    q_i^* = \frac{q}{\operatorname{erf}^3(q R_{gi}/\sqrt{6}} 
     
    4545where the $q$ vector is defined as 
    4646 
    47 .. math: 
     47.. math:: 
    4848 
    4949    q = \sqrt{q_x^2 + q_y^2} 
     
    6666 
    6767category = "shape-independent" 
     68name = "unified_power_Rg" 
     69title = "Unified Power Rg" 
     70description = """ 
     71        The Beaucage model employs the empirical multiple level unified 
     72        Exponential/Power-law fit method developed by G. Beaucage. Four functions 
     73        are included so that 1, 2, 3, or 4 levels can be used. 
     74        """ 
    6875 
    6976# pylint: disable=bad-whitespace, line-too-long 
  • sasmodels/compare.py

    rb32dafd r8407d8c  
    563563    elif dtype.endswith('!'): 
    564564        return eval_ctypes(model_info, data, dtype=dtype[:-1], cutoff=cutoff) 
     565    elif not model_info.opencl: 
     566        return eval_ctypes(model_info, data, dtype=dtype, cutoff=cutoff) 
    565567    else: 
    566568        return eval_opencl(model_info, data, dtype=dtype, cutoff=cutoff) 
  • sasmodels/core.py

    r725ee36 rf49675c  
    4646#    build_model 
    4747 
    48 KINDS = ("all", "py", "c", "double", "single", "1d", "2d", 
     48KINDS = ("all", "py", "c", "double", "single", "opencl", "1d", "2d", 
    4949         "nonmagnetic", "magnetic") 
    5050def list_models(kind=None): 
     
    6060        * single: models which support single precision 
    6161        * double: models which require double precision 
     62        * opencl: controls if OpenCL is supperessed 
    6263        * 1d: models which are 1D only, or 2D using abs(q) 
    6364        * 2d: models which can be 2D 
     
    8586        return True 
    8687    elif kind == "single" and info.single: 
     88        return True 
     89    elif kind == "opencl" and info.opencl: 
    8790        return True 
    8891    elif kind == "2d" and any(p.type == 'orientation' for p in pars): 
     
    215218    """ 
    216219    # Assign default platform, overriding ocl with dll if OpenCL is unavailable 
     220    # If opencl=False OpenCL is switched off 
     221    # Finally one can force OpenCL calculation even if HAVE_OPENCL=False 
    217222    if platform is None: 
    218223        platform = "ocl" 
    219     if platform == "ocl" and not HAVE_OPENCL: 
     224    if platform == "ocl" and not HAVE_OPENCL or not model_info.opencl: 
    220225        platform = "dll" 
     226    #if  model_info.opencl and not HAVE_OPENCL: 
     227    #    platform = "ocl" 
    221228 
    222229    # Check if type indicates dll regardless of which platform is given 
  • sasmodels/modelinfo.py

    r40a87fa r8407d8c  
    731731    info.category = getattr(kernel_module, 'category', None) 
    732732    info.single = getattr(kernel_module, 'single', True) 
     733    info.opencl = getattr(kernel_module, 'opencl', True) 
    733734    info.structure_factor = getattr(kernel_module, 'structure_factor', False) 
    734735    info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) 
Note: See TracChangeset for help on using the changeset viewer.