Changeset 48462b0 in sasmodels
- Timestamp:
- Jul 31, 2017 1:24:42 AM (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:
- 109d963
- Parents:
- 404ebbd
- Location:
- sasmodels
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r0bdddc2 r48462b0 368 368 elif name == 'guinier': 369 369 # Limit guinier to an Rg such that Iq > 1e-30 (single precision cutoff) 370 # I(q) = A e^-(Rg^2 q^2/3) > e^-(30 ln 10) 371 # => ln A - (Rg^2 q^2/3) > -30 ln 10 372 # => Rg^2 q^2/3 < 30 ln 10 + ln A 373 # => Rg < sqrt(90 ln 10 + 3 ln A)/q 370 374 #q_max = 0.2 # mid q maximum 371 375 q_max = 1.0 # high q maximum … … 1319 1323 """ 1320 1324 opts = parse_opts(argv) 1321 if opts['seed'] > -1:1322 print("Randomize using -random=%i"%opts['seed'])1323 np.random.seed(opts['seed'])1324 1325 if opts is not None: 1326 if opts['seed'] > -1: 1327 print("Randomize using -random=%i"%opts['seed']) 1328 np.random.seed(opts['seed']) 1325 1329 if opts['html']: 1326 1330 show_docs(opts) -
sasmodels/models/gauss_lorentz_gel.py
ra807206 r48462b0 3 3 but typically a physical rather than chemical network. 4 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 5 give a functional form similar to Guinier scattering, so interpret with 6 6 care) plus a Lorentzian at higher-q values. See also the gel_fit model. 7 7 … … 88 88 89 89 90 def random(): 91 import numpy as np 92 gauss_scale = 10**np.random.uniform(1, 3) 93 lorentz_scale = 10**np.random.uniform(1, 3) 94 cor_length_static = 10**np.random.uniform(0, 3) 95 cor_length_dynamic = 10**np.random.uniform(0, 3) 96 pars = dict( 97 #background=0, 98 scale=1, 99 gauss_scale=gauss_scale, 100 lorentz_scale=lorentz_scale, 101 cor_length_static=cor_length_static, 102 cor_length_dynamic=cor_length_dynamic, 103 ) 104 return pars 105 106 90 107 demo = dict(scale=1, background=0.1, 91 108 gauss_scale=100.0, -
sasmodels/models/gaussian_peak.py
ra807206 r48462b0 51 51 # VR defaults to 1.0 52 52 53 demo = dict(scale=1, background=0, peak_pos=0.05, sigma=0.005) 53 def random(): 54 import numpy as np 55 peak_pos = 10**np.random.uniform(-3, -1) 56 sigma = 10**np.random.uniform(-1.3, -0.3)*peak_pos 57 scale = 10**np.random.uniform(0, 4) 58 pars = dict( 59 #background=1e-8, 60 scale=scale, 61 peak_pos=peak_pos, 62 sigam=sigma, 63 ) 64 return pars -
sasmodels/models/gel_fit.c
ra807206 r48462b0 10 10 double lorentzian_term = square(q*cor_length); 11 11 lorentzian_term = 1.0 + ((fractal_dim + 1.0)/3.0)*lorentzian_term; 12 lorentzian_term = pow(lorentzian_term, (fractal_dim/2.0));12 lorentzian_term = pow(lorentzian_term, fractal_dim/2.0 ); 13 13 14 14 // Exponential Term 15 15 ////////////////////////double d(x[i]*x[i]*rg*rg); 16 16 double exp_term = square(q*rg); 17 exp_term = exp(- 1.0*(exp_term/3.0));17 exp_term = exp(-exp_term/3.0); 18 18 19 19 // Scattering Law -
sasmodels/models/gel_fit.py
ra807206 r48462b0 71 71 source = ["gel_fit.c"] 72 72 73 def random(): 74 import numpy as np 75 guinier_scale = 10**np.random.uniform(1, 3) 76 lorentz_scale = 10**np.random.uniform(1, 3) 77 rg = 10**np.random.uniform(1, 5) 78 fractal_dim = np.random.uniform(0, 6) 79 cor_length = 10**np.random.uniform(0, 3) 80 pars = dict( 81 #background=0, 82 scale=1, 83 guinier_scale=guinier_scale, 84 lorentz_scale=lorentz_scale, 85 rg=rg, 86 fractal_dim=fractal_dim, 87 cor_length=cor_length 88 ) 89 return pars 90 73 91 demo = dict(background=0.01, 74 92 guinier_scale=1.7, -
sasmodels/models/guinier.py
r404ebbd r48462b0 51 51 def random(): 52 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 53 scale = 10**np.random.uniform(1, 4) 54 # Note: compare.py has Rg cutoff of 1e-30 at q=1 for guinier, so use that 55 # log_10 Ae^(-(q Rg)^2/3) = log_10(A) - (q Rg)^2/ (3 ln 10) > -30 56 # => log_10(A) > Rg^2/(3 ln 10) - 30 55 57 q_max = 1.0 56 58 rg_max = np.sqrt(90*np.log(10) + 3*np.log(scale))/q_max -
sasmodels/models/guinier_porod.py
rcdcebf1 r48462b0 4 4 and dimensionality of scattering objects, including asymmetric objects 5 5 such as rods or platelets, and shapes intermediate between spheres 6 and rods or between rods and platelets, and overcomes some of the 6 and rods or between rods and platelets, and overcomes some of the 7 7 deficiencies of the (Beaucage) Unified_Power_Rg model (see Hammouda, 2010). 8 8 … … 77 77 scale = Guinier Scale 78 78 s = Dimension Variable 79 Rg = Radius of Gyration [A] 79 Rg = Radius of Gyration [A] 80 80 porod_exp = Porod Exponent 81 81 background = Background [1/cm]""" … … 114 114 Iq.vectorized = True # Iq accepts an array of q values 115 115 116 def random(): 117 import numpy as np 118 rg = 10**np.random.uniform(1, 5) 119 s = np.random.uniform(0, 3) 120 porod_exp = s + np.random.uniform(0, 3) 121 pars = dict( 122 #scale=1, background=0, 123 rg=rg, 124 s=s, 125 porod_exp=porod_exp, 126 ) 127 return pars 128 116 129 demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, porod_exp=3.0) 117 130 -
sasmodels/models/line.py
r404ebbd r48462b0 70 70 def random(): 71 71 import numpy as np 72 slope = 1e5*np.random.uniform(-1, 1) 72 scale = 10**np.random.uniform(0, 3) 73 slope = np.random.uniform(-1, 1)*1e2 73 74 offset = 1e-5 + (0 if slope > 0 else -slope) 74 intercept = 10**np.random.uniform(0, 5) + offset75 intercept = 10**np.random.uniform(0, 1) + offset 75 76 pars = dict( 76 scale=1, background=0, 77 #background=0, 78 scale=scale, 77 79 slope=slope, 78 80 intercept=intercept, -
sasmodels/models/spinodal.py
rbba9361 r48462b0 3 3 ---------- 4 4 5 This model calculates the SAS signal of a phase separating solution under spinodal decomposition. 5 This model calculates the SAS signal of a phase separating solution under spinodal decomposition. 6 6 The scattering intensity $I(q)$ is calculated as 7 7 8 .. math:: 8 .. math:: 9 9 I(q) = I_{max}\frac{(1+\gamma/2)x^2}{\gamma/2+x^{2+\gamma}}+B 10 10 11 where $x=q/q_0$ and $B$ is a flat background. The characteristic structure length 12 scales with the correlation peak at $q_0$. The exponent $\gamma$ is equal to 11 where $x=q/q_0$ and $B$ is a flat background. The characteristic structure length 12 scales with the correlation peak at $q_0$. The exponent $\gamma$ is equal to 13 13 $d+1$ with d the dimensionality of the off-critical concentration mixtures. 14 A transition to $\gamma=2d$ is seen near the percolation threshold into the 14 A transition to $\gamma=2d$ is seen near the percolation threshold into the 15 15 critical concentration regime. 16 16 … … 18 18 ---------- 19 19 20 H. Furukawa. Dynamics-scaling theory for phase-separating unmixing mixtures: 20 H. Furukawa. Dynamics-scaling theory for phase-separating unmixing mixtures: 21 21 Growth rates of droplets and scaling properties of autocorrelation functions. Physica A 123,497 (1984). 22 22 … … 25 25 26 26 * **Author:** Dirk Honecker **Date:** Oct 7, 2016 27 * **Last Modified by:** 28 * **Last Reviewed by:** 27 * **Last Modified by:** 28 * **Last Reviewed by:** 29 29 """ 30 30 … … 46 46 # pylint: disable=bad-whitespace, line-too-long 47 47 # ["name", "units", default, [lower, upper], "type", "description"], 48 parameters = [["scale", "", 1.0, [-inf, inf], "", "Scale factor"], 49 ["gamma", "", 3.0, [-inf, inf], "", "Exponent"], 48 parameters = [["gamma", "", 3.0, [-inf, inf], "", "Exponent"], 50 49 ["q_0", "1/Ang", 0.1, [-inf, inf], "", "Correlation peak position"] 51 50 ] … … 53 52 54 53 def Iq(q, 55 scale=1.0,56 54 gamma=3.0, 57 55 q_0=0.1): 58 56 """ 59 57 :param q: Input q-value 60 :param scale: Scale factor61 58 :param gamma: Exponent 62 59 :param q_0: Correlation peak position 63 60 :return: Calculated intensity 64 61 """ 65 62 66 63 with errstate(divide='ignore'): 67 64 x = q/q_0 68 inten = scale * ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma))65 inten = ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma)) 69 66 return inten 70 67 Iq.vectorized = True # Iq accepts an array of q values 71 68 69 def random(): 70 import numpy as np 71 pars = dict( 72 scale=10**np.random.uniform(1, 3), 73 gamma=np.random.uniform(0, 6), 74 q_0=10**np.random.uniform(-3, -1), 75 ) 76 return pars 77 72 78 demo = dict(scale=1, background=0, 73 79 gamma=1, q_0=0.1) -
sasmodels/models/star_polymer.py
r40a87fa r48462b0 59 59 source = ["star_polymer.c"] 60 60 61 demo = dict(scale=1, background=0, 62 rg_squared=100.0, 63 arms=3.0) 61 def random(): 62 import numpy as np 63 pars = dict( 64 #background=0, 65 scale=10**np.random.uniform(1, 4), 66 rg_squared=10**np.random.uniform(1, 8), 67 arms=np.random.uniform(1, 6), 68 ) 69 return pars 64 70 65 71 tests = [[{'rg_squared': 2.0, -
sasmodels/models/surface_fractal.py
r925ad6e r48462b0 74 74 source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "surface_fractal.c"] 75 75 76 demo = dict(scale=1, background=1e-5, 77 radius=10, fractal_dim_surf=2.0, cutoff_length=500) 76 def random(): 77 import numpy as np 78 radius = 10**np.random.uniform(1, 4) 79 fractal_dim_surf = np.random.uniform(1, 3-1e-6) 80 cutoff_length = 1e6 # Sets the low q limit; keep it big for sim 81 pars = dict( 82 #background=0, 83 scale=1, 84 radius=radius, 85 fractal_dim_surf=fractal_dim_surf, 86 cutoff_length=cutoff_length, 87 ) 88 return pars 78 89 79 90 tests = [ -
sasmodels/models/teubner_strey.py
r8393c74 r48462b0 102 102 Iq.vectorized = True # Iq accepts an array of q values 103 103 104 def random(): 105 import numpy as np 106 d = 10**np.random.uniform(1, 4) 107 xi = 10**np.random.uniform(-0.3, 2)*d 108 pars = dict( 109 #background=0, 110 scale=100, 111 volfraction_a=10**np.random.uniform(-3, 0), 112 sld_a=np.random.uniform(-0.5, 12), 113 sld_b=np.random.uniform(-0.5, 12), 114 d=d, 115 xi=xi, 116 ) 117 return pars 118 104 119 demo = dict(scale=1, background=0, volfraction_a=0.5, 105 106 120 sld_a=0.3, sld_b=6.3, 121 d=100.0, xi=30.0) 107 122 tests = [[{}, 0.06, 41.5918888453]] -
sasmodels/models/two_lorentzian.py
r2c74c11 r48462b0 93 93 Iq.vectorized = True # Iq accepts an array of q values 94 94 95 def random(): 96 import numpy as np 97 scale = 10**np.random.uniform(0, 4, 2) 98 length = 10**np.random.uniform(1, 4, 2) 99 expon = np.random.uniform(1, 6, 2) 100 101 pars = dict( 102 #background=0, 103 scale=1, # scale provided in model 104 lorentz_scale_1=scale[0], 105 lorentz_length_1=length[0], 106 lorentz_exp_1=expon[0], 107 lorentz_scale_2=scale[1], 108 lorentz_length_2=length[1], 109 lorentz_exp_2=expon[1], 110 ) 111 return pars 112 95 113 96 114 demo = dict(scale=1, background=0.1, -
sasmodels/models/two_power_law.py
rbb4b509 r48462b0 98 98 Iq.vectorized = True # Iq accepts an array of q values 99 99 100 def random(): 101 import numpy as np 102 coefficient_1 = 1 103 crossover = 10**np.random.uniform(-3, -1) 104 power_1 = np.random.uniform(1, 6) 105 power_2 = np.random.uniform(1, 6) 106 pars = dict( 107 scale=1, #background=0, 108 coefficient_1=coefficient_1, 109 crossover=crossover, 110 power_1=power_1, 111 power_2=power_2, 112 ) 113 return pars 114 100 115 demo = dict(scale=1, background=0.0, 101 116 coefficent_1=1.0, -
sasmodels/models/unified_power_Rg.py
rc3ccaec r48462b0 3 3 ---------- 4 4 5 This model employs the empirical multiple level unified Exponential/Power-law 6 fit method developed by Beaucage. Four functions are included so that 1, 2, 3, 7 or 4 levels can be used. In addition a 0 level has been added which simply 5 This model employs the empirical multiple level unified Exponential/Power-law 6 fit method developed by Beaucage. Four functions are included so that 1, 2, 3, 7 or 4 levels can be used. In addition a 0 level has been added which simply 8 8 calculates 9 9 … … 16 16 (Debye equation), ellipsoidal particles, etc. 17 17 18 The model works best for mass fractal systems characterized by Porod exponents 19 between 5/3 and 3. It should not be used for surface fractal systems. Hammouda 20 (2010) has pointed out a deficiency in the way this model handles the 21 transitioning between the Guinier and Porod regimes and which can create 18 The model works best for mass fractal systems characterized by Porod exponents 19 between 5/3 and 3. It should not be used for surface fractal systems. Hammouda 20 (2010) has pointed out a deficiency in the way this model handles the 21 transitioning between the Guinier and Porod regimes and which can create 22 22 artefacts that appear as kinks in the fitted model function. 23 23 … … 88 88 # pylint: disable=bad-whitespace, line-too-long 89 89 parameters = [ 90 ["level", "", 1, [ 0, 6], "", "Level number"],90 ["level", "", 1, [1, 6], "", "Level number"], 91 91 ["rg[level]", "Ang", 15.8, [0, inf], "", "Radius of gyration"], 92 92 ["power[level]", "", 4, [-inf, inf], "", "Power"], … … 118 118 Iq.vectorized = True 119 119 120 def random(): 121 import numpy as np 122 from scipy.special import gamma 123 level = np.minimum(np.random.poisson(0.5) + 1, 6) 124 n = level 125 power = np.random.uniform(1.6, 3, n) 126 rg = 10**np.random.uniform(1, 5, n) 127 G = np.random.uniform(0.1, 10, n)**2 * 10**np.random.uniform(0.3, 3, n) 128 B = G * power / rg**power * gamma(power/2) 129 scale = 10**np.random.uniform(1, 4) 130 pars = dict( 131 #background=0, 132 scale=scale, 133 level=level, 134 ) 135 pars.update(("power%d"%(k+1), v) for k, v in enumerate(power)) 136 pars.update(("rg%d"%(k+1), v) for k, v in enumerate(rg)) 137 pars.update(("B%d"%(k+1), v) for k, v in enumerate(B)) 138 pars.update(("G%d"%(k+1), v) for k, v in enumerate(G)) 139 return pars 140 120 141 demo = dict( 121 142 level=2, -
sasmodels/models/vesicle.py
r925ad6e r48462b0 120 120 return whole, whole - core 121 121 122 def random(): 123 import numpy as np 124 total_radius = 10**np.random.uniform(1.3, 5) 125 radius = total_radius * np.random.uniform(0, 1) 126 thickness = total_radius - radius 127 volfraction = 10**np.random.uniform(-3, -1) 128 pars = dict( 129 #background=0, 130 scale=1, # volfraction is part of the model, so scale=1 131 radius=radius, 132 thickness=thickness, 133 volfraction=volfraction, 134 ) 135 return pars 122 136 123 137 # parameters for demo
Note: See TracChangeset
for help on using the changeset viewer.