Changeset 404ebbd in sasmodels
- Timestamp:
- Jul 30, 2017 12:56:22 AM (7 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:
- 48462b0
- Parents:
- a151caa
- Location:
- sasmodels/models
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/dab.py
r4962519 r404ebbd 61 61 double numerator = cube(cor_length); 62 62 double denominator = square(1 + square(q*cor_length)); 63 63 64 64 return numerator / denominator ; 65 65 """ 66 67 def random(): 68 import numpy as np 69 pars = dict( 70 scale=10**np.random.uniform(1, 4), 71 cor_length=10**np.random.uniform(0.3, 3), 72 #background = 0, 73 ) 74 pars['scale'] /= pars['cor_length']**3 75 return pars 66 76 67 77 # ER defaults to 1.0 -
sasmodels/models/ellipsoid.py
r9b79f29 r404ebbd 2 2 # Note: model title and parameter table are inserted automatically 3 3 r""" 4 The form factor is normalized by the particle volume 4 The form factor is normalized by the particle volume 5 5 6 6 Definition … … 119 119 * **Last Modified by:** Paul Kienzle **Date:** March 22, 2017 120 120 """ 121 from __future__ import division 121 122 122 123 from numpy import inf, sin, cos, pi … … 177 178 delta = 0.75 * b1 * b2 178 179 179 ddd = np.zeros_like(radius_polar)180 #ddd = np.zeros_like(radius_polar) 180 181 ddd[valid] = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial ** 2 181 182 return 0.5 * ddd ** (1.0 / 3.0) 182 183 184 def random(): 185 import numpy as np 186 V = 10**np.random.uniform(4, 12) 187 radius_polar = 10**np.random.uniform(1.3, 4) 188 radius_equatorial = np.sqrt(V/radius_polar) # ignore 4/3 pi 189 Vf = 10**np.random.uniform(-4, -2) 190 pars = dict( 191 #background=0, sld=0, sld_solvent=1, 192 scale=1e9*Vf/V, 193 radius_polar=radius_polar, 194 radius_equatorial=radius_equatorial, 195 ) 196 return pars 183 197 184 198 demo = dict(scale=1, background=0, -
sasmodels/models/elliptical_cylinder.py
r9802ab3 r404ebbd 33 33 34 34 a = qr'\sin(\alpha) 35 35 36 36 b = q\frac{L}{2}\cos(\alpha) 37 37 38 38 r'=\frac{r_{minor}}{\sqrt{2}}\sqrt{(1+\nu^{2}) + (1-\nu^{2})cos(\psi)} 39 39 … … 57 57 define the axis of the cylinder using two angles $\theta$, $\phi$ and $\Psi$ 58 58 (see :ref:`cylinder orientation <cylinder-angle-definition>`). The angle 59 $\Psi$ is the rotational angle around its own long_c axis. 59 $\Psi$ is the rotational angle around its own long_c axis. 60 60 61 61 All angle parameters are valid and given only for 2D calculation; ie, an … … 72 72 detector plane, with $\Psi$ = 0. 73 73 74 The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data. 74 The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data. 75 75 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 76 appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, the $b$ and $a$ axes of the 77 cylinder cross section. (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) 78 The third orientation distribution, in $\psi$, is about the $c$ axis of the particle. Some experimentation may be required to 79 understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation 80 distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.) 76 appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, the $b$ and $a$ axes of the 77 cylinder cross section. (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) 78 The third orientation distribution, in $\psi$, is about the $c$ axis of the particle. Some experimentation may be required to 79 understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation 80 distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.) 81 81 82 82 NB: The 2nd virial coefficient of the cylinder is calculated based on the … … 110 110 111 111 * **Author:** 112 * **Last Modified by:** 112 * **Last Modified by:** 113 113 * **Last Reviewed by:** Richard Heenan - corrected equation in docs **Date:** December 21, 2016 114 114 … … 156 156 + (length + radius) * (length + pi * radius)) 157 157 return 0.5 * (ddd) ** (1. / 3.) 158 159 def random(): 160 import numpy as np 161 # V = pi * radius_major * radius_minor * length; 162 V = 10**np.random.uniform(3, 9) 163 length = 10**np.random.uniform(1, 3) 164 axis_ratio = 10**(4*np.random.uniform(-2, 2) 165 radius_minor = np.sqrt(V/length/axis_ratio) 166 Vf = 10**np.random.uniform(-4, -2) 167 pars = dict( 168 #background=0, sld=0, sld_solvent=1, 169 scale=1e9*Vf/V, 170 length=length, 171 radius_minor=radius_minor, 172 axis_ratio=axis_ratio, 173 ) 174 return pars 175 158 176 q = 0.1 159 177 # april 6 2017, rkh added a 2d unit test, NOT READY YET pull #890 branch assume correct! -
sasmodels/models/fcc_paracrystal.py
r69e1afc r404ebbd 78 78 .. figure:: img/parallelepiped_angle_definition.png 79 79 80 Orientation of the crystal with respect to the scattering plane, when 80 Orientation of the crystal with respect to the scattering plane, when 81 81 $\theta = \phi = 0$ the $c$ axis is along the beam direction (the $z$ axis). 82 82 … … 119 119 source = ["lib/sas_3j1x_x.c", "lib/gauss150.c", "lib/sphere_form.c", "fcc_paracrystal.c"] 120 120 121 def random(): 122 import numpy as np 123 # Define lattice spacing as a multiple of the particle radius 124 # using the formulat a = 4 r/sqrt(3). Systems which are ordered 125 # are probably mostly filled, so use a distribution which goes from 126 # zero to one, but leaving 90% of them within 80% of the 127 # maximum bcc packing. Lattice distortion values are empirically 128 # useful between 0.01 and 0.7. Use an exponential distribution 129 # in this range 'cuz its easy. 130 dnn_fraction = np.random.beta(a=10, b=1) 131 pars = dict( 132 #sld=1, sld_solvent=0, scale=1, background=1e-32, 133 radius=10**np.random.uniform(1.3, 4), 134 d_factor=10**np.random.uniform(-2, -0.7), # sigma_d in 0.01-0.7 135 ) 136 pars['dnn'] = pars['radius']*4/np.sqrt(3)/dnn_fraction 137 #pars['scale'] = 1/(0.68*dnn_fraction**3) # bcc packing fraction is 0.68 138 pars['scale'] = 1 139 return pars 140 121 141 # parameters for demo 122 142 demo = dict(scale=1, background=0, -
sasmodels/models/fractal.py
rdf89d77 r404ebbd 27 27 28 28 where $\xi$ is the correlation length representing the cluster size and $D_f$ 29 is the fractal dimension, representing the self similarity of the structure. 30 Note that S(q) here goes negative if $D_f$ is too large, and the Gamma function 29 is the fractal dimension, representing the self similarity of the structure. 30 Note that S(q) here goes negative if $D_f$ is too large, and the Gamma function 31 31 diverges at $D_f=0$ and $D_f=1$. 32 32 … … 55 55 56 56 """ 57 from __future__ import division 57 58 58 59 from numpy import inf … … 98 99 source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "lib/fractal_sq.c", "fractal.c"] 99 100 101 def random(): 102 import numpy as np 103 radius = 10**np.random.uniform(0.7, 4) 104 #radius = 5 105 cor_length = 10**np.random.uniform(0.7, 2)*radius 106 #cor_length = 20*radius 107 volfraction = 10**np.random.uniform(-3, -1) 108 #volfraction = 0.05 109 fractal_dim = 2*np.random.beta(3, 4) + 1 110 #fractal_dim = 2 111 pars = dict( 112 #background=0, sld_block=1, sld_solvent=0, 113 scale=1e4/radius**(fractal_dim/2), 114 volfraction=volfraction, 115 radius=radius, 116 cor_length=cor_length, 117 fractal_dim=fractal_dim, 118 ) 119 return pars 120 100 121 demo = dict(volfraction=0.05, 101 122 radius=5.0, -
sasmodels/models/fractal_core_shell.py
r925ad6e r404ebbd 24 24 \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 25 25 26 S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q\xi)^2]^{(D_f-1)/2}} 26 S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q\xi)^2]^{(D_f-1)/2}} 27 27 \frac{\sin[(D_f-1)\tan^{-1}(q\xi)]}{(qr_s)^{D_f}} 28 28 … … 33 33 of the whole particle respectively, $D_f$ is the fractal dimension, and |xi| the 34 34 correlation length. 35 35 36 36 Polydispersity of radius and thickness are also provided for. 37 37 … … 98 98 "lib/fractal_sq.c", "fractal_core_shell.c"] 99 99 100 def random(): 101 import numpy as np 102 total_radius = 10**np.random.uniform(0.7, 4) 103 core_portion = np.random.uniform(0, 1) 104 radius = total_radius * core_portion 105 thickness = total_radius - radius 106 #radius = 5 107 cor_length = 10**np.random.uniform(0.7, 2)*radius 108 #cor_length = 20*radius 109 volfraction = 10**np.random.uniform(-3, -1) 110 #volfraction = 0.05 111 fractal_dim = 2*np.random.beta(3, 4) + 1 112 #fractal_dim = 2 113 pars = dict( 114 #background=0, sld_block=1, sld_solvent=0, 115 scale=1e3/total_radius**(fractal_dim/2), 116 volfraction=volfraction, 117 radius=radius, 118 cor_length=cor_length, 119 fractal_dim=fractal_dim, 120 ) 121 return pars 122 123 100 124 demo = dict(scale=0.05, 101 125 background=0, -
sasmodels/models/guinier.py
r3330bb4 r404ebbd 33 33 description = """ 34 34 I(q) = scale.exp ( - rg^2 q^2 / 3.0 ) 35 35 36 36 List of default parameters: 37 37 scale = scale … … 49 49 """ 50 50 51 def random(): 52 import numpy as np 53 scale = 10**np.random.uniform(1, 5) 54 # Note: compare.py has rg cutoff for guinier, so use that 55 q_max = 1.0 56 rg_max = np.sqrt(90*np.log(10) + 3*np.log(scale))/q_max 57 rg = 10**np.random.uniform(0, np.log10(rg_max)) 58 pars = dict( 59 #background=0, 60 scale=scale, 61 rg=rg, 62 ) 63 return pars 64 51 65 # parameters for demo 52 66 demo = dict(scale=1.0, rg=60.0) -
sasmodels/models/lamellar.py
r40a87fa r404ebbd 89 89 """ 90 90 91 def random(): 92 import numpy as np 93 thickness = 10**np.random.uniform(1, 4) 94 scale = thickness * 10**np.random.uniform(-7, -4) 95 pars = dict( 96 scale=scale, 97 thickness=thickness, 98 ) 99 return pars 100 91 101 # ER defaults to 0.0 92 102 # VR defaults to 1.0 -
sasmodels/models/lamellar_hg.py
ra807206 r404ebbd 98 98 """ 99 99 100 def random(): 101 import numpy as np 102 thickness = 10**np.random.uniform(1, 4) 103 length_head = thickness * np.random.uniform(0, 1) 104 length_tail = thickness - length_head 105 scale = thickness * 10**np.random.uniform(-7, -4) 106 pars = dict( 107 scale=scale, 108 length_head=length_head, 109 length_tail=length_tail, 110 ) 111 return pars 112 100 113 # ER defaults to 0.0 101 114 # VR defaults to 1.0 -
sasmodels/models/lamellar_hg_stack_caille.py
ra57b31d r404ebbd 123 123 # VR defaults to 1.0 124 124 125 def random(): 126 import numpy as np 127 total_thickness = 10**np.random.uniform(2, 4.7) 128 Nlayers = np.random.randint(2, 200) 129 d_spacing = total_thickness / Nlayers 130 thickness = d_spacing * np.random.uniform(0, 1) 131 length_head = thickness * np.random.uniform(0, 1) 132 length_tail = thickness - length_head 133 Caille_parameter = np.random.uniform(0, 0.8) 134 scale = thickness * 10**np.random.uniform(-7, -4) 135 pars = dict( 136 scale=1, 137 length_head=length_head, 138 length_tail=length_tail, 139 Nlayers=Nlayers, 140 d_spacing=d_spacing, 141 Caille_parameter=Caille_parameter, 142 ) 143 return pars 144 125 145 demo = dict( 126 146 scale=1, background=0, -
sasmodels/models/lamellar_stack_caille.py
ra57b31d r404ebbd 98 98 source = ["lamellar_stack_caille.c"] 99 99 100 def random(): 101 import numpy as np 102 total_thickness = 10**np.random.uniform(2, 4.7) 103 Nlayers = np.random.randint(2, 200) 104 d_spacing = total_thickness / Nlayers 105 thickness = d_spacing * np.random.uniform(0, 1) 106 Caille_parameter = np.random.uniform(0, 0.8) 107 scale = thickness * 10**np.random.uniform(-7, -4) 108 pars = dict( 109 scale=1, 110 thickness=thickness, 111 Nlayers=Nlayers, 112 d_spacing=d_spacing, 113 Caille_parameter=Caille_parameter, 114 ) 115 return pars 116 100 117 # No volume normalization despite having a volume parameter 101 118 # This should perhaps be volume normalized? -
sasmodels/models/lamellar_stack_paracrystal.py
ra0168e8 r404ebbd 130 130 form_volume = """ 131 131 return 1.0; 132 """ 132 """ 133 134 def random(): 135 import numpy as np 136 total_thickness = 10**np.random.uniform(2, 4.7) 137 Nlayers = np.random.randint(2, 200) 138 d_spacing = total_thickness / Nlayers 139 thickness = d_spacing * np.random.uniform(0, 1) 140 # Let polydispersity peak around 15%; 95% < 0.4; max=100% 141 sigma_d = np.random.beta(1.5, 7) 142 scale = thickness * 10**np.random.uniform(-7, -4) 143 pars = dict( 144 scale=1, 145 thickness=thickness, 146 Nlayers=Nlayers, 147 d_spacing=d_spacing, 148 sigma_d=sigma_d, 149 ) 150 return pars 133 151 134 152 # ER defaults to 0.0 -
sasmodels/models/line.py
r3330bb4 r404ebbd 68 68 Iqxy.vectorized = True # Iqxy accepts an array of qx qy values 69 69 70 def random(): 71 import numpy as np 72 slope = 1e5*np.random.uniform(-1, 1) 73 offset = 1e-5 + (0 if slope > 0 else -slope) 74 intercept = 10**np.random.uniform(0, 5) + offset 75 pars = dict( 76 scale=1, background=0, 77 slope=slope, 78 intercept=intercept, 79 ) 80 return pars 70 81 71 82 tests = [ -
sasmodels/models/lorentz.py
r2c74c11 r404ebbd 30 30 description = """ 31 31 Model that evaluates a Lorentz (Ornstein-Zernicke) model. 32 32 33 33 I(q) = scale/( 1 + (q*L)^2 ) + bkd 34 35 The model has three parameters: 36 length =screening Length37 scale =scale factor38 background =incoherent background34 35 The model has three parameters: 36 length = screening Length 37 scale = scale factor 38 background = incoherent background 39 39 """ 40 40 category = "shape-independent" … … 48 48 """ 49 49 50 def random(): 51 import numpy as np 52 pars = dict( 53 #background=0, 54 scale=10**np.random.uniform(1, 4), 55 cor_length=10**np.random.uniform(0, 3), 56 ) 57 return pars 58 50 59 # parameters for demo 51 60 demo = dict(scale=1.0, background=0.0, cor_length=50.0) -
sasmodels/models/mass_fractal.py
r925ad6e r404ebbd 88 88 source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "mass_fractal.c"] 89 89 90 def random(): 91 import numpy as np 92 radius = 10**np.random.uniform(0.7, 4) 93 cutoff_length = 10**np.random.uniform(0.7, 2)*radius 94 fractal_dim_mass = 2*np.random.beta(3, 4) + 1 95 Vf = 10**np.random.uniform(-4, -1) 96 pars = dict( 97 #background=0, 98 scale=1, #1e5*Vf/radius**(fractal_dim_mass), 99 radius=radius, 100 cutoff_length=cutoff_length, 101 fractal_dim_mass=fractal_dim_mass, 102 ) 103 return pars 104 90 105 demo = dict(scale=1, background=0, 91 106 radius=10.0, -
sasmodels/models/mass_surface_fractal.py
r6d96b66 r404ebbd 89 89 source = ["mass_surface_fractal.c"] 90 90 91 def random(): 92 import numpy as np 93 fractal_dim = np.random.uniform(1, 6) 94 surface_portion = np.random.uniform(0, 1) 95 fractal_dim_surf = fractal_dim*surface_portion 96 fractal_dim_mass = fractal_dim - fractal_dim_surf 97 rg_cluster = 10**np.random.uniform(1, 5) 98 rg_primary = rg_cluster*10**np.random.uniform(-4, -1) 99 scale = 10**np.random.uniform(2, 5) 100 pars = dict( 101 #background=0, 102 scale=scale, 103 fractal_dim_mass=fractal_dim_mass, 104 fractal_dim_surf=fractal_dim_surf, 105 rg_cluster=rg_cluster, 106 rg_primary=rg_primary, 107 ) 108 return pars 109 110 91 111 demo = dict(scale=1, background=0, 92 112 fractal_dim_mass=1.8, -
sasmodels/models/mono_gauss_coil.py
r3330bb4 r404ebbd 62 62 63 63 description = """ 64 Evaluates the scattering from 64 Evaluates the scattering from 65 65 monodisperse polymer chains. 66 66 """ … … 86 86 Iq.vectorized = True # Iq accepts an array of q values 87 87 88 def random(): 89 import numpy as np 90 rg = 10**np.random.uniform(0, 4) 91 #rg = 1e3 92 pars = dict( 93 #scale=1, background=0, 94 i_zero=1e7, # i_zero is a simple scale 95 rg=rg, 96 ) 97 return pars 98 88 99 demo = dict(scale=1.0, i_zero=70.0, rg=75.0, background=0.0) 89 100 -
sasmodels/models/peak_lorentz.py
r2c74c11 r404ebbd 59 59 Iq.vectorized = True # Iq accepts an array of q values 60 60 61 def random(): 62 import numpy as np 63 peak_pos = 10**np.random.uniform(-3, -1) 64 peak_hwhm = peak_pos * 10**np.random.uniform(-3, 0) 65 pars = dict( 66 #background=0, 67 scale=10**np.random.uniform(2, 6), 68 peak_pos=peak_pos, 69 peak_hwhm=peak_hwhm, 70 ) 71 return pars 72 61 73 demo = dict(scale=100, background=1.0, 62 74 peak_pos=0.05, peak_hwhm=0.005) -
sasmodels/models/poly_gauss_coil.py
r3330bb4 r404ebbd 66 66 67 67 description = """ 68 Evaluates the scattering from 68 Evaluates the scattering from 69 69 polydisperse polymer chains. 70 70 """ … … 96 96 p = [ 97 97 #(-1 - 20*u - 155*u**2 - 580*u**3 - 1044*u**4 - 720*u**5) / 2520., 98 #( 98 #(+1 + 14*u + 71*u**2 + 154*u**3 + 120*u**4) / 360., 99 99 #(-1 - 9*u - 26*u**2 - 24*u**3) / 60., 100 ( 100 (+1 + 5*u + 6*u**2) / 12., 101 101 (-1 - 2*u) / 3., 102 ( 1),102 (+1), 103 103 ] 104 104 result = 2.0 * (power(1.0 + u*z, -1.0/u) + z - 1.0) / (1.0 + u) … … 108 108 return i_zero * result 109 109 Iq.vectorized = True # Iq accepts an array of q values 110 111 def random(): 112 import numpy as np 113 rg = 10**np.random.uniform(0, 4) 114 #rg = 1e3 115 polydispersity = 10**np.random.uniform(0, 3) 116 pars = dict( 117 #scale=1, background=0, 118 i_zero=1e7, # i_zero is a simple scale 119 rg=rg, 120 polydispersity=polydispersity, 121 ) 122 return pars 110 123 111 124 demo = dict(scale=1.0, -
sasmodels/models/polymer_excl_volume.py
r40a87fa r404ebbd 108 108 # ["name", "units", default, [lower, upper], "type", "description"], 109 109 parameters = [ 110 ["rg", "Ang", 60.0, [0, inf], 111 ["porod_exp", "", 3.0, [ -inf, inf], "", "Porod exponent"],110 ["rg", "Ang", 60.0, [0, inf], "", "Radius of Gyration"], 111 ["porod_exp", "", 3.0, [0, inf], "", "Porod exponent"], 112 112 ] 113 113 # pylint: enable=bad-whitespace, line-too-long … … 133 133 Iq.vectorized = True # Iq accepts an array of q values 134 134 135 def random(): 136 import numpy as np 137 rg = 10**np.random.uniform(0, 4) 138 porod_exp = np.random.uniform(1e-3, 6) 139 scale = 10**np.random.uniform(1, 5) 140 pars = dict( 141 #background=0, 142 scale=scale, 143 rg=rg, 144 porod_exp=porod_exp, 145 ) 146 return pars 147 135 148 tests = [ 136 149 # Accuracy tests based on content in test/polyexclvol_default_igor.txt -
sasmodels/models/polymer_micelle.py
r925ad6e r404ebbd 16 16 which then defines a micelle core of $radius\_core$, which is a separate parameter 17 17 even though it could be directly determined. 18 The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly 18 The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly 19 19 distributed around the spherical core, centred at a distance $radius\_core + d\_penetration.rg$ 20 20 from the micelle centre, where $d\_penetration$ is of order unity. … … 27 27 .. math:: 28 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 29 30 30 \beta_s = v\_core(sld\_core - sld\_solvent) 31 31 32 32 \beta_c = v\_corona(sld\_corona - sld\_solvent) 33 33 34 where $N = n\_aggreg$, and for the spherical core of radius $R$ 34 where $N = n\_aggreg$, and for the spherical core of radius $R$ 35 35 36 .. math:: 36 .. math:: 37 37 \Phi(qR)= \frac{\sin(qr) - qr\cos(qr)}{(qr)^3} 38 38 … … 49 49 50 50 .. math:: 51 51 52 52 S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} 53 53 54 54 S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2 55 55 56 56 \psi(Z)=\frac{[1-exp^{-Z}]}{Z} 57 57 … … 60 60 61 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 62 is likely 1.0 if the scattering data is in absolute units. This model has not yet been 63 63 independently validated. 64 64 … … 71 71 """ 72 72 73 from numpy import inf 73 from numpy import inf, pi 74 74 75 75 name = "polymer_micelle" … … 80 80 to block copolymer micelles. To work well the Gaussian chains must be much 81 81 smaller than the core, which is often not the case. Please study the 82 reference to Pedersen and full documentation carefully. 82 reference to Pedersen and full documentation carefully. 83 83 """ 84 84 … … 106 106 source = ["lib/sas_3j1x_x.c", "polymer_micelle.c"] 107 107 108 demo = dict(scale=1, background=0, 109 ndensity=8.94, 110 v_core=62624.0, 111 v_corona=61940.0, 112 sld_solvent=6.4, 113 sld_core=0.34, 114 sld_corona=0.8, 115 radius_core=45.0, 116 rg=20.0, 117 d_penetration=1.0, 118 n_aggreg=6.0) 119 108 def random(): 109 import numpy as np 110 radius_core = 10**np.random.uniform(1, 3) 111 rg = radius_core * 10**np.random.uniform(-2, -0.3) 112 d_penetration = np.random.randn()*0.05 + 1 113 n_aggreg = np.random.randint(3, 30) 114 # volume of head groups is the core volume over the number of groups, 115 # with a correction for packing fraction of the head groups. 116 v_core = 4*pi/3*radius_core**3/n_aggreg * 0.68 117 # Rg^2 for gaussian coil is a^2n/6 => a^2 = 6 Rg^2/n 118 # a=2r => r = Rg sqrt(3/2n) 119 # v = 4/3 pi r^3 n => v = 4/3 pi Rg^3 (3/2n)^(3/2) n = pi Rg^3 sqrt(6/n) 120 tail_segments = np.random.randint(6, 30) 121 v_corona = pi * rg**3 * np.sqrt(6/tail_segments) 122 V = 4*pi/3*(radius_core + rg)**3 123 pars = dict( 124 background=0, 125 scale=1e7/V, 126 ndensity=8.94, 127 v_core=v_core, 128 v_corona=v_corona, 129 radius_core=radius_core, 130 rg=rg, 131 d_penetration=d_penetration, 132 n_aggreg=n_aggreg, 133 ) 134 return pars 120 135 121 136 tests = [ -
sasmodels/models/power_law.py
r40a87fa r404ebbd 50 50 Iq.vectorized = True # Iq accepts an array of q values 51 51 52 def random(): 53 import numpy as np 54 power = np.random.uniform(1, 6) 55 pars = dict( 56 scale=0.1**power*10**np.random.uniform(-4, 2), 57 power=power, 58 ) 59 return pars 60 52 61 demo = dict(scale=1.0, power=4.0, background=0.0) 53 62 -
sasmodels/models/sc_paracrystal.py
r69e1afc r404ebbd 138 138 source = ["lib/sas_3j1x_x.c", "lib/sphere_form.c", "lib/gauss150.c", "sc_paracrystal.c"] 139 139 140 def random(): 141 import numpy as np 142 # Define lattice spacing as a multiple of the particle radius 143 # using the formulat a = 4 r/sqrt(3). Systems which are ordered 144 # are probably mostly filled, so use a distribution which goes from 145 # zero to one, but leaving 90% of them within 80% of the 146 # maximum bcc packing. Lattice distortion values are empirically 147 # useful between 0.01 and 0.7. Use an exponential distribution 148 # in this range 'cuz its easy. 149 dnn_fraction = np.random.beta(a=10, b=1) 150 pars = dict( 151 #sld=1, sld_solvent=0, scale=1, background=1e-32, 152 radius=10**np.random.uniform(1.3, 4), 153 d_factor=10**np.random.uniform(-2, -0.7), # sigma_d in 0.01-0.7 154 ) 155 pars['dnn'] = pars['radius']*4/np.sqrt(3)/dnn_fraction 156 #pars['scale'] = 1/(0.68*dnn_fraction**3) # bcc packing fraction is 0.68 157 pars['scale'] = 1 158 return pars 159 140 160 demo = dict(scale=1, background=0, 141 161 dnn=220.0, -
sasmodels/models/sphere.py
r925ad6e r404ebbd 84 84 return radius 85 85 86 def random(): 87 import numpy as np 88 Vf = 10**np.random.uniform(-4, -2) 89 radius = 10**np.random.uniform(1.3, 4) 90 V = radius**3 91 pars = dict( 92 #background=0, sld=1, sld_solvent=0, 93 scale=1e10*Vf/V, 94 radius=radius, 95 ) 96 return pars 97 86 98 # VR defaults to 1.0 87 99
Note: See TracChangeset
for help on using the changeset viewer.