Changeset 217590b in sasmodels
- Timestamp:
- Oct 20, 2016 4:48:48 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:
- 5c94f41
- Parents:
- 2b9e63f
- git-author:
- Paul Kienzle <pkienzle@…> (10/20/16 16:47:25)
- git-committer:
- Paul Kienzle <pkienzle@…> (10/20/16 16:48:48)
- Location:
- sasmodels/models
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/fractal.c
r6d96b66 r217590b 1 #define INVALID(p) (p.fractal_dim < =0.0)1 #define INVALID(p) (p.fractal_dim < 0.0) 2 2 3 3 static double … … 10 10 double sld_solvent) 11 11 { 12 const double sq = fractal_sq(q, radius, fractal_dim, cor_length); 13 12 14 //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)); 14 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; 36 } 15 const double V = M_4PI_3*cube(radius); 16 const double pq = V * square((sld_block-sld_solvent)*sph_j1c(q*radius)); 37 17 38 18 // scale to units cm-1 sr-1 (assuming data on absolute scale) … … 41 21 // combined: 1e-4 * I(q) 42 22 43 return 1.e-4 * volfraction * pq * sq;23 return 1.e-4 * volfraction * sq * pq; 44 24 } 45 25 -
sasmodels/models/fractal.py
r6d96b66 r217590b 84 84 ["radius", "Ang", 5.0, [0.0, inf], "", 85 85 "radius of particles"], 86 ["fractal_dim", "", 2.0, [ 1.0, 6.0], "",86 ["fractal_dim", "", 2.0, [0.0, 6.0], "", 87 87 "fractal dimension"], 88 88 ["cor_length", "Ang", 100.0, [0.0, inf], "", … … 95 95 # pylint: enable=bad-whitespace, line-too-long 96 96 97 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", " fractal.c"]97 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/fractal_sq.c", "fractal.c"] 98 98 99 99 demo = dict(volfraction=0.05, -
sasmodels/models/fractal_core_shell.c
r6d96b66 r217590b 1 double form_volume(double radius, double thickness); 2 3 double Iq(double q, 4 double radius, 5 double thickness, 6 double core_sld, 7 double shell_sld, 8 double solvent_sld, 9 double volfraction, 10 double fractal_dim, 11 double cor_length); 12 13 double form_volume(double radius, double thickness) 1 static double 2 form_volume(double radius, double thickness) 14 3 { 15 4 return M_4PI_3 * cube(radius + thickness); 16 5 } 17 6 18 double Iq(double q, 19 double radius, 20 double thickness, 21 double core_sld, 22 double shell_sld, 23 double solvent_sld, 24 double volfraction, 25 double fractal_dim, 26 double cor_length) { 27 28 7 static double 8 Iq(double q, 9 double radius, 10 double thickness, 11 double core_sld, 12 double shell_sld, 13 double solvent_sld, 14 double volfraction, 15 double fractal_dim, 16 double cor_length) 17 { 18 const double sq = fractal_sq(q, radius, fractal_dim, cor_length); 29 19 const double pq = core_shell_kernel(q, radius, thickness, 30 20 core_sld, shell_sld, solvent_sld); 31 32 33 //calculate S(q)34 double sq;35 if (q > 0. && fractal_dim > 1.) {36 // q>0, D>037 const double D = fractal_dim;38 const double Dm1 = fractal_dim - 1.0;39 const double t1 = D*sas_gamma(Dm1)*sin((Dm1)*atan(q*cor_length));40 const double t2 = pow(q*radius, -D);41 const double t3 = pow(1.0 + 1.0/square(q*cor_length), -0.5*Dm1);42 sq = 1.0 + t1 * t2 * t3;43 } else if (q > 0.) {44 // q>0, D=145 sq = 1.0 + atan(q*cor_length) / (q*radius);46 } else if (fractal_dim > 1.) {47 // q=0, D>148 const double D = fractal_dim;49 sq = 1.0 + pow(cor_length/radius, D)*sas_gamma(D+1.0);50 } else {51 // q=0, D=152 sq = 1.0 + cor_length/radius;53 }54 21 55 22 // Note: core_shell_kernel already performs the 1e-4 unit conversion -
sasmodels/models/fractal_core_shell.py
r6d96b66 r217590b 69 69 ["sld_solvent", "1e-6/Ang^2", 3.0, [-inf, inf], "sld", "Solvent scattering length density"], 70 70 ["volfraction", "", 1.0, [0.0, inf], "", "Volume fraction of building block spheres"], 71 ["fractal_dim", "", 2.0, [ 1.0, 6.0], "", "Fractal dimension"],71 ["fractal_dim", "", 2.0, [0.0, 6.0], "", "Fractal dimension"], 72 72 ["cor_length", "Ang", 100.0, [0.0, inf], "", "Correlation length of fractal-like aggregates"], 73 73 ] 74 74 # pylint: enable=bad-whitespace, line-too-long 75 75 76 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/core_shell.c", "fractal_core_shell.c"] 76 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/core_shell.c", 77 "lib/fractal_sq.c", "fractal_core_shell.c"] 77 78 78 79 demo = dict(scale=0.05, -
sasmodels/models/lib/sas_gamma.c
r1596de3 r217590b 137 137 138 138 139 inline double sas_gamma( double x) { return tgamma(x+1)/x; } 139 inline double sas_gamma(double x) { 140 #if 1 141 // Fast reliable gamma in [-n,171], where n is a small integer 142 double norm = 1.; 143 while (x < 1.) { 144 norm *= x; 145 x += 1.0; 146 } 147 return tgamma(x)/norm; 148 #else 149 // Fast reliable gamma in [0,170] 150 return tgamma(x+1)/x; 151 #endif 152 }
Note: See TracChangeset
for help on using the changeset viewer.