Changeset 2c74c11 in sasmodels
- Timestamp:
- Jul 24, 2016 10:56:45 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- a4280bd
- Parents:
- f1765a2
- Location:
- sasmodels
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/convert.py
rf1765a2 r2c74c11 282 282 suppress_magnetism = False 283 283 for key in pars.keys(): 284 suppress_magnetism = suppress_magnetism or (pars[key] != 0)285 284 if key.startswith("M0:"): 285 suppress_magnetism = suppress_magnetism or (pars[key] != 0) 286 286 pars[key] = 0 287 287 if suppress_magnetism: -
sasmodels/generate.py
r9eb3632 r2c74c11 565 565 else: 566 566 # Call 1D model with sqrt(qx^2 + qy^2) 567 warnings.warn("Creating Iqxy = Iq(sqrt(qx^2 + qy^2))")567 #warnings.warn("Creating Iqxy = Iq(sqrt(qx^2 + qy^2))") 568 568 # still defined:: refs = ["q[i]"] + _call_pars("v", iq_parameters) 569 569 pars_sqrt = ["sqrt(_q[2*_i]*_q[2*_i]+_q[2*_i+1]*_q[2*_i+1])"] + refs[1:] -
sasmodels/model_test.py
r9eb3632 r2c74c11 201 201 #({}, 0.0, None), 202 202 #({}, (0.0, 0.0), None), 203 # test vector form 204 ({}, [0.1]*2, [None]*2), 205 ({}, [(0.1, 0.1)]*2, [None]*2), 203 206 # test that ER/VR will run if they exist 204 207 ({}, 'ER', None), … … 257 260 if yi is None: 258 261 # smoke test --- make sure it runs and produces a value 259 self.assertTrue(n p.isfinite(actual_yi),262 self.assertTrue(not np.isnan(actual_yi), 260 263 'invalid f(%s): %s' % (xi, actual_yi)) 261 264 elif np.isnan(yi): -
sasmodels/models/adsorbed_layer.py
r42356c8 r2c74c11 51 51 """ 52 52 53 from numpy import inf, sqrt, pi, exp53 from numpy import inf, pi, exp, errstate 54 54 55 55 name = "adsorbed_layer" … … 87 87 ##scale by 10^-2 for units conversion to cm^-1 88 88 #inten = 1.0e-02 * deltarhosqrd * ((numerator / denominator) * eterm) 89 aa = (sld_shell - sld_solvent) * adsorbed_amount / q / density_shell 89 with errstate(divide='ignore'): 90 aa = ((sld_shell - sld_solvent)/density_shell * adsorbed_amount) / q 90 91 bb = q * second_moment 91 92 #scale by 10^-2 for units conversion to cm^-1 92 inten = 6.0e-02 * pi * volfraction * aa * aa * exp(-bb * bb) / radius93 inten = 6.0e-02 * pi * volfraction * aa**2 * exp(-bb**2) / radius 93 94 return inten 94 95 Iq.vectorized = True # Iq accepts an array of q values -
sasmodels/models/be_polyelectrolyte.py
rec45c4f r2c74c11 116 116 117 117 118 def Iqxy(qx, qy, *args):119 """120 :param qx: Input q_x-value121 :param qy: Input q_y-value122 :param args: Remaining arguments123 :return: 2D-Intensity124 """125 intensity = Iq(sqrt(qx**2 + qy**2), *args)126 return intensity127 128 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values129 130 131 118 demo = dict(scale=1, background=0.1, 132 119 contrast_factor=10.0, -
sasmodels/models/broad_peak.py
r65279d8 r2c74c11 41 41 """ 42 42 43 from numpy import inf, sqrt43 from numpy import inf, errstate 44 44 45 45 name = "broad_peak" … … 87 87 :return: Calculated intensity 88 88 """ 89 90 inten = (porod_scale / q ** porod_exp + lorentz_scale 91 / (1.0 + (abs(q - peak_pos) * lorentz_length) ** lorentz_exp)) 89 z = abs(q - peak_pos) * lorentz_length 90 with errstate(divide='ignore'): 91 inten = (porod_scale / q ** porod_exp 92 + lorentz_scale / (1 + z ** lorentz_exp)) 92 93 return inten 93 94 Iq.vectorized = True # Iq accepts an array of q values 94 95 def Iqxy(qx, qy, *args):96 """97 :param qx: Input q_x-value98 :param qy: Input q_y-value99 :param args: Remaining arguments100 :return: 2D-Intensity101 """102 return Iq(sqrt(qx ** 2 + qy ** 2), *args)103 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values104 95 105 96 demo = dict(scale=1, background=0, -
sasmodels/models/core_shell_sphere.c
r7d4b2ae r2c74c11 1 1 double form_volume(double radius, double thickness); 2 2 double Iq(double q, double radius, double thickness, double core_sld, double shell_sld, double solvent_sld); 3 double Iqxy(double qx, double qy, double radius, double thickness, double core_sld, double shell_sld, double solvent_sld);4 5 3 6 4 double Iq(double q, double radius, double thickness, double core_sld, double shell_sld, double solvent_sld) { … … 16 14 } 17 15 18 double Iqxy(double qx, double qy, double radius, double thickness, double core_sld, double shell_sld, double solvent_sld) {19 const double q = sqrt(qx*qx+qy*qy);20 return Iq(q, radius, thickness, core_sld, shell_sld, solvent_sld);21 }22 23 16 double form_volume(double radius, double thickness) 24 17 { -
sasmodels/models/correlation_length.py
rec45c4f r2c74c11 34 34 """ 35 35 36 from numpy import inf, sqrt36 from numpy import inf, errstate 37 37 38 38 name = "correlation_length" … … 57 57 1D calculation of the Correlation length model 58 58 """ 59 porod = porod_scale / pow(q, exponent_p) 60 lorentz = lorentz_scale / (1.0 + pow(q * cor_length, exponent_l)) 59 with errstate(divide='ignore'): 60 porod = porod_scale / q**exponent_p 61 lorentz = lorentz_scale / (1.0 + (q * cor_length)**exponent_l) 61 62 inten = porod + lorentz 62 63 return inten 63 64 def Iqxy(qx, qy, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l): 65 """ 66 2D calculation of the Correlation length model 67 There is no orientation contribution. 68 """ 69 q = sqrt(qx ** 2 + qy ** 2) 70 return Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l) 64 Iq.vectorized = True 71 65 72 66 # parameters for demo -
sasmodels/models/dab.py
rec45c4f r2c74c11 65 65 """ 66 66 67 Iqxy = """68 // never called since no orientation or magnetic parameters.69 //return -1.0;70 return Iq(sqrt(qx*qx + qy*qy), length);71 """72 73 67 # ER defaults to 1.0 74 68 -
sasmodels/models/fractal.c
r12dbc90 r2c74c11 1 double form_volume(double radius);2 3 1 double Iq(double q, 4 2 double volfraction, … … 8 6 double sld_block, 9 7 double sld_solvent); 10 11 double Iqxy(double qx, double qy,12 double volfraction,13 double radius,14 double fractal_dim,15 double cor_length,16 double sld_block,17 double sld_solvent);18 19 8 20 9 double Iq(double q, … … 64 53 } 65 54 66 67 // Iqxy is never called since no orientation or magnetic parameters.68 double Iqxy(double qx, double qy,69 double volfraction,70 double radius,71 double fractal_dim,72 double cor_length,73 double sld_block,74 double sld_solvent)75 {76 double q = sqrt(qx*qx + qy*qy);77 return Iq(q,78 volfraction, radius,79 fractal_dim, cor_length,80 sld_block, sld_solvent);81 82 }83 -
sasmodels/models/fractal_core_shell.c
r6794301 r2c74c11 10 10 double frac_dim, 11 11 double cor_length); 12 13 double Iqxy(double qx, double qy,14 double radius,15 double thickness,16 double core_sld,17 double shell_sld,18 double solvent_sld,19 double volfraction,20 double frac_dim,21 double cor_length);22 12 23 13 double form_volume(double radius, double thickness) … … 56 46 } 57 47 58 double Iqxy(double qx, double qy,59 double radius,60 double thickness,61 double core_sld,62 double shell_sld,63 double solvent_sld,64 double volfraction,65 double frac_dim,66 double cor_length) {67 68 const double q = sqrt(qx*qx+qy*qy);69 return Iq(q,70 radius,71 thickness,72 core_sld,73 shell_sld,74 solvent_sld,75 volfraction,76 frac_dim,77 cor_length);78 79 }80 81 -
sasmodels/models/fuzzy_sphere.py
r42356c8 r2c74c11 99 99 """ 100 100 101 Iqxy = """102 // never called since no orientation or magnetic parameters.103 //return -1.0;104 return Iq(sqrt(qx*qx + qy*qy), sld, sld_solvent, radius, fuzziness);105 """106 107 101 def ER(radius): 108 102 """ -
sasmodels/models/gauss_lorentz_gel.py
rec45c4f r2c74c11 43 43 """ 44 44 45 from numpy import inf, sqrt,exp45 from numpy import inf, exp 46 46 47 47 name = "gauss_lorentz_gel" … … 94 94 95 95 96 def Iqxy(qx, qy, *args):97 """98 :param qx: Input q_x-value99 :param qy: Input q_y-value100 :param args: Remaining aruments101 :return: 2-D intensity102 """103 104 return Iq(sqrt(qx**2 + qy**2), *args)105 106 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values107 108 109 96 demo = dict(scale=1, background=0.1, 110 97 gauss_scale_factor=100.0, -
sasmodels/models/gaussian_peak.py
rec45c4f r2c74c11 45 45 ] 46 46 47 # No volume normalization despite having a volume parameter48 # This should perhaps be volume normalized?49 form_volume = """50 return 1.0;51 """52 53 47 Iq = """ 54 48 double scaled_dq = (q - q0)/sigma; … … 56 50 """ 57 51 58 59 Iqxy = """60 // never called since no orientation or magnetic parameters.61 //return -1.0;62 return Iq(sqrt(qx*qx + qy*qy), q0, sigma);63 """64 65 66 52 # VR defaults to 1.0 67 53 -
sasmodels/models/guinier.py
rec45c4f r2c74c11 46 46 """ 47 47 48 Iqxy = """49 return Iq(sqrt(qx*qx + qy*qy), rg);50 """51 52 48 # parameters for demo 53 49 demo = dict(scale=1.0, rg=60.0) -
sasmodels/models/guinier_porod.py
rec45c4f r2c74c11 63 63 """ 64 64 65 from numpy import inf, sqrt, power, exp65 from numpy import inf, sqrt, exp, errstate 66 66 67 67 name = "guinier_porod" … … 93 93 """ 94 94 n = 3.0 - s 95 ms = 0.5*(m-s) # =(n-3+m)/2 96 97 # preallocate return value 98 iq = 0.0*q 95 99 96 100 # Take care of the singular points 97 if rg <= 0.0: 98 return 0.0 99 if (n-3.0+m) <= 0.0: 100 return 0.0 101 if rg <= 0.0 or ms <= 0.0: 102 return iq 101 103 102 104 # Do the calculation and return the function value 103 q1 = sqrt((n-3.0+m)*n/2.0)/rg 104 if q < q1: 105 iq = (1.0/power(q, (3.0-n)))*exp((-q*q*rg*rg)/n) 106 else: 107 iq = (1.0/power(q, m))*exp(-(n-3.0+m)/2.0)*power(((n-3.0+m)*n/2.0), 108 ((n-3.0+m)/2.0))/power(rg, (n-3.0+m)) 105 idx = q < sqrt(n*ms)/rg 106 with errstate(divide='ignore'): 107 iq[idx] = q[idx]**-s * exp(-(q[idx]*rg)**2/n) 108 iq[~idx] = q[~idx]**-m * (exp(-ms) * (n*ms/rg**2)**ms) 109 109 return iq 110 110 111 Iq.vectorized = False # Iq accepts an array of q values 112 113 def Iqxy(qx, qy, *args): 114 """ 115 @param qx: Input q_x-value 116 @param qy: Input q_y-value 117 @param args: Remaining arguments 118 """ 119 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 120 121 Iqxy.vectorized = False # Iqxy accepts an array of qx, qy values 111 Iq.vectorized = True # Iq accepts an array of q values 122 112 123 113 demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, m=3.0) -
sasmodels/models/line.py
r416609b r2c74c11 66 66 return Iq(qx, *args)*Iq(qy, *args) 67 67 68 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 68 Iqxy.vectorized = True # Iqxy accepts an array of qx qy values 69 69 70 70 71 tests = [ -
sasmodels/models/linear_pearls.c
rcf85329 r2c74c11 2 2 3 3 double Iq(double q, 4 double radius,5 double edge_sep,6 double num_pearls,7 double pearl_sld,8 double solvent_sld);9 10 double Iqxy(double qx, double qy,11 4 double radius, 12 5 double edge_sep, … … 92 85 return result; 93 86 } 94 95 double Iqxy(double qx, double qy,96 double radius,97 double edge_sep,98 double num_pearls,99 double pearl_sld,100 double solvent_sld)101 {102 double q;103 q = sqrt(qx*qx+qy*qy);104 105 double result = linear_pearls_kernel(q,106 radius,107 edge_sep,108 num_pearls,109 pearl_sld,110 solvent_sld);111 112 return result;113 } -
sasmodels/models/lorentz.py
rec45c4f r2c74c11 48 48 """ 49 49 50 Iqxy = """51 return Iq(sqrt(qx*qx + qy*qy), cor_length);52 """53 54 50 # parameters for demo 55 51 demo = dict(scale=1.0, background=0.0, cor_length=50.0) -
sasmodels/models/mass_fractal.c
r6794301 r2c74c11 5 5 double mass_dim, 6 6 double cutoff_length); 7 8 double Iqxy(double qx, double qy,9 double radius,10 double mass_dim,11 double cutoff_length);12 13 7 14 8 static double _mass_fractal_kernel(double q, … … 53 47 cutoff_length); 54 48 } 55 56 // Iqxy is never called since no orientation or magnetic parameters.57 double Iqxy(double qx, double qy,58 double radius,59 double mass_dim,60 double cutoff_length)61 {62 double q = sqrt(qx*qx + qy*qy);63 return _mass_fractal_kernel(q,64 radius,65 mass_dim,66 cutoff_length);67 }68 -
sasmodels/models/mass_surface_fractal.c
r7ed702f r2c74c11 6 6 double cluster_rg, 7 7 double primary_rg); 8 9 double Iqxy(double qx, double qy,10 double mass_dim,11 double surface_dim,12 double cluster_rg,13 double primary_rg);14 15 8 16 9 static double _mass_surface_fractal_kernel(double q, … … 59 52 primary_rg); 60 53 } 61 62 // Iqxy is never called since no orientation or magnetic parameters.63 double Iqxy(double qx, double qy,64 double mass_dim,65 double surface_dim,66 double cluster_rg,67 double primary_rg)68 {69 double q = sqrt(qx*qx + qy*qy);70 return _mass_surface_fractal_kernel(q,71 mass_dim,72 surface_dim,73 cluster_rg,74 primary_rg);75 }76 -
sasmodels/models/mono_gauss_coil.py
rec45c4f r2c74c11 45 45 """ 46 46 47 from numpy import inf, sqrt, exp47 from numpy import inf, exp, errstate 48 48 49 49 name = "mono_gauss_coil" … … 63 63 def Iq(q, i_zero, radius_gyration): 64 64 # pylint: disable = missing-docstring 65 z = (q * radius_gyration) * (q * radius_gyration)66 if (q == 0).any(): 67 inten = i_zero68 else:69 inten = i_zero * 2.0 * (exp(-z) + z - 1.0 ) / (z * z)65 z = (q * radius_gyration)**2 66 67 with errstate(invalid='ignore'): 68 inten = (i_zero * 2.0) * (exp(-z) + z - 1.0)/z**2 69 inten[q == 0] = i_zero 70 70 return inten 71 #Iq.vectorized = True # Iq accepts an array of q values 72 73 def Iqxy(qx, qy, *args): 74 # pylint: disable = missing-docstring 75 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 76 #Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 71 Iq.vectorized = True # Iq accepts an array of q values 77 72 78 73 demo = dict(scale = 1.0, -
sasmodels/models/multilayer_vesicle.c
rc6ca41e r2c74c11 59 59 } 60 60 61 static62 double Iqxy(double qx, double qy,63 double volfraction,64 double radius,65 double thick_shell,66 double thick_solvent,67 double sld_solvent,68 double sld,69 double n_pairs)70 {71 double q = sqrt(qx*qx + qy*qy);72 73 return multilayer_vesicle_kernel(q,74 volfraction,75 radius,76 thick_shell,77 thick_solvent,78 sld_solvent,79 sld,80 n_pairs);81 } -
sasmodels/models/peak_lorentz.py
rec45c4f r2c74c11 29 29 """ 30 30 31 from numpy import inf , sqrt31 from numpy import inf 32 32 33 33 name = "peak_lorentz" … … 59 59 Iq.vectorized = True # Iq accepts an array of q values 60 60 61 def Iqxy(qx, qy, *args):62 """63 Return I(qx, qy)64 """65 return Iq(sqrt(qx ** 2 + qy ** 2), *args)66 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values67 68 69 61 demo = dict(scale=100, background=1.0, 70 62 peak_pos=0.05, peak_hwhm=0.005) -
sasmodels/models/pearl_necklace.c
rcf85329 r2c74c11 6 6 7 7 double Iq(double q, double radius, double edge_separation, 8 double string_thickness, double number_of_pearls, double sld,9 double string_sld, double solvent_sld);10 double Iqxy(double qx, double qy, double radius, double edge_separation,11 8 double string_thickness, double number_of_pearls, double sld, 12 9 double string_sld, double solvent_sld); … … 139 136 return value*tot_vol; 140 137 } 141 142 double Iqxy(double qx, double qy, double radius, double edge_separation,143 double string_thickness, double number_of_pearls, double sld,144 double string_sld, double solvent_sld)145 {146 double q = sqrt(qx*qx + qy*qy);147 return(Iq(q, radius, edge_separation, string_thickness, number_of_pearls,148 sld, string_sld, solvent_sld));149 } -
sasmodels/models/poly_gauss_coil.py
r65279d8 r2c74c11 50 50 """ 51 51 52 import numpy as np 53 from numpy import inf, exp, power, sqrt 52 from numpy import inf, exp, power 54 53 55 54 name = "poly_gauss_coil" … … 83 82 Iq.vectorized = True # Iq accepts an array of q values 84 83 85 def Iqxy(qx, qy, *args):86 # pylint: disable = missing-docstring87 return Iq(sqrt(qx ** 2 + qy ** 2), *args)88 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values89 90 84 demo = dict(scale = 1.0, 91 85 i_zero = 70.0, -
sasmodels/models/polymer_excl_volume.py
r416609b r2c74c11 93 93 """ 94 94 95 from numpy import inf, power, sqrt95 from numpy import inf, power, errstate 96 96 from scipy.special import gammainc, gamma 97 97 … … 120 120 :return: Calculated intensity 121 121 """ 122 nu = 1.0/porod_exp 123 u = q*q*rg*rg*(2.0*nu+1.0) * (2.0*nu+2.0)/6.0 124 o2nu = 1.0/(2.0*nu) 122 u = (q*rg)**2 * (2.0/porod_exp + 1.0) * (2.0/porod_exp + 2.0)/6.0 123 with errstate(divide='ignore', invalid='ignore'): 124 upow = power(u, -0.5*porod_exp) 125 iq = (porod_exp*upow * 126 (gamma(0.5*porod_exp)*gammainc(0.5*porod_exp, u) - 127 upow*gamma(porod_exp)*gammainc(porod_exp, u))) 128 iq[q <= 0] = 1.0 125 129 126 intensity = ((1.0/(nu*power(u, o2nu))) * 127 (gamma(o2nu)*gammainc(o2nu, u) - 128 1.0/power(u, o2nu) * gamma(porod_exp) * 129 gammainc(porod_exp, u))) * (q > 0) + 1.0*(q <= 0) 130 131 return intensity 130 return iq 132 131 133 132 Iq.vectorized = True # Iq accepts an array of q values 134 135 136 def Iqxy(qx, qy, *args):137 """138 :param qx: Input q_x-value139 :param qy: Input q_y-value140 :param args: Remaining arguments141 :return: 2D-Intensity142 """143 return Iq(sqrt(qx**2 + qy**2), *args)144 145 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values146 133 147 134 -
sasmodels/models/polymer_micelle_kernel.c
r1e9a108 r2c74c11 10 10 double d_penetration, 11 11 double n_aggreg); 12 13 14 double Iqxy(double qx, double qy,15 double ndensity,16 double v_core,17 double v_corona,18 double solvent_sld,19 double core_sld,20 double corona_sld,21 double radius_core,22 double radius_gyr,23 double d_penetration,24 double n_aggreg);25 26 12 27 13 static double micelle_spherical_kernel(double q, … … 100 86 n_aggreg); 101 87 } 102 103 double Iqxy(double qx, double qy,104 double ndensity,105 double v_core,106 double v_corona,107 double solvent_sld,108 double core_sld,109 double corona_sld,110 double radius_core,111 double radius_gyr,112 double d_penetration,113 double n_aggreg)114 {115 double q = sqrt(qx*qx + qy*qy);116 return micelle_spherical_kernel(q,117 ndensity,118 v_core,119 v_corona,120 solvent_sld,121 core_sld,122 corona_sld,123 radius_core,124 radius_gyr,125 d_penetration,126 n_aggreg);127 128 }129 -
sasmodels/models/porod.py
r82923a6 r2c74c11 26 26 """ 27 27 28 from numpy import sqrt,power, inf, errstate28 from numpy import power, inf, errstate 29 29 30 30 name = "porod" … … 47 47 Iq.vectorized = True # Iq accepts an array of q values 48 48 49 def Iqxy(qx, qy, *args):50 """51 @param qx: Input q_x-value52 @param qy: Input q_y-value53 @param args: Remaining arguments54 """55 return Iq(sqrt(qx ** 2 + qy ** 2), *args)56 57 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values58 59 49 demo = dict(scale=1.5, background=0.5) 60 50 -
sasmodels/models/power_law.py
rec45c4f r2c74c11 27 27 """ 28 28 29 from numpy import inf, sqrt29 from numpy import inf, errstate 30 30 31 31 name = "power_law" … … 45 45 def Iq(q, power): 46 46 # pylint: disable=missing-docstring 47 inten = (q**-power) 48 return inten 47 with errstate(divide='ignore'): 48 iq = q**-power 49 return iq 49 50 Iq.vectorized = True # Iq accepts an array of q values 50 51 def Iqxy(qx, qy, *args):52 # pylint: disable=missing-docstring53 return Iq(sqrt(qx ** 2 + qy ** 2), *args)54 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values55 51 56 52 demo = dict(scale=1.0, -
sasmodels/models/pringle.c
rb70cb3b r2c74c11 3 3 4 4 double Iq(double q, 5 double radius,6 double thickness,7 double alpha,8 double beta,9 double sld_pringle,10 double sld_solvent);11 12 double Iqxy(double qx, double qy,13 5 double radius, 14 6 double thickness, … … 187 179 return 1.0e-4*form*M_PI*radius*radius*thickness; 188 180 } 189 190 double Iqxy(double qx, double qy,191 double radius,192 double thickness,193 double alpha,194 double beta,195 double sld_pringle,196 double sld_solvent)197 {198 double q = sqrt(qx*qx + qy*qy);199 return Iq(q,200 radius,201 thickness,202 alpha,203 beta,204 sld_pringle,205 sld_solvent);206 }207 -
sasmodels/models/raspberry.c
r616df8f r2c74c11 2 2 3 3 double Iq(double q, 4 double sld_lg, double sld_sm, double sld_solvent,5 double volfraction_lg, double volfraction_sm, double surf_fraction,6 double radius_lg, double radius_sm, double penetration);7 8 double Iqxy(double qx, double qy,9 4 double sld_lg, double sld_sm, double sld_solvent, 10 5 double volfraction_lg, double volfraction_sm, double surf_fraction, … … 88 83 return f2; 89 84 } 90 91 92 93 double Iqxy(double qx, double qy,94 double sld_lg, double sld_sm, double sld_solvent,95 double volfraction_lg, double volfraction_sm, double surf_fraction,96 double radius_lg, double radius_sm, double penetration)97 98 {99 double q = sqrt(qx*qx + qy*qy);100 return Iq(q,101 sld_lg, sld_sm, sld_solvent,102 volfraction_lg, volfraction_sm, surf_fraction,103 radius_lg, radius_sm, penetration);104 105 } -
sasmodels/models/sphere.py
r42356c8 r2c74c11 78 78 """ 79 79 80 Iqxy = """81 // never called since no orientation or magnetic parameters.82 //return -1.0;83 return Iq(sqrt(qx*qx + qy*qy), sld, sld_solvent, radius);84 """85 86 80 def ER(radius): 87 81 """ -
sasmodels/models/stacked_disks.c
r43b7eea r2c74c11 13 13 double layer_sld, 14 14 double solvent_sld); 15 16 double Iqxy(double qx, double qy,17 double core_thick,18 double layer_thick,19 double radius,20 double n_stacking,21 double sigma_d,22 double core_sld,23 double layer_sld,24 double solvent_sld,25 double theta,26 double phi);27 15 28 16 static … … 52 40 const double sinarg2 = qq*(halfheight+layer_thick)*cos(zi); 53 41 54 42 const double be1 = sas_J1c(besarg1); 55 43 const double be2 = sas_J1c(besarg2); 56 44 const double si1 = sin(sinarg1)/sinarg1; … … 215 203 solvent_sld); 216 204 } 217 218 // Iqxy is never called since no orientation or magnetic parameters.219 double Iqxy(double qx, double qy,220 double core_thick,221 double layer_thick,222 double radius,223 double n_stacking,224 double sigma_d,225 double core_sld,226 double layer_sld,227 double solvent_sld,228 double theta,229 double phi)230 {231 double q = sqrt(qx*qx + qy*qy);232 return stacked_disks_kernel_2d(q, qx/q, qy/q,233 core_thick,234 layer_thick,235 radius,236 n_stacking,237 sigma_d,238 core_sld,239 layer_sld,240 solvent_sld,241 theta,242 phi);243 }244 -
sasmodels/models/star_polymer.c
r55b283e8 r2c74c11 2 2 3 3 double Iq(double q, double radius2, double arms); 4 5 double Iqxy(double qx, double qy, double radius2, double arms);6 7 4 8 5 static double _mass_fractal_kernel(double q, double radius2, double arms) … … 28 25 return _mass_fractal_kernel(q, radius2, arms); 29 26 } 30 31 // Iqxy is never called since no orientation or magnetic parameters.32 double Iqxy(double qx, double qy, double radius2, double arms)33 {34 double q = sqrt(qx*qx + qy*qy);35 return _mass_fractal_kernel(q, radius2, arms);36 }37 -
sasmodels/models/surface_fractal.c
r6794301 r2c74c11 5 5 double surface_dim, 6 6 double cutoff_length); 7 8 double Iqxy(double qx, double qy,9 double radius,10 double surface_dim,11 double cutoff_length);12 7 13 8 static double _surface_fractal_kernel(double q, … … 49 44 return _surface_fractal_kernel(q, radius, surface_dim, cutoff_length); 50 45 } 51 52 // Iqxy is never called since no orientation or magnetic parameters.53 double Iqxy(double qx, double qy,54 double radius,55 double surface_dim,56 double cutoff_length)57 {58 double q = sqrt(qx*qx + qy*qy);59 return _surface_fractal_kernel(q, radius, surface_dim, cutoff_length);60 }61 -
sasmodels/models/teubner_strey.py
rec45c4f r2c74c11 68 68 69 69 70 def form_volume(radius):71 return 1.072 73 70 def Iq(q, a2, c1, c2): 74 71 return 1. / np.polyval([c2, c1, a2], q**2) 75 72 Iq.vectorized = True # Iq accepts an array of q values 76 73 77 def Iqxy(qx, qy, a2, c1, c2):78 return Iq(sqrt(qx**2 + qy**2), a2, c1, c2)79 Iqxy.vectorized = True # Iqxy accepts arrays of qx, qy values80 81 # ER defaults to 0.082 83 # VR defaults to 1.084 85 74 demo = dict(scale=1, background=0, a2=0.1, c1=-30.0, c2=5000.0) 86 75 tests = [[{}, 0.2, 0.145927536232]] -
sasmodels/models/two_lorentzian.py
r416609b r2c74c11 34 34 """ 35 35 36 from numpy import inf, power , sqrt36 from numpy import inf, power 37 37 38 38 name = "two_lorentzian" … … 92 92 93 93 Iq.vectorized = True # Iq accepts an array of q values 94 95 96 def Iqxy(qx, qy, *args):97 """98 :param qx: Input q_x-value99 :param qy: Input q_y-value100 :param args: Remaining arguments101 :return: 2D-Intensity102 """103 104 return Iq(sqrt(qx**2 + qy**2), *args)105 106 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values107 94 108 95 -
sasmodels/models/two_power_law.py
rec45c4f r2c74c11 44 44 """ 45 45 46 from numpy import power 47 from numpy import sqrt 48 from numpy import inf 49 from numpy import concatenate 46 from numpy import inf, power, empty, errstate 50 47 51 48 name = "two_power_law" … … 92 89 :return: Calculated intensity 93 90 """ 94 95 #Two sub vectors are created to treat crossover values 96 q_lower = q[q <= crossover] 97 q_upper = q[q > crossover] 98 coefficent_2 = coefficent_1*power(crossover, -1.0*power_1)/power(crossover, -1.0*power_2) 99 intensity_lower = coefficent_1*power(q_lower, -1.0*power_1) 100 intensity_upper = coefficent_2*power(q_upper, -1.0*power_2) 101 intensity = concatenate((intensity_lower, intensity_upper), axis=0) 102 103 return intensity 91 iq = empty(q.shape, 'd') 92 idx = (q <= crossover) 93 with errstate(divide='ignore'): 94 coefficent_2 = coefficent_1 * power(crossover, power_2 - power_1) 95 iq[idx] = coefficent_1 * power(q[idx], -power_1) 96 iq[~idx] = coefficent_2 * power(q[~idx], -power_2) 97 return iq 104 98 105 99 Iq.vectorized = True # Iq accepts an array of q values 106 107 def Iqxy(qx, qy, *args):108 """109 :param qx: Input q_x-value110 :param qy: Input q_y-value111 :param args: Remaining arguments112 :return: 2D-Intensity113 """114 115 return Iq(sqrt(qx**2 + qy**2), *args)116 117 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values118 100 119 101 demo = dict(scale=1, background=0.0, -
sasmodels/models/unified_power_Rg.py
r42356c8 r2c74c11 62 62 63 63 import numpy as np 64 from numpy import inf, exp, sqrt 64 from numpy import inf, exp, sqrt, errstate 65 65 from scipy.special import erf 66 66 … … 76 76 ilevel = int(level) 77 77 if ilevel == 0: 78 return 1./q 78 with errstate(divide='ignore'): 79 return 1./q 79 80 80 result = np.zeros_like(q) 81 for i in range(ilevel): 82 exp_now = exp(-(q*rg[i])**2/3.) 83 pow_now = (erf(q*rg[i]/sqrt(6.))**3/q)**power[i] 84 exp_next = exp(-(q*rg[i+1])**2/3.) if i < ilevel-1 else 1. 85 result += G[i]*exp_now + B[i]*exp_next*pow_now 81 with errstate(divide='ignore', invalid='ignore'): 82 result = np.empty(q.shape, 'd') 83 for i in range(ilevel): 84 exp_now = exp(-(q*rg[i])**2/3.) 85 pow_now = (erf(q*rg[i]/sqrt(6.))**3/q)**power[i] 86 exp_next = exp(-(q*rg[i+1])**2/3.) if i < ilevel-1 else 1. 87 result += G[i]*exp_now + B[i]*exp_next*pow_now 86 88 result[q==0] = np.sum(G[:ilevel]) 87 89 return result 90 88 91 Iq.vectorized = True 89 92 -
sasmodels/models/vesicle.c
r062db5a r2c74c11 2 2 3 3 double Iq(double q, 4 double sld, double sld_solvent, double volfraction,5 double radius, double thickness);6 7 double Iqxy(double qx, double qy,8 4 double sld, double sld_solvent, double volfraction, 9 5 double radius, double thickness); … … 49 45 return(f2); 50 46 } 51 52 53 double Iqxy(double qx, double qy,54 double sld, double sld_solvent, double volfraction,55 double radius, double thickness)56 57 {58 double q = sqrt(qx*qx + qy*qy);59 return Iq(q,60 sld, sld_solvent, volfraction,61 radius,thickness);62 63 }
Note: See TracChangeset
for help on using the changeset viewer.