Changeset ec87470 in sasmodels for sasmodels/models
- Timestamp:
- Aug 3, 2016 10:26:20 AM (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:
- 3a45c2c, 3d9001f
- Parents:
- edf06e1 (diff), d119f34 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- sasmodels/models
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/core_shell_ellipsoid.py
rec45c4f r7f1ee79 99 99 category = "shape:ellipsoid" 100 100 101 single = False # TODO: maybe using sph_j1c inside gfn would help?102 101 # pylint: disable=bad-whitespace, line-too-long 103 102 # ["name", "units", default, [lower, upper], "type", "description"], -
sasmodels/models/gaussian_peak.py
r2c74c11 r7f1ee79 38 38 category = "shape-independent" 39 39 40 single = False41 40 # ["name", "units", default, [lower, upper], "type","description"], 42 41 parameters = [["q0", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], -
sasmodels/models/hardsphere.py
r9eb3632 r7f1ee79 58 58 category = "structure-factor" 59 59 structure_factor = True 60 single = False 60 single = False # TODO: check 61 61 62 62 # ["name", "units", default, [lower, upper], "type","description"], -
sasmodels/models/hollow_cylinder.c
r2f5c6d4 rf95556f 6 6 double solvent_sld, double theta, double phi); 7 7 8 #define INVALID(v) (v.core_radius >= v.radius || v.radius >= v.length)8 #define INVALID(v) (v.core_radius >= v.radius) 9 9 10 10 // From Igor library 11 static double hollow_cylinder_scaling(double integrand, double delrho, double volume) 11 static double hollow_cylinder_scaling( 12 double integrand, double delrho, double volume) 12 13 { 13 14 15 14 double answer; 15 // Multiply by contrast^2 16 answer = integrand*delrho*delrho; 16 17 17 18 18 //normalize by cylinder volume 19 answer *= volume*volume; 19 20 20 21 21 //convert to [cm-1] 22 answer *= 1.0e-4; 22 23 23 24 return answer; 24 25 } 25 26 26 static double _hollow_cylinder_kernel(double q, double core_radius, double radius, 27 double length, double dum) 27 28 static double _hollow_cylinder_kernel( 29 double q, double core_radius, double radius, double length, double dum) 28 30 { 29 double gamma,arg1,arg2,lam1,lam2,psi,sinarg,t2,retval; //local variables 30 31 gamma = core_radius/radius; 32 arg1 = q*radius*sqrt(1.0-dum*dum); //1=shell (outer radius) 33 arg2 = q*core_radius*sqrt(1.0-dum*dum); //2=core (inner radius) 34 if (arg1 == 0.0){ 35 lam1 = 1.0; 36 }else{ 37 lam1 = sas_J1c(arg1); 38 } 39 if (arg2 == 0.0){ 40 lam2 = 1.0; 41 }else{ 42 lam2 = sas_J1c(arg2); 43 } 44 //Todo: Need to check psi behavior as gamma goes to 1. 45 psi = (lam1 - gamma*gamma*lam2)/(1.0-gamma*gamma); //SRK 10/19/00 46 sinarg = q*length*dum/2.0; 47 if (sinarg == 0.0){ 48 t2 = 1.0; 49 }else{ 50 t2 = sin(sinarg)/sinarg; 51 } 31 const double qs = q*sqrt(1.0-dum*dum); 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) 36 const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 37 const double t2 = sinc(q*length*dum/2.0); 38 return square(psi*t2); 39 } 52 40 53 retval = psi*psi*t2*t2;54 55 return(retval);56 }57 static double hollow_cylinder_analytical_2D_scaled(double q, double q_x, double q_y, double radius, double core_radius, double length, double sld,58 double solvent_sld, double theta, double phi) {59 double cyl_x, cyl_y; //, cyl_z60 //double q_z;61 double vol, cos_val, delrho;62 double answer;63 //convert angle degree to radian64 double pi = 4.0*atan(1.0);65 theta = theta * pi/180.0;66 phi = phi * pi/180.0;67 delrho = solvent_sld - sld;68 41 69 // Cylinder orientation 70 cyl_x = cos(theta) * cos(phi); 71 cyl_y = sin(theta); 72 //cyl_z = -cos(theta) * sin(phi); 42 static double hollow_cylinder_analytical_2D_scaled( 43 double q, double q_x, double q_y, double radius, double core_radius, 44 double length, double sld, double solvent_sld, double theta, double phi) 45 { 46 double cyl_x, cyl_y; //, cyl_z 47 //double q_z; 48 double vol, cos_val, delrho; 49 double answer; 50 //convert angle degree to radian 51 theta = theta * M_PI_180; 52 phi = phi * M_PI_180; 53 delrho = solvent_sld - sld; 73 54 74 // q vector 75 //q_z = 0; 55 // Cylinder orientation 56 cyl_x = cos(theta) * cos(phi); 57 cyl_y = sin(theta); 58 //cyl_z = -cos(theta) * sin(phi); 76 59 77 // Compute the angle btw vector q and the 78 // axis of the cylinder 79 cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 60 // q vector 61 //q_z = 0; 80 62 81 answer = _hollow_cylinder_kernel(q, core_radius, radius, length, cos_val); 63 // Compute the angle btw vector q and the 64 // axis of the cylinder 65 cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 82 66 83 vol = form_volume(radius, core_radius, length); 84 answer = hollow_cylinder_scaling(answer, delrho, vol); 67 answer = _hollow_cylinder_kernel(q, core_radius, radius, length, cos_val); 85 68 86 return answer; 69 vol = form_volume(radius, core_radius, length); 70 answer = hollow_cylinder_scaling(answer, delrho, vol); 71 72 return answer; 87 73 } 88 74 … … 90 76 double form_volume(double radius, double core_radius, double length) 91 77 { 92 double pi = 4.0*atan(1.0); 93 double v_shell = pi*length*(radius*radius-core_radius*core_radius); 94 return(v_shell); 78 double v_shell = M_PI*length*(radius*radius-core_radius*core_radius); 79 return(v_shell); 95 80 } 96 81 97 82 98 double Iq(double q, double radius, double core_radius, double length, double sld,99 83 double Iq(double q, double radius, double core_radius, double length, 84 double sld, double solvent_sld) 100 85 { 101 86 int i; 102 int nord=76; //order of integration 103 double lower,upper,zi, inter; //upper and lower integration limits 104 double summ,answer,delrho; //running tally of integration 105 double norm,volume; //final calculation variables 106 107 delrho = solvent_sld - sld; 108 lower = 0.0; 109 upper = 1.0; //limits of numerical integral 87 double lower,upper,zi, inter; //upper and lower integration limits 88 double summ,answer,delrho; //running tally of integration 89 double norm,volume; //final calculation variables 110 90 111 summ = 0.0; //initialize intergral 112 for(i=0;i<nord;i++) { 113 zi = ( Gauss76Z[i] * (upper-lower) + lower + upper )/2.0; 114 inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, core_radius, radius, length, zi); 115 summ += inter; 116 } 117 118 norm = summ*(upper-lower)/2.0; 119 volume = form_volume(radius, core_radius, length); 120 answer = hollow_cylinder_scaling(norm, delrho, volume); 121 122 return(answer); 91 lower = 0.0; 92 upper = 1.0; //limits of numerical integral 93 94 summ = 0.0; //initialize intergral 95 for (i=0;i<76;i++) { 96 zi = ( Gauss76Z[i] * (upper-lower) + lower + upper )/2.0; 97 inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, core_radius, radius, length, zi); 98 summ += inter; 99 } 100 101 norm = summ*(upper-lower)/2.0; 102 volume = form_volume(radius, core_radius, length); 103 delrho = solvent_sld - sld; 104 answer = hollow_cylinder_scaling(norm, delrho, volume); 105 106 return(answer); 123 107 } 124 108 125 double Iqxy(double qx, double qy, double radius, double core_radius, double length, double sld, 126 double solvent_sld, double theta, double phi) 109 110 double Iqxy(double qx, double qy, double radius, double core_radius, 111 double length, double sld, double solvent_sld, double theta, double phi) 127 112 { 128 double q; 129 q = sqrt(qx*qx+qy*qy); 130 return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, core_radius, length, sld, solvent_sld, theta, phi); 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); 131 115 } -
sasmodels/models/hollow_cylinder.py
r42356c8 r58210db 79 79 # pylint: enable=bad-whitespace, line-too-long 80 80 81 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"]81 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 82 82 83 83 # pylint: disable=W0613 -
sasmodels/models/lamellar_hg_stack_caille.py
r42356c8 r7f1ee79 90 90 category = "shape:lamellae" 91 91 92 single = False 92 single = False # TODO: check 93 93 parameters = [ 94 94 # [ "name", "units", default, [lower, upper], "type", -
sasmodels/models/lamellar_stack_caille.py
r42356c8 r7f1ee79 83 83 category = "shape:lamellae" 84 84 85 single = False 85 single = False # TODO: check 86 86 # pylint: disable=bad-whitespace, line-too-long 87 87 # ["name", "units", default, [lower, upper], "type","description"], -
sasmodels/models/linear_pearls.py
r42356c8 rd2d6100 61 61 ] 62 62 # pylint: enable=bad-whitespace, line-too-long 63 single=False 63 64 64 65 source = ["linear_pearls.c"] -
sasmodels/models/multilayer_vesicle.py
r42356c8 rf67f26c 74 74 ["volfraction", "", 0.05, [0.0, 1], "", "volume fraction of vesicles"], 75 75 ["radius", "Ang", 60.0, [0.0, inf], "", "Core radius of the multishell"], 76 ["thick_shell", "Ang", 10.0, [0.0, inf], " sld", "Shell thickness"],76 ["thick_shell", "Ang", 10.0, [0.0, inf], "", "Shell thickness"], 77 77 ["thick_solvent", "Ang", 10.0, [0.0, inf], "", "Water thickness"], 78 78 ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", "Core scattering length density"], -
sasmodels/models/onion.c
r639c4e3 rd119f34 2 2 static double 3 3 f_exp(double q, double r, double sld_in, double sld_out, 4 double thickness, double A) 5 { 6 const double vol = M_4PI_3 * cube(r); 7 const double qr = q * r; 8 const double alpha = A * r/thickness; 9 const double bes = sph_j1c(qr); 10 const double B = (sld_out - sld_in)/expm1(A); 11 const double C = sld_in - B; 12 double fun; 13 if (qr == 0.0) { 14 fun = 1.0; 15 } else if (fabs(A) > 0.0) { 16 const double qrsq = qr*qr; 17 const double alphasq = alpha*alpha; 18 const double sumsq = alphasq + qrsq; 19 double sinqr, cosqr; 20 SINCOS(qr, sinqr, cosqr); 21 fun = -3.0*( 22 ((alphasq - qrsq)*sinqr/qr - 2.0*alpha*cosqr) / sumsq 23 - (alpha*sinqr/qr - cosqr) 24 ) / sumsq; 25 } else { 26 fun = bes; 27 } 28 return vol * (B*fun + C*bes); 29 } 30 31 static double 32 f_linear(double q, double r, double sld, double slope) 4 double thickness, double A, double side) 33 5 { 34 6 const double vol = M_4PI_3 * cube(r); 35 7 const double qr = q * r; 36 8 const double bes = sph_j1c(qr); 37 double fun = 0.0; 38 if (qr > 0.0) { 39 const double qrsq = qr*qr; 9 const double alpha = A * r/thickness; 10 double result; 11 if (qr == 0.0) { 12 result = 1.0; 13 } else if (fabs(A) > 0.0) { 14 const double qrsq = qr * qr; 15 const double alphasq = alpha * alpha; 16 const double sumsq = alphasq + qrsq; 40 17 double sinqr, cosqr; 41 18 SINCOS(qr, sinqr, cosqr); 42 // Jae-He's code seems to simplify to this 43 // fun = 3.0 * slope * r * (2.0*qr*sinqr - (qrsq-2.0)*cosqr)/(qrsq*qrsq); 44 // Rederiving the math, we get the following instead: 45 fun = 3.0 * slope * r * (2.0*cosqr + qr*sinqr)/(qrsq*qrsq); 19 const double t1 = (alphasq - qrsq)*sinqr/qr - 2.0*alpha*cosqr; 20 const double t2 = alpha*sinqr/qr - cosqr; 21 const double fun = -3.0*(t1/sumsq - t2)/sumsq; 22 const double slope = (sld_out - sld_in)/expm1(A); 23 const double contrast = slope*exp(A*side); 24 result = contrast*fun + (sld_in-slope)*bes; 25 } else { 26 result = sld_in*bes; 46 27 } 47 return vol * (sld*bes + fun); 48 } 49 50 static double 51 f_constant(double q, double r, double sld) 52 { 53 const double bes = sph_j1c(q * r); 54 const double vol = M_4PI_3 * cube(r); 55 return sld * vol * bes; 28 return vol * result; 56 29 } 57 30 … … 69 42 static double 70 43 Iq(double q, double sld_core, double core_radius, double sld_solvent, 71 double n , double sld_in[], double sld_out[], double thickness[],44 double n_shells, double sld_in[], double sld_out[], double thickness[], 72 45 double A[]) 73 46 { 74 int i; 75 double r = core_radius; 76 double f = f_constant(q, r, sld_core); 77 for (i=0; i<n; i++){ 78 const double r0 = r; 79 r += thickness[i]; 80 if (r == r0) { 81 // no thickness, so nothing to add 82 } else if (fabs(A[i]) < 1.0e-16 || sld_out[i] == sld_in[i]) { 83 f -= f_constant(q, r0, sld_in[i]); 84 f += f_constant(q, r, sld_in[i]); 85 } else if (fabs(A[i]) < 1.0e-4) { 86 const double slope = (sld_out[i] - sld_in[i])/thickness[i]; 87 f -= f_linear(q, r0, sld_in[i], slope); 88 f += f_linear(q, r, sld_out[i], slope); 89 } else { 90 f -= f_exp(q, r0, sld_in[i], sld_out[i], thickness[i], A[i]); 91 f += f_exp(q, r, sld_in[i], sld_out[i], thickness[i], A[i]); 92 } 47 int n = (int)(n_shells+0.5); 48 double r_out = core_radius; 49 double f = f_exp(q, r_out, sld_core, 0.0, 0.0, 0.0, 0.0); 50 for (int i=0; i < n; i++){ 51 const double r_in = r_out; 52 r_out += thickness[i]; 53 f -= f_exp(q, r_in, sld_in[i], sld_out[i], thickness[i], A[i], 0.0); 54 f += f_exp(q, r_out, sld_in[i], sld_out[i], thickness[i], A[i], 1.0); 93 55 } 94 f -= f_ constant(q, r, sld_solvent);56 f -= f_exp(q, r_out, sld_solvent, 0.0, 0.0, 0.0, 0.0); 95 57 const double f2 = f * f * 1.0e-4; 96 58 -
sasmodels/models/onion.py
r63c6a08 rd119f34 394 394 # Could also specify them individually as 395 395 # "A1": 0, "A2": -1, "A3": 1e-4, "A4": 1, 396 #"core_radius_pd_n": 10, 397 #"core_radius_pd": 0.4, 398 #"thickness4_pd_n": 10, 399 #"thickness4_pd": 0.4, 396 400 } 397 401 -
sasmodels/models/polymer_micelle.py
r42356c8 rd2d6100 51 51 # pylint: enable=bad-whitespace, line-too-long 52 52 53 single = False 54 53 55 source = ["lib/sph_j1c.c", "polymer_micelle_kernel.c"] 54 56 -
sasmodels/models/polymer_micelle_kernel.c
r2c74c11 rc915373 36 36 // Self-correlation term of the chains 37 37 const double qrg2 = q*radius_gyr*q*radius_gyr; 38 const double debye_chain = (qrg2 == 0.0) ? 1.0 : 2.0*(exp (-qrg2)-1+qrg2)/(qrg2*qrg2);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; 40 40 41 41 // Interference cross-term between core and chains 42 const double chain_ampl = (qrg2 == 0.0) ? 1.0 : (1-exp(-qrg2))/qrg2;42 const double chain_ampl = (qrg2 == 0.0) ? 1.0 : -expm1(-qrg2)/qrg2; 43 43 const double bes_corona = sinc(q*(radius_core + d_penetration * radius_gyr)); 44 44 const double term3 = 2 * n_aggreg * n_aggreg * beta_core * beta_corona * -
sasmodels/models/rpa.c
rd680a2b r6351bfa 25 25 double S0ba,Pbb,S0bb,Pbc,S0bc,Pbd,S0bd; 26 26 double S0ca,S0cb,Pcc,S0cc,Pcd,S0cd; 27 double S0da,S0db,S0dc,Pdd,S0dd; 28 double Kaa,Kbb,Kcc,Kdd; 29 double Kba,Kca,Kda,Kcb,Kdb,Kdc; 27 double S0da,S0db,S0dc; 28 double Pdd,S0dd; 29 double Kaa,Kbb,Kcc; 30 double Kba,Kca,Kcb; 31 double Kda,Kdb,Kdc,Kdd; 30 32 double Zaa,Zab,Zac,Zba,Zbb,Zbc,Zca,Zcb,Zcc; 31 33 double DenT,T11,T12,T13,T21,T22,T23,T31,T32,T33; -
sasmodels/models/surface_fractal.py
rec45c4f r33875e3 80 80 parameters = [["radius", "Ang", 10.0, [0, inf], "", 81 81 "Particle radius"], 82 ["surface_dim", "", 2.0, [ 0, inf], "",82 ["surface_dim", "", 2.0, [1, 3], "", 83 83 "Surface fractal dimension"], 84 84 ["cutoff_length", "Ang", 500., [0.0, inf], "", -
sasmodels/models/unified_power_Rg.py
r2c74c11 rec77322 80 80 81 81 with errstate(divide='ignore', invalid='ignore'): 82 result = np. empty(q.shape, 'd')82 result = np.zeros(q.shape, 'd') 83 83 for i in range(ilevel): 84 84 exp_now = exp(-(q*rg[i])**2/3.) -
sasmodels/models/lib/sas_erf.c
r1557a1e redf06e1 280 280 else 281 281 x = a;*/ 282 283 x = fabs f(a);282 // TODO: tinycc does not support fabsf 283 x = fabs(a); 284 284 285 285 … … 302 302 return (0.0); 303 303 } 304 305 304 z = expf(z); 306 305 … … 332 331 float y, z; 333 332 334 if (fabsf(x) > 1.0) 333 // TODO: tinycc does not support fabsf 334 if (fabs(x) > 1.0) 335 335 return (1.0 - erfcf(x)); 336 336 -
sasmodels/models/spherical_sld.py
r63c6a08 redf06e1 217 217 ] 218 218 # pylint: enable=bad-whitespace, line-too-long 219 source = ["lib/ sas_erf.c", "lib/librefl.c", "lib/sph_j1c.c", "spherical_sld.c"]219 source = ["lib/polevl.c", "lib/sas_erf.c", "lib/librefl.c", "lib/sph_j1c.c", "spherical_sld.c"] 220 220 single = False # TODO: fix low q behaviour 221 221
Note: See TracChangeset
for help on using the changeset viewer.