Changeset 5d4777d in sasmodels for sasmodels/models/cylinder.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/cylinder.c
rff7119b r5d4777d 1 1 real form_volume(real radius, real length); 2 2 real Iq(real q, real sld, real solvent_sld, real radius, real length); 3 real Iqxy(real qx, real qy, real sld, real solvent_sld, real radius, real length, real theta, real phi); 3 real Iqxy(real qx, real qy, real sld, real solvent_sld, 4 real radius, real length, real theta, real phi); 5 6 // twovd = 2 * volume * delta_rho 7 // besarg = q * R * sin(alpha) 8 // siarg = q * L/2 * cos(alpha) 9 real _cyl(real twovd, real besarg, real siarg); 10 real _cyl(real twovd, real besarg, real siarg) 11 { 12 const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg); 13 const real si = (siarg == REAL(0.0) ? REAL(1.0) : sin(siarg)/siarg); 14 return twovd*si*bj; 15 } 4 16 5 17 real form_volume(real radius, real length) … … 14 26 real length) 15 27 { 16 const real halflength = REAL(0.5)*length; 17 real summ = REAL(0.0); 28 const real qr = q*radius; 29 const real qh = q*REAL(0.5)*length; 30 const real twovd = REAL(2.0)*(sld-solvent_sld)*form_volume(radius, length); 31 real total = REAL(0.0); 18 32 // real lower=0, upper=M_PI_2; 19 33 for (int i=0; i<76 ;i++) { 20 34 // translate a point in [-1,1] to a point in [lower,upper] 21 //const real zi = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0; 22 const real zi = REAL(0.5)*(Gauss76Z[i]*M_PI_2 + M_PI_2); 23 summ += Gauss76Wt[i] * CylKernel(q, radius, halflength, zi); 35 //const real alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0; 36 const real alpha = REAL(0.5)*(Gauss76Z[i]*M_PI_2 + M_PI_2); 37 real sn, cn; 38 SINCOS(alpha, sn, cn); 39 const real fq = _cyl(twovd, qr*sn, qh*cn); 40 total += Gauss76Wt[i] * fq * fq * sn; 24 41 } 25 42 // translate dx in [-1,1] to dx in [lower,upper] 26 //const real form = (upper-lower)/2.0*summ; 27 const real form = summ * M_PI_4; 28 29 // Multiply by contrast^2, normalize by cylinder volume and convert to cm-1 30 // NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl 31 // The additional volume factor is for polydisperse volume normalization. 32 const real s = (sld - solvent_sld) * form_volume(radius, length); 33 return REAL(1.0e-4) * form * s * s; 43 //const real form = (upper-lower)/2.0*total; 44 return REAL(1.0e-4) * total * M_PI_4; 34 45 } 35 46 … … 43 54 real phi) 44 55 { 56 // TODO: check that radius<0 and length<0 give zero scattering. 57 // This should be the case since the polydispersity weight vector should 58 // be zero length, and this function never called. 45 59 real sn, cn; // slots to hold sincos function output 46 60 … … 54 68 const real alpha = acos(cos_val); 55 69 56 // The following is CylKernel() / sin(alpha), but we are doing it in place 57 // to avoid sin(alpha)/sin(alpha) for alpha = 0. It is also a teensy bit 58 // faster since we don't mulitply and divide sin(alpha). 70 const real twovd = REAL(2.0)*(sld-solvent_sld)*form_volume(radius, length); 59 71 SINCOS(alpha, sn, cn); 60 const real besarg = q*radius*sn; 61 const real siarg = REAL(0.5)*q*length*cn; 62 // lim_{x->0} J1(x)/x = 1/2, lim_{x->0} sin(x)/x = 1 63 const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg); 64 const real si = (siarg == REAL(0.0) ? REAL(1.0) : sin(siarg)/siarg); 65 const real form = REAL(4.0)*bj*bj*si*si; 66 67 // Multiply by contrast^2, normalize by cylinder volume and convert to cm-1 68 // NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl 69 // The additional volume factor is for polydisperse volume normalization. 70 const real s = (sld - solvent_sld) * form_volume(radius, length); 71 return REAL(1.0e-4) * form * s * s; // * correction; 72 const real fq = _cyl(twovd, q*radius*sn, q*REAL(0.5)*length*cn); 73 return REAL(1.0e-4) * fq * fq; // * correction; 72 74 }
Note: See TracChangeset
for help on using the changeset viewer.