Changeset 8f04da4 in sasmodels
- Timestamp:
- Aug 2, 2017 2:53:56 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:
- bd21b12
- Parents:
- 1511c37c
- Location:
- sasmodels
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r31df0c9 r8f04da4 763 763 for k in range(opts['sets']): 764 764 opts['pars'] = parse_pars(opts) 765 if opts['pars'] is None: 766 return 765 767 result = run_models(opts, verbose=True) 766 768 if opts['plot']: … … 1395 1397 elif opts['explore']: 1396 1398 opts['pars'] = parse_pars(opts) 1399 if opts['pars'] is None: 1400 return 1397 1401 explore(opts) 1398 1402 else: -
sasmodels/models/adsorbed_layer.py
r0bdddc2 r8f04da4 99 99 # scale = 6 pi/100 (contrast/density*absorbed_amount)^2 * Vf/radius 100 100 # the remaining parameters can be randomly generated from zero to 101 # twice the default value .101 # twice the default value as done by default in compare.py 102 102 import numpy as np 103 103 pars = dict( -
sasmodels/models/bcc_paracrystal.py
r1511c37c r8f04da4 154 154 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 155 155 # add 2d test later 156 q = 4.*pi/220.156 q = 4.*pi/220. 157 157 tests = [ 158 [{ }, 159 [0.001, q, 0.215268], [1.46601394721, 2.85851284174, 0.00866710287078]], 158 [{}, [0.001, q, 0.215268], [1.46601394721, 2.85851284174, 0.00866710287078]], 160 159 [{'theta': 20.0, 'phi': 30, 'psi': 40.0}, (-0.017, 0.035), 2082.20264399], 161 160 [{'theta': 20.0, 'phi': 30, 'psi': 40.0}, (-0.081, 0.011), 0.436323144781], -
sasmodels/models/be_polyelectrolyte.py
ra151caa r8f04da4 141 141 def random(): 142 142 import numpy as np 143 # TODO: review random be_polyelectrolyte model generation 143 144 pars = dict( 144 145 scale=10000, #background=0, -
sasmodels/models/binary_hard_sphere.py
r925ad6e r8f04da4 110 110 source = ["lib/sas_3j1x_x.c", "binary_hard_sphere.c"] 111 111 112 def random(): 113 import numpy as np 114 # TODO: binary_hard_sphere fails at low qr 115 radius_lg = 10**np.random.uniform(2, 4.7) 116 radius_sm = 10**np.random.uniform(2, 4.7) 117 volfraction_lg = 10**np.random.uniform(-3, -0.3) 118 volfraction_sm = 10**np.random.uniform(-3, -0.3) 119 # TODO: Get slightly different results if large and small are swapped 120 # modify the model so it doesn't care which is which 121 if radius_lg < radius_sm: 122 radius_lg, radius_sm = radius_sm, radius_lg 123 volfraction_lg, volfraction_sm = volfraction_sm, volfraction_lg 124 pars = dict( 125 radius_lg=radius_lg, 126 radius_sm=radius_sm, 127 volfraction_lg=volfraction_lg, 128 volfraction_sm=volfraction_sm, 129 ) 130 return pars 131 112 132 # parameters for demo and documentation 113 133 demo = dict(sld_lg=3.5, sld_sm=0.5, sld_solvent=6.36, -
sasmodels/models/core_shell_bicelle_elliptical.py
r9802ab3 r8f04da4 6 6 core-shell scattering length density profile. Thus this is a variation 7 7 of the core-shell bicelle model, but with an elliptical cylinder for the core. 8 Outer shells on the rims and flat ends may be of different thicknesses and 8 Outer shells on the rims and flat ends may be of different thicknesses and 9 9 scattering length densities. The form factor is normalized by the total particle volume. 10 10 … … 17 17 .. figure:: img/core_shell_bicelle_parameters.png 18 18 19 Cross section of model used here. Users will have 20 to decide how to distribute "heads" and "tails" between the rim, face 19 Cross section of model used here. Users will have 20 to decide how to distribute "heads" and "tails" between the rim, face 21 21 and core regions in order to estimate appropriate starting parameters. 22 22 … … 27 27 .. math:: 28 28 29 \rho(r) = 30 \begin{cases} 29 \rho(r) = 30 \begin{cases} 31 31 &\rho_c \text{ for } 0 \lt r \lt R; -L \lt z\lt L \\[1.5ex] 32 32 &\rho_f \text{ for } 0 \lt r \lt R; -(L+2t) \lt z\lt -L; … … 48 48 .. math:: 49 49 50 \begin{align} 51 F(Q,\alpha,\psi) = &\bigg[ 50 \begin{align} 51 F(Q,\alpha,\psi) = &\bigg[ 52 52 (\rho_c - \rho_f) V_c \frac{2J_1(QR'sin \alpha)}{QR'sin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 53 53 &+(\rho_f - \rho_r) V_{c+f} \frac{2J_1(QR'sin\alpha)}{QR'sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 54 54 &+(\rho_r - \rho_s) V_t \frac{2J_1(Q(R'+t_r)sin\alpha)}{Q(R'+t_r)sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} 55 55 \bigg] 56 \end{align} 56 \end{align} 57 57 58 58 where … … 61 61 62 62 R'=\frac{R}{\sqrt{2}}\sqrt{(1+X_{core}^{2}) + (1-X_{core}^{2})cos(\psi)} 63 64 65 and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle, 66 $V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ 63 64 65 and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle, 66 $V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ 67 67 the volume of the core plus the volume of the faces, $R$ is the radius 68 of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core, 69 $t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual 70 first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 71 as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 72 limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 68 of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core, 69 $t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual 70 first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 71 as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 72 limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 73 73 setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an equivalent solution! 74 74 … … 76 76 bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 77 77 78 For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 78 For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 79 79 see the :ref:`elliptical-cylinder` model for further information. 80 80 … … 82 82 .. figure:: img/elliptical_cylinder_angle_definition.png 83 83 84 Definition of the angles for the oriented core_shell_bicelle_elliptical particles. 84 Definition of the angles for the oriented core_shell_bicelle_elliptical particles. 85 85 86 86 … … 105 105 description = """ 106 106 core_shell_bicelle_elliptical 107 Elliptical cylinder core, optional shell on the two flat faces, and shell of 108 uniform thickness on its rim (extending around the end faces). 107 Elliptical cylinder core, optional shell on the two flat faces, and shell of 108 uniform thickness on its rim (extending around the end faces). 109 109 Please see full documentation for equations and further details. 110 110 Involves a double numerical integral around the ellipsoid diameter … … 136 136 "core_shell_bicelle_elliptical.c"] 137 137 138 demo = dict(scale=1, background=0, 139 radius=30.0, 140 x_core=3.0, 141 thick_rim=8.0, 142 thick_face=14.0, 143 length=50.0, 144 sld_core=4.0, 145 sld_face=7.0, 146 sld_rim=1.0, 147 sld_solvent=6.0, 148 theta=90, 149 phi=0, 150 psi=0) 138 def random(): 139 import numpy as np 140 outer_major = 10**np.random.uniform(1, 4.7) 141 outer_minor = 10**np.random.uniform(1, 4.7) 142 # Use a distribution with a preference for thin shell or thin core, 143 # limited by the minimum radius. Avoid core,shell radii < 1 144 min_radius = min(outer_major, outer_minor) 145 thick_rim = np.random.beta(0.5, 0.5)*(min_radius-2) + 1 146 radius_major = outer_major - thick_rim 147 radius_minor = outer_minor - thick_rim 148 radius = radius_major 149 x_core = radius_minor/radius_major 150 outer_length = 10**np.random.uniform(1, 4.7) 151 # Caps should be a small percentage of the total length, but at least one 152 # angstrom long. Since outer length >= 10, the following will suffice 153 thick_face = 10**np.random.uniform(-np.log10(outer_length), -1)*outer_length 154 length = outer_length - thick_face 155 pars = dict( 156 radius=radius, 157 x_core=x_core, 158 thick_rim=thick_rim, 159 thick_face=thick_face, 160 length=length 161 ) 162 return pars 163 151 164 152 165 q = 0.1 -
sasmodels/models/core_shell_cylinder.py
r9b79f29 r8f04da4 142 142 return whole, whole - core 143 143 144 def random(): 145 import numpy as np 146 outer_radius = 10**np.random.uniform(1, 4.7) 147 # Use a distribution with a preference for thin shell or thin core 148 # Avoid core,shell radii < 1 149 radius = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 150 thickness = outer_radius - core 151 length = np.random.uniform(1, 4.7) 152 pars = dict( 153 radius=radius, 154 thickness=thickness, 155 length=length, 156 ) 157 return pars 158 144 159 demo = dict(scale=1, background=0, 145 160 sld_core=6, sld_shell=8, sld_solvent=1, -
sasmodels/models/core_shell_ellipsoid.py
r31df0c9 r8f04da4 154 154 import numpy as np 155 155 V = 10**np.random.uniform(5, 12) 156 radius_polar = 10**np.random.uniform(1.3, 4) 157 radius_equatorial = np.sqrt(V/radius_polar) # ignore 4/3 pi 158 thickness_polar = np.random.uniform(0.01, 1)*radius_polar 159 thickness_equatorial = np.random.uniform(0.01, 1)*radius_equatorial 160 radius_polar -= thickness_polar 161 radius_equatorial -= thickness_equatorial 156 outer_polar = 10**np.random.uniform(1.3, 4) 157 outer_equatorial = np.sqrt(V/radius_polar) # ignore 4/3 pi 158 # Use a distribution with a preference for thin shell or thin core 159 # Avoid core,shell radii < 1 160 thickness_polar = np.random.beta(0.5, 0.5)*(outer__polar-2) + 1 161 thickness_equatorial = np.random.beta(0.5, 0.5)*(outer_equatorial-2) + 1 162 radius_polar = outer_polar - thickness_polar 163 radius_equatorial = outer_equatorial - thickness_equatorial 162 164 x_core = radius_polar/radius_equatorial 163 165 x_polar_shell = thickness_polar/thickness_equatorial -
sasmodels/models/core_shell_parallelepiped.py
r9b79f29 r8f04da4 4 4 5 5 Calculates the form factor for a rectangular solid with a core-shell structure. 6 The thickness and the scattering length density of the shell or 6 The thickness and the scattering length density of the shell or 7 7 "rim" can be different on each (pair) of faces. However at this time 8 8 the 1D calculation does **NOT** actually calculate a c face rim despite the presence of … … 42 42 43 43 **meaning that there are "gaps" at the corners of the solid.** Again note that 44 $t_C = 0$ currently. 44 $t_C = 0$ currently. 45 45 46 46 The intensity calculated follows the :ref:`parallelepiped` model, with the … … 82 82 based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ 83 83 and length $(C+2t_C)$ values, after appropriately 84 sorting the three dimensions to give an oblate or prolate particle, to give an 84 sorting the three dimensions to give an oblate or prolate particle, to give an 85 85 effective radius, for $S(Q)$ when $P(Q) * S(Q)$ is applied. 86 86 … … 126 126 title = "Rectangular solid with a core-shell structure." 127 127 description = """ 128 P(q)= 128 P(q)= 129 129 """ 130 130 category = "shape:parallelepiped" … … 179 179 # VR defaults to 1.0 180 180 181 def random(): 182 import numpy as np 183 outer = 10**np.random.uniform(1, 4.7, size=3) 184 thick = np.random.beta(0.5, 0.5, size=3)*(outer-2) + 1 185 length = outer - thick 186 pars = dict( 187 length_a=length[0], 188 length_b=length[1], 189 length_c=length[2], 190 thick_rim_a=thick[0], 191 thick_rim_b=thick[1], 192 thick_rim_c=thick[2], 193 ) 194 return pars 195 181 196 # parameters for demo 182 197 demo = dict(scale=1, background=0.0, -
sasmodels/models/core_shell_sphere.py
r31df0c9 r8f04da4 101 101 def random(): 102 102 import numpy as np 103 total_radius = 10**np.random.uniform(1.3, 4.3) 104 radius = np.random.uniform(0, 1)*total_radius 105 thickness = total_radius - radius 103 outer_radius = 10**np.random.uniform(1.3, 4.3) 104 # Use a distribution with a preference for thin shell or thin core 105 # Avoid core,shell radii < 1 106 radius = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 107 thickness = outer_radius - core 106 108 pars = dict( 107 109 radius=radius, … … 112 114 tests = [ 113 115 [{'radius': 20.0, 'thickness': 10.0}, 'ER', 30.0], 114 115 116 116 # TODO: VR test suppressed until we sort out new product model 117 # and determine what to do with volume ratio. 118 #[{'radius': 20.0, 'thickness': 10.0}, 'VR', 0.703703704], 117 119 118 # The SasView test result was 0.00169, with a background of 0.001 119 [{'radius': 60.0, 'thickness': 10.0, 'sld_core': 1.0, 'sld_shell':2.0, 120 'sld_solvent':3.0, 'background':0.0}, 121 0.4, 0.000698838], 120 # The SasView test result was 0.00169, with a background of 0.001 121 [{'radius': 60.0, 'thickness': 10.0, 'sld_core': 1.0, 'sld_shell': 2.0, 122 'sld_solvent': 3.0, 'background': 0.0}, 0.4, 0.000698838], 122 123 ] -
sasmodels/models/fcc_paracrystal.py
r1511c37c r8f04da4 125 125 d_factor = 10**np.random.uniform(-2, -0.7) # sigma_d in 0.01-0.7 126 126 dnn_fraction = np.random.beta(a=10, b=1) 127 dnn = radius*4/np.sqrt( 3)/dnn_fraction127 dnn = radius*4/np.sqrt(2)/dnn_fraction 128 128 pars = dict( 129 129 #sld=1, sld_solvent=0, scale=1, background=1e-32, … … 135 135 136 136 # april 10 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 137 q = 4.*pi/220.137 q = 4.*pi/220. 138 138 tests = [ 139 [{ }, 140 [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]], 141 [{}, (-0.047, -0.007), 238.103096286 ], 142 [{}, (0.053, 0.063), 0.863609587796 ], 139 [{}, [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]], 140 [{}, (-0.047, -0.007), 238.103096286], 141 [{}, (0.053, 0.063), 0.863609587796], 143 142 ] -
sasmodels/models/fractal_core_shell.py
r1511c37c r8f04da4 100 100 def random(): 101 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 102 outer_radius = 10**np.random.uniform(0.7, 4) 103 # Use a distribution with a preference for thin shell or thin core 104 # Avoid core,shell radii < 1 105 thickness = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 106 radius = outer_radius - thickness 107 cor_length = 10**np.random.uniform(0.7, 2)*outer_radius 109 108 volfraction = 10**np.random.uniform(-3, -1) 110 #volfraction = 0.05111 109 fractal_dim = 2*np.random.beta(3, 4) + 1 112 #fractal_dim = 2113 110 pars = dict( 114 111 #background=0, sld_block=1, sld_solvent=0, … … 119 116 ) 120 117 return pars 121 122 118 123 119 demo = dict(scale=0.05, -
sasmodels/models/hardsphere.py
r40a87fa r8f04da4 75 75 Iq = r""" 76 76 double D,A,B,G,X,X2,X4,S,C,FF,HARDSPH; 77 // these are c compiler instructions, can also put normal code inside the "if else" structure 77 // these are c compiler instructions, can also put normal code inside the "if else" structure 78 78 #if FLOAT_SIZE > 4 79 79 // double precision orig had 0.2, don't call the variable cutoff as PAK already has one called that! Must use UPPERCASE name please. … … 82 82 #else 83 83 // 0.1 bad, 0.2 OK, 0.3 good, 0.4 better, 0.8 no good 84 #define CUTOFFHS 0.4 84 #define CUTOFFHS 0.4 85 85 #endif 86 86 … … 110 110 if(X < CUTOFFHS) { 111 111 // RKH Feb 2016, use Taylor series expansion for small X 112 // else no obvious way to rearrange the equations to avoid needing a very high number of significant figures. 113 // Series expansion found using Mathematica software. Numerical test in .xls showed terms to X^2 are sufficient 114 // for 5 or 6 significant figures, but I put the X^4 one in anyway 112 // else no obvious way to rearrange the equations to avoid needing a very high number of significant figures. 113 // Series expansion found using Mathematica software. Numerical test in .xls showed terms to X^2 are sufficient 114 // for 5 or 6 significant figures, but I put the X^4 one in anyway 115 115 //FF = 8*A +6*B + 4*G - (0.8*A +2.0*B/3.0 +0.5*G)*X2 +(A/35. +B/40. +G/50.)*X4; 116 116 // refactoring the polynomial makes it very slightly faster (0.5 not 0.6 msec) … … 153 153 """ 154 154 155 def random(): 156 import numpy as np 157 pars = dict( 158 scale=1, background=0, 159 radius_effective=10**np.random.uniform(1, 4), 160 volfraction=10**np.random.uniform(-2, 0), # high volume fraction 161 ) 162 return pars 163 155 164 # ER defaults to 0.0 156 165 # VR defaults to 1.0 -
sasmodels/models/hayter_msa.py
r5702f52 r8f04da4 64 64 Routine takes absolute value of charge, use HardSphere if charge 65 65 goes to zero. 66 In sasview the effective radius and volume fraction may be calculated 66 In sasview the effective radius and volume fraction may be calculated 67 67 from the parameters used in P(Q). 68 68 """ … … 89 89 # ER defaults to 0.0 90 90 # VR defaults to 1.0 91 92 def random(): 93 import numpy as np 94 # TODO: too many failures for random hayter_msa parameters 95 pars = dict( 96 scale=1, background=0, 97 radius_effective=10**np.random.uniform(1, 4.7), 98 volfraction=10**np.random.uniform(-2, 0), # high volume fraction 99 charge=min(int(10**np.random.uniform(0, 1.3)+0.5), 200), 100 temperature=10**np.random.uniform(0, np.log10(450)), # max T = 450 101 #concentration_salt=10**np.random.uniform(-3, 1), 102 dialectconst=10**np.random.uniform(0, 6), 103 #charge=10, 104 #temperature=318.16, 105 concentration_salt=0.0, 106 #dielectconst=71.08, 107 ) 108 return pars 91 109 92 110 # default parameter set, use compare.sh -midQ -linear -
sasmodels/models/hollow_cylinder.py
r31df0c9 r8f04da4 123 123 def random(): 124 124 import numpy as np 125 length = 10**np.random.uniform(2, 6) 126 radius = 10**np.random.uniform(1, 3) 127 kuhn_length = 10**np.random.uniform(-2, -0.7)*length # at least 10 segments 125 length = 10**np.random.uniform(1, 4.7) 126 outer_radius = 10**np.random.uniform(1, 4.7) 127 # Use a distribution with a preference for thin shell or thin core 128 # Avoid core,shell radii < 1 129 thickness = np.random.beta(0.5, 0.5)*(outer_radius-2) + 1 130 radius = outer_radius - thickness 128 131 pars = dict( 129 132 length=length, 130 133 radius=radius, 131 kuhn_length=kuhn_length,134 thickness=thickness, 132 135 ) 133 136 return pars 134 137 138 # parameters for demo 139 demo = dict(scale=1.0, background=0.0, length=400.0, radius=20.0, 140 thickness=10, sld=6.3, sld_solvent=1, theta=90, phi=0, 141 thickness_pd=0.2, thickness_pd_n=9, 142 length_pd=.2, length_pd_n=10, 143 radius_pd=.2, radius_pd_n=9, 144 theta_pd=10, theta_pd_n=5, 145 ) 135 146 q = 0.1 136 147 # april 6 2017, rkh added a 2d unit test, assume correct! -
sasmodels/models/hollow_rectangular_prism.py
r31df0c9 r8f04da4 149 149 import numpy as np 150 150 a, b, c = 10**np.random.uniform(1, 4.7, size=3) 151 thickness = np.random.uniform(0.01, 0.49) * min(a, b, c) 151 # Thickness is limited to 1/2 the smallest dimension 152 # Use a distribution with a preference for thin shell or thin core 153 # Avoid core,shell radii < 1 154 min_dim = 0.5*min(a, b, c) 155 thickness = np.random.beta(0.5, 0.5)*(min_dim-2) + 1 156 #print(a, b, c, thickness, thickness/min_dim) 152 157 pars = dict( 153 158 length_a=a, -
sasmodels/models/lamellar_stack_paracrystal.py
r1511c37c r8f04da4 140 140 # Let polydispersity peak around 15%; 95% < 0.4; max=100% 141 141 sigma_d = np.random.beta(1.5, 7) 142 scale = thickness * 10**np.random.uniform(-7, -4)143 142 pars = dict( 144 #scale=1,145 143 thickness=thickness, 146 144 Nlayers=Nlayers, -
sasmodels/models/linear_pearls.py
rc3ccaec r8f04da4 65 65 source = ["lib/sas_3j1x_x.c", "linear_pearls.c"] 66 66 67 demo = dict(scale=1.0, background=0.0, 68 radius=80.0, 69 edge_sep=350.0, 70 num_pearls=3, 71 sld=1.0, 72 sld_solvent=6.3) 67 def random(): 68 import numpy as np 69 radius = 10**np.random.uniform(1, 3) # 1 - 1000 70 edge_sep = 10**np.random.uniform(0, 3) # 1 - 1000 71 num_pearls = np.round(10**np.random.uniform(0.3, 3)) # 2 - 1000 72 pars = dict( 73 radius=radius, 74 edge_sep=edge_sep, 75 num_pearls=num_pearls, 76 ) 77 return pars 73 78 74 79 """ -
sasmodels/models/multilayer_vesicle.py
r5d23de2 r8f04da4 149 149 return radius + n_shells * (thick_shell + thick_solvent) - thick_solvent 150 150 151 demo = dict(scale=1, background=0, 152 volfraction=0.05, 153 radius=60.0, 154 thick_shell=10.0, 155 thick_solvent=10.0, 156 sld_solvent=6.4, 157 sld=0.4, 158 n_shells=2.0) 151 def random(): 152 import numpy as np 153 volfraction = 10**np.random.uniform(-3, -0.5) # scale from 0.1% to 30% 154 radius = 10**np.random.uniform(0, 2.5) # core less than 300 A 155 total_thick = 10**np.random.uniform(2, 4) # up to 10000 A of shells 156 # random number of shells, with shell+solvent thickness > 10 A 157 n_shells = int(10**np.random.uniform(0, np.log10(total_thick)-1)+0.5) 158 # split total shell thickness with preference for shell over solvent; 159 # make sure that shell thickness is at least 1 A 160 one_thick = total_thick/n_shells 161 thick_solvent = 10**np.random.uniform(-2, 0)*(one_thick - 1) 162 thick_shell = one_thick - thick_solvent 163 pars = dict( 164 scale=1, 165 volfraction=volfraction, 166 radius=radius, 167 thick_shell=thick_shell, 168 thick_solvent=thick_solvent, 169 n_shells=n_shells, 170 ) 171 return pars 159 172 160 173 tests = [ -
sasmodels/models/parallelepiped.py
r31df0c9 r8f04da4 245 245 def random(): 246 246 import numpy as np 247 a, b, c= 10**np.random.uniform(1, 4.7, size=3)247 length = 10**np.random.uniform(1, 4.7, size=3) 248 248 pars = dict( 249 length_a= a,250 length_b= b,251 length_c= c,249 length_a=length[0], 250 length_b=length[1], 251 length_c=length[2], 252 252 ) 253 253 return pars -
sasmodels/models/pearl_necklace.py
r1bd1ea2 r8f04da4 117 117 return rad_out 118 118 119 def random(): 120 import numpy as np 121 radius = 10**np.random.uniform(1, 3) # 1 - 1000 122 thick_string = 10**np.random.uniform(0, np.log10(radius)-1) # 1 - radius/10 123 edge_sep = 10**np.random.uniform(0, 3) # 1 - 1000 124 num_pearls = np.round(10**np.random.uniform(0.3, 3)) # 2 - 1000 125 pars = dict( 126 radius=radius, 127 edge_sep=edge_sep, 128 thick_string=thick_string, 129 num_pearls=num_pearls, 130 ) 131 return pars 132 119 133 # parameters for demo 120 134 demo = dict(scale=1, background=0, radius=80.0, edge_sep=350.0, -
sasmodels/models/pringle.py
r30fbe2e r8f04da4 85 85 return 0.5 * (ddd) ** (1. / 3.) 86 86 87 demo = dict(background=0.0, 88 scale=1.0, 89 radius=60.0, 90 thickness=10.0, 91 alpha=0.001, 92 beta=0.02, 93 sld=1.0, 94 sld_solvent=6.35) 87 def random(): 88 import numpy as np 89 alpha, beta = 10**np.random.uniform(-1, 1, size=2) 90 radius = 10**np.random.uniform(1, 3) 91 thickness = 10**np.random.uniform(0.7, 2) 92 pars = dict( 93 radius=radius, 94 thickness=thickness, 95 alpha=alpha, 96 beta=beta, 97 ) 98 return pars 95 99 96 100 tests = [ -
sasmodels/models/raspberry.py
rc3ccaec r8f04da4 154 154 source = ["lib/sas_3j1x_x.c", "raspberry.c"] 155 155 156 def random(): 157 import numpy as np 158 # Limit volume fraction to 20% each 159 volfraction_lg = 10**np.random.uniform(-3, -0.3) 160 volfraction_sm = 10**np.random.uniform(-3, -0.3) 161 # Prefer most particles attached (peak near 60%), but not all or none 162 surface_fraction = np.random.beta(6, 4) 163 radius_lg = 10**np.random.uniform(1.7, 4.7) # 500 - 50000 A 164 radius_sm = 10**np.random.uniform(-3, -0.3)*radius_lg # 0.1% - 20% 165 penetration = np.random.beta(1, 10) # up to 20% pen. for 90% of examples 166 pars = dict( 167 volfraction_lg=volfraction_lg, 168 volfraction_sm=volfraction_sm, 169 surface_fraction=surface_fraction, 170 radius_lg=radius_lg, 171 radius_sm=radius_sm, 172 penetration=penetration, 173 ) 174 return pars 175 156 176 # parameters for demo 157 177 demo = dict(scale=1, background=0.001, -
sasmodels/models/sc_paracrystal.py
r1511c37c r8f04da4 144 144 d_factor = 10**np.random.uniform(-2, -0.7) # sigma_d in 0.01-0.7 145 145 dnn_fraction = np.random.beta(a=10, b=1) 146 dnn = radius*4/np.sqrt( 3)/dnn_fraction146 dnn = radius*4/np.sqrt(4)/dnn_fraction 147 147 pars = dict( 148 148 #sld=1, sld_solvent=0, scale=1, background=1e-32, -
sasmodels/models/squarewell.py
r3330bb4 r8f04da4 91 91 double S,C,SL,CL; 92 92 x= q; 93 93 94 94 req = radius_effective; 95 95 phis = volfraction; 96 96 edibkb = welldepth; 97 97 lambda = wellwidth; 98 98 99 99 sigma = req*2.; 100 100 eta = phis; … … 110 110 beta = -(eta/3.0) * ( 18. + 20.*eta - 12.*eta2 + eta4 )/etam14; 111 111 gamm = 0.5*eta*( sk + eta3*(eta-4.) )/etam14; 112 112 113 113 // calculate the structure factor 114 114 115 115 sk = x*sigma; 116 116 sk2 = sk*sk; … … 125 125 ck = -24.0*eta*( t1 + t2 + t3 + t4 )/sk3/sk3; 126 126 struc = 1./(1.-ck); 127 127 128 128 return(struc); 129 129 """ … … 132 132 # VR defaults to 1.0 133 133 134 def random(): 135 import numpy as np 136 pars = dict( 137 scale=1, background=0, 138 radius_effective=10**np.random.uniform(1, 4.7), 139 volfraction=np.random.uniform(0.00001, 0.08), 140 welldepth=np.random.uniform(0, 1.5), 141 wellwidth=np.random.uniform(1, 1.2), 142 ) 143 return pars 144 134 145 demo = dict(radius_effective=50, volfraction=0.04, welldepth=1.5, 135 146 wellwidth=1.2, radius_effective_pd=0, radius_effective_pd_n=0) 136 147 # 137 148 tests = [ 138 [{'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 139 'volfraction' : 0.04,'welldepth' : 1.5, 'wellwidth' : 1.2, 140 'radius_effective_pd' : 0}, 141 [0.001], [0.97665742]], 149 [{'scale': 1.0, 'background': 0.0, 'radius_effective': 50.0, 150 'volfraction': 0.04,'welldepth': 1.5, 'wellwidth': 1.2, 151 'radius_effective_pd': 0}, [0.001], [0.97665742]], 142 152 ] 143 153 # ADDED by: converting from sasview RKH ON: 16Mar2016 -
sasmodels/models/stacked_disks.py
r9d50a1e r8f04da4 137 137 138 138 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "stacked_disks.c"] 139 140 def random(): 141 import numpy as np 142 radius = 10**np.random.uniform(1, 4.7) 143 total_stack = 10**np.random.uniform(1, 4.7) 144 n_stacking = int(10**np.random.uniform(0, np.log10(total_stack)-1) + 0.5) 145 d = total_stack/n_stacking 146 thick_core = np.random.uniform(0, d-2) # at least 1 A for each layer 147 thick_layer = (d - thick_core)/2 148 # Let polydispersity peak around 15%; 95% < 0.4; max=100% 149 sigma_d = d * np.random.beta(1.5, 7) 150 pars = dict( 151 thick_core=thick_core, 152 thick_layer=thick_layer, 153 radius=radius, 154 n_stacking=n_stacking, 155 sigma_d=sigma_d, 156 ) 157 return pars 139 158 140 159 demo = dict(background=0.001, -
sasmodels/models/stickyhardsphere.py
r40a87fa r8f04da4 98 98 ] 99 99 100 def random(): 101 import numpy as np 102 pars = dict( 103 scale=1, background=0, 104 radius_effective=10**np.random.uniform(1, 4.7), 105 volfraction=np.random.uniform(0.00001, 0.74), 106 perturb=10**np.random.uniform(-2, -1), 107 stickiness=np.random.uniform(0, 1), 108 ) 109 return pars 110 100 111 # No volume normalization despite having a volume parameter 101 112 # This should perhaps be volume normalized? -
sasmodels/product.py
rf88e248 r8f04da4 93 93 # Remember the component info blocks so we can build the model 94 94 model_info.composition = ('product', [p_info, s_info]) 95 # TODO: delegate random to p_info, s_info 96 #model_info.random = lambda: {} 95 97 model_info.demo = demo 96 98
Note: See TracChangeset
for help on using the changeset viewer.