Changeset a807206 in sasmodels
- Timestamp:
- Sep 30, 2016 10:42:06 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:
- caddb14, 5031ca3
- Parents:
- 2222134
- Location:
- sasmodels/models
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/correlation_length.py
r40a87fa ra807206 16 16 multiplicative factors $A$ and $C$, and the two exponents $n$ and $m$ are 17 17 used as fitting parameters. (Respectively *porod_scale*, *lorentz_scale*, 18 * exponent_p* and *exponent_l* in the parameter list.) The remaining18 *porod_exp* and *lorentz_exp* in the parameter list.) The remaining 19 19 parameter $\xi$ (*cor_length* in the parameter list) is a correlation 20 20 length for the polymer chains. Note that when $m=2$ this functional form … … 48 48 ["porod_scale", "", 1e-06, [0, inf], "", "Porod Scaling Factor"], 49 49 ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length, xi, in Lorentzian"], 50 [" exponent_p", "", 3.0, [0, inf], "", "Porod Exponent, n, in q^-n"],51 [" exponent_l", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent, m, in 1/( 1 + (q.xi)^m)"],50 ["porod_exp", "", 3.0, [0, inf], "", "Porod Exponent, n, in q^-n"], 51 ["lorentz_exp", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent, m, in 1/( 1 + (q.xi)^m)"], 52 52 ] 53 53 # pylint: enable=bad-continuation, line-too-long 54 54 55 def Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l):55 def Iq(q, lorentz_scale, porod_scale, cor_length, porod_exp, lorentz_exp): 56 56 """ 57 57 1D calculation of the Correlation length model 58 58 """ 59 59 with errstate(divide='ignore'): 60 porod = porod_scale / q** exponent_p61 lorentz = lorentz_scale / (1.0 + (q * cor_length)** exponent_l)60 porod = porod_scale / q**porod_exp 61 lorentz = lorentz_scale / (1.0 + (q * cor_length)**lorentz_exp) 62 62 inten = porod + lorentz 63 63 return inten … … 66 66 # parameters for demo 67 67 demo = dict(lorentz_scale=10.0, porod_scale=1.0e-06, cor_length=50.0, 68 exponent_p=3.0, exponent_l=2.0, background=0.1,68 porod_exp=3.0, lorentz_exp=2.0, background=0.1, 69 69 ) 70 70 -
sasmodels/models/dab.py
r2c74c11 ra807206 55 55 56 56 # ["name", "units", default, [lower, upper], "type", "description"], 57 parameters = [[" length", "Ang", 50.0, [0, inf], "", "correlation length"],57 parameters = [["cor_length", "Ang", 50.0, [0, inf], "", "correlation length"], 58 58 ] 59 59 60 60 Iq = """ 61 double numerator = pow( length, 3);62 double denominator = pow(1 + pow(q* length,2), 2);61 double numerator = pow(cor_length, 3); 62 double denominator = pow(1 + pow(q*cor_length,2), 2); 63 63 64 64 return numerator / denominator ; … … 69 69 # VR defaults to 1.0 70 70 71 demo = dict(scale=1, background=0, length=50)71 demo = dict(scale=1, background=0, cor_length=50) -
sasmodels/models/ellipsoid.c
r50e1e40 ra807206 1 double form_volume(double r polar, double requatorial);2 double Iq(double q, double sld, double s olvent_sld, double rpolar, double requatorial);3 double Iqxy(double qx, double qy, double sld, double s olvent_sld,4 double r polar, double requatorial, double theta, double phi);1 double form_volume(double radius_polar, double radius_equatorial); 2 double Iq(double q, double sld, double sld_solvent, double radius_polar, double radius_equatorial); 3 double Iqxy(double qx, double qy, double sld, double sld_solvent, 4 double radius_polar, double radius_equatorial, double theta, double phi); 5 5 6 double _ellipsoid_kernel(double q, double r polar, double requatorial, double sin_alpha);7 double _ellipsoid_kernel(double q, double r polar, double requatorial, double sin_alpha)6 double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha); 7 double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha) 8 8 { 9 double ratio = r polar/requatorial;10 const double u = q*r equatorial*sqrt(1.09 double ratio = radius_polar/radius_equatorial; 10 const double u = q*radius_equatorial*sqrt(1.0 11 11 + sin_alpha*sin_alpha*(ratio*ratio - 1.0)); 12 12 const double f = sph_j1c(u); … … 15 15 } 16 16 17 double form_volume(double r polar, double requatorial)17 double form_volume(double radius_polar, double radius_equatorial) 18 18 { 19 return M_4PI_3*r polar*requatorial*requatorial;19 return M_4PI_3*radius_polar*radius_equatorial*radius_equatorial; 20 20 } 21 21 22 22 double Iq(double q, 23 23 double sld, 24 double s olvent_sld,25 double r polar,26 double r equatorial)24 double sld_solvent, 25 double radius_polar, 26 double radius_equatorial) 27 27 { 28 28 // translate a point in [-1,1] to a point in [0, 1] … … 33 33 //const double sin_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2; 34 34 const double sin_alpha = Gauss76Z[i]*zm + zb; 35 total += Gauss76Wt[i] * _ellipsoid_kernel(q, r polar, requatorial, sin_alpha);35 total += Gauss76Wt[i] * _ellipsoid_kernel(q, radius_polar, radius_equatorial, sin_alpha); 36 36 } 37 37 // translate dx in [-1,1] to dx in [lower,upper] 38 38 const double form = total*zm; 39 const double s = (sld - s olvent_sld) * form_volume(rpolar, requatorial);39 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 40 40 return 1.0e-4 * s * s * form; 41 41 } … … 43 43 double Iqxy(double qx, double qy, 44 44 double sld, 45 double s olvent_sld,46 double r polar,47 double r equatorial,45 double sld_solvent, 46 double radius_polar, 47 double radius_equatorial, 48 48 double theta, 49 49 double phi) … … 55 55 // TODO: check if this is actually sin(alpha), not cos(alpha) 56 56 const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 57 const double form = _ellipsoid_kernel(q, r polar, requatorial, cos_alpha);58 const double s = (sld - s olvent_sld) * form_volume(rpolar, requatorial);57 const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha); 58 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 59 59 60 60 return 1.0e-4 * form * s * s; -
sasmodels/models/ellipsoid.py
r42356c8 ra807206 74 74 calculated from our 2D model and the intensity from the NIST SANS 75 75 analysis software. The parameters used were: *scale* = 1.0, 76 *r _polar* = 20 |Ang|, *r_equatorial* = 400 |Ang|,76 *radius_polar* = 20 |Ang|, *radius_equatorial* = 400 |Ang|, 77 77 *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. 78 78 … … 122 122 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 123 123 "Solvent scattering length density"], 124 ["r _polar", "Ang", 20, [0, inf], "volume",124 ["radius_polar", "Ang", 20, [0, inf], "volume", 125 125 "Polar radius"], 126 ["r _equatorial", "Ang", 400, [0, inf], "volume",126 ["radius_equatorial", "Ang", 400, [0, inf], "volume", 127 127 "Equatorial radius"], 128 128 ["theta", "degrees", 60, [-inf, inf], "orientation", … … 134 134 source = ["lib/sph_j1c.c", "lib/gauss76.c", "ellipsoid.c"] 135 135 136 def ER(r _polar, r_equatorial):136 def ER(radius_polar, radius_equatorial): 137 137 import numpy as np 138 138 139 ee = np.empty_like(r _polar)140 idx = r _polar > r_equatorial141 ee[idx] = (r _polar[idx] ** 2 - r_equatorial[idx] ** 2) / r_polar[idx] ** 2142 idx = r _polar < r_equatorial143 ee[idx] = (r _equatorial[idx] ** 2 - r_polar[idx] ** 2) / r_equatorial[idx] ** 2144 idx = r _polar == r_equatorial145 ee[idx] = 2 * r _polar[idx]146 valid = (r _polar * r_equatorial != 0)139 ee = np.empty_like(radius_polar) 140 idx = radius_polar > radius_equatorial 141 ee[idx] = (radius_polar[idx] ** 2 - radius_equatorial[idx] ** 2) / radius_polar[idx] ** 2 142 idx = radius_polar < radius_equatorial 143 ee[idx] = (radius_equatorial[idx] ** 2 - radius_polar[idx] ** 2) / radius_equatorial[idx] ** 2 144 idx = radius_polar == radius_equatorial 145 ee[idx] = 2 * radius_polar[idx] 146 valid = (radius_polar * radius_equatorial != 0) 147 147 bd = 1.0 - ee[valid] 148 148 e1 = np.sqrt(ee[valid]) … … 152 152 delta = 0.75 * b1 * b2 153 153 154 ddd = np.zeros_like(r _polar)155 ddd[valid] = 2.0 * (delta + 1.0) * r _polar * r_equatorial ** 2154 ddd = np.zeros_like(radius_polar) 155 ddd[valid] = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial ** 2 156 156 return 0.5 * ddd ** (1.0 / 3.0) 157 157 … … 159 159 demo = dict(scale=1, background=0, 160 160 sld=6, sld_solvent=1, 161 r _polar=50, r_equatorial=30,161 radius_polar=50, radius_equatorial=30, 162 162 theta=30, phi=15, 163 r _polar_pd=.2, r_polar_pd_n=15,164 r _equatorial_pd=.2, r_equatorial_pd_n=15,163 radius_polar_pd=.2, radius_polar_pd_n=15, 164 radius_equatorial_pd=.2, radius_equatorial_pd_n=15, 165 165 theta_pd=15, theta_pd_n=45, 166 166 phi_pd=15, phi_pd_n=1) -
sasmodels/models/elliptical_cylinder.c
r40a87fa ra807206 1 double form_volume(double r _minor, double r_ratio, double length);2 double Iq(double q, double r _minor, double r_ratio, double length,1 double form_volume(double radius_minor, double r_ratio, double length); 2 double Iq(double q, double radius_minor, double r_ratio, double length, 3 3 double sld, double solvent_sld); 4 double Iqxy(double qx, double qy, double r _minor, double r_ratio, double length,4 double Iqxy(double qx, double qy, double radius_minor, double r_ratio, double length, 5 5 double sld, double solvent_sld, double theta, double phi, double psi); 6 6 7 7 8 double _elliptical_cylinder_kernel(double q, double r _minor, double r_ratio, double theta);8 double _elliptical_cylinder_kernel(double q, double radius_minor, double r_ratio, double theta); 9 9 10 double _elliptical_cylinder_kernel(double q, double r _minor, double r_ratio, double theta)10 double _elliptical_cylinder_kernel(double q, double radius_minor, double r_ratio, double theta) 11 11 { 12 12 // This is the function LAMBDA1^2 in Feigin's notation 13 13 // q is the q-value for the calculation (1/A) 14 // r _minor is the transformed radius"a" in Feigin's notation14 // radius_minor is the transformed radius"a" in Feigin's notation 15 15 // r_ratio is the ratio (major radius)/(minor radius) of the Ellipsoid [=] --- 16 16 // theta is the dummy variable of the integration … … 18 18 double retval,arg; 19 19 20 arg = q*r _minor*sqrt((1.0+r_ratio*r_ratio)/2+(1.0-r_ratio*r_ratio)*cos(theta)/2);20 arg = q*radius_minor*sqrt((1.0+r_ratio*r_ratio)/2+(1.0-r_ratio*r_ratio)*cos(theta)/2); 21 21 //retval = 2.0*J1(arg)/arg; 22 22 retval = sas_J1c(arg); … … 25 25 26 26 27 double form_volume(double r _minor, double r_ratio, double length)27 double form_volume(double radius_minor, double r_ratio, double length) 28 28 { 29 return M_PI * r _minor * r_minor * r_ratio * length;29 return M_PI * radius_minor * radius_minor * r_ratio * length; 30 30 } 31 31 32 double Iq(double q, double r _minor, double r_ratio, double length,32 double Iq(double q, double radius_minor, double r_ratio, double length, 33 33 double sld, double solvent_sld) { 34 34 … … 55 55 summj=0; 56 56 zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0; //the "x" dummy 57 arg = r _minor*sqrt(1.0-zi*zi);57 arg = radius_minor*sqrt(1.0-zi*zi); 58 58 for(int j=0;j<nordj;j++) { 59 59 //20 gauss points for the inner integral … … 77 77 answer *= delrho*delrho; 78 78 79 const double vol = form_volume(r _minor, r_ratio, length);79 const double vol = form_volume(radius_minor, r_ratio, length); 80 80 return answer*vol*vol*1.0e-4; 81 81 } 82 82 83 83 84 double Iqxy(double qx, double qy, double r _minor, double r_ratio, double length,84 double Iqxy(double qx, double qy, double radius_minor, double r_ratio, double length, 85 85 double sld, double solvent_sld, double theta, double phi, double psi) { 86 86 const double _theta = theta * M_PI / 180.0; … … 139 139 } 140 140 141 const double r_major = r_ratio * r _minor;142 const double qr = q*sqrt( r_major*r_major*cos_nu*cos_nu + r _minor*r_minor*cos_mu*cos_mu );141 const double r_major = r_ratio * radius_minor; 142 const double qr = q*sqrt( r_major*r_major*cos_nu*cos_nu + radius_minor*radius_minor*cos_mu*cos_mu ); 143 143 const double qL = q*length*cos_val/2.0; 144 144 … … 159 159 160 160 const double k = 2.0 * Be * Si; 161 const double vol = form_volume(r _minor, r_ratio, length);161 const double vol = form_volume(radius_minor, r_ratio, length); 162 162 return (sld - solvent_sld) * (sld - solvent_sld) * k * k *vol*vol*1.0e-4; 163 163 } -
sasmodels/models/elliptical_cylinder.py
r40a87fa ra807206 110 110 # pylint: disable=bad-whitespace, line-too-long 111 111 # ["name", "units", default, [lower, upper], "type","description"], 112 parameters = [["r _minor", "Ang", 20.0, [0, inf], "volume", "Ellipse minor radius"],112 parameters = [["radius_minor", "Ang", 20.0, [0, inf], "volume", "Ellipse minor radius"], 113 113 ["axis_ratio", "", 1.5, [1, inf], "volume", "Ratio of major radius over minor radius"], 114 114 ["length", "Ang", 400.0, [1, inf], "volume", "Length of the cylinder"], … … 124 124 "elliptical_cylinder.c"] 125 125 126 demo = dict(scale=1, background=0, r _minor=100, axis_ratio=1.5, length=400.0,126 demo = dict(scale=1, background=0, radius_minor=100, axis_ratio=1.5, length=400.0, 127 127 sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, 128 128 theta_pd=10, phi_pd=2, psi_pd=3) 129 129 130 def ER(r _minor, axis_ratio, length):130 def ER(radius_minor, axis_ratio, length): 131 131 """ 132 132 Equivalent radius 133 @param r _minor: Ellipse minor radius133 @param radius_minor: Ellipse minor radius 134 134 @param axis_ratio: Ratio of major radius over minor radius 135 135 @param length: Length of the cylinder 136 136 """ 137 radius = sqrt(r _minor * r_minor * axis_ratio)137 radius = sqrt(radius_minor * radius_minor * axis_ratio) 138 138 ddd = 0.75 * radius * (2 * radius * length 139 139 + (length + radius) * (length + pi * radius)) … … 141 141 142 142 tests = [ 143 [{'r _minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024],144 [{'r _minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1],143 [{'radius_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 144 [{'radius_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 145 145 146 146 # The SasView test result was 0.00169, with a background of 0.001 147 [{'r _minor': 20.0, 'axis_ratio': 1.5, 'sld': 4.0, 'length':400.0,147 [{'radius_minor': 20.0, 'axis_ratio': 1.5, 'sld': 4.0, 'length':400.0, 148 148 'sld_solvent':1.0, 'background':0.0}, 149 149 0.001, 675.504402], -
sasmodels/models/fractal_core_shell.c
r2c74c11 ra807206 8 8 double solvent_sld, 9 9 double volfraction, 10 double frac _dim,10 double fractal_dim, 11 11 double cor_length); 12 12 … … 23 23 double solvent_sld, 24 24 double volfraction, 25 double frac _dim,25 double fractal_dim, 26 26 double cor_length) { 27 27 … … 34 34 solvent_sld); 35 35 //calculate S(q) 36 double frac_1 = frac _dim-1.0;36 double frac_1 = fractal_dim-1.0; 37 37 double qr = q*radius; 38 38 39 double t1 = frac _dim*sas_gamma(frac_1)*sin(frac_1*atan(q*cor_length));39 double t1 = fractal_dim*sas_gamma(frac_1)*sin(frac_1*atan(q*cor_length)); 40 40 double t2 = (1.0 + 1.0/(q*cor_length)/(q*cor_length)); 41 double t3 = pow(qr, frac _dim) * pow(t2, (frac_1/2.0));41 double t3 = pow(qr, fractal_dim) * pow(t2, (frac_1/2.0)); 42 42 double sq = t1/t3; 43 43 sq += 1.0; -
sasmodels/models/fractal_core_shell.py
r42356c8 ra807206 31 31 {(qr_c)^{D_f}\left(1+\frac{1}{q^2\xi ^2} \right)^{\frac{D_f-1}{2}}} 32 32 33 where $D_f$ = frac _dim, |xi| = cor_length, $r_c$ = (core) radius, and33 where $D_f$ = fractal_dim, |xi| = cor_length, $r_c$ = (core) radius, and 34 34 $scale$ = volume fraction. 35 35 … … 69 69 ["sld_solvent", "1e-6/Ang^2", 3.0, [-inf, inf], "sld", "Solvent scattering length density"], 70 70 ["volfraction", "", 1.0, [0, inf], "", "Volume fraction of building block spheres"], 71 ["frac _dim", "", 2.0, [-inf, inf], "", "Fractal dimension"],71 ["fractal_dim", "", 2.0, [-inf, inf], "", "Fractal dimension"], 72 72 ["cor_length", "Ang", 100.0, [0, inf], "", "Correlation length of fractal-like aggregates"]] 73 73 # pylint: enable=bad-whitespace, line-too-long … … 83 83 sld_solvent=6.35, 84 84 volfraction=0.05, 85 frac _dim=2.0,85 fractal_dim=2.0, 86 86 cor_length=100.0) 87 87 -
sasmodels/models/gauss_lorentz_gel.py
r40a87fa ra807206 56 56 # pylint: disable=bad-whitespace, line-too-long 57 57 # ["name", "units", default, [lower, upper], "type", "description"], 58 parameters = [["gauss_scale _factor", "", 100.0, [-inf, inf], "", "Gauss scale factor"],59 [" static_cor_length", "Ang", 100.0, [0, inf], "", "Static correlation length"],60 ["lorentz_scale _factor", "", 50.0, [-inf, inf], "", "Lorentzian scale factor"],61 [" dynamic_cor_length", "Ang", 20.0, [0, inf], "", "Dynamic correlation length"],58 parameters = [["gauss_scale", "", 100.0, [-inf, inf], "", "Gauss scale factor"], 59 ["cor_length_static", "Ang", 100.0, [0, inf], "", "Static correlation length"], 60 ["lorentz_scale", "", 50.0, [-inf, inf], "", "Lorentzian scale factor"], 61 ["cor_length_dynamic", "Ang", 20.0, [0, inf], "", "Dynamic correlation length"], 62 62 ] 63 63 # pylint: enable=bad-whitespace, line-too-long 64 64 65 65 def Iq(q, 66 gauss_scale _factor=100.0,67 static_cor_length=100.0,68 lorentz_scale _factor=50.0,69 dynamic_cor_length=20.0):66 gauss_scale=100.0, 67 cor_length_static=100.0, 68 lorentz_scale=50.0, 69 cor_length_dynamic=20.0): 70 70 """ 71 71 72 72 :param q: Input q-value 73 :param gauss_scale _factor: Gauss scale factor74 :param static_cor_length: Static correlation length75 :param lorentz_scale _factor: Lorentzian scale factor76 :param dynamic_cor_length: Dynamic correlation length73 :param gauss_scale: Gauss scale factor 74 :param cor_length_static: Static correlation length 75 :param lorentz_scale: Lorentzian scale factor 76 :param cor_length_dynamic: Dynamic correlation length 77 77 :return: 1-D intensity 78 78 """ 79 79 80 term1 = gauss_scale _factor*\81 exp(-1.0*q*q* static_cor_length*static_cor_length/2.0)82 term2 = lorentz_scale _factor/\83 (1.0+(q* dynamic_cor_length)*(q*dynamic_cor_length))80 term1 = gauss_scale *\ 81 exp(-1.0*q*q*cor_length_static*cor_length_static/2.0) 82 term2 = lorentz_scale /\ 83 (1.0+(q*cor_length_dynamic)*(q*cor_length_dynamic)) 84 84 85 85 return term1 + term2 … … 89 89 90 90 demo = dict(scale=1, background=0.1, 91 gauss_scale _factor=100.0,92 static_cor_length=100.0,93 lorentz_scale _factor=50.0,94 dynamic_cor_length=20.0)91 gauss_scale=100.0, 92 cor_length_static=100.0, 93 lorentz_scale=50.0, 94 cor_length_dynamic=20.0) 95 95 96 96 tests = [ 97 97 98 98 # Accuracy tests based on content in test/utest_extra_models.py 99 [{'gauss_scale _factor': 100.0,100 ' static_cor_length': 100.0,101 'lorentz_scale _factor': 50.0,102 ' dynamic_cor_length': 20.0,99 [{'gauss_scale': 100.0, 100 'cor_length_static': 100.0, 101 'lorentz_scale': 50.0, 102 'cor_length_dynamic': 20.0, 103 103 }, 0.001, 149.482], 104 104 105 [{'gauss_scale _factor': 100.0,106 ' static_cor_length': 100.0,107 'lorentz_scale _factor': 50.0,108 ' dynamic_cor_length': 20.0,105 [{'gauss_scale': 100.0, 106 'cor_length_static': 100.0, 107 'lorentz_scale': 50.0, 108 'cor_length_dynamic': 20.0, 109 109 }, 0.105363, 9.1913], 110 110 111 [{'gauss_scale _factor': 100.0,112 ' static_cor_length': 100.0,113 'lorentz_scale _factor': 50.0,114 ' dynamic_cor_length': 20.0,111 [{'gauss_scale': 100.0, 112 'cor_length_static': 100.0, 113 'lorentz_scale': 50.0, 114 'cor_length_dynamic': 20.0, 115 115 }, 0.441623, 0.633811], 116 116 117 117 # Additional tests with larger range of parameters 118 [{'gauss_scale _factor': 10.0,119 ' static_cor_length': 100.0,120 'lorentz_scale _factor': 3.0,121 ' dynamic_cor_length': 1.0,118 [{'gauss_scale': 10.0, 119 'cor_length_static': 100.0, 120 'lorentz_scale': 3.0, 121 'cor_length_dynamic': 1.0, 122 122 }, 0.1, 2.9712970297], 123 123 124 [{'gauss_scale _factor': 10.0,125 ' static_cor_length': 100.0,126 'lorentz_scale _factor': 3.0,127 ' dynamic_cor_length': 1.0,124 [{'gauss_scale': 10.0, 125 'cor_length_static': 100.0, 126 'lorentz_scale': 3.0, 127 'cor_length_dynamic': 1.0, 128 128 'background': 100.0 129 129 }, 5.0, 100.116384615], 130 130 131 [{'gauss_scale _factor': 10.0,132 ' static_cor_length': 100.0,133 'lorentz_scale _factor': 3.0,134 ' dynamic_cor_length': 1.0,131 [{'gauss_scale': 10.0, 132 'cor_length_static': 100.0, 133 'lorentz_scale': 3.0, 134 'cor_length_dynamic': 1.0, 135 135 'background': 0.0, 136 136 }, 200., 7.49981250469e-05], -
sasmodels/models/gaussian_peak.py
r7f1ee79 ra807206 34 34 description = """ 35 35 Model describes a Gaussian shaped peak including a flat background 36 Provide F(q) = scale*exp( -1/2 *[(q- q0)/sigma]^2 )+ background36 Provide F(q) = scale*exp( -1/2 *[(q-peak_pos)/sigma]^2 )+ background 37 37 """ 38 38 category = "shape-independent" 39 39 40 40 # ["name", "units", default, [lower, upper], "type","description"], 41 parameters = [[" q0", "1/Ang", 0.05, [-inf, inf], "", "Peak position"],41 parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], 42 42 ["sigma", "1/Ang", 0.005, [0, inf], "", 43 43 "Peak width (standard deviation)"], … … 45 45 46 46 Iq = """ 47 double scaled_dq = (q - q0)/sigma;47 double scaled_dq = (q - peak_pos)/sigma; 48 48 return exp(-0.5*scaled_dq*scaled_dq); //sqrt(2*M_PI*sigma*sigma); 49 49 """ … … 51 51 # VR defaults to 1.0 52 52 53 demo = dict(scale=1, background=0, q0=0.05, sigma=0.005)53 demo = dict(scale=1, background=0, peak_pos=0.05, sigma=0.005) -
sasmodels/models/gel_fit.c
r03cac08 ra807206 1 1 static double Iq(double q, 2 2 double guinier_scale, 3 double lorentz ian_scale,4 double gyration_radius,5 double fractal_ exp,3 double lorentz_scale, 4 double rg, 5 double fractal_dim, 6 6 double cor_length) 7 7 { … … 9 9 ////////////////////////double a(x[i]*x[i]*zeta*zeta); 10 10 double lorentzian_term = square(q*cor_length); 11 lorentzian_term = 1.0 + ((fractal_ exp+ 1.0)/3.0)*lorentzian_term;12 lorentzian_term = pow(lorentzian_term, (fractal_ exp/2.0) );11 lorentzian_term = 1.0 + ((fractal_dim + 1.0)/3.0)*lorentzian_term; 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 double exp_term = square(q* gyration_radius);16 double exp_term = square(q*rg); 17 17 exp_term = exp(-1.0*(exp_term/3.0)); 18 18 19 19 // Scattering Law 20 double result = lorentz ian_scale/lorentzian_term + guinier_scale*exp_term;20 double result = lorentz_scale/lorentzian_term + guinier_scale*exp_term; 21 21 return result; 22 22 } -
sasmodels/models/gel_fit.py
r40a87fa ra807206 62 62 # ["name", "units", default, [lower, upper], "type","description"], 63 63 parameters = [["guinier_scale", "cm^-1", 1.7, [-inf, inf], "", "Guinier length scale"], 64 ["lorentz ian_scale", "cm^-1", 3.5, [-inf, inf], "", "Lorentzian length scale"],65 [" gyration_radius", "Ang", 104.0, [2, inf], "", "Radius of gyration"],66 ["fractal_ exp", "", 2.0, [0, inf], "", "Fractal exponent"],64 ["lorentz_scale", "cm^-1", 3.5, [-inf, inf], "", "Lorentzian length scale"], 65 ["rg", "Ang", 104.0, [2, inf], "", "Radius of gyration"], 66 ["fractal_dim", "", 2.0, [0, inf], "", "Fractal exponent"], 67 67 ["cor_length", "Ang", 16.0, [0, inf], "", "Correlation length"] 68 68 ] … … 73 73 demo = dict(background=0.01, 74 74 guinier_scale=1.7, 75 lorentz ian_scale=3.5,76 gyration_radius=104,77 fractal_ exp=2.0,75 lorentz_scale=3.5, 76 rg=104, 77 fractal_dim=2.0, 78 78 cor_length=16.0) 79 79 80 80 tests = [[{'guinier_scale': 1.0, 81 'lorentz ian_scale': 1.0,82 ' gyration_radius': 10.0,83 'fractal_ exp': 10.0,81 'lorentz_scale': 1.0, 82 'rg': 10.0, 83 'fractal_dim': 10.0, 84 84 'cor_length': 20.0, 85 85 'background': 0.0, … … 87 87 88 88 [{'guinier_scale': 4.0, 89 'lorentz ian_scale': 10.0,90 ' gyration_radius': 500.0,91 'fractal_ exp': 1.0,89 'lorentz_scale': 10.0, 90 'rg': 500.0, 91 'fractal_dim': 1.0, 92 92 'cor_length': 20.0, 93 93 'background': 20.0, -
sasmodels/models/guinier_porod.py
r40a87fa ra807206 72 72 description = """\ 73 73 I(q) = scale/q^s* exp ( - R_g^2 q^2 / (3-s) ) for q<= ql 74 = scale/q^ m*exp((-ql^2*Rg^2)/(3-s))*ql^(m-s) for q>=ql75 where ql = sqrt(( m-s)(3-s)/2)/Rg.74 = scale/q^porod_exp*exp((-ql^2*Rg^2)/(3-s))*ql^(porod_exp-s) for q>=ql 75 where ql = sqrt((porod_exp-s)(3-s)/2)/Rg. 76 76 List of parameters: 77 77 scale = Guinier Scale 78 78 s = Dimension Variable 79 79 Rg = Radius of Gyration [A] 80 m= Porod Exponent80 porod_exp = Porod Exponent 81 81 background = Background [1/cm]""" 82 82 … … 87 87 parameters = [["rg", "Ang", 60.0, [0, inf], "", "Radius of gyration"], 88 88 ["s", "", 1.0, [0, inf], "", "Dimension variable"], 89 [" m", "", 3.0, [0, inf], "", "Porod exponent"]]89 ["porod_exp", "", 3.0, [0, inf], "", "Porod exponent"]] 90 90 # pylint: enable=bad-whitespace, line-too-long 91 91 92 92 # pylint: disable=C0103 93 def Iq(q, rg, s, m):93 def Iq(q, rg, s, porod_exp): 94 94 """ 95 95 @param q: Input q-value 96 96 """ 97 97 n = 3.0 - s 98 ms = 0.5*( m-s) # =(n-3+m)/298 ms = 0.5*(porod_exp-s) # =(n-3+porod_exp)/2 99 99 100 100 # preallocate return value … … 109 109 with errstate(divide='ignore'): 110 110 iq[idx] = q[idx]**-s * exp(-(q[idx]*rg)**2/n) 111 iq[~idx] = q[~idx]**- m* (exp(-ms) * (n*ms/rg**2)**ms)111 iq[~idx] = q[~idx]**-porod_exp * (exp(-ms) * (n*ms/rg**2)**ms) 112 112 return iq 113 113 114 114 Iq.vectorized = True # Iq accepts an array of q values 115 115 116 demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, m=3.0)116 demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, porod_exp=3.0) 117 117 118 118 tests = [[{'scale': 1.5, 'background':0.5}, 0.04, 5.290096890253155]] -
sasmodels/models/hayter_msa.py
r0bef47b ra807206 51 51 # dp[2] = volfraction(); 52 52 # dp[3] = temperature(); 53 # dp[4] = salt_concentration();53 # dp[4] = concentration_salt(); 54 54 # dp[5] = dielectconst(); 55 55 … … 76 76 ["charge", "e", 19.0, [0, inf], "", "charge on sphere (in electrons)"], 77 77 ["temperature", "K", 318.16, [0, inf], "", "temperature, in Kelvin, for Debye length calculation"], 78 [" salt_concentration", "M", 0.0, [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"],78 ["concentration_salt", "M", 0.0, [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 79 79 ["dielectconst", "None", 71.08, [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] 80 80 ] … … 93 93 # note the calculation varies in different limiting cases so a wide range of 94 94 # parameters will be required for a thorough test! 95 # odd that the default st has salt_concentrationzero95 # odd that the default st has concentration_salt zero 96 96 demo = dict(radius_effective=20.75, 97 97 charge=19.0, 98 98 volfraction=0.0192, 99 99 temperature=318.16, 100 salt_concentration=0.05,100 concentration_salt=0.05, 101 101 dielectconst=71.08, 102 102 radius_effective_pd=0.1, … … 113 113 'volfraction': 0.0192, 114 114 'temperature': 298.0, 115 ' salt_concentration': 0,115 'concentration_salt': 0, 116 116 'dielectconst': 78.0, 117 117 'radius_effective_pd': 0}, … … 123 123 'volfraction': 0.0192, 124 124 'temperature': 298.0, 125 ' salt_concentration': 0.05,125 'concentration_salt': 0.05, 126 126 'dielectconst': 78.0, 127 127 'radius_effective_pd': 0.1, -
sasmodels/models/hollow_cylinder.c
rf95556f ra807206 1 double form_volume(double radius, double core_radius, double length);1 double form_volume(double radius, double radius_core, double length); 2 2 3 double Iq(double q, double radius, double core_radius, double length, double sld,3 double Iq(double q, double radius, double radius_core, double length, double sld, 4 4 double solvent_sld); 5 double Iqxy(double qx, double qy, double radius, double core_radius, double length, double sld,5 double Iqxy(double qx, double qy, double radius, double radius_core, double length, double sld, 6 6 double solvent_sld, double theta, double phi); 7 7 8 #define INVALID(v) (v. core_radius>= v.radius)8 #define INVALID(v) (v.radius_core >= v.radius) 9 9 10 10 // From Igor library … … 27 27 28 28 static double _hollow_cylinder_kernel( 29 double q, double core_radius, double radius, double length, double dum)29 double q, double radius_core, double radius, double length, double dum) 30 30 { 31 31 const double qs = q*sqrt(1.0-dum*dum); 32 32 const double lam1 = sas_J1c(radius*qs); 33 const double lam2 = sas_J1c( core_radius*qs);34 const double gamma_sq = square( core_radius/radius);35 //Note: lim_{r -> r_c} psi = J0( core_radius*qs)33 const double lam2 = sas_J1c(radius_core*qs); 34 const double gamma_sq = square(radius_core/radius); 35 //Note: lim_{r -> r_c} psi = J0(radius_core*qs) 36 36 const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 37 37 const double t2 = sinc(q*length*dum/2.0); … … 41 41 42 42 static double hollow_cylinder_analytical_2D_scaled( 43 double q, double q_x, double q_y, double radius, double core_radius,43 double q, double q_x, double q_y, double radius, double radius_core, 44 44 double length, double sld, double solvent_sld, double theta, double phi) 45 45 { … … 65 65 cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 66 66 67 answer = _hollow_cylinder_kernel(q, core_radius, radius, length, cos_val);67 answer = _hollow_cylinder_kernel(q, radius_core, radius, length, cos_val); 68 68 69 vol = form_volume(radius, core_radius, length);69 vol = form_volume(radius, radius_core, length); 70 70 answer = hollow_cylinder_scaling(answer, delrho, vol); 71 71 … … 74 74 75 75 76 double form_volume(double radius, double core_radius, double length)76 double form_volume(double radius, double radius_core, double length) 77 77 { 78 double v_shell = M_PI*length*(radius*radius- core_radius*core_radius);78 double v_shell = M_PI*length*(radius*radius-radius_core*radius_core); 79 79 return(v_shell); 80 80 } 81 81 82 82 83 double Iq(double q, double radius, double core_radius, double length,83 double Iq(double q, double radius, double radius_core, double length, 84 84 double sld, double solvent_sld) 85 85 { … … 95 95 for (i=0;i<76;i++) { 96 96 zi = ( Gauss76Z[i] * (upper-lower) + lower + upper )/2.0; 97 inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, core_radius, radius, length, zi);97 inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, radius_core, radius, length, zi); 98 98 summ += inter; 99 99 } 100 100 101 101 norm = summ*(upper-lower)/2.0; 102 volume = form_volume(radius, core_radius, length);102 volume = form_volume(radius, radius_core, length); 103 103 delrho = solvent_sld - sld; 104 104 answer = hollow_cylinder_scaling(norm, delrho, volume); … … 108 108 109 109 110 double Iqxy(double qx, double qy, double radius, double core_radius,110 double Iqxy(double qx, double qy, double radius, double radius_core, 111 111 double length, double sld, double solvent_sld, double theta, double phi) 112 112 { 113 113 const double q = sqrt(qx*qx+qy*qy); 114 return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, core_radius, length, sld, solvent_sld, theta, phi);114 return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, radius_core, length, sld, solvent_sld, theta, phi); 115 115 } -
sasmodels/models/hollow_cylinder.py
r58210db ra807206 39 39 40 40 In the parameters, the contrast represents SLD :sub:`shell` - SLD :sub:`solvent` 41 and the *radius* is $R_\text{shell}$ while * core_radius* is $R_\text{core}$.41 and the *radius* is $R_\text{shell}$ while *radius_core* is $R_\text{core}$. 42 42 43 43 To provide easy access to the orientation of the core-shell cylinder, we define … … 58 58 description = """ 59 59 P(q) = scale*<f*f>/Vol + background, where f is the scattering amplitude. 60 core_radius= the radius of core60 radius_core = the radius of core 61 61 radius = the radius of shell 62 62 length = the total length of the cylinder … … 70 70 parameters = [ 71 71 ["radius", "Ang", 30.0, [0, inf], "volume", "Cylinder radius"], 72 [" core_radius", "Ang", 20.0, [0, inf], "volume", "Hollow core radius"],72 ["radius_core", "Ang", 20.0, [0, inf], "volume", "Hollow core radius"], 73 73 ["length", "Ang", 400.0, [0, inf], "volume", "Cylinder length"], 74 74 ["sld", "1/Ang^2", 6.3, [-inf, inf], "sld", "Cylinder sld"], … … 82 82 83 83 # pylint: disable=W0613 84 def ER(radius, core_radius, length):84 def ER(radius, radius_core, length): 85 85 """ 86 86 :param radius: Cylinder radius 87 :param core_radius: Hollow core radius, UNUSED87 :param radius_core: Hollow core radius, UNUSED 88 88 :param length: Cylinder length 89 89 :return: Effective radius … … 99 99 return diam 100 100 101 def VR(radius, core_radius, length):101 def VR(radius, radius_core, length): 102 102 """ 103 103 :param radius: Cylinder radius 104 :param core_radius: Hollow core radius104 :param radius_core: Hollow core radius 105 105 :param length: Cylinder length 106 106 :return: Volf ratio for P(q)*S(q) 107 107 """ 108 vol_core = pi* core_radius*core_radius*length108 vol_core = pi*radius_core*radius_core*length 109 109 vol_total = pi*radius*radius*length 110 110 vol_shell = vol_total - vol_core … … 113 113 # parameters for demo 114 114 demo = dict(scale=1.0, background=0.0, length=400.0, radius=30.0, 115 core_radius=20.0, sld=6.3, sld_solvent=1, theta=90, phi=0,115 radius_core=20.0, sld=6.3, sld_solvent=1, theta=90, phi=0, 116 116 radius_pd=.2, radius_pd_n=9, 117 117 length_pd=.2, length_pd_n=10, 118 core_radius_pd=.2, core_radius_pd_n=9,118 radius_core_pd=.2, radius_core_pd_n=9, 119 119 theta_pd=10, theta_pd_n=5, 120 120 ) -
sasmodels/models/hollow_rectangular_prism.c
rdeb7ee0 ra807206 1 double form_volume(double a_side, double b2a_ratio, double c2a_ratio, double thickness);2 double Iq(double q, double sld, double solvent_sld, double a_side,1 double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness); 2 double Iq(double q, double sld, double solvent_sld, double length_a, 3 3 double b2a_ratio, double c2a_ratio, double thickness); 4 4 double Iqxy(double qx, double qy, double sld, double solvent_sld, 5 double a_side, double b2a_ratio, double c2a_ratio, double thickness);5 double length_a, double b2a_ratio, double c2a_ratio, double thickness); 6 6 7 double form_volume(double a_side, double b2a_ratio, double c2a_ratio, double thickness)7 double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness) 8 8 { 9 double b_side = a_side* b2a_ratio;10 double c_side = a_side* c2a_ratio;11 double a_core = a_side- 2.0*thickness;9 double b_side = length_a * b2a_ratio; 10 double c_side = length_a * c2a_ratio; 11 double a_core = length_a - 2.0*thickness; 12 12 double b_core = b_side - 2.0*thickness; 13 13 double c_core = c_side - 2.0*thickness; 14 14 double vol_core = a_core * b_core * c_core; 15 double vol_total = a_side* b_side * c_side;15 double vol_total = length_a * b_side * c_side; 16 16 double vol_shell = vol_total - vol_core; 17 17 return vol_shell; … … 21 21 double sld, 22 22 double solvent_sld, 23 double a_side,23 double length_a, 24 24 double b2a_ratio, 25 25 double c2a_ratio, … … 28 28 double termA1, termA2, termB1, termB2, termC1, termC2; 29 29 30 double b_side = a_side* b2a_ratio;31 double c_side = a_side* c2a_ratio;32 double a_half = 0.5 * a_side;30 double b_side = length_a * b2a_ratio; 31 double c_side = length_a * c2a_ratio; 32 double a_half = 0.5 * length_a; 33 33 double b_half = 0.5 * b_side; 34 34 double c_half = 0.5 * c_side; … … 73 73 if (fabs(arg) > 1.e-16) {termB2 = sin(arg)/arg;} else {termB2 = 1.0;} 74 74 75 double AP1 = ( a_side*b_side*c_side) * termA1 * termB1 * termC1;75 double AP1 = (length_a*b_side*c_side) * termA1 * termB1 * termC1; 76 76 double AP2 = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness) * termA2 * termB2 * termC2; 77 77 double AP = AP1 - AP2; … … 105 105 double sld, 106 106 double solvent_sld, 107 double a_side,107 double length_a, 108 108 double b2a_ratio, 109 109 double c2a_ratio, … … 111 111 { 112 112 double q = sqrt(qx*qx + qy*qy); 113 double intensity = Iq(q, sld, solvent_sld, a_side, b2a_ratio, c2a_ratio, thickness);113 double intensity = Iq(q, sld, solvent_sld, length_a, b2a_ratio, c2a_ratio, thickness); 114 114 return intensity; 115 115 } -
sasmodels/models/hollow_rectangular_prism.py
r40a87fa ra807206 105 105 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 106 106 "Solvent scattering length density"], 107 [" a_side", "Ang", 35, [0, inf], "volume",107 ["length_a", "Ang", 35, [0, inf], "volume", 108 108 "Shorter side of the parallelepiped"], 109 109 ["b2a_ratio", "Ang", 1, [0, inf], "volume", … … 117 117 source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 118 118 119 def ER( a_side, b2a_ratio, c2a_ratio, thickness):119 def ER(length_a, b2a_ratio, c2a_ratio, thickness): 120 120 """ 121 121 Return equivalent radius (ER) 122 122 thickness parameter not used 123 123 """ 124 b_side = a_side* b2a_ratio125 c_side = a_side* c2a_ratio124 b_side = length_a * b2a_ratio 125 c_side = length_a * c2a_ratio 126 126 127 127 # surface average radius (rough approximation) 128 surf_rad = sqrt( a_side* b_side / pi)128 surf_rad = sqrt(length_a * b_side / pi) 129 129 130 130 ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 131 131 return 0.5 * (ddd) ** (1. / 3.) 132 132 133 def VR( a_side, b2a_ratio, c2a_ratio, thickness):133 def VR(length_a, b2a_ratio, c2a_ratio, thickness): 134 134 """ 135 135 Return shell volume and total volume 136 136 """ 137 b_side = a_side* b2a_ratio138 c_side = a_side* c2a_ratio139 a_core = a_side- 2.0*thickness137 b_side = length_a * b2a_ratio 138 c_side = length_a * c2a_ratio 139 a_core = length_a - 2.0*thickness 140 140 b_core = b_side - 2.0*thickness 141 141 c_core = c_side - 2.0*thickness 142 142 vol_core = a_core * b_core * c_core 143 vol_total = a_side* b_side * c_side143 vol_total = length_a * b_side * c_side 144 144 vol_shell = vol_total - vol_core 145 145 return vol_total, vol_shell … … 149 149 demo = dict(scale=1, background=0, 150 150 sld=6.3e-6, sld_solvent=1.0e-6, 151 a_side=35, b2a_ratio=1, c2a_ratio=1, thickness=1,152 a_side_pd=0.1, a_side_pd_n=10,151 length_a=35, b2a_ratio=1, c2a_ratio=1, thickness=1, 152 length_a_pd=0.1, length_a_pd_n=10, 153 153 b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, 154 154 c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) -
sasmodels/models/hollow_rectangular_prism_thin_walls.c
r3d8283b ra807206 1 double form_volume(double a_side, double b2a_ratio, double c2a_ratio);2 double Iq(double q, double sld, double solvent_sld, double a_side,1 double form_volume(double length_a, double b2a_ratio, double c2a_ratio); 2 double Iq(double q, double sld, double solvent_sld, double length_a, 3 3 double b2a_ratio, double c2a_ratio); 4 4 double Iqxy(double qx, double qy, double sld, double solvent_sld, 5 double a_side, double b2a_ratio, double c2a_ratio);5 double length_a, double b2a_ratio, double c2a_ratio); 6 6 7 double form_volume(double a_side, double b2a_ratio, double c2a_ratio)7 double form_volume(double length_a, double b2a_ratio, double c2a_ratio) 8 8 { 9 double b_side = a_side* b2a_ratio;10 double c_side = a_side* c2a_ratio;11 double vol_shell = 2.0 * ( a_side*b_side + a_side*c_side + b_side*c_side);9 double b_side = length_a * b2a_ratio; 10 double c_side = length_a * c2a_ratio; 11 double vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side); 12 12 return vol_shell; 13 13 } … … 16 16 double sld, 17 17 double solvent_sld, 18 double a_side,18 double length_a, 19 19 double b2a_ratio, 20 20 double c2a_ratio) 21 21 { 22 double b_side = a_side* b2a_ratio;23 double c_side = a_side* c2a_ratio;24 double a_half = 0.5 * a_side;22 double b_side = length_a * b2a_ratio; 23 double c_side = length_a * c2a_ratio; 24 double a_half = 0.5 * length_a; 25 25 double b_half = 0.5 * b_side; 26 26 double c_half = 0.5 * c_side; … … 88 88 double sld, 89 89 double solvent_sld, 90 double a_side,90 double length_a, 91 91 double b2a_ratio, 92 92 double c2a_ratio) 93 93 { 94 94 double q = sqrt(qx*qx + qy*qy); 95 double intensity = Iq(q, sld, solvent_sld, a_side, b2a_ratio, c2a_ratio);95 double intensity = Iq(q, sld, solvent_sld, length_a, b2a_ratio, c2a_ratio); 96 96 return intensity; 97 97 } -
sasmodels/models/hollow_rectangular_prism_thin_walls.py
r42356c8 ra807206 91 91 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 92 92 "Solvent scattering length density"], 93 [" a_side", "Ang", 35, [0, inf], "volume",93 ["length_a", "Ang", 35, [0, inf], "volume", 94 94 "Shorter side of the parallelepiped"], 95 95 ["b2a_ratio", "Ang", 1, [0, inf], "volume", … … 101 101 source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] 102 102 103 def ER( a_side, b2a_ratio, c2a_ratio):103 def ER(length_a, b2a_ratio, c2a_ratio): 104 104 """ 105 105 Return equivalent radius (ER) 106 106 """ 107 b_side = a_side* b2a_ratio108 c_side = a_side* c2a_ratio107 b_side = length_a * b2a_ratio 108 c_side = length_a * c2a_ratio 109 109 110 110 # surface average radius (rough approximation) 111 surf_rad = sqrt( a_side* b_side / pi)111 surf_rad = sqrt(length_a * b_side / pi) 112 112 113 113 ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 114 114 return 0.5 * (ddd) ** (1. / 3.) 115 115 116 def VR( a_side, b2a_ratio, c2a_ratio):116 def VR(length_a, b2a_ratio, c2a_ratio): 117 117 """ 118 118 Return shell volume and total volume 119 119 """ 120 b_side = a_side* b2a_ratio121 c_side = a_side* c2a_ratio122 vol_total = a_side* b_side * c_side123 vol_shell = 2.0 * ( a_side*b_side + a_side*c_side + b_side*c_side)120 b_side = length_a * b2a_ratio 121 c_side = length_a * c2a_ratio 122 vol_total = length_a * b_side * c_side 123 vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side) 124 124 return vol_shell, vol_total 125 125 … … 128 128 demo = dict(scale=1, background=0, 129 129 sld=6.3e-6, sld_solvent=1.0e-6, 130 a_side=35, b2a_ratio=1, c2a_ratio=1,131 a_side_pd=0.1, a_side_pd_n=10,130 length_a=35, b2a_ratio=1, c2a_ratio=1, 131 length_a_pd=0.1, length_a_pd_n=10, 132 132 b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, 133 133 c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) -
sasmodels/models/lamellar_hg.py
r40a87fa ra807206 25 25 \right\rbrace^2 26 26 27 where $\delta_T$ is * tail_length*, $\delta_H$ is *head_length*,27 where $\delta_T$ is *length_tail*, $\delta_H$ is *length_head*, 28 28 $\Delta\rho_H$ is the head contrast (*sld_head* $-$ *sld_solvent*), 29 29 and $\Delta\rho_T$ is tail contrast (*sld* $-$ *sld_solvent*). … … 67 67 # pylint: disable=bad-whitespace, line-too-long 68 68 # ["name", "units", default, [lower, upper], "type","description"], 69 parameters = [[" tail_length", "Ang", 15, [0, inf], "volume", "Tail thickness ( total = H+T+T+H)"],70 [" head_length", "Ang", 10, [0, inf], "volume", "Head thickness"],69 parameters = [["length_tail", "Ang", 15, [0, inf], "volume", "Tail thickness ( total = H+T+T+H)"], 70 ["length_head", "Ang", 10, [0, inf], "volume", "Head thickness"], 71 71 ["sld", "1e-6/Ang^2", 0.4, [-inf,inf], "sld", "Tail scattering length density"], 72 72 ["sld_head", "1e-6/Ang^2", 3.0, [-inf,inf], "sld", "Head scattering length density"], … … 84 84 const double drh = sld_head - sld_solvent; 85 85 const double drt = sld - sld_solvent; //correction 13FEB06 by L.Porcar 86 const double qT = q* tail_length;86 const double qT = q*length_tail; 87 87 double Pq, inten; 88 Pq = drh*(sin(q*( head_length+tail_length))-sin(qT)) + drt*sin(qT);88 Pq = drh*(sin(q*(length_head+length_tail))-sin(qT)) + drt*sin(qT); 89 89 Pq *= Pq; 90 90 Pq *= 4.0/(qsq); … … 93 93 94 94 // normalize by the bilayer thickness 95 inten /= 2.0*( head_length+tail_length);95 inten /= 2.0*(length_head+length_tail); 96 96 97 97 return inten; … … 102 102 103 103 demo = dict(scale=1, background=0, 104 tail_length=15, head_length=10,104 length_tail=15, length_head=10, 105 105 sld=0.4, sld_head=3.0, sld_solvent=6.0, 106 tail_length_pd=0.2, tail_length_pd_n=40,107 head_length_pd=0.01, head_length_pd_n=40)106 length_tail_pd=0.2, length_tail_pd_n=40, 107 length_head_pd=0.01, length_head_pd_n=40) 108 108 109 109 # 110 110 tests = [ 111 [{'scale': 1.0, 'background': 0.0, ' tail_length': 15.0, 'head_length': 10.0,111 [{'scale': 1.0, 'background': 0.0, 'length_tail': 15.0, 'length_head': 10.0, 112 112 'sld': 0.4, 'sld_head': 3.0, 'sld_solvent': 6.0}, 113 113 [0.001], [653143.9209]], -
sasmodels/models/lamellar_hg_stack_caille.c
r0bef47b ra807206 4 4 5 5 double Iq(double qval, 6 double tail_length,7 double head_length,6 double length_tail, 7 double length_head, 8 8 double Nlayers, 9 9 double dd, … … 14 14 15 15 double Iq(double qval, 16 double tail_length,17 double head_length,16 double length_tail, 17 double length_head, 18 18 double Nlayers, 19 19 double dd, … … 34 34 NN = trunc(Nlayers); //be sure that NN is an integer 35 35 36 Pq = (head_sld-solvent_sld)*(sin(qval*( head_length+tail_length))-sin(qval*tail_length)) +37 (tail_sld-solvent_sld)*sin(qval* tail_length);36 Pq = (head_sld-solvent_sld)*(sin(qval*(length_head+length_tail))-sin(qval*length_tail)) + 37 (tail_sld-solvent_sld)*sin(qval*length_tail); 38 38 Pq *= Pq; 39 39 Pq *= 4.0/(qval*qval); -
sasmodels/models/lamellar_hg_stack_caille.py
r0bef47b ra807206 42 42 43 43 44 $\delta_T$ is the tail length (or * tail_length*), $\delta_H$ is the head45 thickness (or * head_length*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent),44 $\delta_T$ is the tail length (or *length_tail*), $\delta_H$ is the head 45 thickness (or *length_head*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent), 46 46 and $\Delta\rho_T$ is SLD(tail) - SLD(headgroup). Here $d$ is (repeat) spacing, 47 47 $K$ is smectic bending elasticity, $B$ is compression modulus, and $N$ is the … … 94 94 # [ "name", "units", default, [lower, upper], "type", 95 95 # "description" ], 96 [" tail_length", "Ang", 10, [0, inf], "volume",96 ["length_tail", "Ang", 10, [0, inf], "volume", 97 97 "Tail thickness"], 98 [" head_length", "Ang", 2, [0, inf], "volume",98 ["length_head", "Ang", 2, [0, inf], "volume", 99 99 "head thickness"], 100 100 ["Nlayers", "", 30, [0, inf], "", … … 126 126 scale=1, background=0, 127 127 Nlayers=20, spacing=200., Caille_parameter=0.05, 128 tail_length=15, head_length=10,128 length_tail=15, length_head=10, 129 129 #sld=-1, sld_head=4.0, sld_solvent=6.0, 130 130 sld=-1, sld_head=4.1, sld_solvent=6.0, 131 tail_length_pd=0.1, tail_length_pd_n=20,132 head_length_pd=0.05, head_length_pd_n=30,131 length_tail_pd=0.1, length_tail_pd_n=20, 132 length_head_pd=0.05, length_head_pd_n=30, 133 133 spacing_pd=0.2, spacing_pd_n=40, 134 134 ) 135 135 136 136 # 137 tests = [[{'scale': 1.0, 'background': 0.0, ' tail_length': 10.0, 'head_length': 2.0,137 tests = [[{'scale': 1.0, 'background': 0.0, 'length_tail': 10.0, 'length_head': 2.0, 138 138 'Nlayers': 30.0, 'spacing': 40., 'Caille_parameter': 0.001, 'sld': 0.4, 139 'sld_head': 2.0, 'sld_solvent': 6.0, ' tail_length_pd': 0.0,140 ' head_length_pd': 0.0, 'spacing_pd': 0.0}, [0.001], [6838238.571488]]]139 'sld_head': 2.0, 'sld_solvent': 6.0, 'length_tail_pd': 0.0, 140 'length_head_pd': 0.0, 'spacing_pd': 0.0}, [0.001], [6838238.571488]]] 141 141 # ADDED by: RKH ON: 18Mar2016 converted from sasview previously, now renaming everything & sorting the docs -
sasmodels/models/mass_fractal.c
r2c74c11 ra807206 3 3 double Iq(double q, 4 4 double radius, 5 double mass_dim,5 double fractal_dim_mass, 6 6 double cutoff_length); 7 7 8 8 static double _mass_fractal_kernel(double q, 9 9 double radius, 10 double mass_dim,10 double fractal_dim_mass, 11 11 double cutoff_length) 12 12 { 13 13 // Actively check the argument. 14 if ( mass_dim<= 1.0){14 if (fractal_dim_mass <= 1.0){ 15 15 return 0.0; 16 16 } … … 21 21 22 22 //calculate S(q) 23 double mmo = mass_dim-1.0;23 double mmo = fractal_dim_mass-1.0; 24 24 double sq = sas_gamma(mmo)*sin((mmo)*atan(q*cutoff_length)); 25 25 sq *= pow(cutoff_length, mmo); … … 39 39 double Iq(double q, 40 40 double radius, 41 double mass_dim,41 double fractal_dim_mass, 42 42 double cutoff_length) 43 43 { 44 44 return _mass_fractal_kernel(q, 45 45 radius, 46 mass_dim,46 fractal_dim_mass, 47 47 cutoff_length); 48 48 } -
sasmodels/models/mass_fractal.py
rec45c4f ra807206 68 68 where delta = sldParticle -sldSolv. 69 69 radius = Particle radius 70 mass_dim= Mass fractal dimension70 fractal_dim_mass = Mass fractal dimension 71 71 cutoff_length = Cut-off length 72 72 background = background 73 73 Ref.:Mildner, Hall,J Phys D Appl Phys(1986), 9, 1535-1545 74 Note I: This model is valid for 1< mass_dim<6.74 Note I: This model is valid for 1<fractal_dim_mass<6. 75 75 Note II: This model is not in absolute scale. 76 76 """ … … 80 80 # ["name", "units", default, [lower, upper], "type","description"], 81 81 parameters = [["radius", "Ang", 10.0, [0.0, inf], "", "Particle radius"], 82 [" mass_dim", "", 1.9, [1.0, 6.0], "", "Mass fractal dimension"],82 ["fractal_dim_mass", "", 1.9, [1.0, 6.0], "", "Mass fractal dimension"], 83 83 ["cutoff_length", "Ang", 100.0, [0.0, inf], "", "Cut-off length"], 84 84 ] … … 89 89 demo = dict(scale=1, background=0, 90 90 radius=10.0, 91 mass_dim=1.9,91 fractal_dim_mass=1.9, 92 92 cutoff_length=100.0) 93 93 … … 96 96 # Accuracy tests based on content in test/utest_other_models.py 97 97 [{'radius': 10.0, 98 ' mass_dim': 1.9,98 'fractal_dim_mass': 1.9, 99 99 'cutoff_length': 100.0, 100 100 }, 0.05, 279.59422], … … 102 102 # Additional tests with larger range of parameters 103 103 [{'radius': 2.0, 104 ' mass_dim': 3.3,104 'fractal_dim_mass': 3.3, 105 105 'cutoff_length': 1.0, 106 106 }, 0.5, 1.29116774904], 107 107 108 108 [{'radius': 1.0, 109 ' mass_dim': 1.3,109 'fractal_dim_mass': 1.3, 110 110 'cutoff_length': 1.0, 111 111 'background': 0.8, … … 113 113 114 114 [{'radius': 1.0, 115 ' mass_dim': 2.3,115 'fractal_dim_mass': 2.3, 116 116 'cutoff_length': 1.0, 117 117 'scale': 10.0, -
sasmodels/models/mass_surface_fractal.c
r2c74c11 ra807206 2 2 3 3 double Iq(double q, 4 double mass_dim,5 double surface_dim,6 double cluster_rg,4 double fractal_dim_mass, 5 double fractal_dim_surf, 6 double rg_cluster, 7 7 double primary_rg); 8 8 9 9 static double _mass_surface_fractal_kernel(double q, 10 double mass_dim,11 double surface_dim,12 double cluster_rg,10 double fractal_dim_mass, 11 double fractal_dim_surf, 12 double rg_cluster, 13 13 double primary_rg) 14 14 { 15 15 //computation 16 double tot_dim = 6.0 - surface_dim - mass_dim;17 mass_dim/= 2.0;16 double tot_dim = 6.0 - fractal_dim_surf - fractal_dim_mass; 17 fractal_dim_mass /= 2.0; 18 18 tot_dim /= 2.0; 19 19 20 double rc_norm = cluster_rg * cluster_rg / (3.0 * mass_dim);20 double rc_norm = rg_cluster * rg_cluster / (3.0 * fractal_dim_mass); 21 21 double rp_norm = primary_rg * primary_rg / (3.0 * tot_dim); 22 22 … … 25 25 double x_val2 = 1.0 + q * q * rp_norm; 26 26 27 double inv_form = pow(x_val1, mass_dim) * pow(x_val2, tot_dim);27 double inv_form = pow(x_val1, fractal_dim_mass) * pow(x_val2, tot_dim); 28 28 29 29 //another singular … … 41 41 42 42 double Iq(double q, 43 double mass_dim,44 double surface_dim,45 double cluster_rg,43 double fractal_dim_mass, 44 double fractal_dim_surf, 45 double rg_cluster, 46 46 double primary_rg) 47 47 { 48 48 return _mass_surface_fractal_kernel(q, 49 mass_dim,50 surface_dim,51 cluster_rg,49 fractal_dim_mass, 50 fractal_dim_surf, 51 rg_cluster, 52 52 primary_rg); 53 53 } -
sasmodels/models/mass_surface_fractal.py
rec45c4f ra807206 66 66 b = rg^2/(3*(6-Ds-Dm)/2) 67 67 scale = scale factor * N*Volume^2*contrast^2 68 mass_dim= Dm (mass fractal dimension)69 surface_dim= Ds70 cluster_rg= Rg68 fractal_dim_mass = Dm (mass fractal dimension) 69 fractal_dim_surf = Ds 70 rg_cluster = Rg 71 71 primary_rg = rg 72 72 background = background … … 79 79 # pylint: disable=bad-whitespace, line-too-long 80 80 # ["name", "units", default, [lower, upper], "type","description"], 81 parameters = [[" mass_dim", "", 1.8, [1e-16, 6.0], "",81 parameters = [["fractal_dim_mass", "", 1.8, [1e-16, 6.0], "", 82 82 "Mass fractal dimension"], 83 [" surface_dim", "", 2.3, [1e-16, 6.0], "",83 ["fractal_dim_surf", "", 2.3, [1e-16, 6.0], "", 84 84 "Surface fractal dimension"], 85 [" cluster_rg", "Ang", 86.7, [0.0, inf], "",85 ["rg_cluster", "Ang", 86.7, [0.0, inf], "", 86 86 "Cluster radius of gyration"], 87 87 ["primary_rg", "Ang", 4000., [0.0, inf], "", … … 93 93 94 94 demo = dict(scale=1, background=0, 95 mass_dim=1.8,96 surface_dim=2.3,97 cluster_rg=86.7,95 fractal_dim_mass=1.8, 96 fractal_dim_surf=2.3, 97 rg_cluster=86.7, 98 98 primary_rg=4000.0) 99 99 … … 101 101 102 102 # Accuracy tests based on content in test/utest_other_models.py 103 [{' mass_dim': 1.8,104 ' surface_dim': 2.3,105 ' cluster_rg': 86.7,103 [{'fractal_dim_mass': 1.8, 104 'fractal_dim_surf': 2.3, 105 'rg_cluster': 86.7, 106 106 'primary_rg': 4000.0, 107 107 'background': 0.0, … … 109 109 110 110 # Additional tests with larger range of parameters 111 [{' mass_dim': 3.3,112 ' surface_dim': 1.0,113 ' cluster_rg': 90.0,111 [{'fractal_dim_mass': 3.3, 112 'fractal_dim_surf': 1.0, 113 'rg_cluster': 90.0, 114 114 'primary_rg': 4000.0, 115 115 }, 0.001, 0.18562699016], 116 116 117 [{' mass_dim': 1.3,118 ' surface_dim': 1.0,119 ' cluster_rg': 90.0,117 [{'fractal_dim_mass': 1.3, 118 'fractal_dim_surf': 1.0, 119 'rg_cluster': 90.0, 120 120 'primary_rg': 2000.0, 121 121 'background': 0.8, 122 122 }, 0.001, 1.16539753641], 123 123 124 [{' mass_dim': 2.3,125 ' surface_dim': 1.0,126 ' cluster_rg': 90.0,124 [{'fractal_dim_mass': 2.3, 125 'fractal_dim_surf': 1.0, 126 'rg_cluster': 90.0, 127 127 'primary_rg': 1000.0, 128 128 'scale': 10.0, -
sasmodels/models/mono_gauss_coil.py
r40a87fa ra807206 71 71 parameters = [ 72 72 ["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 73 ["r adius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"],73 ["rg", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 74 74 ] 75 75 # pylint: enable=bad-whitespace, line-too-long 76 76 77 77 # NB: Scale and Background are implicit parameters on every model 78 def Iq(q, i_zero, r adius_gyration):78 def Iq(q, i_zero, rg): 79 79 # pylint: disable = missing-docstring 80 z = (q * r adius_gyration)**280 z = (q * rg)**2 81 81 82 82 with errstate(invalid='ignore'): … … 86 86 Iq.vectorized = True # Iq accepts an array of q values 87 87 88 demo = dict(scale=1.0, i_zero=70.0, r adius_gyration=75.0, background=0.0)88 demo = dict(scale=1.0, i_zero=70.0, rg=75.0, background=0.0) 89 89 90 90 # these unit test values taken from SasView 3.1.2 91 91 tests = [ 92 [{'scale': 1.0, 'i_zero': 70.0, 'r adius_gyration': 75.0, 'background': 0.0},92 [{'scale': 1.0, 'i_zero': 70.0, 'rg': 75.0, 'background': 0.0}, 93 93 [0.0106939, 0.469418], [57.1241, 0.112859]], 94 94 ] -
sasmodels/models/parallelepiped.c
rdeb7ee0 ra807206 1 double form_volume(double a_side, double b_side, double c_side);2 double Iq(double q, double sld, double solvent_sld, double a_side, double b_side, double c_side);1 double form_volume(double length_a, double length_b, double length_c); 2 double Iq(double q, double sld, double solvent_sld, double length_a, double length_b, double length_c); 3 3 double Iqxy(double qx, double qy, double sld, double solvent_sld, 4 double a_side, double b_side, double c_side, double theta, double phi, double psi);4 double length_a, double length_b, double length_c, double theta, double phi, double psi); 5 5 6 6 // From Igor library … … 32 32 33 33 34 double form_volume(double a_side, double b_side, double c_side)34 double form_volume(double length_a, double length_b, double length_c) 35 35 { 36 return a_side * b_side * c_side;36 return length_a * length_b * length_c; 37 37 } 38 38 … … 41 41 double sld, 42 42 double solvent_sld, 43 double a_side,44 double b_side,45 double c_side)43 double length_a, 44 double length_b, 45 double length_c) 46 46 { 47 47 double tmp1, tmp2; 48 48 49 double mu = q * b_side;49 double mu = q * length_b; 50 50 51 51 // Scale sides by B 52 double a_scaled = a_side / b_side;53 double c_scaled = c_side / b_side;52 double a_scaled = length_a / length_b; 53 double c_scaled = length_c / length_b; 54 54 55 55 //Order of integration … … 102 102 } 103 103 104 const double vd = (sld-solvent_sld) * form_volume( a_side, b_side, c_side);104 const double vd = (sld-solvent_sld) * form_volume(length_a, length_b, length_c); 105 105 106 106 // convert from [1e-12 A-1] to [cm-1] and 0.5 factor for outer integral … … 113 113 double sld, 114 114 double solvent_sld, 115 double a_side,116 double b_side,117 double c_side,115 double length_a, 116 double length_b, 117 double length_c, 118 118 double theta, 119 119 double phi, … … 161 161 162 162 // Call the IGOR library function to get the kernel 163 double form = _pkernel( q* a_side, q*b_side, q*c_side, cos_val_a, cos_val_b, cos_val_c);163 double form = _pkernel( q*length_a, q*length_b, q*length_c, cos_val_a, cos_val_b, cos_val_c); 164 164 165 165 // Multiply by contrast^2 166 const double vd = (sld - solvent_sld) * form_volume( a_side, b_side, c_side);166 const double vd = (sld - solvent_sld) * form_volume(length_a, length_b, length_c); 167 167 return 1.0e-4 * vd * vd * form; 168 168 } -
sasmodels/models/parallelepiped.py
r9a4811a ra807206 190 190 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 191 191 "Solvent scattering length density"], 192 [" a_side", "Ang", 35, [0, inf], "volume",192 ["length_a", "Ang", 35, [0, inf], "volume", 193 193 "Shorter side of the parallelepiped"], 194 [" b_side", "Ang", 75, [0, inf], "volume",194 ["length_b", "Ang", 75, [0, inf], "volume", 195 195 "Second side of the parallelepiped"], 196 [" c_side", "Ang", 400, [0, inf], "volume",196 ["length_c", "Ang", 400, [0, inf], "volume", 197 197 "Larger side of the parallelepiped"], 198 198 ["theta", "degrees", 60, [-inf, inf], "orientation", … … 206 206 source = ["lib/gauss76.c", "parallelepiped.c"] 207 207 208 def ER( a_side, b_side, c_side):208 def ER(length_a, length_b, length_c): 209 209 """ 210 210 Return effective radius (ER) for P(q)*S(q) … … 212 212 213 213 # surface average radius (rough approximation) 214 surf_rad = sqrt( a_side * b_side/ pi)215 216 ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side+ pi * surf_rad))214 surf_rad = sqrt(length_a * length_b / pi) 215 216 ddd = 0.75 * surf_rad * (2 * surf_rad * length_c + (length_c + surf_rad) * (length_c + pi * surf_rad)) 217 217 return 0.5 * (ddd) ** (1. / 3.) 218 218 … … 222 222 demo = dict(scale=1, background=0, 223 223 sld=6.3e-6, sld_solvent=1.0e-6, 224 a_side=35, b_side=75, c_side=400,224 length_a=35, length_b=75, length_c=400, 225 225 theta=45, phi=30, psi=15, 226 a_side_pd=0.1, a_side_pd_n=10,227 b_side_pd=0.1, b_side_pd_n=1,228 c_side_pd=0.1, c_side_pd_n=1,226 length_a_pd=0.1, length_a_pd_n=10, 227 length_b_pd=0.1, length_b_pd_n=1, 228 length_c_pd=0.1, length_c_pd_n=1, 229 229 theta_pd=10, theta_pd_n=1, 230 230 phi_pd=10, phi_pd_n=1, -
sasmodels/models/pearl_necklace.c
r2f5c6d4 ra807206 1 double _pearl_necklace_kernel(double q, double radius, double edge_sep aration,1 double _pearl_necklace_kernel(double q, double radius, double edge_sep, 2 2 double thick_string, double num_pearls, double sld_pearl, 3 3 double sld_string, double sld_solv); 4 double form_volume(double radius, double edge_sep aration,5 double string_thickness, double number_of_pearls);4 double form_volume(double radius, double edge_sep, 5 double thick_string, double num_pearls); 6 6 7 double Iq(double q, double radius, double edge_sep aration,8 double string_thickness, double number_of_pearls, double sld,7 double Iq(double q, double radius, double edge_sep, 8 double thick_string, double num_pearls, double sld, 9 9 double string_sld, double solvent_sld); 10 10 11 #define INVALID(v) (v. string_thickness >= v.radius || v.number_of_pearls <= 0)11 #define INVALID(v) (v.thick_string >= v.radius || v.num_pearls <= 0) 12 12 13 13 // From Igor library 14 double _pearl_necklace_kernel(double q, double radius, double edge_sep aration, double thick_string,14 double _pearl_necklace_kernel(double q, double radius, double edge_sep, double thick_string, 15 15 double num_pearls, double sld_pearl, double sld_string, double sld_solv) 16 16 { … … 27 27 28 28 // center to center distance between the neighboring pearls 29 double A_s = edge_sep aration+ 2.0 * radius;29 double A_s = edge_sep + 2.0 * radius; 30 30 31 31 // Repeated Calculations … … 33 33 double oneminussinc = 1 - sincasq; 34 34 double q_r = q * radius; 35 double q_edge = q * edge_sep aration;35 double q_edge = q * edge_sep; 36 36 37 37 // each volume 38 double string_vol = edge_sep aration* pi * thick_string * thick_string / 4.0;38 double string_vol = edge_sep * pi * thick_string * thick_string / 4.0; 39 39 double pearl_vol = 4.0 / 3.0 * pi * radius * radius * radius; 40 40 … … 105 105 } 106 106 107 double form_volume(double radius, double edge_sep aration,108 double string_thickness, double number_of_pearls)107 double form_volume(double radius, double edge_sep, 108 double thick_string, double num_pearls) 109 109 { 110 110 double total_vol; 111 111 112 112 double pi = 4.0*atan(1.0); 113 double number_of_strings = num ber_of_pearls - 1.0;113 double number_of_strings = num_pearls - 1.0; 114 114 115 double string_vol = edge_sep aration * pi * string_thickness * string_thickness/ 4.0;115 double string_vol = edge_sep * pi * thick_string * thick_string / 4.0; 116 116 double pearl_vol = 4.0 / 3.0 * pi * radius * radius * radius; 117 117 118 118 total_vol = number_of_strings * string_vol; 119 total_vol += num ber_of_pearls * pearl_vol;119 total_vol += num_pearls * pearl_vol; 120 120 121 121 return(total_vol); 122 122 } 123 123 124 double Iq(double q, double radius, double edge_sep aration,125 double string_thickness, double number_of_pearls, double sld,124 double Iq(double q, double radius, double edge_sep, 125 double thick_string, double num_pearls, double sld, 126 126 double string_sld, double solvent_sld) 127 127 { 128 128 double value, tot_vol; 129 129 130 value = _pearl_necklace_kernel(q, radius, edge_sep aration, string_thickness,131 num ber_of_pearls, sld, string_sld, solvent_sld);132 tot_vol = form_volume(radius, edge_sep aration, string_thickness, number_of_pearls);130 value = _pearl_necklace_kernel(q, radius, edge_sep, thick_string, 131 num_pearls, sld, string_sld, solvent_sld); 132 tot_vol = form_volume(radius, edge_sep, thick_string, num_pearls); 133 133 134 134 return value*tot_vol; -
sasmodels/models/pearl_necklace.py
r42356c8 ra807206 46 46 pearl_necklace model are the following 47 47 48 NB: *num ber_of_pearls* must be an integer.48 NB: *num_pearls* must be an integer. 49 49 50 50 References … … 68 68 sld_string: the SLD of the strings 69 69 sld_solvent: the SLD of the solvent 70 num ber_of_pearls: number of the pearls70 num_pearls: number of the pearls 71 71 radius: the radius of a pearl 72 edge_sep aration: the length of string segment; surface to surface73 string_thickness: thickness (ie, diameter) of the string72 edge_sep: the length of string segment; surface to surface 73 thick_string: thickness (ie, diameter) of the string 74 74 """ 75 75 category = "shape:cylinder" … … 78 78 parameters = [["radius", "Ang", 80.0, [0, inf], "volume", 79 79 "Mean radius of the chained spheres"], 80 ["edge_sep aration", "Ang", 350.0, [0, inf], "volume",80 ["edge_sep", "Ang", 350.0, [0, inf], "volume", 81 81 "Mean separation of chained particles"], 82 [" string_thickness", "Ang", 2.5, [0, inf], "volume",82 ["thick_string", "Ang", 2.5, [0, inf], "volume", 83 83 "Thickness of the chain linkage"], 84 ["num ber_of_pearls", "none", 3, [0, inf], "volume",84 ["num_pearls", "none", 3, [0, inf], "volume", 85 85 "Number of pearls in the necklace (must be integer)"], 86 86 ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", … … 95 95 single = False # use double precision unless told otherwise 96 96 97 def volume(radius, edge_sep aration, string_thickness, number_of_pearls):97 def volume(radius, edge_sep, thick_string, num_pearls): 98 98 """ 99 99 Calculates the total particle volume of the necklace. 100 100 Redundant with form_volume. 101 101 """ 102 number_of_strings = num ber_of_pearls - 1.0103 string_vol = edge_sep aration * pi * pow((string_thickness/ 2.0), 2.0)102 number_of_strings = num_pearls - 1.0 103 string_vol = edge_sep * pi * pow((thick_string / 2.0), 2.0) 104 104 pearl_vol = 4.0 /3.0 * pi * pow(radius, 3.0) 105 105 total_vol = number_of_strings * string_vol 106 total_vol += num ber_of_pearls * pearl_vol106 total_vol += num_pearls * pearl_vol 107 107 return total_vol 108 108 109 def ER(radius, edge_sep aration, string_thickness, number_of_pearls):109 def ER(radius, edge_sep, thick_string, num_pearls): 110 110 """ 111 111 Calculation for effective radius. 112 112 """ 113 tot_vol = volume(radius, edge_sep aration, string_thickness, number_of_pearls)113 tot_vol = volume(radius, edge_sep, thick_string, num_pearls) 114 114 rad_out = pow((3.0*tot_vol/4.0/pi), 0.33333) 115 115 return rad_out 116 116 117 117 # parameters for demo 118 demo = dict(scale=1, background=0, radius=80.0, edge_sep aration=350.0,119 num ber_of_pearls=3, sld=1, sld_solvent=6.3, sld_string=1,120 string_thickness=2.5,118 demo = dict(scale=1, background=0, radius=80.0, edge_sep=350.0, 119 num_pearls=3, sld=1, sld_solvent=6.3, sld_string=1, 120 thick_string=2.5, 121 121 radius_pd=.2, radius_pd_n=5, 122 edge_sep aration_pd=25.0, edge_separation_pd_n=5,123 num ber_of_pearls_pd=0, number_of_pearls_pd_n=0,124 string_thickness_pd=0.2, string_thickness_pd_n=5,122 edge_sep_pd=25.0, edge_sep_pd_n=5, 123 num_pearls_pd=0, num_pearls_pd_n=0, 124 thick_string_pd=0.2, thick_string_pd_n=5, 125 125 ) 126 126 -
sasmodels/models/poly_gauss_coil.py
r40a87fa ra807206 74 74 parameters = [ 75 75 ["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 76 ["r adius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"],76 ["rg", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 77 77 ["polydispersity", "None", 2.0, [1.0, inf], "", "Polymer Mw/Mn"], 78 78 ] … … 80 80 81 81 # NB: Scale and Background are implicit parameters on every model 82 def Iq(q, i_zero, r adius_gyration, polydispersity):82 def Iq(q, i_zero, rg, polydispersity): 83 83 # pylint: disable = missing-docstring 84 84 u = polydispersity - 1.0 85 z = (q*r adius_gyration)**2 / (1.0 + 2.0*u)85 z = (q*rg)**2 / (1.0 + 2.0*u) 86 86 # need to trap the case of the polydispersity being 1 (ie, monodisperse!) 87 87 if polydispersity == 1.0: … … 97 97 demo = dict(scale=1.0, 98 98 i_zero=70.0, 99 r adius_gyration=75.0,99 rg=75.0, 100 100 polydispersity=2.0, 101 101 background=0.0) … … 103 103 # these unit test values taken from SasView 3.1.2 104 104 tests = [ 105 [{'scale': 1.0, 'i_zero': 70.0, 'r adius_gyration': 75.0,105 [{'scale': 1.0, 'i_zero': 70.0, 'rg': 75.0, 106 106 'polydispersity': 2.0, 'background': 0.0}, 107 107 [0.0106939, 0.469418], [57.6405, 0.169016]], -
sasmodels/models/polymer_micelle.c
r0bef47b ra807206 7 7 double corona_sld, 8 8 double radius_core, 9 double r adius_gyr,9 double rg, 10 10 double d_penetration, 11 11 double n_aggreg); … … 19 19 double corona_sld, 20 20 double radius_core, 21 double r adius_gyr,21 double rg, 22 22 double d_penetration, 23 23 double n_aggreg) … … 35 35 36 36 // Self-correlation term of the chains 37 const double qrg2 = q*r adius_gyr*q*radius_gyr;37 const double qrg2 = q*rg*q*rg; 38 38 const double debye_chain = (qrg2 == 0.0) ? 1.0 : 2.0*(expm1(-qrg2)+qrg2)/(qrg2*qrg2); 39 39 const double term2 = n_aggreg * beta_corona * beta_corona * debye_chain; … … 41 41 // Interference cross-term between core and chains 42 42 const double chain_ampl = (qrg2 == 0.0) ? 1.0 : -expm1(-qrg2)/qrg2; 43 const double bes_corona = sinc(q*(radius_core + d_penetration * r adius_gyr));43 const double bes_corona = sinc(q*(radius_core + d_penetration * rg)); 44 44 const double term3 = 2 * n_aggreg * n_aggreg * beta_core * beta_corona * 45 45 bes_core * chain_ampl * bes_corona; … … 70 70 double corona_sld, 71 71 double radius_core, 72 double r adius_gyr,72 double rg, 73 73 double d_penetration, 74 74 double n_aggreg) … … 82 82 corona_sld, 83 83 radius_core, 84 r adius_gyr,84 rg, 85 85 d_penetration, 86 86 n_aggreg); -
sasmodels/models/polymer_micelle.py
r0bef47b ra807206 45 45 ["sld_core", "1e-6/Ang^2", 0.34, [0.0, inf], "sld", "Core scattering length density"], 46 46 ["sld_corona", "1e-6/Ang^2", 0.8, [0.0, inf], "sld", "Corona scattering length density"], 47 ["radius_core", "Ang", 45.0, [0.0, inf], "", "Radius of core ( must be >> r adius_gyr)"],48 ["r adius_gyr", "Ang", 20.0, [0.0, inf], "", "Radius of gyration of chains in corona"],47 ["radius_core", "Ang", 45.0, [0.0, inf], "", "Radius of core ( must be >> rg )"], 48 ["rg", "Ang", 20.0, [0.0, inf], "", "Radius of gyration of chains in corona"], 49 49 ["d_penetration", "", 1.0, [-inf, inf], "", "Factor to mimic non-penetration of Gaussian chains"], 50 50 ["n_aggreg", "", 6.0, [-inf, inf], "", "Aggregation number of the micelle"], … … 64 64 sld_corona=0.8, 65 65 radius_core=45.0, 66 r adius_gyr=20.0,66 rg=20.0, 67 67 d_penetration=1.0, 68 68 n_aggreg=6.0) -
sasmodels/models/rectangular_prism.c
rdeb7ee0 ra807206 1 double form_volume(double a_side, double b2a_ratio, double c2a_ratio);2 double Iq(double q, double sld, double solvent_sld, double a_side,1 double form_volume(double length_a, double b2a_ratio, double c2a_ratio); 2 double Iq(double q, double sld, double solvent_sld, double length_a, 3 3 double b2a_ratio, double c2a_ratio); 4 4 double Iqxy(double qx, double qy, double sld, double solvent_sld, 5 double a_side, double b2a_ratio, double c2a_ratio);5 double length_a, double b2a_ratio, double c2a_ratio); 6 6 7 double form_volume(double a_side, double b2a_ratio, double c2a_ratio)7 double form_volume(double length_a, double b2a_ratio, double c2a_ratio) 8 8 { 9 return a_side * (a_side*b2a_ratio) * (a_side*c2a_ratio);9 return length_a * (length_a*b2a_ratio) * (length_a*c2a_ratio); 10 10 } 11 11 … … 13 13 double sld, 14 14 double solvent_sld, 15 double a_side,15 double length_a, 16 16 double b2a_ratio, 17 17 double c2a_ratio) … … 19 19 double termA, termB, termC; 20 20 21 double b_side = a_side* b2a_ratio;22 double c_side = a_side* c2a_ratio;23 double volume = a_side* b_side * c_side;24 double a_half = 0.5 * a_side;21 double b_side = length_a * b2a_ratio; 22 double c_side = length_a * c2a_ratio; 23 double volume = length_a * b_side * c_side; 24 double a_half = 0.5 * length_a; 25 25 double b_half = 0.5 * b_side; 26 26 double c_half = 0.5 * c_side; … … 92 92 double sld, 93 93 double solvent_sld, 94 double a_side,94 double length_a, 95 95 double b2a_ratio, 96 96 double c2a_ratio) 97 97 { 98 98 double q = sqrt(qx*qx + qy*qy); 99 double intensity = Iq(q, sld, solvent_sld, a_side, b2a_ratio, c2a_ratio);99 double intensity = Iq(q, sld, solvent_sld, length_a, b2a_ratio, c2a_ratio); 100 100 return intensity; 101 101 } -
sasmodels/models/rectangular_prism.py
r42356c8 ra807206 99 99 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 100 100 "Solvent scattering length density"], 101 [" a_side", "Ang", 35, [0, inf], "volume",101 ["length_a", "Ang", 35, [0, inf], "volume", 102 102 "Shorter side of the parallelepiped"], 103 103 ["b2a_ratio", "Ang", 1, [0, inf], "volume", … … 109 109 source = ["lib/gauss76.c", "rectangular_prism.c"] 110 110 111 def ER( a_side, b2a_ratio, c2a_ratio):111 def ER(length_a, b2a_ratio, c2a_ratio): 112 112 """ 113 113 Return equivalent radius (ER) 114 114 """ 115 b_side = a_side* b2a_ratio116 c_side = a_side* c2a_ratio115 b_side = length_a * b2a_ratio 116 c_side = length_a * c2a_ratio 117 117 118 118 # surface average radius (rough approximation) 119 surf_rad = sqrt( a_side* b_side / pi)119 surf_rad = sqrt(length_a * b_side / pi) 120 120 121 121 ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) … … 126 126 demo = dict(scale=1, background=0, 127 127 sld=6.3e-6, sld_solvent=1.0e-6, 128 a_side=35, b2a_ratio=1, c2a_ratio=1,129 a_side_pd=0.1, a_side_pd_n=10,128 length_a=35, b2a_ratio=1, c2a_ratio=1, 129 length_a_pd=0.1, length_a_pd_n=10, 130 130 b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, 131 131 c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) -
sasmodels/models/stacked_disks.c
r2c74c11 ra807206 1 double form_volume(double core_thick,2 double layer_thick,1 double form_volume(double thick_core, 2 double thick_layer, 3 3 double radius, 4 4 double n_stacking); 5 5 6 6 double Iq(double q, 7 double core_thick,8 double layer_thick,7 double thick_core, 8 double thick_layer, 9 9 double radius, 10 10 double n_stacking, 11 double sigma_d ,11 double sigma_dnn, 12 12 double core_sld, 13 13 double layer_sld, … … 21 21 double solvent_sld, 22 22 double halfheight, 23 double layer_thick,23 double thick_layer, 24 24 double zi, 25 double sigma_d ,25 double sigma_dnn, 26 26 double d, 27 27 double n_stacking) … … 38 38 39 39 const double sinarg1 = qq*halfheight*cos(zi); 40 const double sinarg2 = qq*(halfheight+ layer_thick)*cos(zi);40 const double sinarg2 = qq*(halfheight+thick_layer)*cos(zi); 41 41 42 42 const double be1 = sas_J1c(besarg1); … … 48 48 const double dr2 = (layer_sld-solvent_sld); 49 49 const double area = M_PI*radius*radius; 50 const double totald=2.0*( layer_thick+halfheight);50 const double totald=2.0*(thick_layer+halfheight); 51 51 52 52 const double t1 = area*(2.0*halfheight)*dr1*(si1)*(be1); … … 59 59 double sqq=0.0; 60 60 for(int kk=1;kk<n_stacking;kk+=1) { 61 double dexpt=qq*cos(zi)*qq*cos(zi)*d*d*sigma_d *sigma_d*kk/2.0;61 double dexpt=qq*cos(zi)*qq*cos(zi)*d*d*sigma_dnn*sigma_dnn*kk/2.0; 62 62 sqq=sqq+(n_stacking-kk)*cos(qq*cos(zi)*d*kk)*exp(-1.*dexpt); 63 63 } … … 74 74 static 75 75 double stacked_disks_kernel(double q, 76 double core_thick,77 double layer_thick,76 double thick_core, 77 double thick_layer, 78 78 double radius, 79 79 double n_stacking, 80 double sigma_d ,80 double sigma_dnn, 81 81 double core_sld, 82 82 double layer_sld, … … 88 88 double summ = 0.0; //initialize integral 89 89 90 double d=2.0* layer_thick+core_thick;91 double halfheight = core_thick/2.0;90 double d=2.0*thick_layer+thick_core; 91 double halfheight = thick_core/2.0; 92 92 93 93 for(int i=0;i<N_POINTS_76;i++) { … … 100 100 solvent_sld, 101 101 halfheight, 102 layer_thick,102 thick_layer, 103 103 zi, 104 sigma_d ,104 sigma_dnn, 105 105 d, 106 106 n_stacking); … … 117 117 118 118 static double stacked_disks_kernel_2d(double q, double q_x, double q_y, 119 double core_thick,120 double layer_thick,119 double thick_core, 120 double thick_layer, 121 121 double radius, 122 122 double n_stacking, 123 double sigma_d ,123 double sigma_dnn, 124 124 double core_sld, 125 125 double layer_sld, … … 154 154 155 155 // Call the IGOR library function to get the kernel 156 double d = 2 * layer_thick + core_thick;157 double halfheight = core_thick/2.0;156 double d = 2 * thick_layer + thick_core; 157 double halfheight = thick_core/2.0; 158 158 double answer = _kernel(q, 159 159 radius, … … 162 162 solvent_sld, 163 163 halfheight, 164 layer_thick,164 thick_layer, 165 165 alpha, 166 sigma_d ,166 sigma_dnn, 167 167 d, 168 168 n_stacking); … … 175 175 } 176 176 177 double form_volume(double core_thick,178 double layer_thick,177 double form_volume(double thick_core, 178 double thick_layer, 179 179 double radius, 180 180 double n_stacking){ 181 double d = 2 * layer_thick + core_thick;181 double d = 2 * thick_layer + thick_core; 182 182 return acos(-1.0) * radius * radius * d * n_stacking; 183 183 } 184 184 185 185 double Iq(double q, 186 double core_thick,187 double layer_thick,186 double thick_core, 187 double thick_layer, 188 188 double radius, 189 189 double n_stacking, 190 double sigma_d ,190 double sigma_dnn, 191 191 double core_sld, 192 192 double layer_sld, … … 194 194 { 195 195 return stacked_disks_kernel(q, 196 core_thick,197 layer_thick,196 thick_core, 197 thick_layer, 198 198 radius, 199 199 n_stacking, 200 sigma_d ,200 sigma_dnn, 201 201 core_sld, 202 202 layer_sld, -
sasmodels/models/stacked_disks.py
r40a87fa ra807206 54 54 \right]^2 \sin{\alpha}\ d\alpha 55 55 56 where $d$ = thickness of the layer (* layer_thick*),57 $2h$ = core thickness (* core_thick*), and $R$ = radius of the disc (*radius*).56 where $d$ = thickness of the layer (*thick_layer*), 57 $2h$ = core thickness (*thick_core*), and $R$ = radius of the disc (*radius*). 58 58 59 59 .. math:: 60 60 61 61 S(q) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})} 62 \exp\left[ -k(q\cos{\alpha})^2\sigma_D /2\right]62 \exp\left[ -k(q\cos{\alpha})^2\sigma_Dnn/2\right] 63 63 64 64 where $n$ is the total number of the disc stacked (*n_stacking*), 65 65 $D = 2(d+h)$ is the next neighbor center-to-center distance (d-spacing), 66 and $\sigma_D $ = the Gaussian standard deviation of the d-spacing (*sigma_d*).66 and $\sigma_Dnn$ = the Gaussian standard deviation of the d-spacing (*sigma_dnn*). 67 67 68 68 .. note:: 69 Each ass mebly in the stack is layer/core/layer, so the spacing of the69 Each assembly in the stack is layer/core/layer, so the spacing of the 70 70 cores is core plus two layers. The 2nd virial coefficient of the cylinder 71 71 is calculated based on the *radius* and *length* 72 = *n_stacking* * (* core_thick* + 2 * *layer_thick*)72 = *n_stacking* * (*thick_core* + 2 * *thick_layer*) 73 73 values, and used as the effective radius for $S(Q)$ when $P(Q) * S(Q)$ 74 74 is applied. … … 114 114 One layer of disk consists of a core, a top layer, and a bottom layer. 115 115 radius = the radius of the disk 116 core_thick= thickness of the core117 layer_thick= thickness of a layer116 thick_core = thickness of the core 117 thick_layer = thickness of a layer 118 118 sld_core = the SLD of the core 119 119 sld_layer = the SLD of the layers 120 120 n_stacking = the number of the disks 121 sigma_d = Gaussian STD of d-spacing121 sigma_dnn = Gaussian STD of d-spacing 122 122 sld_solvent = the SLD of the solvent 123 123 """ … … 127 127 # ["name", "units", default, [lower, upper], "type","description"], 128 128 parameters = [ 129 [" core_thick", "Ang", 10.0, [0, inf], "volume", "Thickness of the core disk"],130 [" layer_thick", "Ang", 10.0, [0, inf], "volume", "Thickness of layer each side of core"],129 ["thick_core", "Ang", 10.0, [0, inf], "volume", "Thickness of the core disk"], 130 ["thick_layer", "Ang", 10.0, [0, inf], "volume", "Thickness of layer each side of core"], 131 131 ["radius", "Ang", 15.0, [0, inf], "volume", "Radius of the stacked disk"], 132 132 ["n_stacking", "", 1.0, [0, inf], "volume", "Number of stacked layer/core/layer disks"], 133 ["sigma_d ", "Ang", 0, [0, inf], "", "GSD of disks sigma_d"],133 ["sigma_dnn", "Ang", 0, [0, inf], "", "Sigma of nearest neighbor spacing"], 134 134 ["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Core scattering length density"], 135 135 ["sld_layer", "1e-6/Ang^2", 0.0, [-inf, inf], "sld", "Layer scattering length density"], … … 144 144 demo = dict(background=0.001, 145 145 scale=0.01, 146 core_thick=10.0,147 layer_thick=10.0,146 thick_core=10.0, 147 thick_layer=10.0, 148 148 radius=15.0, 149 149 n_stacking=1, 150 sigma_d =0,150 sigma_dnn=0, 151 151 sld_core=4, 152 152 sld_layer=0.0, … … 158 158 # Accuracy tests based on content in test/utest_extra_models.py. 159 159 # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB 160 [{' core_thick': 10.0,161 ' layer_thick': 15.0,162 'radius': 3000.0, 163 'n_stacking': 1.0, 164 'sigma_d ': 0.0,160 [{'thick_core': 10.0, 161 'thick_layer': 15.0, 162 'radius': 3000.0, 163 'n_stacking': 1.0, 164 'sigma_dnn': 0.0, 165 165 'sld_core': 4.0, 166 166 'sld_layer': -0.4, … … 172 172 }, 0.001, 5075.12], 173 173 174 [{' core_thick': 10.0,175 ' layer_thick': 15.0,174 [{'thick_core': 10.0, 175 'thick_layer': 15.0, 176 176 'radius': 3000.0, 177 177 'n_stacking': 5.0, 178 'sigma_d ': 0.0,178 'sigma_dnn': 0.0, 179 179 'sld_core': 4.0, 180 180 'sld_layer': -0.4, … … 186 186 }, 0.001, 5065.12793824], 187 187 188 [{' core_thick': 10.0,189 ' layer_thick': 15.0,188 [{'thick_core': 10.0, 189 'thick_layer': 15.0, 190 190 'radius': 3000.0, 191 191 'n_stacking': 5.0, 192 'sigma_d ': 0.0,192 'sigma_dnn': 0.0, 193 193 'sld_core': 4.0, 194 194 'sld_layer': -0.4, … … 200 200 }, 0.164, 0.0127673597265], 201 201 202 [{' core_thick': 10.0,203 ' layer_thick': 15.0,204 'radius': 3000.0, 205 'n_stacking': 1.0, 206 'sigma_d ': 0.0,202 [{'thick_core': 10.0, 203 'thick_layer': 15.0, 204 'radius': 3000.0, 205 'n_stacking': 1.0, 206 'sigma_dnn': 0.0, 207 207 'sld_core': 4.0, 208 208 'sld_layer': -0.4, … … 214 214 }, [0.001, 90.0], [5075.12, 0.001]], 215 215 216 [{' core_thick': 10.0,217 ' layer_thick': 15.0,218 'radius': 3000.0, 219 'n_stacking': 1.0, 220 'sigma_d ': 0.0,216 [{'thick_core': 10.0, 217 'thick_layer': 15.0, 218 'radius': 3000.0, 219 'n_stacking': 1.0, 220 'sigma_dnn': 0.0, 221 221 'sld_core': 4.0, 222 222 'sld_layer': -0.4, … … 228 228 }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 229 229 230 [{' core_thick': 10.0,231 ' layer_thick': 15.0,232 'radius': 3000.0, 233 'n_stacking': 1.0, 234 'sigma_d ': 0.0,230 [{'thick_core': 10.0, 231 'thick_layer': 15.0, 232 'radius': 3000.0, 233 'n_stacking': 1.0, 234 'sigma_dnn': 0.0, 235 235 'sld_core': 4.0, 236 236 'sld_layer': -0.4, -
sasmodels/models/surface_fractal.c
r2c74c11 ra807206 3 3 double Iq(double q, 4 4 double radius, 5 double surface_dim,5 double fractal_dim_surf, 6 6 double cutoff_length); 7 7 8 8 static double _surface_fractal_kernel(double q, 9 9 double radius, 10 double surface_dim,10 double fractal_dim_surf, 11 11 double cutoff_length) 12 12 { … … 20 20 21 21 //calculate S(q) 22 mmo = 5.0 - surface_dim;22 mmo = 5.0 - fractal_dim_surf; 23 23 sq = sas_gamma(mmo)*sin(-(mmo)*atan(q*cutoff_length)); 24 24 sq *= pow(cutoff_length, mmo); … … 38 38 double Iq(double q, 39 39 double radius, 40 double surface_dim,40 double fractal_dim_surf, 41 41 double cutoff_length 42 42 ) 43 43 { 44 return _surface_fractal_kernel(q, radius, surface_dim, cutoff_length);44 return _surface_fractal_kernel(q, radius, fractal_dim_surf, cutoff_length); 45 45 } -
sasmodels/models/surface_fractal.py
r33875e3 ra807206 66 66 delta = sldParticle -sldSolv. 67 67 radius = Particle radius 68 surface_dim= Surface fractal dimension (Ds)68 fractal_dim_surf = Surface fractal dimension (Ds) 69 69 co_length = Cut-off length 70 70 background = background 71 71 72 72 Ref. :Mildner, Hall,J Phys D Appl Phys(1986), 19, 1535-1545 73 Note I : This model is valid for 1< surface_dim<3 with limited q range.73 Note I : This model is valid for 1<fractal_dim_surf<3 with limited q range. 74 74 Note II: This model is not in absolute scale. 75 75 """ … … 80 80 parameters = [["radius", "Ang", 10.0, [0, inf], "", 81 81 "Particle radius"], 82 [" surface_dim", "", 2.0, [1, 3], "",82 ["fractal_dim_surf", "", 2.0, [1, 3], "", 83 83 "Surface fractal dimension"], 84 84 ["cutoff_length", "Ang", 500., [0.0, inf], "", … … 90 90 91 91 demo = dict(scale=1, background=0, 92 radius=10, surface_dim=2.0, cutoff_length=500)92 radius=10, fractal_dim_surf=2.0, cutoff_length=500) 93 93 94 94 tests = [ 95 95 # Accuracy tests based on content in test/utest_other_models.py 96 96 [{'radius': 10.0, 97 ' surface_dim': 2.0,97 'fractal_dim_surf': 2.0, 98 98 'cutoff_length': 500.0, 99 99 }, 0.05, 301428.66016], … … 101 101 # Additional tests with larger range of parameters 102 102 [{'radius': 1.0, 103 ' surface_dim': 1.0,103 'fractal_dim_surf': 1.0, 104 104 'cutoff_length': 10.0, 105 105 }, 0.332070182643, 1125.00421004], 106 106 107 107 [{'radius': 3.5, 108 ' surface_dim': 0.1,108 'fractal_dim_surf': 0.1, 109 109 'cutoff_length': 30.0, 110 110 'background': 0.01, … … 112 112 113 113 [{'radius': 3.0, 114 ' surface_dim': 1.0,114 'fractal_dim_surf': 1.0, 115 115 'cutoff_length': 33.0, 116 116 'scale': 0.1, -
sasmodels/models/triaxial_ellipsoid.c
r2f5c6d4 ra807206 1 double form_volume(double r eq_minor, double req_major, double rpolar);2 double Iq(double q, double sld, double s olvent_sld,3 double r eq_minor, double req_major, double rpolar);4 double Iqxy(double qx, double qy, double sld, double s olvent_sld,5 double r eq_minor, double req_major, double rpolar, double theta, double phi, double psi);1 double form_volume(double radius_equat_minor, double radius_equat_major, double radius_polar); 2 double Iq(double q, double sld, double sld_solvent, 3 double radius_equat_minor, double radius_equat_major, double radius_polar); 4 double Iqxy(double qx, double qy, double sld, double sld_solvent, 5 double radius_equat_minor, double radius_equat_major, double radius_polar, double theta, double phi, double psi); 6 6 7 //#define INVALID(v) (v.r eq_minor > v.req_major || v.req_major > v.rpolar)7 //#define INVALID(v) (v.radius_equat_minor > v.radius_equat_major || v.radius_equat_major > v.radius_polar) 8 8 9 9 10 double form_volume(double r eq_minor, double req_major, double rpolar)10 double form_volume(double radius_equat_minor, double radius_equat_major, double radius_polar) 11 11 { 12 return 1.333333333333333*M_PI*r eq_minor*req_major*rpolar;12 return 1.333333333333333*M_PI*radius_equat_minor*radius_equat_major*radius_polar; 13 13 } 14 14 15 15 double Iq(double q, 16 16 double sld, 17 double s olvent_sld,18 double r eq_minor,19 double r eq_major,20 double r polar)17 double sld_solvent, 18 double radius_equat_minor, 19 double radius_equat_major, 20 double radius_polar) 21 21 { 22 22 double sn, cn; … … 29 29 const double x = 0.5*(Gauss76Z[i] + 1.0); 30 30 SINCOS(M_PI_2*x, sn, cn); 31 const double acosx2 = r eq_minor*req_minor*cn*cn;32 const double bsinx2 = r eq_major*req_major*sn*sn;33 const double c2 = r polar*rpolar;31 const double acosx2 = radius_equat_minor*radius_equat_minor*cn*cn; 32 const double bsinx2 = radius_equat_major*radius_equat_major*sn*sn; 33 const double c2 = radius_polar*radius_polar; 34 34 35 35 double inner = 0.0; … … 44 44 // translate dx in [-1,1] to dx in [lower,upper] 45 45 const double fqsq = outer*zm; 46 const double s = (sld - s olvent_sld) * form_volume(req_minor, req_major, rpolar);46 const double s = (sld - sld_solvent) * form_volume(radius_equat_minor, radius_equat_major, radius_polar); 47 47 return 1.0e-4 * s * s * fqsq; 48 48 } … … 50 50 double Iqxy(double qx, double qy, 51 51 double sld, 52 double s olvent_sld,53 double r eq_minor,54 double r eq_major,55 double r polar,52 double sld_solvent, 53 double radius_equat_minor, 54 double radius_equat_major, 55 double radius_polar, 56 56 double theta, 57 57 double phi, … … 71 71 const double cnu = (-cphi*spsi*stheta + sphi*cpsi)*qxhat + spsi*ctheta*qyhat; 72 72 const double cmu = (-stheta*cpsi*cphi - spsi*sphi)*qxhat + ctheta*cpsi*qyhat; 73 const double t = q*sqrt(r eq_minor*req_minor*cnu*cnu74 + r eq_major*req_major*cmu*cmu75 + r polar*rpolar*calpha*calpha);73 const double t = q*sqrt(radius_equat_minor*radius_equat_minor*cnu*cnu 74 + radius_equat_major*radius_equat_major*cmu*cmu 75 + radius_polar*radius_polar*calpha*calpha); 76 76 const double fq = sph_j1c(t); 77 const double s = (sld - s olvent_sld) * form_volume(req_minor, req_major, rpolar);77 const double s = (sld - sld_solvent) * form_volume(radius_equat_minor, radius_equat_major, radius_polar); 78 78 79 79 return 1.0e-4 * square(s * fq); -
sasmodels/models/triaxial_ellipsoid.py
r42356c8 ra807206 88 88 parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld", 89 89 "Ellipsoid scattering length density"], 90 ["s olvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "sld",90 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 91 91 "Solvent scattering length density"], 92 ["r eq_minor", "Ang", 20, [0, inf], "volume",92 ["radius_equat_minor", "Ang", 20, [0, inf], "volume", 93 93 "Minor equatorial radius"], 94 ["r eq_major", "Ang", 400, [0, inf], "volume",94 ["radius_equat_major", "Ang", 400, [0, inf], "volume", 95 95 "Major equatorial radius"], 96 ["r polar", "Ang", 10, [0, inf], "volume",96 ["radius_polar", "Ang", 10, [0, inf], "volume", 97 97 "Polar radius"], 98 98 ["theta", "degrees", 60, [-inf, inf], "orientation", … … 106 106 source = ["lib/sph_j1c.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 107 107 108 def ER(r eq_minor, req_major, rpolar):108 def ER(radius_equat_minor, radius_equat_major, radius_polar): 109 109 """ 110 110 Returns the effective radius used in the S*P calculation … … 112 112 import numpy as np 113 113 from .ellipsoid import ER as ellipsoid_ER 114 return ellipsoid_ER(r polar, np.sqrt(req_minor * req_major))114 return ellipsoid_ER(radius_polar, np.sqrt(radius_equat_minor * radius_equat_major)) 115 115 116 116 demo = dict(scale=1, background=0, 117 sld=6, s olvent_sld=1,117 sld=6, sld_solvent=1, 118 118 theta=30, phi=15, psi=5, 119 r eq_minor=25, req_major=36, rpolar=50,120 r eq_minor_pd=0, req_minor_pd_n=1,121 r eq_major_pd=0, req_major_pd_n=1,122 r polar_pd=.2, rpolar_pd_n=30,119 radius_equat_minor=25, radius_equat_major=36, radius_polar=50, 120 radius_equat_minor_pd=0, radius_equat_minor_pd_n=1, 121 radius_equat_major_pd=0, radius_equat_major_pd_n=1, 122 radius_polar_pd=.2, radius_polar_pd_n=30, 123 123 theta_pd=15, theta_pd_n=45, 124 124 phi_pd=15, phi_pd_n=1,
Note: See TracChangeset
for help on using the changeset viewer.