Changeset 459e890 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 12:57:13 PM (9 years ago)
Author:
awashington
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:
3a45c2c
Parents:
c94577f (diff), 39674a0 (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 github.com:SasView/sasmodels

Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • doc/conf.py

    r22975f0 r39674a0  
    5656# General information about the project. 
    5757project = 'SAS Models' 
    58 copyright = '2014, sasview team' 
     58copyright = '2016, sasview team' 
    5959 
    6060# The version info for the project you're documenting, acts as replacement for 
  • 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/gauss_lorentz_gel.py

    raa2edb2 rb8954d7  
    22This model calculates the scattering from a gel structure, 
    33but typically a physical rather than chemical network. 
    4 It is modeled as a sum of a low-q exponential decay plus 
    5 a lorentzian at higher-q values. 
     4It is modeled as a sum of a low-q exponential decay (which happens to 
     5give a functional form similar to Guinier scattering, so interpret with  
     6care) plus a Lorentzian at higher-q values. See also the gel_fit model. 
    67 
    78Definition 
     
    1617$\Xi$ is the length scale of the static correlations in the gel, 
    1718which can be attributed to the "frozen-in" crosslinks. 
    18 $\xi is the dynamic correlation length, which can be attributed to the 
     19\ |xi|\ is the dynamic correlation length, which can be attributed to the 
    1920fluctuating polymer chains between crosslinks. 
    20 $IG(0)$ and $IL(0)$ are the scaling factors for each of these structures. 
     21$I_G(0)$ and $I_L(0)$ are the scaling factors for each of these structures. 
    2122Think carefully about how these map to your particular system! 
    2223 
  • sasmodels/models/gel_fit.py

    raa2edb2 rb8954d7  
    88and a longer distance (denoted here as $a2$ ) needed to account for the static 
    99accumulations of polymer pinned down by junction points or clusters of such 
    10 points. The latter is derived from a simple Guinier function. 
     10points. The latter is derived from a simple Guinier function. Compare also the  
     11gauss_lorentz_gel model. 
    1112 
    1213 
     
    3334 
    3435 
    35 Reference 
    36 --------- 
     36References 
     37---------- 
    3738 
    3839Mitsuhiro Shibayama, Toyoichi Tanaka, Charles C Han, 
     
    6061# pylint: disable=bad-whitespace, line-too-long 
    6162#             ["name", "units", default, [lower, upper], "type","description"], 
    62 parameters = [["guinier_scale",    "cm^{-1}",   1.7, [-inf, inf], "", "Guinier length scale"], 
    63               ["lorentzian_scale", "cm^{-1}",   3.5, [-inf, inf], "", "Lorentzian length scale"], 
     63parameters = [["guinier_scale",    "cm^-1",   1.7, [-inf, inf], "", "Guinier length scale"], 
     64              ["lorentzian_scale", "cm^-1",   3.5, [-inf, inf], "", "Lorentzian length scale"], 
    6465              ["gyration_radius",  "Ang",     104.0, [2, inf],    "", "Radius of gyration"], 
    6566              ["fractal_exp",      "",          2.0, [0, inf],    "", "Fractal exponent"], 
  • 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 
  • sasmodels/models/raspberry.py

    r5745f0b r2c1bbcdd  
    33---------- 
    44 
    5 The figure below shows a schematic of a large droplet surrounded by several smaller particles 
    6 forming a structure similar to that of Pickering emulsions. 
     5The figure below shows a schematic of a large droplet surrounded by several 
     6smaller particles forming a structure similar to that of Pickering emulsions. 
    77 
    88.. figure:: img/raspberry_geometry.jpg 
     
    1010    Schematic of the raspberry model 
    1111 
    12 In order to calculate the form factor of the entire complex, the self-correlation of the large droplet, 
    13 the self-correlation of the particles, the correlation terms between different particles 
    14 and the cross terms between large droplet and small particles all need to be calculated. 
     12In order to calculate the form factor of the entire complex, the self- 
     13correlation of the large droplet, the self-correlation of the particles, the 
     14correlation terms between different particles and the cross terms between large 
     15droplet and small particles all need to be calculated. 
    1516 
    16 Consider two infinitely thin shells of radii R2 and R2 separated by distance r. The general 
    17 structure of the equation is then the form factor of the two shells multiplied by the phase 
    18 factor that accounts for the separation of their centers. 
     17Consider two infinitely thin shells of radii R1 and R2 separated by distance r. 
     18The general structure of the equation is then the form factor of the two shells 
     19multiplied by the phase factor that accounts for the separation of their 
     20centers. 
    1921 
    2022.. math:: 
     
    2224    S(q) = \frac{sin(qR_1)}{qR_1}\frac{sin(qR_2)}{qR_2}\frac{sin(qr)}{qr} 
    2325 
    24 In this case, the large droplet and small particles are solid spheres rather than thin shells. Thus 
    25 the two terms must be integrated over $R_L$ and $R_S$ respectively using the weighting function of 
    26 a sphere. We then obtain the functions for the form of the two spheres: 
     26In this case, the large droplet and small particles are solid spheres rather 
     27than thin shells. Thus the two terms must be integrated over $R_L$ and $R_S$ 
     28respectively using the weighting function of a sphere. We then obtain the 
     29functions for the form of the two spheres: 
    2730 
    2831.. math:: 
    2932 
    30     \Psi_L = \int_0^{R_L}(4\pi R^2_L)\frac{sin(qR_L)}{qR_L}dR_L = \frac{3[sin(qR_L)-qR_Lcos(qR_L)]}{(qR_L)^2} 
     33    \Psi_L = \int_0^{R_L}(4\pi R^2_L)\frac{sin(qR_L)}{qR_L}dR_L =  
     34    \frac{3[sin(qR_L)-qR_Lcos(qR_L)]}{(qR_L)^2} 
    3135 
    3236.. math:: 
    3337 
    34     \Psi_S = \int_0^{R_S}(4\pi R^2_S)\frac{sin(qR_S)}{qR_S}dR_S = \frac{3[sin(qR_S)-qR_Lcos(qR_S)]}{(qR_S)^2} 
     38    \Psi_S = \int_0^{R_S}(4\pi R^2_S)\frac{sin(qR_S)}{qR_S}dR_S = 
     39    \frac{3[sin(qR_S)-qR_Lcos(qR_S)]}{(qR_S)^2} 
    3540 
    3641The cross term between the large droplet and small particles is given by: 
     
    4247 
    4348.. math:: 
    44     S_{SS} = \Psi_S^2\bigl[\frac{sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)}\bigr]^2 
     49    S_{SS} = \Psi_S^2\biggl[\frac{sin(q(R_L+\delta R_S))}{q(R_L+\delta\ R_S)} 
     50    \biggr]^2 
    4551 
    4652The number of small particles per large droplet, $N_p$, is given by: 
     
    5056    N_p = \frac{\phi_S\phi_{surface}V_L}{\phi_L V_S} 
    5157 
    52 where $\phi_S$ is the volume fraction of small particles in the sample, $\phi_{surface}$ is the 
    53 fraction of the small particles that are adsorbed to the large droplets, $\phi_L$ is the volume fraction 
    54 of large droplets in the sample, and $V_S$ and $V_L$ are the volumes of individual small particles and 
     58where $\phi_S$ is the volume fraction of small particles in the sample, 
     59$\phi_{surface}$ is the fraction of the small particles that are adsorbed to 
     60the large droplets, $\phi_L$ is the volume fraction of large droplets in the 
     61sample, and $V_S$ and $V_L$ are the volumes of individual small particles and 
    5562large droplets respectively. 
    5663 
    57 The form factor of the entire complex can now be calculated including the excess scattering length 
    58 densities of the components $\Delta\rho_L$ and $\Delta\rho_S$, where $\Delta\rho_x = |\rho_x-\rho_{solvent}|$ : 
     64The form factor of the entire complex can now be calculated including the excess 
     65scattering length densities of the components $\Delta\rho_L$ and $\Delta\rho_S$, 
     66where $\Delta\rho_x = |\rho_x-\rho_{solvent}|$ : 
    5967 
    6068.. math:: 
    6169 
    62     P_{LS} = \frac{1}{M^2}\bigl[(\Delta\rho_L)^2V_L^2\Psi_L^2+N_p(\Delta\rho_S)^2V_S^2\Psi_S^2 
    63                 + N_p(1-N_p)(\Delta\rho_S)^2V_S^2S_{SS} + 2N_p\Delta\rho_L\Delta\rho_SV_LV_SS_{LS} 
     70    P_{LS} = \frac{1}{M^2}\bigl[(\Delta\rho_L)^2V_L^2\Psi_L^2 
     71                +N_p(\Delta\rho_S)^2V_S^2\Psi_S^2 
     72                + N_p(1-N_p)(\Delta\rho_S)^2V_S^2S_{SS} 
     73                + 2N_p\Delta\rho_L\Delta\rho_SV_LV_SS_{LS}\bigr] 
    6474 
    6575where M is the total scattering length of the whole complex : 
     
    6878    M = \Delta\rho_LV_L + N_p\Delta\rho_SV_S 
    6979 
    70 In a real system, there will ususally be an excess of small particles such that some fraction remain unbound. 
    71 Therefore the overall scattering intensity is given by: 
     80In a real system, there will ususally be an excess of small particles such that 
     81some fraction remain unbound. Therefore the overall scattering intensity is 
     82given by: 
    7283 
    7384.. math:: 
    74     I(Q) = I_{LS}(Q) + I_S(Q) = (\phi_L(\Delta\rho_L)^2V_L + \phi_S\phi_{surface}N_p(\Delta\rho_S)^2V_S)P_{LS} 
     85    I(Q) = I_{LS}(Q) + I_S(Q) = (\phi_L(\Delta\rho_L)^2V_L +  
     86            \phi_S\phi_{surface}N_p(\Delta\rho_S)^2V_S)P_{LS} 
    7587            + \phi_S(1-\phi_{surface})(\Delta\rho_S)^2V_S\Psi_S^2 
    7688 
    77 A useful parameter to extract is the fraction of the surface area of the large droplets that is covered by small 
    78 particles. This can be calculated from the model parameters as: 
     89A useful parameter to extract is the fraction of the surface area of the large 
     90droplets that is covered by small particles. This can be calculated from the 
     91model parameters as: 
    7992 
    8093.. math:: 
     
    8598---------- 
    8699 
    87 K Larson-Smith, A Jackson, and D C Pozzo, *Small angle scattering model for Pickering emulsions and raspberry* 
    88 *particles*, *Journal of Colloid and Interface Science*, 343(1) (2010) 36-41 
     100K Larson-Smith, A Jackson, and D C Pozzo, *Small angle scattering model for 
     101Pickering emulsions and raspberry particles*, *Journal of Colloid and Interface 
     102Science*, 343(1) (2010) 36-41 
    89103 
    90104**Author:** Andrew Jackson **on:** 2008 
  • sasmodels/sesans.py

    ra154ad16 rc94577f  
    189189        integral = besselj(0, q*SElength_i)*Iq*q 
    190190        G[i] = np.sum(integral) 
     191    G0 = np.sum(Iq*q) 
    191192 
    192193    # [m^-1] step size in q, needed for integration 
     
    195196    # integration step, convert q into [m**-1] and 2 pi circle integration 
    196197    G *= dq*1e10*2*pi 
    197  
    198     P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0])) 
     198    G0 *= dq*1e10*2*pi 
     199 
     200    P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0)) 
    199201 
    200202    return P 
Note: See TracChangeset for help on using the changeset viewer.