Changeset 4416868 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 12:09:13 PM (9 years ago)
Author:
richardh
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:
65bf704, 3a45c2c
Parents:
45330ed (diff), 6ad0e87 (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

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r17bbadd r6ad0e87  
    5151import ctypes as ct 
    5252from ctypes import c_void_p, c_int, c_longdouble, c_double, c_float 
     53import _ctypes 
    5354 
    5455import numpy as np 
     
    125126    if callable(model_info.get('Iq', None)): 
    126127        return PyModel(model_info) 
    127  
     128     
    128129    dtype = np.dtype(dtype) 
    129130    if dtype == generate.F16: 
     
    138139    else: 
    139140        tempfile_prefix = 'sas_' + model_info['name'] + '128_' 
    140  
     141  
    141142    source = generate.convert_type(source, dtype) 
    142143    source_files = generate.model_sources(model_info) + [model_info['filename']] 
     
    188189    Call :meth:`release` when done with the kernel. 
    189190    """ 
     191     
    190192    def __init__(self, dllpath, model_info, dtype=generate.F32): 
    191193        self.info = model_info 
     
    217219        self.Iqxy = self.dll[generate.kernel_name(self.info, True)] 
    218220        self.Iqxy.argtypes = IQXY_ARGS + pd_args_2d + [fp]*Nfixed2d 
     221         
     222        self.release() 
    219223 
    220224    def __getstate__(self): 
     
    230234        kernel = self.Iqxy if q_input.is_2d else self.Iq 
    231235        return DllKernel(kernel, self.info, q_input) 
    232  
     236     
    233237    def release(self): 
    234238        """ 
    235239        Release any resources associated with the model. 
    236240        """ 
    237         pass # TODO: should release the dll 
     241        if os.name == 'nt': 
     242            #dll = ct.cdll.LoadLibrary(self.dllpath) 
     243            dll = ct.CDLL(self.dllpath) 
     244            libHandle = dll._handle 
     245            #libHandle = ct.c_void_p(dll._handle) 
     246            del dll, self.dll 
     247            self.dll = None 
     248            #_ctypes.FreeLibrary(libHandle) 
     249            ct.windll.kernel32.FreeLibrary(libHandle) 
     250        else:     
     251            pass  
    238252 
    239253 
  • sasmodels/models/guinier.py

    ra84a0ca r45330ed  
    55This model fits the Guinier function 
    66 
    7 .. math:: q_1=\frac{1}{R_g}\sqrt{\frac{(m-s)(3-s)}{2}} 
     7.. math:: I(q) = scale \exp{\left[ \frac{-Q^2R_g^2}{3} \right]} 
    88 
    99to the data directly without any need for linearisation 
    10 (*cf*. $\ln I(q)$ vs $q^2$\ ). 
     10(*cf*. the usual plot of $\ln I(q)$ vs $q^2$\ ). Note that you may have to  
     11restrict the data range to include small q only, where the Guinier approximation 
     12actually applies. See also the guinier_porod model. 
    1113 
    1214For 2D data the scattering intensity is calculated in the same way as 1D, 
     
    2729title = "" 
    2830description = """ 
    29  I(q) = scale exp ( - rg^2 q^2 / 3.0 ) 
     31 I(q) = scale.exp ( - rg^2 q^2 / 3.0 ) 
    3032  
    3133    List of default parameters: 
  • sasmodels/models/guinier_porod.py

    raa2edb2 r45330ed  
    3939Note that the radius-of-gyration for a sphere of radius R is given by $R_g = R \sqrt(3/5)$. 
    4040 
    41 The cross-sectional radius-of-gyration for a randomly oriented cylinder 
    42 of radius R is given by $R_g = R / \sqrt(2)$. 
     41For a cylinder of radius $R$ and length $L$,    $R_g^2 = \frac{L^2}{12} + \frac{R^2}{2}$ 
    4342 
    44 The cross-sectional radius-of-gyration of a randomly oriented lamella 
     43from which the cross-sectional radius-of-gyration for a randomly oriented thin  
     44cylinder is $R_g = R / \sqrt(2)$. 
     45 
     46and the cross-sectional radius-of-gyration of a randomly oriented lamella 
    4547of thickness $T$ is given by $R_g = T / \sqrt(12)$. 
    4648 
Note: See TracChangeset for help on using the changeset viewer.