Changeset 0ae0f9a in sasmodels
- Timestamp:
- Oct 8, 2016 3:30:56 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- eb8a82e
- Parents:
- 0444c02 (diff), 630cdd4 (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. - Files:
-
- 7 added
- 1 deleted
- 15 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/ref/gpu/gpu_computations.rst
r886fa25 r711f17e 1 .. _models-comp litation:1 .. _models-computation: 2 2 3 3 **************** … … 8 8 9 9 To run on the GPU, your computer must have OpenCL drivers installed. 10 For information about OpenCL installation see th e11 :ref:`opencl-installation` documentation10 For information about OpenCL installation see this 11 :ref:`opencl-installation` guidance. 12 12 13 13 Where the model is evaluated is a little bit complicated. … … 16 16 on the CPU. If the OpenCL driver is not available for the CPU then 17 17 it will run as a normal program on the CPU. 18 18 19 For models with a large number of parameters or with a lot of code, 19 20 the GPU may be too small to run the program effectively. 20 21 In this case, you should try simplifying the model, maybe breaking it 21 into several different mod els so that you don't need ifstatements in your code.22 into several different modules so that you don't need *IF* statements in your code. 22 23 If it is still too big, you can set *opencl=False* in the model file and 23 24 the model will only run as a normal program on the CPU. 24 25 This will not usually be necessary. 25 26 27 Device Selection 28 ................ 26 29 If you have multiple GPU devices you can tell SasView which device to use. 27 30 By default, SasView looks for one GPU and one CPU device 28 31 from available OpenCL platforms. 29 32 30 It prefers AMD or NVIDIA drivers for GPU, and prefers Intel or 31 Apple drivers for CPU. 32 Both GPU and CPU are included on the assumption that CPU is always available 33 and supports double precision. 33 SasView prefers AMD or NVIDIA drivers for GPU, and prefers Intel or 34 Apple drivers for CPU. Both GPU and CPU are included on the assumption that CPU 35 is always available and supports double precision. 34 36 35 37 The device order is important: GPU is checked before CPU on the assumption that 36 38 it will be faster. By examining ~/sasview.log you can see which device SasView 37 39 chose to run the model. 40 38 41 If you don't want to use OpenCL, you can set *SAS_OPENCL=None* 39 42 in the environment, and it will only use normal programs. 43 40 44 If you want to use one of the other devices, you can run the following 41 45 from the python console in SasView:: … … 48 52 Use that value as the value of *SAS_OPENCL*. 49 53 54 Compiler Selection 55 .................. 50 56 For models run as normal programs, you may need to specify a compiler. 51 57 This is done using the SAS_COMPILER environment variable. … … 54 60 TinyCC is provided with SasView so that is the default. 55 61 If you want one of the other compilers, be sure to have it available 56 on the path so SasView can find it. 62 in your *PATH* so SasView can find it! 63 64 65 .. note:: 66 This help document was last changed by Steve King, 08Oct2016 -
doc/ref/index.rst
r886fa25 rc34a31f 9 9 intro.rst 10 10 refs.rst 11 gpu _computations.rst11 gpu/gpu_computations.rst 12 12 magnetism/magnetism.rst 13 13 sesans/sans_to_sesans.rst 14 sesans/sesans_fitting.rst 15 -
sasmodels/generate.py
r2e49f9e r462a115 214 214 "1/Ang": "|Ang^-1|", 215 215 "1/Ang^2": "|Ang^-2|", 216 "Ang^3": "|Ang^3|", 217 "1e15/cm^3": "|1e15cm^3|", 218 "Ang^3/mol": "|Ang^3|/mol", 216 219 "1e-6/Ang^2": "|1e-6Ang^-2|", 217 220 "degrees": "degree", -
sasmodels/models/be_polyelectrolyte.py
rb0c4271 r5df888c 3 3 ---------- 4 4 This model calculates the structure factor of a polyelectrolyte solution with 5 the RPA expression derived by Borue and Erukhimovich\ [#Borue]_. The scattering intensity 6 $I(q)$ is calculated as 5 the RPA expression derived by Borue and Erukhimovich\ [#Borue]_. Note however 6 that the fitting procedure here does not follow the notation in that reference 7 as 's' and 't' are **not** decoupled. Instead the scattering intensity $I(q)$ 8 is calculated as 7 9 8 10 .. math:: 9 11 10 I(q) = K\frac{q^2+k^2}{4\pi L \alpha ^2}12 I(q) = K\frac{q^2+k^2}{4\pi L_b\alpha ^2} 11 13 \frac{1}{1+r_{0}^2(q^2+k^2)(q^2-12hC_a/b^2)} + background 12 14 13 k^2 = 4\pi L (2C_s + \alpha C_a)15 k^2 = 4\pi L_b(2C_s + \alpha C_a) 14 16 15 17 r_{0}^2 = \frac{1}{\alpha \sqrt{C_a} \left( b/\sqrt{48\pi L_b}\right)} 16 18 17 where $K$ is the contrast factor for the polymer, $L_b$ is the Bjerrum length, 18 $h$ is the virial parameter, $b$ is the monomer length, 19 $C_s$ is the concentration of monovalent salt, $\alpha$ is the ionization 20 degree, $C_a$ is the polymer molar concentration, and $background$ is the 21 incoherent background. 19 where 20 21 $K$ is the contrast factor for the polymer which is defined differently than in 22 other models and is given in barns where $1 barn = 10^{-24} cm^2$. $K$ is 23 defined as: 24 25 .. math:: 26 27 K = a^2 28 29 a = b_p - (v_p/v_s) b_s 30 31 where $b_p$ and $b_s$ are sum of the scattering lengths of the atoms 32 constituting the monomer of the polymer and the sum of the scattering lengths 33 of the atoms constituting the solvent molecules respectively, and $v_p$ and 34 $v_s$ are the partial molar volume of the polymer and the solvent respectively 35 36 $L_b$ is the Bjerrum length(|Ang|) - **Note:** This parameter needs to be 37 kept constant for a given solvent and temperature! 38 39 $h$ is the virial parameter (|Ang^3|/mol) - **Note:** See [#Borue]_ for the 40 correct interpretation of this parameter. It incorporates second and third 41 virial coefficients and can be Negative. 42 43 $b$ is the monomer length(|Ang|), $C_s$ is the concentration of monovalent 44 salt(mol/L), $\alpha$ is the ionization degree (ionization degree : ratio of 45 charged monomers to total number of monomers), $C_a$ is the polymer molar 46 concentration(mol/L), and $background$ is the incoherent background. 22 47 23 48 For 2D data the scattering intensity is calculated in the same way as 1D, 24 where the $ q$ vector is defined as49 where the $\vec q$ vector is defined as 25 50 26 51 .. math:: 27 52 28 53 q = \sqrt{q_x^2 + q_y^2} 29 30 31 NB: $1 barn = 10^{-24} cm^2$32 54 33 55 References … … 69 91 ["contrast_factor", "barns", 10.0, [-inf, inf], "", "Contrast factor of the polymer"], 70 92 ["bjerrum_length", "Ang", 7.1, [0, inf], "", "Bjerrum length"], 71 ["virial_param", " 1/Ang^2", 12.0, [-inf, inf], "", "Virial parameter"],93 ["virial_param", "Ang^3/mol", 12.0, [-inf, inf], "", "Virial parameter"], 72 94 ["monomer_length", "Ang", 10.0, [0, inf], "", "Monomer length"], 73 95 ["salt_concentration", "mol/L", 0.0, [-inf, inf], "", "Concentration of monovalent salt"], -
sasmodels/models/broad_peak.py
rb0c4271 r43fe34b 17 17 .. math:: I(q) = \frac{A}{q^n} + \frac{C}{1 + (|q - q_0|\xi)^m} + B 18 18 19 Here the peak position is related to the d-spacing as $q_ o = 2\pi / d_o$.19 Here the peak position is related to the d-spacing as $q_0 = 2\pi / d_0$. 20 20 21 21 $A$ is the Porod law scale factor, $n$ the Porod exponent, $C$ is the -
sasmodels/models/core_shell_bicelle.py
radc753d r416f5c7 42 42 I(Q,\alpha) = \frac{\text{scale}}{V} \cdot 43 43 F(Q,\alpha)^2 + \text{background} 44 44 45 where 45 46 46 47 .. math:: 47 48 48 \begin{align}49 F(Q,\alpha) = &\ frac{1}{V_t} \bigg[50 (\rho_c - \rho_f) V_c \frac{J_1(QRsin \alpha)}{QRsin\alpha}\frac{2 \cdot QLcos\alpha}{QLcos\alpha} \\51 &+(\rho_f - \rho_r) V_{c+f} \frac{J_1(QRsin\alpha)}{QRsin\alpha}\frac{2 \cdot Q(L+t_f)cos\alpha}{Q(L+t_f)cos\alpha} \\52 &+(\rho_r - \rho_s) V_t \frac{J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha}\frac{2 \cdot Q(L+t_f)cos\alpha}{Q(L+t_f)cos\alpha}49 \begin{align} 50 F(Q,\alpha) = &\bigg[ 51 (\rho_c - \rho_f) V_c \frac{J_1(QRsin \alpha)}{QRsin\alpha}\frac{2 \cdot sin(QLcos\alpha/2)}{QLcos\alpha} \\ 52 &+(\rho_f - \rho_r) V_{c+f} \frac{J_1(QRsin\alpha)}{QRsin\alpha}\frac{2 \cdot sin(Q(L/2+t_f)cos\alpha)}{Q(L+2t_f)cos\alpha} \\ 53 &+(\rho_r - \rho_s) V_t \frac{J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha}\frac{2 \cdot sin(Q(L/2+t_f)cos\alpha)}{Q(L+2t_f)cos\alpha} 53 54 \bigg] 54 55 \end{align} … … 130 131 # ["name", "units", default, [lower, upper], "type", "description"], 131 132 parameters = [ 132 ["radius", "Ang", 20, [0, inf], "volume", "Cylinder core radius"],133 ["radius", "Ang", 80, [0, inf], "volume", "Cylinder core radius"], 133 134 ["thick_rim", "Ang", 10, [0, inf], "volume", "Rim shell thickness"], 134 135 ["thick_face", "Ang", 10, [0, inf], "volume", "Cylinder face thickness"], 135 ["length", "Ang", 400, [0, inf], "volume", "Cylinder length"],136 ["length", "Ang", 50, [0, inf], "volume", "Cylinder length"], 136 137 ["sld_core", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Cylinder core scattering length density"], 137 138 ["sld_face", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Cylinder face scattering length density"], -
sasmodels/models/core_shell_ellipsoid.py
rb99734a r416f5c7 11 11 .. figure:: img/core_shell_ellipsoid_geometry.png 12 12 13 The geometric parameters of this model are 14 15 *radius_equat_core =* equatorial core radius *= Rminor_core* 16 17 *X_core = polar_core / radius_equat_core = Rmajor_core / Rminor_core* 18 19 *Thick_shell = equat_outer - radius_equat_core = Rminor_outer - Rminor_core* 20 21 *XpolarShell = Tpolar_shell / Thick_shell = (Rmajor_outer - Rmajor_core)/ 22 (Rminor_outer - Rminor_core)* 23 24 In terms of the original radii 25 26 *polar_core = radius_equat_core * X_core* 27 28 *equat_shell = radius_equat_core + Thick_shell* 29 30 *polar_shell = radius_equat_core * X_core + Thick_shell * XpolarShell* 31 32 (where we note that "shell" perhaps confusingly, relates to the outer radius) 13 The geometric parameters of this model are shown in the diagram above, which 14 shows (a) a cut through at the circular equator and (b) a cross section through 15 the poles, of a prolate ellipsoid. 16 33 17 When *X_core < 1* the core is oblate; when *X_core > 1* it is prolate. 34 18 *X_core = 1* is a spherical core. 35 19 36 20 For a fixed shell thickness *XpolarShell = 1*, to scale the shell thickness 37 pro-rata with the radius *XpolarShell = X_core*.21 pro-rata with the radius set or constrain *XpolarShell = X_core*. 38 22 39 23 When including an $S(q)$, the radius in $S(q)$ is calculated to be that of … … 41 25 ellipsoid. This may have some undesirable effects if the aspect ratio of the 42 26 ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$ 43 - which assumes spheres - will not in any case be valid. 27 - which assumes spheres - will not in any case be valid. Generating a 28 custom product model will enable separate effective volume fraction and effective 29 radius in the $S(q)$. 44 30 45 31 If SAS data are in absolute units, and the SLDs are correct, then scale should … … 48 34 or contain some other units conversion factor (for example, if you have SAXS data). 49 35 36 The calculation of intensity follows that for the solid ellipsoid, but with separate 37 terms for the core-shell and shell-solvent boundaries. 38 39 .. math:: 40 41 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background} 42 43 where 44 45 .. math:: 46 \begin{align} 47 F(q,\alpha) = &f(q,radius\_equat\_core,radius\_equat\_core.x\_core,\alpha) \\ 48 &+ f(q,radius\_equat\_core + thick\_shell,radius\_equat\_core.x\_core + thick\_shell.x\_polar\_shell,\alpha) 49 \end{align} 50 51 where 52 53 .. math:: 54 55 f(q,R_e,R_p,\alpha) = \frac{3 \Delta \rho V (\sin[qr(R_p,R_e,\alpha)] 56 - \cos[qr(R_p,R_e,\alpha)])} 57 {[qr(R_p,R_e,\alpha)]^3} 58 59 and 60 61 .. math:: 62 63 r(R_e,R_p,\alpha) = \left[ R_e^2 \sin^2 \alpha 64 + R_p^2 \cos^2 \alpha \right]^{1/2} 65 66 67 $\alpha$ is the angle between the axis of the ellipsoid and $\vec q$, 68 $V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the polar radius along the 69 rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular 70 to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the 71 scattering length density difference, either $(sld\_core - sld\_shell)$ or $(sld\_shell - sld\_solvent)$. 72 73 For randomly oriented particles: 74 75 .. math:: 76 77 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} 78 79 50 80 References 51 81 ---------- 52 53 R K Heenan, 2015, reparametrised the core_shell_ellipsoid model 82 see for example: 83 Kotlarchyk, M.; Chen, S.-H. J. Chem. Phys., 1983, 79, 2461. 84 Berr, S. J. Phys. Chem., 1987, 91, 4760. 85 86 Authorship and Verification 87 ---------------------------- 88 89 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 90 * **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 91 * **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016 54 92 55 93 """ -
sasmodels/models/cylinder.py
r551398c r416f5c7 14 14 .. math:: 15 15 16 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q ) + \text{background}16 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background} 17 17 18 18 where … … 20 20 .. math:: 21 21 22 F(q ) = 2 (\Delta \rho) V22 F(q,\alpha) = 2 (\Delta \rho) V 23 23 \frac{\sin \left(\tfrac12 qL\cos\alpha \right)} 24 24 {\tfrac12 qL \cos \alpha} … … 31 31 first order Bessel function. 32 32 33 For randomly oriented particles: 34 35 .. math:: 36 37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} 38 39 33 40 To provide easy access to the orientation of the cylinder, we define the 34 41 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 35 are defined in :numref:`cylinder-angle-definition` .42 are defined in :numref:`cylinder-angle-definition` . 36 43 37 44 .. _cylinder-angle-definition: -
sasmodels/models/ellipsoid.py
ra807206 r416f5c7 35 35 to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the 36 36 scattering length density difference between the scatterer and the solvent. 37 38 For randomly oriented particles: 39 40 .. math:: 41 42 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} 43 37 44 38 45 To provide easy access to the orientation of the ellipsoid, we define -
sasmodels/models/parallelepiped.py
ra807206 r416f5c7 10 10 11 11 | This model calculates the scattering from a rectangular parallelepiped 12 | ( :numref:`parallelepiped-image`).12 | (\:numref:`parallelepiped-image`\). 13 13 | If you need to apply polydispersity, see also :ref:`rectangular-prism`. 14 14 -
sasmodels/models/polymer_micelle.py
ra807206 rbba9361 11 11 12 12 The 1D scattering intensity for this model is calculated according to 13 the equations given by Pedersen (Pedersen, 2000). 13 the equations given by Pedersen (Pedersen, 2000), summarised briefly here. 14 15 The micelle core is imagined as $N\_aggreg$ polymer heads, each of volume $v\_core$, 16 which then defines a micelle core of $radius\_core$, which is a separate parameter 17 even though it could be directly determined. 18 The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly 19 distributed around the spherical core, centred at a distance $radius\_core + d\_penetration.rg$ 20 from the micelle centre, where $d\_penetration$ is of order unity. 21 A volume $v\_corona$ is defined for each coil. 22 The model in detail seems to separately parametrise the terms for the shape of I(Q) and the 23 relative intensity of each term, so use with caution and check parameters for consistency. 24 The spherical core is monodisperse, so it's intensity and the cross terms may have sharp 25 oscillations (use q resolution smearing if needs be to help remove them). 26 27 .. math:: 28 P(q) = N^2\beta^2_s\Phi(qR)^2+N\beta^2_cP_c(q)+2N^2\beta_s\beta_cS_{sc}s_c(q)+N(N-1)\beta_c^2S_{cc}(q) 29 30 \beta_s = v\_core(sld\_core - sld\_solvent) 31 32 \beta_c = v\_corona(sld\_corona - sld\_solvent) 33 34 where $N = n\_aggreg$, and for the spherical core of radius $R$ 35 36 .. math:: 37 \Phi(qR)= \frac{\sin(qr) - qr\cos(qr)}{(qr)^3} 38 39 whilst for the Gaussian coils 40 41 .. math:: 42 43 P_c(q) &= 2 [\exp(-Z) + Z - 1] / Z^2 44 45 Z &= (q R_g)^2 46 47 The sphere to coil ( core to corona) and coil to coil (corona to corona) cross terms are 48 approximated by: 49 50 .. math:: 51 52 S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} 53 54 S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2 55 56 \psi(Z)=\frac{[1-exp^{-Z}]}{Z} 14 57 15 58 Validation 16 59 ---------- 17 60 18 This model has not yet been validated. Feb2015 61 $P(q)$ above is multiplied by $ndensity$, and a units conversion of 10^{-13}, so $scale$ 62 is likely 1.0 if the scattering data is in absolute units. This model has not yet been 63 independently validated. 19 64 20 65 … … 31 76 title = "Polymer micelle model" 32 77 description = """ 33 This model provides an approximate form factor, P(q), for a micelle with 34 a spherical core with Gaussian polymer chains attached to the surface. 78 This model provides the form factor, $P(q)$, for a micelle with a spherical 79 core and Gaussian polymer chains attached to the surface, thus may be applied 80 to block copolymer micelles. To work well the Gaussian chains must be much 81 smaller than the core, which is often not the case. Please study the 82 reference to Pedersen and full documentation carefully. 35 83 """ 84 85 36 86 category = "shape:sphere" 37 87 -
sasmodels/models/triaxial_ellipsoid.py
ra807206 r416f5c7 36 36 we define the axis of the cylinder using the angles $\theta$, $\phi$ 37 37 and $\psi$. These angles are defined on 38 :numref:`triaxial-ellipsoid-angles` .38 :numref:`triaxial-ellipsoid-angles` . 39 39 The angle $\psi$ is the rotational angle around its own $c$ axis 40 40 against the $q$ plane. For example, $\psi = 0$ when the -
sasmodels/resolution.py
r0444c02 r0ae0f9a 55 55 return theory 56 56 57 58 class SESANS1D(Resolution): 59 60 def __init__(self, data, q_calc): 61 self.data = data 62 self.q_calc = q_calc 63 64 def apply(self, theory): 65 return sesans.transform(self.data, self.q_calc, theory, None, None) 57 66 58 67 class Pinhole1D(Resolution): … … 306 315 weights[i, :] = (in_x + abs_x) * np.diff(q_edges) / (2*h) 307 316 else: 308 for k in range(-n_height, h_height+1):317 for k in range(-n_height, n_height+1): 309 318 weights[i, :] += _q_perp_weights(q_edges, qi+k*h/n_height, w) 310 319 weights[i, :] /= 2*n_height + 1 -
sasmodels/direct_model.py
r4cc161e r0444c02 31 31 from . import resolution2d 32 32 from .details import make_kernel_args, dispersion_mesh 33 from sas.sasgui.perspectives.fitting.fitpage import FitPage 33 34 34 35 try: … … 193 194 # interpret data 194 195 if hasattr(data, 'lam'): 196 #if not FitPage.no_transform.GetValue(): #if the no_transform radio button is not active DOES NOT WORK! not active before fitting 195 197 self.data_type = 'sesans' 196 198 elif hasattr(data, 'qx_data'): -
sasmodels/sesans.py
r7ae2b7f r0444c02 15 15 from numpy import pi, exp # type: ignore 16 16 from scipy.special import jv as besselj 17 from sas.sasgui.perspectives.fitting.fitpage import FitPage 17 18 #import direct_model.DataMixin as model 18 19 … … 61 62 """ 62 63 nqmono = len(qmono) 63 if nqmono == 0: 64 #if nqmono == 0 # if radiobutton hankel is active 65 if FitPage.hankel.GetValue(): 64 66 result = call_hankel(data, q_calc, Iq_calc) 65 67 elif nqmono == 1: 66 68 q = qmono[0] 67 69 result = call_HankelAccept(data, q_calc, Iq_calc, q, Iq_mono) 68 else: 70 else: #if radiobutton Cosine is active 69 71 Qx, Qy = [qmono[0], qmono[1]] 70 72 Qx = np.reshape(Qx, nqx, nqy)
Note: See TracChangeset
for help on using the changeset viewer.