Changeset 5d4777d in sasmodels for sasmodels/models/ellipsoid.c
- Timestamp:
- Sep 2, 2014 1:24:38 AM (10 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:
- f4cf580
- Parents:
- ff7119b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/ellipsoid.c
rce27e21 r5d4777d 1 /* PARAMETERS 1 real form_volume(real rpolar, real requatorial); 2 real Iq(real q, real sld, real solvent_sld, real rpolar, real requatorial); 3 real Iqxy(real qx, real qy, real sld, real solvent_sld, 4 real rpolar, real requatorial, real theta, real phi); 5 6 real _ellipsoid_kernel(real q, real rpolar, real requatorial, real cos_alpha); 7 real _ellipsoid_kernel(real q, real rpolar, real requatorial, real cos_alpha) 2 8 { 3 name: "ellipsoid", 4 title: "Ellipsoid with uniform scattering length density", 5 include: [ "lib/gauss76.c" ], 6 parameters: [ 7 // [ "name", "units", default, [lower, upper], "type", "description" ], 8 [ "sld", "1e-6/Ang^2", 4, [-Infinity,Infinity], "", 9 "Cylinder scattering length density" ], 10 [ "solvent_sld", "1e-6/Ang^2", 1, [-Infinity,Infinity], "", 11 "Solvent scattering length density" ], 12 [ "a", "Ang", 20, [0, Infinity], "volume", 13 "Cylinder radius" ], 14 [ "b", "Ang", 20, [0, Infinity], "volume", 15 "Cylinder length" ], 16 [ "theta", "degrees", 60, [-Infinity, Infinity], "orientation", 17 "In plane angle" ], 18 [ "phi", "degrees", 60, [-Infinity, Infinity], "orientation", 19 "Out of plane angle" ], 20 ], 21 } 22 PARAMETERS END 23 24 DOCUMENTATION 25 .. _EllipseModel: 26 27 DOCUMENTATION END 28 */ 29 30 real form_volume(real a, real b); 31 real Iq(real qx, real qy, real sld, real solvent_sld, real a, real b); 32 real Iqxy(real qx, real qy, real sld, real solvent_sld, real a, real b, real theta, real phi); 33 34 real form_volume(real a, real b) 35 { 36 return REAL(1.333333333333333)*M_PI_2*a*b*b; 9 real sn, cn; 10 real ratio = rpolar/requatorial; 11 const real u = q*requatorial*sqrt(REAL(1.0) 12 + cos_alpha*cos_alpha*(ratio*ratio - REAL(1.0))); 13 SINCOS(u, sn, cn); 14 const real f = ( u==REAL(0.0) ? REAL(1.0) : REAL(3.0)*(sn-u*cn)/(u*u*u) ); 15 return f*f; 37 16 } 38 17 39 real ellipsoid_kernel(double q, double b, double a, double dum)18 real form_volume(real rpolar, real requatorial) 40 19 { 41 real sn, cn; 42 const real nu = a/b; 43 const real arg = q * b * sqrt(REAL(1.0)+(dum*dum*(nu*nu--REAL(1.0)))); 44 SINCOS(arg, sn, cn); 45 const real f = (arg==REAL(0.0) ? REAL(1.0) : REAL(3.0)*(sn-arg*cn)/(arg*arg*arg); 46 return f*f; 20 return REAL(1.333333333333333)*M_PI*rpolar*requatorial*requatorial; 47 21 } 48 22 … … 50 24 real sld, 51 25 real solvent_sld, 52 real a,53 real b)26 real rpolar, 27 real requatorial) 54 28 { 55 real summ = REAL(0.0); 29 //const real lower = REAL(0.0); 30 //const real upper = REAL(1.0); 31 real total = REAL(0.0); 56 32 for (int i=0;i<76;i++) { 57 //const real zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;58 zi = ( Gauss76Z[i] + REAL(1.0))/REAL(2.0);59 summ += Gauss76Wt[i] * ellipsoid_kernel(q, b, a, zi);33 //const real cos_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2; 34 const real cos_alpha = REAL(0.5)*(Gauss76Z[i] + REAL(1.0)); 35 total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha); 60 36 } 61 //const real form = (up lim-lolim)/2.0*summ;62 const real form = REAL(0.5)* summ63 const real s = (sld - s ld_solvent) * form_volume(a, b);37 //const real form = (upper-lower)/2*total; 38 const real form = REAL(0.5)*total; 39 const real s = (sld - solvent_sld) * form_volume(rpolar, requatorial); 64 40 return REAL(1.0e-4) * form * s * s; 65 41 } … … 68 44 real sld, 69 45 real solvent_sld, 70 real a,71 real b,46 real rpolar, 47 real requatorial, 72 48 real theta, 73 49 real phi) … … 77 53 const real q = sqrt(qx*qx + qy*qy); 78 54 SINCOS(theta*M_PI_180, sn, cn); 79 const real cos_ val= cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);80 const real form = ellipsoid_kernel(q, b, a, cos_val);81 const real s = (sld - solvent_sld) * form_volume( a, b);55 const real cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 56 const real form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha); 57 const real s = (sld - solvent_sld) * form_volume(rpolar, requatorial); 82 58 83 59 return REAL(1.0e-4) * form * s * s;
Note: See TracChangeset
for help on using the changeset viewer.