Changeset 71b751d in sasmodels
- Timestamp:
- Aug 14, 2018 12:09:34 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 86aa992
- Parents:
- 2f8cbb9
- Location:
- sasmodels
- Files:
-
- 66 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r7e923c2 r71b751d 364 364 actual = [p.name for p in model.info.parameters.kernel_parameters] 365 365 target = ("sld sld_solvent radius length theta phi volfraction" 366 " A_sld A_sld_solvent A_radius").split()366 " beta_mode A_sld A_sld_solvent A_radius").split() 367 367 assert target == actual, "%s != %s"%(target, actual) 368 368 -
sasmodels/models/barbell.c
r108e70e r71b751d 62 62 } 63 63 64 static double65 Iq(double q, double sld, double solvent_sld,64 static void 65 Fq(double q,double *F1, double *F2, double sld, double solvent_sld, 66 66 double radius_bell, double radius, double length) 67 67 { … … 72 72 const double zm = M_PI_4; 73 73 const double zb = M_PI_4; 74 double total = 0.0; 74 double total_F1 = 0.0; 75 double total_F2 = 0.0; 75 76 for (int i = 0; i < GAUSS_N; i++){ 76 77 const double alpha= GAUSS_Z[i]*zm + zb; … … 78 79 SINCOS(alpha, sin_alpha, cos_alpha); 79 80 const double Aq = _fq(q*sin_alpha, q*cos_alpha, h, radius_bell, radius, half_length); 80 total += GAUSS_W[i] * Aq * Aq * sin_alpha; 81 total_F1 += GAUSS_W[i] * Aq * sin_alpha; 82 total_F2 += GAUSS_W[i] * Aq * Aq * sin_alpha; 81 83 } 82 84 // translate dx in [-1,1] to dx in [lower,upper] 83 const double form = total*zm; 85 const double form_avg = total_F1*zm; 86 const double form_squared_avg = total_F2*zm; 84 87 85 88 //Contrast 86 89 const double s = (sld - solvent_sld); 87 return 1.0e-4 * s * s * form; 90 *F1 = 1.0e-2 * s * form_avg; 91 *F2 = 1.0e-4 * s * s * form_squared_avg; 88 92 } 89 90 93 91 94 static double -
sasmodels/models/barbell.py
r2d81cfe r71b751d 116 116 117 117 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "barbell.c"] 118 have_Fq = True 118 119 119 120 def random(): -
sasmodels/models/binary_hard_sphere.c
r925ad6e r71b751d 1 1 double form_volume(void); 2 2 3 double Iq(double q, 3 double Iq(double q, 4 4 double lg_radius, double sm_radius, 5 5 double lg_vol_frac, double sm_vol_frac, 6 6 double lg_sld, double sm_sld, double solvent_sld 7 7 ); 8 8 9 9 void calculate_psfs(double qval, 10 10 double r2, double nf2, … … 22 22 double lg_vol_frac, double sm_vol_frac, 23 23 double lg_sld, double sm_sld, double solvent_sld) 24 25 24 { 26 25 double r2,r1,nf2,phi,aa,rho2,rho1,rhos,inten; //my local names … … 28 27 double phi1,phi2,phr,a3; 29 28 double v1,v2,n1,n2,qr1,qr2,b1,b2,sc1,sc2; 30 29 31 30 r2 = lg_radius; 32 31 r1 = sm_radius; … … 36 35 rho1 = sm_sld; 37 36 rhos = solvent_sld; 38 39 37 38 40 39 phi = phi1 + phi2; 41 40 aa = r1/r2; … … 46 45 // calculate the PSF's here 47 46 calculate_psfs(q,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 48 47 49 48 // /* do form factor calculations */ 50 49 51 50 v1 = M_4PI_3*r1*r1*r1; 52 51 v2 = M_4PI_3*r2*r2*r2; 53 52 54 53 n1 = phi1/v1; 55 54 n2 = phi2/v2; 56 55 57 56 qr1 = r1*q; 58 57 qr2 = r2*q; … … 68 67 inten *= 1.0e8; 69 68 ///*convert rho^2 in 10^-6A to A*/ 70 inten *= 1.0e-12; 69 inten *= 1.0e-12; 71 70 return(inten); 72 71 } … … 77 76 double aa, double phi, 78 77 double *s11, double *s22, double *s12) 79 80 78 { 81 79 // variable qval,r2,nf2,aa,phi,&s11,&s22,&s12 82 80 83 81 // calculate constant terms 84 82 double s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4; … … 87 85 double c11,c22,c12,f12,f22,ttt1,ttt2,ttt3,ttt4,yl,y13; 88 86 double t21,t22,t23,t31,t32,t33,t41,t42,yl3,wma3,y1; 89 87 90 88 s2 = 2.0*r2; 91 89 // s1 = aa*s2; why is this never used? check original paper? … … 108 106 gm1=(v1*a1+a3*v2*a2)*.5; 109 107 gm12=2.*gm1*(1.-aa)/aa; 110 //c 108 //c 111 109 //c calculate the direct correlation functions and print results 112 110 //c 113 111 // do 20 j=1,npts 114 112 115 113 yy=qval*s2; 116 114 //c calculate direct correlation functions … … 123 121 t3=gm1*((4.*ay*ay2-24.*ay)*sin(ay)-(ay2*ay2-12.*ay2+24.)*cos(ay)+24.)/ay3; 124 122 f11=24.*v1*(t1+t2+t3)/ay3; 125 123 126 124 //c ------c22 127 125 y2=yy*yy; … … 131 129 tt3=gm1*((4.*y3-24.*yy)*sin(yy)-(y2*y2-12.*y2+24.)*cos(yy)+24.)/ay3; 132 130 f22=24.*v2*(tt1+tt2+tt3)/y3; 133 131 134 132 //c -----c12 135 133 yl=.5*yy*(1.-aa); … … 151 149 ttt4=a1*(t41+t42)/y1; 152 150 f12=ttt1+24.*v*sqrt(nf2)*sqrt(1.-nf2)*a3*(ttt2+ttt3+ttt4)/(nf2+(1.-nf2)*a3); 153 151 154 152 c11=f11; 155 153 c22=f22; 156 154 c12=f12; 157 155 *s11=1./(1.+c11-(c12)*c12/(1.+c22)); 158 *s22=1./(1.+c22-(c12)*c12/(1.+c11)); 159 *s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12)); 160 156 *s22=1./(1.+c22-(c12)*c12/(1.+c11)); 157 *s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12)); 158 161 159 return; 162 160 } 163 -
sasmodels/models/capped_cylinder.c
r108e70e r71b751d 84 84 } 85 85 86 static double87 Iq(double q, double sld, double solvent_sld,86 static void 87 Fq(double q,double *F1, double *F2, double sld, double solvent_sld, 88 88 double radius, double radius_cap, double length) 89 89 { … … 94 94 const double zm = M_PI_4; 95 95 const double zb = M_PI_4; 96 double total = 0.0; 96 double total_F1 = 0.0; 97 double total_F2 = 0.0; 97 98 for (int i=0; i<GAUSS_N ;i++) { 98 99 const double theta = GAUSS_Z[i]*zm + zb; … … 103 104 const double Aq = _fq(qab, qc, h, radius_cap, radius, half_length); 104 105 // scale by sin_theta for spherical coord integration 105 total += GAUSS_W[i] * Aq * Aq * sin_theta; 106 total_F1 += GAUSS_W[i] * Aq * sin_theta; 107 total_F2 += GAUSS_W[i] * Aq * Aq * sin_theta; 106 108 } 107 109 // translate dx in [-1,1] to dx in [lower,upper] 108 const double form = total * zm; 110 const double form_avg = total_F1 * zm; 111 const double form_squared_avg = total_F2 * zm; 109 112 110 113 // Contrast 111 114 const double s = (sld - solvent_sld); 112 return 1.0e-4 * s * s * form; 115 *F1 = 1.0e-2 * s * form_avg; 116 *F2 = 1.0e-4 * s * s * form_squared_avg; 113 117 } 114 118 -
sasmodels/models/capped_cylinder.py
r2d81cfe r71b751d 136 136 137 137 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] 138 have_Fq = True 138 139 139 140 def random(): -
sasmodels/models/core_multi_shell.c
rc3ccaec r71b751d 19 19 } 20 20 21 static double22 Iq(double q, double core_sld, double core_radius,21 static void 22 Fq(double q, double *F1, double *F2, double core_sld, double core_radius, 23 23 double solvent_sld, double fp_n, double sld[], double thickness[]) 24 24 { … … 34 34 } 35 35 f += M_4PI_3 * cube(r) * (solvent_sld - last_sld) * sas_3j1x_x(q*r); 36 return f * f * 1.0e-4; 36 *F1 = 1e-2 * f; 37 *F2 = 1e-4 * f * f; 37 38 } -
sasmodels/models/core_multi_shell.py
r2d81cfe r71b751d 99 99 100 100 source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] 101 have_Fq = True 101 102 102 103 def random(): -
sasmodels/models/core_shell_bicelle.c
r108e70e r71b751d 36 36 } 37 37 38 static double 39 Iq(double q, 38 static void 39 Fq(double q, 40 double *F1, 41 double *F2, 40 42 double radius, 41 43 double thick_radius, … … 51 53 const double halflength = 0.5*length; 52 54 53 double total = 0.0; 55 double total_F1 = 0.0; 56 double total_F2 = 0.0; 54 57 for(int i=0;i<GAUSS_N;i++) { 55 58 double theta = (GAUSS_Z[i] + 1.0)*uplim; 56 59 double sin_theta, cos_theta; // slots to hold sincos function output 57 60 SINCOS(theta, sin_theta, cos_theta); 58 double f q= bicelle_kernel(q*sin_theta, q*cos_theta, radius, thick_radius, thick_face,61 double form = bicelle_kernel(q*sin_theta, q*cos_theta, radius, thick_radius, thick_face, 59 62 halflength, sld_core, sld_face, sld_rim, sld_solvent); 60 total += GAUSS_W[i]*fq*fq*sin_theta; 63 total_F1 += GAUSS_W[i]*form*sin_theta; 64 total_F2 += GAUSS_W[i]*form*form*sin_theta; 61 65 } 66 // Correct for integration range 67 total_F1 *= uplim; 68 total_F2 *= uplim; 62 69 63 // calculate value of integral to return 64 double answer = total*uplim; 65 return 1.0e-4*answer; 70 *F1 = 1.0e-2*total_F1; 71 *F2 = 1.0e-4*total_F2; 66 72 } 67 73 -
sasmodels/models/core_shell_bicelle.py
r2d81cfe r71b751d 154 154 source = ["lib/sas_Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", 155 155 "core_shell_bicelle.c"] 156 have_Fq = True 156 157 157 158 def random(): -
sasmodels/models/core_shell_bicelle_elliptical.c
r108e70e r71b751d 10 10 } 11 11 12 static double 13 Iq(double q, 12 static void 13 Fq(double q, 14 double *F1, 15 double *F2, 14 16 double r_minor, 15 17 double x_core, … … 36 38 37 39 //initialize integral 38 double outer_sum = 0.0; 40 double outer_total_F1 = 0.0; 41 double outer_total_F2 = 0.0; 39 42 for(int i=0;i<GAUSS_N;i++) { 40 43 //setup inner integral over the ellipsoidal cross-section 41 //const double va = 0.0;42 //const double vb = 1.0;43 44 //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; 44 45 const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0; … … 48 49 const double si1 = sas_sinx_x(halfheight*qc); 49 50 const double si2 = sas_sinx_x((halfheight+thick_face)*qc); 50 double inner_sum=0.0; 51 double inner_total_F1 = 0; 52 double inner_total_F2 = 0; 51 53 for(int j=0;j<GAUSS_N;j++) { 52 54 //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe) 53 // inner integral limits 54 //const double vaj=0.0; 55 //const double vbj=M_PI; 56 //const double phi = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; 57 const double phi = ( GAUSS_Z[j] +1.0)*M_PI_2; 58 const double rr = sqrt(r2A - r2B*cos(phi)); 55 //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; 56 const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2; 57 const double rr = sqrt(r2A - r2B*cos(beta)); 59 58 const double be1 = sas_2J1x_x(rr*qab); 60 59 const double be2 = sas_2J1x_x((rr+thick_rim)*qab); 61 const double f q= dr1*si1*be1 + dr2*si2*be2 + dr3*si2*be1;60 const double f = dr1*si1*be1 + dr2*si2*be2 + dr3*si2*be1; 62 61 63 inner_sum += GAUSS_W[j] * fq * fq; 62 inner_total_F1 += GAUSS_W[j] * f; 63 inner_total_F2 += GAUSS_W[j] * f * f; 64 64 } 65 65 //now calculate outer integral 66 outer_sum += GAUSS_W[i] * inner_sum; 66 outer_total_F1 += GAUSS_W[i] * inner_total_F1; 67 outer_total_F2 += GAUSS_W[i] * inner_total_F2; 67 68 } 69 // now complete change of integration variables (1-0)/(1-(-1))= 0.5 70 outer_total_F1 *= 0.25; 71 outer_total_F2 *= 0.25; 68 72 69 return outer_sum*2.5e-05; 73 //convert from [1e-12 A-1] to [cm-1] 74 *F1 = 1e-2*outer_total_F1; 75 *F2 = 1e-4*outer_total_F2; 70 76 } 71 77 -
sasmodels/models/core_shell_bicelle_elliptical.py
rfc3ae1b r71b751d 146 146 source = ["lib/sas_Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", 147 147 "core_shell_bicelle_elliptical.c"] 148 have_Fq = True 148 149 149 150 def random(): -
sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c
r108e70e r71b751d 11 11 } 12 12 13 static double 14 Iq(double q, 13 static void 14 Fq(double q, 15 double *F1, 16 double *F2, 15 17 double r_minor, 16 18 double x_core, … … 24 26 double sigma) 25 27 { 26 double si1,si2,be1,be2;27 28 // core_shell_bicelle_elliptical_belt, RKH 5th Oct 2017, core_shell_bicelle_elliptical 28 29 // tested briefly against limiting cases of cylinder, hollow cylinder & elliptical cylinder models … … 38 39 const double r2A = 0.5*(square(r_major) + square(r_minor)); 39 40 const double r2B = 0.5*(square(r_major) - square(r_minor)); 41 const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight); 42 const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight; 43 const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); 40 44 // dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face, 41 const double dr1 = (-rhor - rhoh + rhoc + rhosolv) *M_PI*r_minor*r_major* 42 2.0*halfheight; 43 const double dr2 = (rhor-rhosolv) *M_PI*(r_minor+thick_rim)*( 44 r_major+thick_rim)* 2.0*halfheight; 45 const double dr3 = (rhoh-rhosolv) *M_PI*r_minor*r_major* 46 2.0*(halfheight+thick_face); 45 const double dr1 = vol1*(-rhor - rhoh + rhoc + rhosolv); 46 const double dr2 = vol2*(rhor-rhosolv); 47 const double dr3 = vol3*(rhoh-rhosolv); 48 47 49 //initialize integral 48 double outer_sum = 0.0; 50 double outer_total_F1 = 0.0; 51 double outer_total_F2 = 0.0; 49 52 for(int i=0;i<GAUSS_N;i++) { 50 53 //setup inner integral over the ellipsoidal cross-section 51 54 // since we generate these lots of times, why not store them somewhere? 52 //const double cos_alpha = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; 53 const double cos_alpha = ( GAUSS_Z[i] + 1.0 )/2.0; 54 const double sin_alpha = sqrt(1.0 - cos_alpha*cos_alpha); 55 double inner_sum=0; 56 double sinarg1 = q*halfheight*cos_alpha; 57 double sinarg2 = q*(halfheight+thick_face)*cos_alpha; 58 si1 = sas_sinx_x(sinarg1); 59 si2 = sas_sinx_x(sinarg2); 55 //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; 56 const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0; 57 const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); 58 const double qab = q*sin_theta; 59 const double qc = q*cos_theta; 60 const double si1 = sas_sinx_x(halfheight*qc); 61 const double si2 = sas_sinx_x((halfheight+thick_face)*qc); 62 double inner_total_F1 = 0; 63 double inner_total_F2 = 0; 60 64 for(int j=0;j<GAUSS_N;j++) { 61 65 //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe) … … 63 67 const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2; 64 68 const double rr = sqrt(r2A - r2B*cos(beta)); 65 double besarg1 = q*rr*sin_alpha; 66 double besarg2 = q*(rr+thick_rim)*sin_alpha; 67 be1 = sas_2J1x_x(besarg1); 68 be2 = sas_2J1x_x(besarg2); 69 inner_sum += GAUSS_W[j] *square(dr1*si1*be1 + 70 dr2*si1*be2 + 71 dr3*si2*be1); 69 const double be1 = sas_2J1x_x(rr*qab); 70 const double be2 = sas_2J1x_x((rr+thick_rim)*qab); 71 const double f = dr1*si1*be1 + dr2*si1*be2 + dr3*si2*be1; 72 73 inner_total_F1 += GAUSS_W[j] * f; 74 inner_total_F2 += GAUSS_W[j] * f * f; 72 75 } 73 76 //now calculate outer integral 74 outer_sum += GAUSS_W[i] * inner_sum; 77 outer_total_F1 += GAUSS_W[i] * inner_total_F1; 78 outer_total_F2 += GAUSS_W[i] * inner_total_F2; 75 79 } 80 // now complete change of integration variables (1-0)/(1-(-1))= 0.5 81 outer_total_F1 *= 0.25; 82 outer_total_F2 *= 0.25; 76 83 77 return outer_sum*2.5e-05*exp(-0.5*square(q*sigma)); 84 //convert from [1e-12 A-1] to [cm-1] 85 *F1 = 1e-2*outer_total_F1*exp(-0.25*square(q*sigma)); 86 *F2 = 1e-4*outer_total_F2*exp(-0.5*square(q*sigma)); 78 87 } 79 88 … … 111 120 const double si1 = sas_sinx_x( halfheight*qc ); 112 121 const double si2 = sas_sinx_x( (halfheight + thick_face)*qc ); 113 const double Aq = square( vol1*dr1*si1*be1 + vol2*dr2*si1*be2 + vol3*dr3*si2*be1); 114 return 1.0e-4 * Aq*exp(-0.5*(square(qa) + square(qb) + square(qc) )*square(sigma)); 122 const double fq = vol1*dr1*si1*be1 + vol2*dr2*si1*be2 + vol3*dr3*si2*be1; 123 const double atten = exp(-0.5*(qa*qa + qb*qb + qc*qc)*(sigma*sigma)); 124 return 1.0e-4 * fq*fq * atten; 115 125 } -
sasmodels/models/core_shell_bicelle_elliptical_belt_rough.py
rfc3ae1b r71b751d 159 159 source = ["lib/sas_Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", 160 160 "core_shell_bicelle_elliptical_belt_rough.c"] 161 have_Fq = True 161 162 162 163 demo = dict(scale=1, background=0, -
sasmodels/models/core_shell_cylinder.c
rd86f0fc r71b751d 13 13 } 14 14 15 static double 16 Iq(double q, 15 static void 16 Fq(double q, 17 double *F1, 18 double *F2, 17 19 double core_sld, 18 20 double shell_sld, … … 29 31 const double shell_h = (0.5*length + thickness); 30 32 const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld); 31 double total = 0.0; 33 double total_F1 = 0.0; 34 double total_F2 = 0.0; 32 35 for (int i=0; i<GAUSS_N ;i++) { 33 36 // translate a point in [-1,1] to a point in [0, pi/2] … … 40 43 const double fq = _cyl(core_vd, core_r*qab, core_h*qc) 41 44 + _cyl(shell_vd, shell_r*qab, shell_h*qc); 42 total += GAUSS_W[i] * fq * fq * sin_theta; 45 total_F1 += GAUSS_W[i] * fq * sin_theta; 46 total_F2 += GAUSS_W[i] * fq * fq * sin_theta; 43 47 } 44 48 // translate dx in [-1,1] to dx in [lower,upper] 45 49 //const double form = (upper-lower)/2.0*total; 46 return 1.0e-4 * total * M_PI_4; 50 *F1 = 1.0e-2 * total_F1 * M_PI_4; 51 *F2 = 1.0e-4 * total_F2 * M_PI_4; 47 52 } 48 49 53 50 54 static double -
sasmodels/models/core_shell_cylinder.py
r2d81cfe r71b751d 125 125 126 126 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"] 127 have_Fq = True 127 128 128 129 def ER(radius, thickness, length): -
sasmodels/models/core_shell_ellipsoid.c
r108e70e r71b751d 38 38 } 39 39 40 static double 41 Iq(double q, 40 static void 41 Fq(double q, 42 double *F1, 43 double *F2, 42 44 double radius_equat_core, 43 45 double x_core, … … 58 60 const double m = 0.5; 59 61 const double b = 0.5; 60 double total = 0.0; //initialize intergral 62 double total_F1 = 0.0; //initialize intergral 63 double total_F2 = 0.0; //initialize intergral 61 64 for(int i=0;i<GAUSS_N;i++) { 62 65 const double cos_theta = GAUSS_Z[i]*m + b; … … 66 69 equat_shell, polar_shell, 67 70 sld_core_shell, sld_shell_solvent); 68 total += GAUSS_W[i] * fq * fq; 71 total_F1 += GAUSS_W[i] * fq; 72 total_F2 += GAUSS_W[i] * fq * fq; 69 73 } 70 total *= m; 74 total_F1 *= m; 75 total_F2 *= m; 71 76 72 77 // convert to [cm-1] 73 return 1.0e-4 * total; 78 *F1 = 1.0e-2 * total_F1; 79 *F2 = 1.0e-4 * total_F2; 74 80 } 81 75 82 76 83 static double -
sasmodels/models/core_shell_ellipsoid.py
r2d81cfe r71b751d 145 145 146 146 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] 147 have_Fq = True 147 148 148 149 def ER(radius_equat_core, x_core, thick_shell, x_polar_shell): -
sasmodels/models/core_shell_parallelepiped.c
rdbf1a60 r71b751d 27 27 } 28 28 29 static double 30 Iq(double q, 29 static void 30 Fq(double q, 31 double *F1, 32 double *F2, 31 33 double core_sld, 32 34 double arim_sld, … … 60 62 // outer integral (with gauss points), integration limits = 0, 1 61 63 // substitute d_cos_alpha for sin_alpha d_alpha 62 double outer_sum = 0; //initialize integral 64 double outer_sum_F1 = 0; //initialize integral 65 double outer_sum_F2 = 0; //initialize integral 63 66 for( int i=0; i<GAUSS_N; i++) { 64 67 const double cos_alpha = 0.5 * ( GAUSS_Z[i] + 1.0 ); … … 69 72 // inner integral (with gauss points), integration limits = 0, 1 70 73 // substitute beta = PI/2 u (so 2/PI * d_(PI/2 * beta) = d_beta) 71 double inner_sum = 0.0; 74 double inner_sum_F1 = 0.0; 75 double inner_sum_F2 = 0.0; 72 76 for(int j=0; j<GAUSS_N; j++) { 73 77 const double u = 0.5 * ( GAUSS_Z[j] + 1.0 ); … … 91 95 #endif 92 96 93 inner_sum += GAUSS_W[j] * f * f; 97 inner_sum_F1 += GAUSS_W[j] * f; 98 inner_sum_F2 += GAUSS_W[j] * f * f; 94 99 } 95 100 // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 96 inner_sum *= 0.5;97 // now sum up the outer integral98 outer_sum += GAUSS_W[i] * inner_sum;101 // and sum up the outer integral 102 outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * 0.5; 103 outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * 0.5; 99 104 } 100 105 // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 101 outer_sum *= 0.5; 106 outer_sum_F1 *= 0.5; 107 outer_sum_F2 *= 0.5; 102 108 103 109 //convert from [1e-12 A-1] to [cm-1] 104 return 1.0e-4 * outer_sum; 110 *F1 = 1.0e-2 * outer_sum_F1; 111 *F2 = 1.0e-4 * outer_sum_F2; 105 112 } 106 113 -
sasmodels/models/core_shell_parallelepiped.py
rf89ec96 r71b751d 226 226 227 227 source = ["lib/gauss76.c", "core_shell_parallelepiped.c"] 228 have_Fq = True 228 229 229 230 -
sasmodels/models/core_shell_sphere.c
r3a48772 r71b751d 1 double form_volume(double radius, double thickness); 2 double Iq(double q, double radius, double thickness, double core_sld, double shell_sld, double solvent_sld); 1 static double 2 form_volume(double radius, double thickness) 3 { 4 return M_4PI_3 * cube(radius + thickness); 5 } 3 6 4 double Iq(double q, double radius, double thickness, double core_sld, double shell_sld, double solvent_sld) { 5 6 7 double intensity = core_shell_kernel(q,7 static void 8 Fq(double q, double *F1, double *F2, double radius, 9 double thickness, double core_sld, double shell_sld, double solvent_sld) { 10 double form = core_shell_fq(q, 8 11 radius, 9 12 thickness, … … 11 14 shell_sld, 12 15 solvent_sld); 13 return intensity; 16 *F1 = 1.0e-2*form; 17 *F2 = 1.0e-4*form*form; 14 18 } 15 16 double form_volume(double radius, double thickness)17 {18 return M_4PI_3 * cube(radius + thickness);19 } -
sasmodels/models/core_shell_sphere.py
rc036ddb r71b751d 77 77 78 78 source = ["lib/sas_3j1x_x.c", "lib/core_shell.c", "core_shell_sphere.c"] 79 have_Fq = True 79 80 80 81 demo = dict(scale=1, background=0, radius=60, thickness=10, -
sasmodels/models/cylinder.c
r108e70e r71b751d 8 8 9 9 static double 10 fq(double qab, double qc, double radius, double length)10 _fq(double qab, double qc, double radius, double length) 11 11 { 12 12 return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length); 13 13 } 14 14 15 static double 16 orient_avg_1D(double q, double radius, double length) 15 static void 16 Fq(double q, 17 double *F1, 18 double *F2, 19 double sld, 20 double solvent_sld, 21 double radius, 22 double length) 17 23 { 18 24 // translate a point in [-1,1] to a point in [0, pi/2] … … 20 26 const double zb = M_PI_4; 21 27 22 double total = 0.0; 28 double total_F1 = 0.0; 29 double total_F2 = 0.0; 23 30 for (int i=0; i<GAUSS_N ;i++) { 24 31 const double theta = GAUSS_Z[i]*zm + zb; … … 26 33 // theta (theta,phi) the projection of the cylinder on the detector plane 27 34 SINCOS(theta , sin_theta, cos_theta); 28 const double form = fq(q*sin_theta, q*cos_theta, radius, length); 29 total += GAUSS_W[i] * form * form * sin_theta; 35 const double form = _fq(q*sin_theta, q*cos_theta, radius, length); 36 total_F1 += GAUSS_W[i] * form * sin_theta; 37 total_F2 += GAUSS_W[i] * form * form * sin_theta; 30 38 } 31 39 // translate dx in [-1,1] to dx in [lower,upper] 32 return total*zm; 40 total_F1 *= zm; 41 total_F2 *= zm; 42 const double s = (sld - solvent_sld) * form_volume(radius, length); 43 *F1 = 1e-2 * s * total_F1; 44 *F2 = 1e-4 * s * s * total_F2; 33 45 } 34 46 35 static double 36 Iq(double q, 37 double sld, 38 double solvent_sld, 39 double radius, 40 double length) 41 { 42 const double s = (sld - solvent_sld) * form_volume(radius, length); 43 return 1.0e-4 * s * s * orient_avg_1D(q, radius, length); 44 } 47 45 48 46 49 static double … … 51 54 double length) 52 55 { 56 const double form = _fq(qab, qc, radius, length); 53 57 const double s = (sld-solvent_sld) * form_volume(radius, length); 54 const double form = fq(qab, qc, radius, length);55 58 return 1.0e-4 * square(s * form); 56 59 } 60 -
sasmodels/models/cylinder.py
r2d81cfe r71b751d 138 138 139 139 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 140 have_Fq = True 140 141 141 142 def ER(radius, length): -
sasmodels/models/ellipsoid.c
rc036ddb r71b751d 4 4 return M_4PI_3*radius_polar*radius_equatorial*radius_equatorial; 5 5 } 6 7 /* Fq overrides Iq8 static double9 Iq(double q,10 double sld,11 double sld_solvent,12 double radius_polar,13 double radius_equatorial)14 {15 // Using ratio v = Rp/Re, we can implement the form given in Guinier (1955)16 // i(h) = int_0^pi/2 Phi^2(h a sqrt(cos^2 + v^2 sin^2) cos dT17 // = int_0^pi/2 Phi^2(h a sqrt((1-sin^2) + v^2 sin^2) cos dT18 // = int_0^pi/2 Phi^2(h a sqrt(1 + sin^2(v^2-1)) cos dT19 // u-substitution of20 // u = sin, du = cos dT21 // i(h) = int_0^1 Phi^2(h a sqrt(1 + u^2(v^2-1)) du22 const double v_square_minus_one = square(radius_polar/radius_equatorial) - 1.0;23 24 // translate a point in [-1,1] to a point in [0, 1]25 // const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper+lower)/2;26 const double zm = 0.5;27 const double zb = 0.5;28 double total = 0.0;29 for (int i=0;i<GAUSS_N;i++) {30 const double u = GAUSS_Z[i]*zm + zb;31 const double r = radius_equatorial*sqrt(1.0 + u*u*v_square_minus_one);32 const double f = sas_3j1x_x(q*r);33 total += GAUSS_W[i] * f * f;34 }35 // translate dx in [-1,1] to dx in [lower,upper]36 const double form = total*zm;37 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial);38 return 1.0e-4 * s * s * form;39 }40 */41 6 42 7 static void … … 71 36 } 72 37 // translate dx in [-1,1] to dx in [lower,upper] 73 const double form_squared_avg = total_F2*zm;74 const double form_avg = total_F1*zm;38 total_F1 *= zm; 39 total_F2 *= zm; 75 40 const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 76 *F1 = 1e-2 * s * form_avg;77 *F2 = 1e-4 * s * s * form_squared_avg;41 *F1 = 1e-2 * s * total_F1; 42 *F2 = 1e-4 * s * s * total_F2; 78 43 } 79 44 -
sasmodels/models/ellipsoid.py
rc036ddb r71b751d 163 163 164 164 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"] 165 166 165 have_Fq = True 167 166 -
sasmodels/models/elliptical_cylinder.c
r108e70e r71b751d 5 5 } 6 6 7 static double8 Iq(double q, double radius_minor, double r_ratio, double length,7 static void 8 Fq(double q, double *F1, double *F2, double radius_minor, double r_ratio, double length, 9 9 double sld, double solvent_sld) 10 10 { … … 21 21 22 22 //initialize integral 23 double outer_sum = 0.0; 23 double outer_sum_F1 = 0.0; 24 double outer_sum_F2 = 0.0; 24 25 for(int i=0;i<GAUSS_N;i++) { 25 26 //setup inner integral over the ellipsoidal cross-section … … 27 28 const double sin_val = sqrt(1.0 - cos_val*cos_val); 28 29 //const double arg = radius_minor*sin_val; 29 double inner_sum=0; 30 double inner_sum_F1 = 0.0; 31 double inner_sum_F2 = 0.0; 30 32 for(int j=0;j<GAUSS_N;j++) { 31 33 const double theta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; 32 34 const double r = sin_val*sqrt(rA - rB*cos(theta)); 33 35 const double be = sas_2J1x_x(q*r); 34 inner_sum += GAUSS_W[j] * be * be; 36 inner_sum_F1 += GAUSS_W[j] * be; 37 inner_sum_F2 += GAUSS_W[j] * be * be; 35 38 } 36 39 //now calculate the value of the inner integral 37 inner_sum *= 0.5*(vbj-vaj); 40 inner_sum_F1 *= 0.5*(vbj-vaj); 41 inner_sum_F2 *= 0.5*(vbj-vaj); 38 42 39 43 //now calculate outer integral 40 44 const double si = sas_sinx_x(q*0.5*length*cos_val); 41 outer_sum += GAUSS_W[i] * inner_sum * si * si; 45 outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * si; 46 outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * si * si; 42 47 } 43 outer_sum *= 0.5*(vb-va); 44 45 //divide integral by Pi 46 const double form = outer_sum/M_PI; 48 // correct limits and divide integral by pi 49 outer_sum_F1 *= 0.5*(vb-va)/M_PI; 50 outer_sum_F2 *= 0.5*(vb-va)/M_PI; 47 51 48 52 // scale by contrast and volume, and convert to to 1/cm units 49 const double vol = form_volume(radius_minor, r_ratio, length); 50 const double delrho = sld - solvent_sld; 51 return 1.0e-4*square(delrho*vol)*form; 53 const double volume = form_volume(radius_minor, r_ratio, length); 54 const double contrast = sld - solvent_sld; 55 const double s = contrast*volume; 56 *F1 = 1.0e-2*s*outer_sum_F1; 57 *F2 = 1.0e-4*s*s*outer_sum_F2; 52 58 } 53 59 … … 63 69 const double be = sas_2J1x_x(qr); 64 70 const double si = sas_sinx_x(qc*0.5*length); 65 const double Aq = be * si;66 const double delrho= sld - solvent_sld;67 const double vol = form_volume(radius_minor, r_ratio, length);68 return 1.0e-4 * square( delrho * vol * Aq);71 const double fq = be * si; 72 const double contrast = sld - solvent_sld; 73 const double volume = form_volume(radius_minor, r_ratio, length); 74 return 1.0e-4 * square(contrast * volume * fq); 69 75 } -
sasmodels/models/elliptical_cylinder.py
ra261a83 r71b751d 122 122 123 123 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "elliptical_cylinder.c"] 124 have_Fq = True 124 125 125 126 demo = dict(scale=1, background=0, radius_minor=100, axis_ratio=1.5, length=400.0, -
sasmodels/models/fcc_paracrystal.c
r108e70e r71b751d 79 79 } 80 80 81 82 81 static double Iqabc(double qa, double qb, double qc, 83 82 double dnn, double d_factor, double radius, -
sasmodels/models/flexible_cylinder_elliptical.c
r74768cb r71b751d 72 72 return result; 73 73 } 74 -
sasmodels/models/fractal.c
r4788822 r71b751d 19 19 20 20 //calculate P(q) for the spherical subunits 21 const double pq = square(form_volume(radius) * (sld_block-sld_solvent)22 *sas_3j1x_x(q*radius) );21 const double fq = form_volume(radius) * (sld_block-sld_solvent) 22 *sas_3j1x_x(q*radius); 23 23 24 24 // scale to units cm-1 sr-1 (assuming data on absolute scale) … … 27 27 // combined: 1e-4 * I(q) 28 28 29 return 1.e-4 * volfraction * sq * pq;29 return 1.e-4 * volfraction * sq * fq * fq; 30 30 } 31 -
sasmodels/models/fractal_core_shell.c
rbdd08df r71b751d 16 16 double cor_length) 17 17 { 18 //The radius for the building block of the core shell particle that is 18 //The radius for the building block of the core shell particle that is 19 19 //needed by the Teixeira fractal S(q) is the radius of the whole particle. 20 20 const double cs_radius = radius + thickness; 21 21 const double sq = fractal_sq(q, cs_radius, fractal_dim, cor_length); 22 const double pq = core_shell_kernel(q, radius, thickness,23 22 const double fq = core_shell_fq(q, radius, thickness, 23 core_sld, shell_sld, solvent_sld); 24 24 25 25 // Note: core_shell_kernel already performs the 1e-4 unit conversion 26 return volfraction * sq * pq;26 return 1.0e-4 * volfraction * sq * fq * fq; 27 27 } 28 -
sasmodels/models/fuzzy_sphere.py
r2d81cfe r71b751d 83 83 84 84 source = ["lib/sas_3j1x_x.c"] 85 have_Fq = True 85 86 86 # No volume normalization despite having a volume parameter 87 # This should perhaps be volume normalized? 88 form_volume = """ 87 c_code = """ 88 static double form_volume(double radius) 89 { 89 90 return M_4PI_3*cube(radius); 90 """ 91 } 91 92 92 Iq = """ 93 static void Fq(double q, double *F1, double *F2, double sld, double sld_solvent, 94 double radius, double fuzziness) 95 { 93 96 const double qr = q*radius; 94 97 const double bes = sas_3j1x_x(qr); 95 const double qf = q*fuzziness; 96 const double fq = bes * (sld - sld_solvent) * form_volume(radius) * exp(-0.5*qf*qf); 97 return 1.0e-4*fq*fq; 98 """ 98 const double qf = exp(-0.5*square(q*fuzziness)); 99 const double contrast = (sld - sld_solvent); 100 const double form = contrast * form_volume(radius) * bes * qf; 101 *F1 = 1.0e-2*form; 102 *F2 = 1.0e-4*form*form; 103 } 104 """ 99 105 100 106 def ER(radius): -
sasmodels/models/hardsphere.py
r2d81cfe r71b751d 62 62 63 63 # ["name", "units", default, [lower, upper], "type","description"], 64 parameters = [["radius_effective", "Ang", 50.0, [0, inf], " volume",64 parameters = [["radius_effective", "Ang", 50.0, [0, inf], "", 65 65 "effective radius of hard sphere"], 66 66 ["volfraction", "", 0.2, [0, 0.74], "", 67 67 "volume fraction of hard spheres"], 68 68 ] 69 70 # No volume normalization despite having a volume parameter71 # This should perhaps be volume normalized?72 form_volume = """73 return 1.0;74 """75 69 76 70 Iq = r""" -
sasmodels/models/hollow_cylinder.c
r108e70e r71b751d 1 1 //#define INVALID(v) (v.radius_core >= v.radius) 2 3 // From Igor library4 static double5 _hollow_cylinder_scaling(double integrand, double delrho, double volume)6 {7 return 1.0e-4 * square(volume * delrho) * integrand;8 }9 2 10 3 static double … … 30 23 31 24 32 static double33 Iq(double q, double radius, double thickness, double length,25 static void 26 Fq(double q, double *F1, double *F2, double radius, double thickness, double length, 34 27 double sld, double solvent_sld) 35 28 { … … 37 30 const double upper = 1.0; //limits of numerical integral 38 31 39 double summ = 0.0; //initialize intergral 32 double total_F1 = 0.0; //initialize intergral 33 double total_F2 = 0.0; 40 34 for (int i=0;i<GAUSS_N;i++) { 41 35 const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper ); … … 43 37 const double form = _fq(q*sin_theta, q*cos_theta, 44 38 radius, thickness, length); 45 summ += GAUSS_W[i] * form * form; 39 total_F1 += GAUSS_W[i] * form; 40 total_F2 += GAUSS_W[i] * form * form; 46 41 } 42 total_F1 *= 0.5*(upper-lower); 43 total_F2 *= 0.5*(upper-lower); 44 const double s = (sld - solvent_sld) * form_volume(radius, thickness, length); 45 *F1 = 1e-2 * s * total_F1; 46 *F2 = 1e-4 * s*s * total_F2; 47 } 47 48 48 const double Aq = 0.5*summ*(upper-lower);49 const double volume = form_volume(radius, thickness, length);50 return _hollow_cylinder_scaling(Aq, solvent_sld - sld, volume);51 }52 49 53 50 static double … … 57 54 { 58 55 const double form = _fq(qab, qc, radius, thickness, length); 59 60 const double vol = form_volume(radius, thickness, length); 61 return _hollow_cylinder_scaling(form*form, solvent_sld-sld, vol); 56 const double s = (sld - solvent_sld) * form_volume(radius, thickness, length); 57 return 1.0e-4*square(s * form); 62 58 } -
sasmodels/models/hollow_cylinder.py
r2d81cfe r71b751d 89 89 90 90 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 91 have_Fq = True 91 92 92 93 # pylint: disable=W0613 -
sasmodels/models/hollow_rectangular_prism.c
rd86f0fc r71b751d 13 13 } 14 14 15 static double 16 Iq(double q, 15 static void 16 Fq(double q, 17 double *F1, 18 double *F2, 17 19 double sld, 18 20 double solvent_sld, … … 36 38 const double v2b = M_PI_2; //phi integration limits 37 39 38 double outer_sum = 0.0; 40 double outer_sum_F1 = 0.0; 41 double outer_sum_F2 = 0.0; 39 42 for(int i=0; i<GAUSS_N; i++) { 40 43 … … 46 49 const double termC2 = sas_sinx_x(q * (c_half-thickness)*cos(theta)); 47 50 48 double inner_sum = 0.0; 51 double inner_sum_F1 = 0.0; 52 double inner_sum_F2 = 0.0; 49 53 for(int j=0; j<GAUSS_N; j++) { 50 54 … … 64 68 const double AP2 = vol_core * termA2 * termB2 * termC2; 65 69 66 inner_sum += GAUSS_W[j] * square(AP1-AP2); 70 inner_sum_F1 += GAUSS_W[j] * (AP1-AP2); 71 inner_sum_F2 += GAUSS_W[j] * square(AP1-AP2); 67 72 } 68 inner_sum *= 0.5 * (v2b-v2a); 73 inner_sum_F1 *= 0.5 * (v2b-v2a); 74 inner_sum_F2 *= 0.5 * (v2b-v2a); 69 75 70 outer_sum += GAUSS_W[i] * inner_sum * sin(theta); 76 outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin(theta); 77 outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin(theta); 71 78 } 72 outer_sum *= 0.5*(v1b-v1a); 79 outer_sum_F1 *= 0.5*(v1b-v1a); 80 outer_sum_F2 *= 0.5*(v1b-v1a); 73 81 74 82 // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) 75 83 // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) 76 const double form = outer_sum/M_PI_2; 84 const double form_avg = outer_sum_F1/M_PI_2; 85 const double form_squared_avg = outer_sum_F2/M_PI_2; 77 86 78 87 // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. 79 const double delrho= sld - solvent_sld;88 const double contrast = sld - solvent_sld; 80 89 81 90 // Convert from [1e-12 A-1] to [cm-1] 82 return 1.0e-4 * delrho * delrho * form; 91 *F1 = 1.0e-2 * contrast * form_avg; 92 *F2 = 1.0e-4 * contrast * contrast * form_squared_avg; 83 93 } 84 94 -
sasmodels/models/hollow_rectangular_prism.py
r0e55afe r71b751d 142 142 143 143 source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 144 have_Fq = True 144 145 145 146 def ER(length_a, b2a_ratio, c2a_ratio, thickness): -
sasmodels/models/hollow_rectangular_prism_thin_walls.c
rd86f0fc r71b751d 8 8 } 9 9 10 static double 11 Iq(double q, 10 static void 11 Fq(double q, 12 double *F1, 13 double *F2, 12 14 double sld, 13 15 double solvent_sld, … … 28 30 const double v2b = M_PI_2; //phi integration limits 29 31 30 double outer_sum = 0.0; 32 double outer_sum_F1 = 0.0; 33 double outer_sum_F2 = 0.0; 31 34 for(int i=0; i<GAUSS_N; i++) { 32 35 const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); … … 41 44 const double termAT_theta = 8.0 * sin_c / (q*q*sin_theta*cos_theta); 42 45 43 double inner_sum = 0.0; 46 double inner_sum_F1 = 0.0; 47 double inner_sum_F2 = 0.0; 44 48 for(int j=0; j<GAUSS_N; j++) { 45 49 const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); … … 60 64 * ( cos_a*sin_b/cos_phi + cos_b*sin_a/sin_phi ); 61 65 62 inner_sum += GAUSS_W[j] * square(AL+AT); 66 inner_sum_F1 += GAUSS_W[j] * (AL+AT); 67 inner_sum_F2 += GAUSS_W[j] * square(AL+AT); 63 68 } 64 69 65 inner_sum *= 0.5 * (v2b-v2a); 66 outer_sum += GAUSS_W[i] * inner_sum * sin_theta; 70 inner_sum_F1 *= 0.5 * (v2b-v2a); 71 inner_sum_F2 *= 0.5 * (v2b-v2a); 72 outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta; 73 outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta; 67 74 } 68 75 69 outer_sum *= 0.5*(v1b-v1a); 76 outer_sum_F1 *= 0.5*(v1b-v1a); 77 outer_sum_F2 *= 0.5*(v1b-v1a); 70 78 71 79 // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) 72 80 // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) 73 double answer = outer_sum/M_PI_2; 81 const double form_avg = outer_sum_F1/M_PI_2; 82 const double form_squared_avg = outer_sum_F2/M_PI_2; 74 83 75 84 // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. 76 answer *= square(sld-solvent_sld);85 const double contrast = sld - solvent_sld; 77 86 78 87 // Convert from [1e-12 A-1] to [cm-1] 79 answer *= 1.0e-4; 80 81 return answer; 88 *F1 = 1e-2 * contrast * form_avg; 89 *F2 = 1e-4 * contrast * contrast * form_squared_avg; 82 90 } -
sasmodels/models/hollow_rectangular_prism_thin_walls.py
r2d81cfe r71b751d 102 102 103 103 source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] 104 have_Fq = True 104 105 105 106 def ER(length_a, b2a_ratio, c2a_ratio): -
sasmodels/models/lamellar_hg_stack_caille.c
r1c6286d r71b751d 56 56 return inten; 57 57 } 58 -
sasmodels/models/lamellar_stack_caille.c
r1c6286d r71b751d 52 52 return(inten); 53 53 } 54 -
sasmodels/models/lamellar_stack_paracrystal.c
r5467cd8 r71b751d 18 18 int n2 = n1 + 1; 19 19 const double xn = (double)n2 - fp_Nlayers; //fractional contribution of n1 20 20 21 21 const double ww = exp(-0.5*square(qval*pd*davg)); 22 22 … … 27 27 28 28 Znq = xn*Snq; 29 29 30 30 //calculate the n2 contribution 31 31 an = paraCryst_an(ww,qval,davg,n2); … … 33 33 34 34 Znq += (1.0-xn)*Snq; 35 35 36 36 //and the independent contribution 37 37 Znq += (1.0-ww*ww)/(1.0+ww*ww-2.0*ww*cos(qval*davg)); 38 38 39 39 //the limit when Nlayers approaches infinity 40 40 // Zq = (1-ww^2)/(1+ww^2-2*ww*cos(qval*davg)) 41 41 42 42 const double xi = th/2.0; //use 1/2 the bilayer thickness 43 43 const double Pbil = square(sas_sinx_x(qval*xi)); 44 44 45 45 const double contr = sld - solvent_sld; 46 46 const double inten = 2.0*M_PI*contr*contr*Pbil*Znq/(qval*qval); … … 52 52 double 53 53 paraCryst_sn(double ww, double qval, double davg, int Nlayers, double an) { 54 54 55 55 double Snq; 56 56 57 57 Snq = an/( (double)Nlayers*square(1.0+ww*ww-2.0*ww*cos(qval*davg)) ); 58 58 59 59 return Snq; 60 60 } … … 63 63 paraCryst_an(double ww, double qval, double davg, int Nlayers) { 64 64 double an; 65 65 66 66 an = 4.0*ww*ww - 2.0*(ww*ww*ww+ww)*cos(qval*davg); 67 67 an -= 4.0*pow(ww,(Nlayers+2))*cos((double)Nlayers*qval*davg); 68 68 an += 2.0*pow(ww,(Nlayers+3))*cos((double)(Nlayers-1)*qval*davg); 69 69 an += 2.0*pow(ww,(Nlayers+1))*cos((double)(Nlayers+1)*qval*davg); 70 70 71 71 return an; 72 72 } -
sasmodels/models/lib/core_shell.c
r925ad6e r71b751d 7 7 ********************************************************************/ 8 8 static 9 double core_shell_ kernel(double q,9 double core_shell_fq(double q, 10 10 double radius, 11 11 double thickness, 12 12 double core_sld, 13 13 double shell_sld, 14 double solvent_sld) { 14 double solvent_sld) 15 { 15 16 // Core first, then add in shell 16 17 const double core_qr = q * radius; … … 26 27 const double shell_volume = M_4PI_3 * cube(radius + thickness); 27 28 f += shell_volume * shell_bes * shell_contrast; 28 return f * f * 1.0e-4;29 return f; 29 30 } 31 32 // Deprecated function: use core_shell_fq instead. 33 static 34 double core_shell_kernel(double q, 35 double radius, 36 double thickness, 37 double core_sld, 38 double shell_sld, 39 double solvent_sld) 40 { 41 const double fq = core_shell_fq(q, radius, thickness, core_sld, shell_sld, solvent_sld); 42 return 1.0e-4 * fq*fq; 43 } -
sasmodels/models/linear_pearls.c
rc3ccaec r71b751d 46 46 double psi = sas_3j1x_x(q * radius); 47 47 48 // N pearls interaction terms 48 // N pearls interaction terms 49 49 double structure_factor = (double)num_pearls; 50 50 for(int num=1; num<num_pearls; num++) { -
sasmodels/models/mass_surface_fractal.py
r7994359 r71b751d 38 38 39 39 The surface ( $D_s$ ) and mass ( $D_m$ ) fractal dimensions are only 40 valid if $0 < surface\_dim < 6$ , $0 < mass\_dim < 6$, and41 $(surface\_dim + mass\_dim ) < 6$ .40 valid if $0 < surface\_dim < 6$, $0 < mass\_dim < 6$, and 41 $(surface\_dim + mass\_dim ) < 6$. 42 42 Older versions of sasview may have the default primary particle radius 43 larger than the cluster radius, this was an error, also present in the 44 Schmidt review paper below. The primary particle should be the smaller 45 as described in the original Hurd et.al. who also point out that46 polydispersity in the primary particle sizes may affect their 43 larger than the cluster radius, this was an error, also present in the 44 Schmidt review paper below. The primary particle should be the smaller 45 as described in the original Hurd, et al., who also point out that 46 polydispersity in the primary particle sizes may affect their 47 47 apparent surface fractal dimension. 48 48 49 49 50 50 References -
sasmodels/models/multilayer_vesicle.c
rec1d4bc r71b751d 12 12 static double 13 13 multilayer_vesicle_kernel(double q, 14 double volfraction,15 14 double radius, 16 15 double thick_shell, … … 45 44 //unilamellar vesicles (C. Glinka, 11/24/03) 46 45 47 return 1.0e-4*volfraction*fval*fval; // Volume normalization happens in caller46 return fval; // Volume normalization happens in caller 48 47 } 49 48 50 static double 51 Iq(double q, 49 static void 50 Fq(double q, 51 double *F1, 52 double *F2, 52 53 double volfraction, 53 54 double radius, … … 59 60 { 60 61 int n_shells = (int)(fp_n_shells + 0.5); 61 return multilayer_vesicle_kernel(q, 62 volfraction, 62 const double fq = multilayer_vesicle_kernel(q, 63 63 radius, 64 64 thick_shell, … … 67 67 sld, 68 68 n_shells); 69 // See comment in vesicle.c regarding volfraction normalization. 70 *F1 = 1.0e-2 * sqrt(volfraction)*fq; 71 *F2 = 1.0e-4 * volfraction*fq*fq; 69 72 } 70 73 -
sasmodels/models/multilayer_vesicle.py
ref07e95 r71b751d 145 145 146 146 source = ["lib/sas_3j1x_x.c", "multilayer_vesicle.c"] 147 have_Fq = True 147 148 148 149 def ER(radius, thick_shell, thick_solvent, n_shells): -
sasmodels/models/onion.c
rc3ccaec r71b751d 40 40 } 41 41 42 static double43 Iq(double q, double sld_core, double radius_core, double sld_solvent,42 static void 43 Fq(double q, double *F1, double *F2, double sld_core, double radius_core, double sld_solvent, 44 44 double n_shells, double sld_in[], double sld_out[], double thickness[], 45 45 double A[]) … … 55 55 } 56 56 f -= f_exp(q, r_out, sld_solvent, 0.0, 0.0, 0.0, 0.0); 57 const double f2 = f * f * 1.0e-4;58 57 59 return f2; 58 *F1 = 1e-2 * f; 59 *F2 = 1e-4 * f * f; 60 60 } -
sasmodels/models/onion.py
r2d81cfe r71b751d 315 315 source = ["lib/sas_3j1x_x.c", "onion.c"] 316 316 single = False 317 have_Fq = True 317 318 318 319 profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] -
sasmodels/models/parallelepiped.c
rdbf1a60 r71b751d 6 6 7 7 8 static double 9 Iq(double q, 8 static void 9 Fq(double q, 10 double *F1, 11 double *F2, 10 12 double sld, 11 13 double solvent_sld, … … 21 23 22 24 // outer integral (with gauss points), integration limits = 0, 1 23 double outer_total =0; //initialize integral24 25 double outer_total_F1 = 0.0; //initialize integral 26 double outer_total_F2 = 0.0; //initialize integral 25 27 for( int i=0; i<GAUSS_N; i++) { 26 28 const double sigma = 0.5 * ( GAUSS_Z[i] + 1.0 ); … … 29 31 // inner integral (with gauss points), integration limits = 0, 1 30 32 // corresponding to angles from 0 to pi/2. 31 double inner_total = 0.0; 33 double inner_total_F1 = 0.0; 34 double inner_total_F2 = 0.0; 32 35 for(int j=0; j<GAUSS_N; j++) { 33 36 const double uu = 0.5 * ( GAUSS_Z[j] + 1.0 ); … … 36 39 const double si1 = sas_sinx_x(mu_proj * sin_uu * a_scaled); 37 40 const double si2 = sas_sinx_x(mu_proj * cos_uu); 38 inner_total += GAUSS_W[j] * square(si1 * si2); 41 const double fq = si1 * si2; 42 inner_total_F1 += GAUSS_W[j] * fq; 43 inner_total_F2 += GAUSS_W[j] * fq * fq; 39 44 } 40 45 // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 41 inner_total *= 0.5; 46 inner_total_F1 *= 0.5; 47 inner_total_F2 *= 0.5; 42 48 43 49 const double si = sas_sinx_x(mu * c_scaled * sigma); 44 outer_total += GAUSS_W[i] * inner_total * si * si; 50 outer_total_F1 += GAUSS_W[i] * inner_total_F1 * si; 51 outer_total_F2 += GAUSS_W[i] * inner_total_F2 * si * si; 45 52 } 46 53 // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 47 outer_total *= 0.5; 54 outer_total_F1 *= 0.5; 55 outer_total_F2 *= 0.5; 48 56 49 57 // Multiply by contrast^2 and convert from [1e-12 A-1] to [cm-1] 50 58 const double V = form_volume(length_a, length_b, length_c); 51 const double drho = (sld-solvent_sld); 52 return 1.0e-4 * square(drho * V) * outer_total; 59 const double contrast = (sld-solvent_sld); 60 const double s = contrast * V; 61 *F1 = 1.0e-2 * s * outer_total_F1; 62 *F2 = 1.0e-4 * s * s * outer_total_F2; 53 63 } 54 55 64 56 65 static double -
sasmodels/models/parallelepiped.py
rf89ec96 r71b751d 230 230 231 231 source = ["lib/gauss76.c", "parallelepiped.c"] 232 have_Fq = True 232 233 233 234 def ER(length_a, length_b, length_c): -
sasmodels/models/raspberry.c
r925ad6e r71b751d 1 1 double form_volume(double radius_lg); 2 2 3 double Iq(double q, 3 double Iq(double q, 4 4 double sld_lg, double sld_sm, double sld_solvent, 5 5 double volfraction_lg, double volfraction_sm, double surf_fraction, … … 27 27 double sfLS,sfSS; 28 28 double slT; 29 29 30 30 vfL = volfraction_lg; 31 31 rL = radius_lg; … … 37 37 deltaS = penetration; 38 38 sldSolv = sld_solvent; 39 39 40 40 delrhoL = fabs(sldL - sldSolv); 41 delrhoS = fabs(sldS - sldSolv); 42 41 delrhoS = fabs(sldS - sldSolv); 42 43 43 VL = M_4PI_3*rL*rL*rL; 44 44 VS = M_4PI_3*rS*rS*rS; … … 76 76 //I(q) for free small particles 77 77 f2+= vfS*(1.0-fSs)*delrhoS*delrhoS*VS*psiS*psiS; 78 78 79 79 // normalize to single particle volume and convert to 1/cm 80 80 f2 *= 1.0e8; // [=] 1/cm 81 81 f2 *= 1.0e-12; // convert for (1/A^-6)^2 to (1/A)^2 82 82 83 83 return f2; 84 84 } -
sasmodels/models/rectangular_prism.c
rd86f0fc r71b751d 68 68 } 69 69 70 static void 71 Fq(double q, 72 double *F1, 73 double *F2, 74 double sld, 75 double solvent_sld, 76 double length_a, 77 double b2a_ratio, 78 double c2a_ratio) 79 { 80 const double length_b = length_a * b2a_ratio; 81 const double length_c = length_a * c2a_ratio; 82 const double a_half = 0.5 * length_a; 83 const double b_half = 0.5 * length_b; 84 const double c_half = 0.5 * length_c; 85 86 //Integration limits to use in Gaussian quadrature 87 const double v1a = 0.0; 88 const double v1b = M_PI_2; //theta integration limits 89 const double v2a = 0.0; 90 const double v2b = M_PI_2; //phi integration limits 91 92 double outer_sum_F1 = 0.0; 93 double outer_sum_F2 = 0.0; 94 for(int i=0; i<GAUSS_N; i++) { 95 const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); 96 double sin_theta, cos_theta; 97 SINCOS(theta, sin_theta, cos_theta); 98 99 const double termC = sas_sinx_x(q * c_half * cos_theta); 100 101 double inner_sum_F1 = 0.0; 102 double inner_sum_F2 = 0.0; 103 for(int j=0; j<GAUSS_N; j++) { 104 double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); 105 double sin_phi, cos_phi; 106 SINCOS(phi, sin_phi, cos_phi); 107 108 // Amplitude AP from eqn. (12), rewritten to avoid round-off effects when arg=0 109 const double termA = sas_sinx_x(q * a_half * sin_theta * sin_phi); 110 const double termB = sas_sinx_x(q * b_half * sin_theta * cos_phi); 111 const double AP = termA * termB * termC; 112 inner_sum_F1 += GAUSS_W[j] * AP; 113 inner_sum_F2 += GAUSS_W[j] * AP * AP; 114 } 115 inner_sum_F1 = 0.5 * (v2b-v2a) * inner_sum_F1; 116 inner_sum_F2 = 0.5 * (v2b-v2a) * inner_sum_F2; 117 outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta; 118 outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta; 119 } 120 121 outer_sum_F1 *= 0.5*(v1b-v1a); 122 outer_sum_F2 *= 0.5*(v1b-v1a); 123 124 // Normalize by Pi (Eqn. 16). 125 // The term (ABC)^2 does not appear because it was introduced before on 126 // the definitions of termA, termB, termC. 127 // The factor 2 appears because the theta integral has been defined between 128 // 0 and pi/2, instead of 0 to pi. 129 outer_sum_F1 /= M_PI_2; 130 outer_sum_F2 /= M_PI_2; 131 132 // Multiply by contrast and volume 133 const double s = (sld-solvent_sld) * (length_a * length_b * length_c); 134 135 // Convert from [1e-12 A-1] to [cm-1] 136 *F1 = 1e-2 * s * outer_sum_F1; 137 *F2 = 1e-4 * s * s * outer_sum_F2; 138 } 139 70 140 71 141 static double … … 82 152 const double b_half = 0.5 * length_b; 83 153 const double c_half = 0.5 * length_c; 84 const double volume = length_a * length_b * length_c;85 154 86 155 // Amplitude AP from eqn. (13) 87 88 156 const double termA = sas_sinx_x(qa * a_half); 89 157 const double termB = sas_sinx_x(qb * b_half); 90 158 const double termC = sas_sinx_x(qc * c_half); 91 92 159 const double AP = termA * termB * termC; 93 160 94 // Multiply by contrast ^2. Factor corresponding to volume^2 cancels with previous normalization.95 const double delrho = sld - solvent_sld;161 // Multiply by contrast and volume 162 const double s = (sld-solvent_sld) * (length_a * length_b * length_c); 96 163 97 164 // Convert from [1e-12 A-1] to [cm-1] 98 return 1.0e-4 * square( volume * delrho* AP);165 return 1.0e-4 * square(s * AP); 99 166 } -
sasmodels/models/rectangular_prism.py
r0e55afe r71b751d 135 135 136 136 source = ["lib/gauss76.c", "rectangular_prism.c"] 137 have_Fq = True 137 138 138 139 def ER(length_a, b2a_ratio, c2a_ratio): -
sasmodels/models/rpa.c
reb63414 r71b751d 39 39 double S31,S32,S33,S34,S41,S42,S43,S44; 40 40 double Lad,Lbd,Lcd,Nav,Intg; 41 41 42 42 // Set values for non existent parameters (eg. no A or B in case 0 and 1 etc) 43 43 //icase was shifted to N-1 from the original code … … 58 58 Kab = Kac = Kad = -0.0004; 59 59 } 60 60 61 61 // Set volume fraction of component D based on constraint that sum of vol frac =1 62 62 Phi[3]=1.0-Phi[0]-Phi[1]-Phi[2]; … … 84 84 Phicd=sqrt(Phi[2]*Phi[3]); 85 85 86 // Calculate Q^2 * Rg^2 for each homopolymer assuming random walk 86 // Calculate Q^2 * Rg^2 for each homopolymer assuming random walk 87 87 Xa=q*q*b[0]*b[0]*N[0]/6.0; 88 88 Xb=q*q*b[1]*b[1]*N[1]/6.0; … … 311 311 //Note that should multiply by Nav to get units of SLD which will become 312 312 // Nav*2 in the next line (SLD^2) but then normalization in that line would 313 //need to divide by Nav leaving only Nav or sqrt(Nav) before squaring. 313 //need to divide by Nav leaving only Nav or sqrt(Nav) before squaring. 314 314 Nav=6.022045e+23; 315 315 Lad=(L[0]/v[0]-L[3]/v[3])*sqrt(Nav); … … 320 320 321 321 //rescale for units of Lij^2 (fm^2 to cm^2) 322 Intg *= 1.0e-26; 322 Intg *= 1.0e-26; 323 323 324 324 return Intg; -
sasmodels/models/sc_paracrystal.c
r108e70e r71b751d 80 80 } 81 81 82 83 82 static double 84 83 Iqabc(double qa, double qb, double qc, -
sasmodels/models/sphere.py
rc036ddb r71b751d 67 67 ] 68 68 69 source = ["lib/sas_3j1x_x.c", "lib/sphere_form.c"] 69 source = ["lib/sas_3j1x_x.c"] 70 have_Fq = True 70 71 71 72 c_code = """ 72 73 static double form_volume(double radius) 73 74 { 74 return sphere_volume(radius);75 return M_4PI_3*cube(radius); 75 76 } 76 77 77 static void Fq(double q, double * F1,double *F2, double sld, double solvent_sld, double radius)78 static void Fq(double q, double *f1, double *f2, double sld, double sld_solvent, double radius) 78 79 { 79 const double fq= sas_3j1x_x(q*radius);80 const double contrast = (sld - s olvent_sld);81 const double form = 1e-2 * contrast * sphere_volume(radius) * fq;82 * F1 =form;83 * F2 =form*form;80 const double bes = sas_3j1x_x(q*radius); 81 const double contrast = (sld - sld_solvent); 82 const double form = contrast * form_volume(radius) * bes; 83 *f1 = 1.0e-2*form; 84 *f2 = 1.0e-4*form*form; 84 85 } 85 86 """ 86 87 # TODO: figure this out by inspection88 have_Fq = True89 87 90 88 def ER(radius): -
sasmodels/models/spherical_sld.c
r3330bb4 r71b751d 101 101 } 102 102 103 static void Fq( 104 double q, 105 double *F1, 106 double *F2, 107 double fp_n_shells, 108 double sld_solvent, 109 double sld[], 110 double thickness[], 111 double interface[], 112 double shape[], 113 double nu[], 114 double fp_n_steps) 115 { 116 // iteration for # of shells + core + solvent 117 int n_shells = (int)(fp_n_shells + 0.5); 118 int n_steps = (int)(fp_n_steps + 0.5); 119 double f=0.0; 120 double r=0.0; 121 for (int shell=0; shell<n_shells; shell++){ 122 const double sld_l = sld[shell]; 123 124 // uniform shell; r=0 => r^3=0 => f=0, so works for core as well. 125 f -= M_4PI_3 * cube(r) * sld_l * sas_3j1x_x(q*r); 126 r += thickness[shell]; 127 f += M_4PI_3 * cube(r) * sld_l * sas_3j1x_x(q*r); 128 129 // iterate over sub_shells in the interface 130 const double dr = interface[shell]/n_steps; 131 const double delta = (shell==n_shells-1 ? sld_solvent : sld[shell+1]) - sld_l; 132 const double nu_shell = fmax(fabs(nu[shell]), 1.e-14); 133 const int shape_shell = (int)(shape[shell]); 134 135 // if there is no interface the equations don't work 136 if (dr == 0.) continue; 137 138 double sld_in = sld_l; 139 for (int step=1; step <= n_steps; step++) { 140 // find sld_i at the outer boundary of sub-shell step 141 //const double z = (double)step/(double)n_steps; 142 const double z = (double)step/(double)n_steps; 143 const double fraction = blend(shape_shell, nu_shell, z); 144 const double sld_out = fraction*delta + sld_l; 145 // calculate slope 146 const double slope = (sld_out - sld_in)/dr; 147 const double contrast = sld_in - slope*r; 148 149 // iteration for the left and right boundary of the shells 150 f -= f_linear(q, r, contrast, slope); 151 r += dr; 152 f += f_linear(q, r, contrast, slope); 153 sld_in = sld_out; 154 } 155 } 156 // add in solvent effect 157 f -= M_4PI_3 * cube(r) * sld_solvent * sas_3j1x_x(q*r); 158 159 *F1 = 1e-2*f; 160 *F2 = 1e-4*f*f; 161 } -
sasmodels/models/spherical_sld.py
r2d81cfe r71b751d 209 209 source = ["lib/polevl.c", "lib/sas_erf.c", "lib/sas_3j1x_x.c", "spherical_sld.c"] 210 210 single = False # TODO: fix low q behaviour 211 have_Fq = True 211 212 212 213 profile_axes = ['Radius (A)', 'SLD (1e-6/A^2)'] -
sasmodels/models/spinodal.py
ref07e95 r71b751d 60 60 :return: Calculated intensity 61 61 """ 62 63 62 with errstate(divide='ignore'): 64 63 x = q/q_0 -
sasmodels/models/triaxial_ellipsoid.c
r108e70e r71b751d 7 7 } 8 8 9 static double 10 Iq(double q, 9 10 static void 11 Fq(double q, 12 double *F1, 13 double *F2, 11 14 double sld, 12 15 double sld_solvent, … … 20 23 const double zm = M_PI_4; 21 24 const double zb = M_PI_4; 22 double outer = 0.0; 25 double outer_sum_F1 = 0.0; 26 double outer_sum_F2 = 0.0; 23 27 for (int i=0;i<GAUSS_N;i++) { 24 28 //const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper + lower)/2; … … 26 30 const double pa_sinsq_phi = pa*square(sin(phi)); 27 31 28 double inner = 0.0; 32 double inner_sum_F1 = 0.0; 33 double inner_sum_F2 = 0.0; 29 34 const double um = 0.5; 30 35 const double ub = 0.5; … … 34 39 const double r = radius_equat_major*sqrt(pa_sinsq_phi*(1.0-usq) + 1.0 + pc*usq); 35 40 const double fq = sas_3j1x_x(q*r); 36 inner += GAUSS_W[j] * fq * fq; 41 inner_sum_F1 += GAUSS_W[j] * fq; 42 inner_sum_F2 += GAUSS_W[j] * fq * fq; 37 43 } 38 outer += GAUSS_W[i] * inner; // correcting for dx later 44 outer_sum_F1 += GAUSS_W[i] * inner_sum_F1; // correcting for dx later 45 outer_sum_F2 += GAUSS_W[i] * inner_sum_F2; // correcting for dx later 39 46 } 40 47 // translate integration ranges from [-1,1] to [lower,upper] and normalize by 4 pi 41 const double fqsq = outer/4.0; // = outer*um*zm*8.0/(4.0*M_PI); 42 const double vol = form_volume(radius_equat_minor, radius_equat_major, radius_polar); 43 const double drho = (sld - sld_solvent); 44 return 1.0e-4 * square(vol*drho) * fqsq; 48 outer_sum_F1 *= 0.25; // = outer*um*zm*8.0/(4.0*M_PI); 49 outer_sum_F2 *= 0.25; // = outer*um*zm*8.0/(4.0*M_PI); 50 51 const double volume = form_volume(radius_equat_minor, radius_equat_major, radius_polar); 52 const double contrast = (sld - sld_solvent); 53 *F1 = 1.0e-2 * contrast * volume * outer_sum_F1; 54 *F2 = 1.0e-4 * square(contrast * volume) * outer_sum_F2; 45 55 } 56 46 57 47 58 static double -
sasmodels/models/triaxial_ellipsoid.py
r37f08d2 r71b751d 157 157 158 158 source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 159 have_Fq = True 159 160 160 161 def ER(radius_equat_minor, radius_equat_major, radius_polar): -
sasmodels/models/two_lorentzian.py
ref07e95 r71b751d 87 87 power(q*lorentz_length_2, lorentz_exp_2)) 88 88 # pylint: enable=bad-whitespace 89 90 89 return intensity 91 90 -
sasmodels/models/vesicle.c
r925ad6e r71b751d 1 double form_volume(double radius, double thickness); 2 3 double Iq(double q, 4 double sld, double sld_solvent, double volfraction, 5 double radius, double thickness); 6 7 double form_volume(double radius, double thickness) 1 static double 2 form_volume(double radius, double thickness) 8 3 { 9 4 //note that for the vesicle model, the volume is ONLY the shell volume … … 11 6 } 12 7 13 double Iq(double q, 8 9 static void 10 Fq(double q, 11 double *F1, 12 double *F2, 14 13 double sld, 15 14 double sld_solvent, … … 31 30 vol = M_4PI_3*cube(radius); 32 31 f = vol * sas_3j1x_x(q*radius) * contrast; 33 32 34 33 //now the shell. No volume normalization as this is done by the caller 35 34 contrast = sld-sld_solvent; … … 37 36 f += vol * sas_3j1x_x(q*(radius+thickness)) * contrast; 38 37 39 //rescale to [cm-1]. 40 f2 = volfraction * f*f*1.0e-4; 41 42 return f2; 38 //rescale to [cm-1]. 39 // With volume fraction as part of the model in the dilute limit need 40 // to return F2 = Vf <fq^2>. In order for beta approx. to work correctly 41 // need F1^2/F2 equal to <fq>^2 / <fq^2>. By returning F1 = sqrt(Vf) <fq> 42 // and F2 = Vf <fq^2> both conditions are satisfied. 43 // Since Vf is the volume fraction of vesicles of all radii, it is 44 // constant when averaging F1 and F2 over radii and so pops out of the 45 // polydispersity loop, so it is safe to apply it inside the model 46 // (albeit conceptually ugly). 47 *F1 = 1e-2 * sqrt(volfraction) * f; 48 *F2 = 1.0e-4 * volfraction * f * f; 43 49 } -
sasmodels/models/vesicle.py
ref07e95 r71b751d 94 94 95 95 source = ["lib/sas_3j1x_x.c", "vesicle.c"] 96 have_Fq = True 96 97 97 98 def ER(radius, thickness):
Note: See TracChangeset
for help on using the changeset viewer.