Changes in / [0495db8:42f71da] in sasmodels
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/conf.py
r22975f0 r39674a0 56 56 # General information about the project. 57 57 project = 'SAS Models' 58 copyright = '201 4, sasview team'58 copyright = '2016, sasview team' 59 59 60 60 # The version info for the project you're documenting, acts as replacement for -
sasmodels/kerneldll.py
r17bbadd r6ad0e87 51 51 import ctypes as ct 52 52 from ctypes import c_void_p, c_int, c_longdouble, c_double, c_float 53 import _ctypes 53 54 54 55 import numpy as np … … 125 126 if callable(model_info.get('Iq', None)): 126 127 return PyModel(model_info) 127 128 128 129 dtype = np.dtype(dtype) 129 130 if dtype == generate.F16: … … 138 139 else: 139 140 tempfile_prefix = 'sas_' + model_info['name'] + '128_' 140 141 141 142 source = generate.convert_type(source, dtype) 142 143 source_files = generate.model_sources(model_info) + [model_info['filename']] … … 188 189 Call :meth:`release` when done with the kernel. 189 190 """ 191 190 192 def __init__(self, dllpath, model_info, dtype=generate.F32): 191 193 self.info = model_info … … 217 219 self.Iqxy = self.dll[generate.kernel_name(self.info, True)] 218 220 self.Iqxy.argtypes = IQXY_ARGS + pd_args_2d + [fp]*Nfixed2d 221 222 self.release() 219 223 220 224 def __getstate__(self): … … 230 234 kernel = self.Iqxy if q_input.is_2d else self.Iq 231 235 return DllKernel(kernel, self.info, q_input) 232 236 233 237 def release(self): 234 238 """ 235 239 Release any resources associated with the model. 236 240 """ 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 238 252 239 253 -
sasmodels/models/gauss_lorentz_gel.py
raa2edb2 rb8954d7 2 2 This model calculates the scattering from a gel structure, 3 3 but 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. 4 It is modeled as a sum of a low-q exponential decay (which happens to 5 give a functional form similar to Guinier scattering, so interpret with 6 care) plus a Lorentzian at higher-q values. See also the gel_fit model. 6 7 7 8 Definition … … 16 17 $\Xi$ is the length scale of the static correlations in the gel, 17 18 which can be attributed to the "frozen-in" crosslinks. 18 $\xiis the dynamic correlation length, which can be attributed to the19 \ |xi|\ is the dynamic correlation length, which can be attributed to the 19 20 fluctuating polymer chains between crosslinks. 20 $I G(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. 21 22 Think carefully about how these map to your particular system! 22 23 -
sasmodels/models/gel_fit.py
raa2edb2 rb8954d7 8 8 and a longer distance (denoted here as $a2$ ) needed to account for the static 9 9 accumulations of polymer pinned down by junction points or clusters of such 10 points. The latter is derived from a simple Guinier function. 10 points. The latter is derived from a simple Guinier function. Compare also the 11 gauss_lorentz_gel model. 11 12 12 13 … … 33 34 34 35 35 Reference 36 --------- 36 References 37 ---------- 37 38 38 39 Mitsuhiro Shibayama, Toyoichi Tanaka, Charles C Han, … … 60 61 # pylint: disable=bad-whitespace, line-too-long 61 62 # ["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"],63 parameters = [["guinier_scale", "cm^-1", 1.7, [-inf, inf], "", "Guinier length scale"], 64 ["lorentzian_scale", "cm^-1", 3.5, [-inf, inf], "", "Lorentzian length scale"], 64 65 ["gyration_radius", "Ang", 104.0, [2, inf], "", "Radius of gyration"], 65 66 ["fractal_exp", "", 2.0, [0, inf], "", "Fractal exponent"], -
sasmodels/models/guinier.py
ra84a0ca r45330ed 5 5 This model fits the Guinier function 6 6 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]} 8 8 9 9 to 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 11 restrict the data range to include small q only, where the Guinier approximation 12 actually applies. See also the guinier_porod model. 11 13 12 14 For 2D data the scattering intensity is calculated in the same way as 1D, … … 27 29 title = "" 28 30 description = """ 29 I(q) = scale 31 I(q) = scale.exp ( - rg^2 q^2 / 3.0 ) 30 32 31 33 List of default parameters: -
sasmodels/models/guinier_porod.py
raa2edb2 r45330ed 39 39 Note that the radius-of-gyration for a sphere of radius R is given by $R_g = R \sqrt(3/5)$. 40 40 41 The cross-sectional radius-of-gyration for a randomly oriented cylinder 42 of radius R is given by $R_g = R / \sqrt(2)$. 41 For a cylinder of radius $R$ and length $L$, $R_g^2 = \frac{L^2}{12} + \frac{R^2}{2}$ 43 42 44 The cross-sectional radius-of-gyration of a randomly oriented lamella 43 from which the cross-sectional radius-of-gyration for a randomly oriented thin 44 cylinder is $R_g = R / \sqrt(2)$. 45 46 and the cross-sectional radius-of-gyration of a randomly oriented lamella 45 47 of thickness $T$ is given by $R_g = T / \sqrt(12)$. 46 48 -
sasmodels/models/raspberry.py
r5745f0b r2c1bbcdd 3 3 ---------- 4 4 5 The figure below shows a schematic of a large droplet surrounded by several smaller particles6 forming a structure similar to that of Pickering emulsions.5 The figure below shows a schematic of a large droplet surrounded by several 6 smaller particles forming a structure similar to that of Pickering emulsions. 7 7 8 8 .. figure:: img/raspberry_geometry.jpg … … 10 10 Schematic of the raspberry model 11 11 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. 12 In order to calculate the form factor of the entire complex, the self- 13 correlation of the large droplet, the self-correlation of the particles, the 14 correlation terms between different particles and the cross terms between large 15 droplet and small particles all need to be calculated. 15 16 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. 17 Consider two infinitely thin shells of radii R1 and R2 separated by distance r. 18 The general structure of the equation is then the form factor of the two shells 19 multiplied by the phase factor that accounts for the separation of their 20 centers. 19 21 20 22 .. math:: … … 22 24 S(q) = \frac{sin(qR_1)}{qR_1}\frac{sin(qR_2)}{qR_2}\frac{sin(qr)}{qr} 23 25 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: 26 In this case, the large droplet and small particles are solid spheres rather 27 than thin shells. Thus the two terms must be integrated over $R_L$ and $R_S$ 28 respectively using the weighting function of a sphere. We then obtain the 29 functions for the form of the two spheres: 27 30 28 31 .. math:: 29 32 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} 31 35 32 36 .. math:: 33 37 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} 35 40 36 41 The cross term between the large droplet and small particles is given by: … … 42 47 43 48 .. 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 45 51 46 52 The number of small particles per large droplet, $N_p$, is given by: … … 50 56 N_p = \frac{\phi_S\phi_{surface}V_L}{\phi_L V_S} 51 57 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 58 where $\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 60 the large droplets, $\phi_L$ is the volume fraction of large droplets in the 61 sample, and $V_S$ and $V_L$ are the volumes of individual small particles and 55 62 large droplets respectively. 56 63 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}|$ : 64 The form factor of the entire complex can now be calculated including the excess 65 scattering length densities of the components $\Delta\rho_L$ and $\Delta\rho_S$, 66 where $\Delta\rho_x = |\rho_x-\rho_{solvent}|$ : 59 67 60 68 .. math:: 61 69 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] 64 74 65 75 where M is the total scattering length of the whole complex : … … 68 78 M = \Delta\rho_LV_L + N_p\Delta\rho_SV_S 69 79 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: 80 In a real system, there will ususally be an excess of small particles such that 81 some fraction remain unbound. Therefore the overall scattering intensity is 82 given by: 72 83 73 84 .. 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} 75 87 + \phi_S(1-\phi_{surface})(\Delta\rho_S)^2V_S\Psi_S^2 76 88 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: 89 A useful parameter to extract is the fraction of the surface area of the large 90 droplets that is covered by small particles. This can be calculated from the 91 model parameters as: 79 92 80 93 .. math:: … … 85 98 ---------- 86 99 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 100 K Larson-Smith, A Jackson, and D C Pozzo, *Small angle scattering model for 101 Pickering emulsions and raspberry particles*, *Journal of Colloid and Interface 102 Science*, 343(1) (2010) 36-41 89 103 90 104 **Author:** Andrew Jackson **on:** 2008 -
sasmodels/sesans.py
ra154ad16 rc94577f 189 189 integral = besselj(0, q*SElength_i)*Iq*q 190 190 G[i] = np.sum(integral) 191 G0 = np.sum(Iq*q) 191 192 192 193 # [m^-1] step size in q, needed for integration … … 195 196 # integration step, convert q into [m**-1] and 2 pi circle integration 196 197 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)) 199 201 200 202 return P
Note: See TracChangeset
for help on using the changeset viewer.