Changeset 6d96b66 in sasmodels for sasmodels/models/fractal.c
- Timestamp:
- Oct 18, 2016 10:32:18 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- f0afad2
- Parents:
- 3e8ea5d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/fractal.c
r2c74c11 r6d96b66 1 double Iq(double q, 2 double volfraction, 3 double radius, 4 double fractal_dim, 5 double cor_length, 6 double sld_block, 7 double sld_solvent); 1 #define INVALID(p) (p.fractal_dim <= 0.0) 8 2 9 double Iq(double q, 10 double volfraction, 11 double radius, 12 double fractal_dim, 13 double cor_length, 14 double sld_block, 15 double sld_solvent) 3 static double 4 Iq(double q, 5 double volfraction, 6 double radius, 7 double fractal_dim, 8 double cor_length, 9 double sld_block, 10 double sld_solvent) 16 11 { 17 double qr,r0,Df,corr,phi,sldp,sldm;18 double pq,sq,inten;12 //calculate P(q) for the spherical subunits 13 const double pq = M_4PI_3*cube(radius) * square((sld_block-sld_solvent)*sph_j1c(q*radius)); 19 14 20 // Actively check the argument - needed for mass fractal - is it needie 21 //here? 22 if (fractal_dim <= 0.0){ 23 return 0.0; 15 //calculate S(q), using Teixeira, Eq(15) 16 double sq; 17 if (q > 0. && fractal_dim > 1.) { 18 // q>0, D>0 19 const double D = fractal_dim; 20 const double Dm1 = fractal_dim - 1.0; 21 // Note: for large Dm1, sin(Dm1*atan(q*cor_length) can go negative 22 const double t1 = D*sas_gamma(Dm1)*sin(Dm1*atan(q*cor_length)); 23 const double t2 = pow(q*radius, -D); 24 const double t3 = pow(1.0 + 1.0/square(q*cor_length), -0.5*Dm1); 25 sq = 1.0 + t1 * t2 * t3; 26 } else if (q > 0.) { 27 // q>0, D=1 28 sq = 1.0 + atan(q*cor_length) / (q*radius); 29 } else if (fractal_dim > 1.) { 30 // q=0, D>1 31 const double D = fractal_dim; 32 sq = 1.0 + pow(cor_length/radius, D)*sas_gamma(D+1.0); 33 } else { 34 // q=0, D=1 35 sq = 1.0 + cor_length/radius; 24 36 } 25 26 phi = volfraction; // volume fraction of building block spheres... 27 r0 = radius; // radius of building block 28 Df = fractal_dim; // fractal dimension 29 corr = cor_length; // correlation length of fractal-like aggregates 30 sldp = sld_block; // SLD of building block 31 sldm = sld_solvent; // SLD of matrix or solution 32 33 qr=q*r0; 34 35 //calculate P(q) for the spherical subunits 36 pq = phi*M_4PI_3*r0*r0*r0*(sldp-sldm)*(sldp-sldm)*sph_j1c(qr)*sph_j1c(qr); 37 38 //calculate S(q) 39 sq = Df*sas_gamma(Df-1.0)*sin((Df-1.0)*atan(q*corr)); 40 sq /= pow(qr,Df) * pow((1.0 + 1.0/(q*corr)/(q*corr)),((Df-1.0)/2.0)); 41 sq += 1.0; 42 43 //combine, scale to units cm-1 sr-1 (assuming data on absolute scale) 44 //and return 45 inten = pq*sq; 46 // convert I(1/A) to (1/cm) 47 inten *= 1.0e8; 48 //convert rho^2 in 10^-6 1/A to 1/A 49 inten *= 1.0e-12; 50 51 52 return(inten); 37 38 // scale to units cm-1 sr-1 (assuming data on absolute scale) 39 // convert I(1/A) to (1/cm) => 1e8 * I(q) 40 // convert rho^2 in 10^-6 1/A to 1/A => 1e-12 * I(q) 41 // combined: 1e-4 * I(q) 42 43 return 1.e-4 * volfraction * pq * sq; 53 44 } 54 45
Note: See TracChangeset
for help on using the changeset viewer.