Changeset e7678b2 in sasmodels
- Timestamp:
- Feb 29, 2016 8:21:55 AM (9 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:
- 73860b6
- Parents:
- deac08c
- Location:
- sasmodels
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_template.c
rdeac08c re7678b2 88 88 # define M_PI_4 0.7853981633974483 89 89 #endif 90 #ifndef M_E 91 # define M_E 2.718281828459045091 92 #endif 90 93 91 94 // Non-standard function library -
sasmodels/models/core_shell_bicelle.c
r8007311 re7678b2 29 29 } 30 30 31 inline double sinc(double x) {return x==0 ? 1.0 : sin(x)/x;} 32 31 33 static double 32 34 bicelle_kernel(double qq, … … 41 43 double dum) 42 44 { 43 double dr1,dr2,dr3; 44 double besarg1,besarg2; 45 double vol1,vol2,vol3; 46 double sinarg1,sinarg2; 47 double t1,t2,t3; 48 double retval,si1,si2,be1,be2; 45 double si1,si2,be1,be2; 49 46 50 dr1 = rhoc-rhoh; 51 dr2 = rhor-rhosolv; 52 dr3= rhoh-rhor; 53 vol1 = M_PI*rad*rad*(2.0*length); 54 vol2 = M_PI*(rad+radthick)*(rad+radthick)*(2.0*length+2.0*facthick); 55 vol3= M_PI*(rad)*(rad)*(2.0*length+2.0*facthick); 56 besarg1 = qq*rad*sin(dum); 57 besarg2 = qq*(rad+radthick)*sin(dum); 58 sinarg1 = qq*length*cos(dum); 59 sinarg2 = qq*(length+facthick)*cos(dum); 47 const double dr1 = rhoc-rhoh; 48 const double dr2 = rhor-rhosolv; 49 const double dr3 = rhoh-rhor; 50 const double vol1 = M_PI*rad*rad*(2.0*length); 51 const double vol2 = M_PI*(rad+radthick)*(rad+radthick)*2.0*(length+facthick); 52 const double vol3 = M_PI*rad*rad*2.0*(length+facthick); 53 double sn,cn; 54 SINCOS(dum, sn, cn); 55 double besarg1 = qq*rad*sn; 56 double besarg2 = qq*(rad+radthick)*sn; 57 double sinarg1 = qq*length*cn; 58 double sinarg2 = qq*(length+facthick)*cn; 60 59 61 if(besarg1 == 0) { 62 be1 = 0.5; 63 } else { 64 be1 = J1(besarg1)/besarg1; 65 } 66 if(besarg2 == 0) { 67 be2 = 0.5; 68 } else { 69 be2 = J1(besarg2)/besarg2; 70 } 71 if(sinarg1 == 0) { 72 si1 = 1.0; 73 } else { 74 si1 = sin(sinarg1)/sinarg1; 75 } 76 if(sinarg2 == 0) { 77 si2 = 1.0; 78 } else { 79 si2 = sin(sinarg2)/sinarg2; 80 } 81 t1 = 2.0*vol1*dr1*si1*be1; 82 t2 = 2.0*vol2*dr2*si2*be2; 83 t3 = 2.0*vol3*dr3*si2*be1; 60 be1 = J1c(besarg1); 61 be2 = J1c(besarg2); 62 si1 = sinc(sinarg1); 63 si2 = sinc(sinarg2); 84 64 85 retval = ((t1+t2+t3)*(t1+t2+t3))*sin(dum); 86 return(retval); 65 const double t = vol1*dr1*si1*be1 + 66 vol2*dr2*si2*be2 + 67 vol3*dr3*si2*be1; 68 69 const double retval = t*t*sn; 70 71 return(retval); 87 72 88 73 } … … 99 84 double rhosolv) 100 85 { 86 // set up the integration end points 87 const double uplim = M_PI/4; 88 const double halfheight = length/2.0; 101 89 90 double summ = 0.0; 91 for(int i=0;i<N_POINTS_76;i++) { 92 double zi = (Gauss76Z[i] + 1.0)*uplim; 93 double yyy = Gauss76Wt[i] * bicelle_kernel(qq, rad, radthick, facthick, 94 halfheight, rhoc, rhoh, rhor,rhosolv, zi); 95 summ += yyy; 96 } 102 97 103 double answer,halfheight; 104 double lolim,uplim,summ,yyy,zi; 105 int nord,i; 106 107 // set up the integration end points 108 nord = 76; 109 lolim = 0.0; 110 uplim = M_PI/2; 111 halfheight = length/2.0; 112 113 summ = 0.0; 114 i=0; 115 for(i=0;i<nord;i++) { 116 zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 117 yyy = Gauss76Wt[i] * bicelle_kernel(qq, rad, radthick, facthick, 118 halfheight, rhoc, rhoh, rhor,rhosolv, zi); 119 summ += yyy; 120 } 121 122 // calculate value of integral to return 123 answer = (uplim-lolim)/2.0*summ; 124 return(answer); 98 // calculate value of integral to return 99 double answer = uplim*summ; 100 return(answer); 125 101 } 126 102 … … 138 114 double phi) 139 115 { 140 double cyl_x, cyl_y;141 double alpha, cos_val;142 double answer;143 144 116 //convert angle degree to radian 145 theta *= M_PI /180.0;146 phi *= M_PI /180.0;117 theta *= M_PI_180; 118 phi *= M_PI_180; 147 119 148 120 // Cylinder orientation 149 c yl_x = cos(theta) * cos(phi);150 c yl_y = sin(theta);121 const double cyl_x = cos(theta) * cos(phi); 122 const double cyl_y = sin(theta); 151 123 152 124 // Compute the angle btw vector q and the axis of the cylinder 153 co s_val = cyl_x*q_x + cyl_y*q_y;154 alpha = acos( cos_val );125 const double cos_val = cyl_x*q_x + cyl_y*q_y; 126 const double alpha = acos( cos_val ); 155 127 156 128 // Get the kernel 157 answer = bicelle_kernel(q, radius, rim_thickness, face_thickness,129 double answer = bicelle_kernel(q, radius, rim_thickness, face_thickness, 158 130 length/2.0, core_sld, face_sld, rim_sld, 159 131 solvent_sld, alpha) / fabs(sin(alpha)); -
sasmodels/models/core_shell_bicelle.py
rfa8011eb re7678b2 91 91 # pylint: enable=bad-whitespace, line-too-long 92 92 93 source = ["lib/ J1.c", "lib/gauss76.c", "core_shell_bicelle.c"]93 source = ["lib/Si.c", "lib/J1.c", "lib/J1c.c", "lib/gauss76.c", "core_shell_bicelle.c"] 94 94 95 95 demo = dict(scale=1, background=0, -
sasmodels/models/core_shell_ellipsoid.c
r81dd619 re7678b2 44 44 double solvent_sld) 45 45 { 46 double delpc,delps;47 double uplim,lolim; //upper and lower integration limits48 double summ,zi,yyy,answer; //running tally of integration49 46 50 lolim = 0.0; 51 uplim = 1.0; 47 //upper and lower integration limits 48 const double lolim = 0.0; 49 const double uplim = 1.0; 52 50 53 51 double summ = 0.0; //initialize intergral 54 52 55 delpc = core_sld - shell_sld;//core - shell56 53 const double delpc = core_sld - shell_sld; //core - shell 54 const double delps = shell_sld - solvent_sld; //shell - solvent 57 55 58 for(int i=0;i<76;i++) {59 60 61 62 63 64 65 66 67 68 69 56 for(int i=0;i<N_POINTS_76;i++) { 57 double zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 58 double yyy = Gauss76Wt[i] * gfn4(zi, 59 equat_core, 60 polar_core, 61 equat_shell, 62 polar_shell, 63 delpc, 64 delps, 65 q); 66 summ += yyy; 67 } 70 68 71 69 double answer = (uplim-lolim)/2.0*summ; 72 70 73 74 71 //convert to [cm-1] 72 answer *= 1.0e-4; 75 73 76 74 return answer; 77 75 } 78 76 … … 89 87 double phi) 90 88 { 91 double cyl_x, cyl_y;92 double cos_val;93 double answer;94 double sldcs,sldss;95 96 89 //convert angle degree to radian 97 theta = theta * M_PI /180.0;98 phi = phi * M_PI /180.0;90 theta = theta * M_PI_180; 91 phi = phi * M_PI_180; 99 92 100 93 101 94 // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. 102 c yl_x = cos(theta) * cos(phi);103 c yl_y = sin(theta);95 const double cyl_x = cos(theta) * cos(phi); 96 const double cyl_y = sin(theta); 104 97 105 sldcs = core_sld - shell_sld;106 sldss = shell_sld- solvent_sld;98 const double sldcs = core_sld - shell_sld; 99 const double sldss = shell_sld- solvent_sld; 107 100 108 101 // Compute the angle btw vector q and the 109 102 // axis of the cylinder 110 co s_val = cyl_x*q_x + cyl_y*q_y;103 const double cos_val = cyl_x*q_x + cyl_y*q_y; 111 104 112 105 // Call the IGOR library function to get the kernel: MUST use gfn4 not gf2 because of the def of params. 113 answer = gfn4(cos_val,106 double answer = gfn4(cos_val, 114 107 equat_core, 115 108 polar_core, -
sasmodels/models/core_shell_ellipsoid_xt.c
r81bb668 re7678b2 30 30 double x_polar_shell) 31 31 { 32 double equat_shell, polar_shell; 33 equat_shell = equat_core + t_shell; 34 polar_shell = equat_core*x_core + t_shell*x_polar_shell; 32 const double equat_shell = equat_core + t_shell; 33 const double polar_shell = equat_core*x_core + t_shell*x_polar_shell; 35 34 double vol = 4.0*M_PI/3.0*equat_shell*equat_shell*polar_shell; 36 35 return vol; … … 47 46 double solvent_sld) 48 47 { 49 double delpc,delps; 50 double uplim,lolim; //upper and lower integration limits 51 double summ,zi,yyy,answer; //running tally of integration 52 double polar_core, equat_shell, polar_shell; 48 const double lolim = 0.0; 49 const double uplim = 1.0; 53 50 54 lolim = 0.0; 55 uplim = 1.0; 51 double summ = 0.0; //initialize intergral 56 52 57 summ = 0.0; //initialize intergral 58 59 delpc = core_sld - shell_sld; //core - shell 60 delps = shell_sld - solvent_sld; //shell - solvent 53 const double delpc = core_sld - shell_sld; //core - shell 54 const double delps = shell_sld - solvent_sld; //shell - solvent 61 55 62 56 63 polar_core = equat_core*x_core;64 equat_shell = equat_core + t_shell;65 polar_shell = equat_core*x_core + t_shell*x_polar_shell;57 const double polar_core = equat_core*x_core; 58 const double equat_shell = equat_core + t_shell; 59 const double polar_shell = equat_core*x_core + t_shell*x_polar_shell; 66 60 67 for(int i=0;i<76;i++) {68 69 70 61 for(int i=0;i<N_POINTS_76;i++) { 62 double zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 63 double yyy = Gauss76Wt[i] * gfn4(zi, 64 equat_core, 71 65 polar_core, 72 66 equat_shell, 73 67 polar_shell, 74 75 76 77 78 68 delpc, 69 delps, 70 q); 71 summ += yyy; 72 } 79 73 80 answer = (uplim-lolim)/2.0*summ; 74 double answer = (uplim-lolim)/2.0*summ; 75 //convert to [cm-1] 76 answer *= 1.0e-4; 81 77 82 //convert to [cm-1] 83 answer *= 1.0e-4; 84 85 return answer; 78 return answer; 86 79 } 87 80 … … 98 91 double phi) 99 92 { 100 double cyl_x, cyl_y;101 double cos_val;102 double answer;103 double sldcs,sldss;104 double polar_core, equat_shell, polar_shell;105 106 93 //convert angle degree to radian 107 theta = theta * M_PI/180.0; 108 phi = phi * M_PI/180.0; 109 94 theta = theta * M_PI_180; 95 phi = phi * M_PI_180; 110 96 111 97 // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. 112 c yl_x = cos(theta) * cos(phi);113 c yl_y = sin(theta);98 const double cyl_x = cos(theta) * cos(phi); 99 const double cyl_y = sin(theta); 114 100 115 sldcs = core_sld - shell_sld;116 sldss = shell_sld- solvent_sld;101 const double sldcs = core_sld - shell_sld; 102 const double sldss = shell_sld- solvent_sld; 117 103 118 104 // Compute the angle btw vector q and the 119 105 // axis of the cylinder 120 co s_val = cyl_x*q_x + cyl_y*q_y;106 const double cos_val = cyl_x*q_x + cyl_y*q_y; 121 107 122 polar_core = equat_core*x_core;123 equat_shell = equat_core + t_shell;124 polar_shell = equat_core*x_core + t_shell*x_polar_shell;108 const double polar_core = equat_core*x_core; 109 const double equat_shell = equat_core + t_shell; 110 const double polar_shell = equat_core*x_core + t_shell*x_polar_shell; 125 111 126 112 // Call the IGOR library function to get the kernel: 127 113 // MUST use gfn4 not gf2 because of the def of params. 128 answer = gfn4(cos_val,114 double answer = gfn4(cos_val, 129 115 equat_core, 130 116 polar_core, -
sasmodels/models/flexible_cylinder.c
rf94d8a2 re7678b2 22 22 { 23 23 24 double Pi = 4.0*atan(1.0); 25 26 double cont = sld-solvent_sld; 27 double qr = q*radius; 28 double flex = Sk_WR(q,length,kuhn_length); 29 double crossSect = (2.0*J1(qr)/qr)*(2.0*J1(qr)/qr); 30 31 flex *= crossSect; 32 flex *= Pi*radius*radius*length; 33 flex *= cont*cont; 34 flex *= 1.0e-4; 35 36 return flex; 24 const double cont = sld-solvent_sld; 25 const double qr = q*radius; 26 //const double crossSect = (2.0*J1(qr)/qr)*(2.0*J1(qr)/qr); 27 const double crossSect = J1c(qr); 28 double flex = Sk_WR(q,length,kuhn_length); 29 flex *= crossSect*crossSect; 30 flex *= M_PI*radius*radius*length; 31 flex *= cont*cont; 32 flex *= 1.0e-4; 33 return flex; 37 34 } 38 35 … … 45 42 { 46 43 47 double result = flexible_cylinder_kernel(q, length, kuhn_length, radius, sld, solvent_sld); 48 49 return result; 44 double result = flexible_cylinder_kernel(q, length, kuhn_length, radius, sld, solvent_sld); 45 return result; 50 46 } 51 47 … … 57 53 double solvent_sld) 58 54 { 59 60 61 55 double q; 56 q = sqrt(qx*qx+qy*qy); 57 double result = flexible_cylinder_kernel(q, length, kuhn_length, radius, sld, solvent_sld); 62 58 63 59 return result; 64 60 } -
sasmodels/models/flexible_cylinder.py
r13ed84c re7678b2 90 90 ] 91 91 # pylint: enable=bad-whitespace, line-too-long 92 source = ["lib/J1.c", "lib/ wrc_cyl.c", "flexible_cylinder.c"]92 source = ["lib/J1.c", "lib/J1c.c", "lib/wrc_cyl.c", "flexible_cylinder.c"] 93 93 94 94 demo = dict(scale=1.0, background=0.0001, -
sasmodels/models/flexible_cylinder_ex.c
r504abee re7678b2 17 17 elliptical_crosssection(double q, double a, double b) 18 18 { 19 double uplim,lolim,Pi,summ,arg,zi,yyy,answer; 20 int i,nord=76; 19 double summ=0.0; 21 20 22 Pi = 4.0*atan(1.0); 23 lolim=0.0; 24 uplim=Pi/2.0; 25 summ=0.0; 21 for(int i=0;i<N_POINTS_76;i++) { 22 double zi = ( Gauss76Z[i] + 1.0 )*M_PI/4.0; 23 double sn, cn; 24 SINCOS(zi, sn, cn); 25 double arg = q*sqrt(a*a*sn*sn+b*b*cn*cn); 26 double yyy = pow((double)J1c(arg),2); 27 yyy *= Gauss76Wt[i]; 28 summ += yyy; 29 } 26 30 27 for(i=0;i<nord;i++) { 28 zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 29 arg = q*sqrt(a*a*sin(zi)*sin(zi)+b*b*cos(zi)*cos(zi)); 30 yyy = pow((2.0 * J1(arg) / arg),2); 31 yyy *= Gauss76Wt[i]; 32 summ += yyy; 33 } 34 answer = (uplim-lolim)/2.0*summ; 35 answer *= 2.0/Pi; 36 return(answer); 31 summ /= 2.0; 32 return(summ); 37 33 38 34 } … … 47 43 { 48 44 49 double Pi,flex,crossSect, cont;45 double flex,crossSect, cont; 50 46 51 Pi = 4.0*atan(1.0); 52 cont = sld - solvent_sld; 53 crossSect = elliptical_crosssection(q,radius,(radius*axis_ratio)); 47 cont = sld - solvent_sld; 48 crossSect = elliptical_crosssection(q,radius,(radius*axis_ratio)); 54 49 55 56 57 flex *= Pi*radius*radius*axis_ratio*axis_ratio*length;58 59 50 flex = Sk_WR(q,length,kuhn_length); 51 flex *= crossSect; 52 flex *= M_PI*radius*radius*axis_ratio*axis_ratio*length; 53 flex *= cont*cont; 54 flex *= 1.0e-4; 60 55 61 56 return flex; 62 57 } 63 58 … … 71 66 { 72 67 73 74 75 76 77 78 79 68 double result = flexible_cylinder_ex_kernel(q, 69 length, 70 kuhn_length, 71 radius, 72 axis_ratio, 73 sld, 74 solvent_sld); 80 75 81 76 return result; 82 77 } 83 78 … … 90 85 double solvent_sld) 91 86 { 92 93 94 95 96 97 98 99 100 87 double q; 88 q = sqrt(qx*qx+qy*qy); 89 double result = flexible_cylinder_ex_kernel(q, 90 length, 91 kuhn_length, 92 radius, 93 axis_ratio, 94 sld, 95 solvent_sld); 101 96 102 97 return result; 103 98 } -
sasmodels/models/flexible_cylinder_ex.py
r13ed84c re7678b2 113 113 # pylint: enable=bad-whitespace, line-too-long 114 114 115 source = ["lib/J1.c", "lib/ gauss76.c", "lib/wrc_cyl.c", "flexible_cylinder_ex.c"]115 source = ["lib/J1.c", "lib/J1c.c", "lib/gauss76.c", "lib/wrc_cyl.c", "flexible_cylinder_ex.c"] 116 116 117 117 demo = dict(scale=1.0, background=0.0001, -
sasmodels/models/lib/Si.c
rf12357f re7678b2 4 4 double Si(double x) 5 5 { 6 double out; 7 double pi = 4.0*atan(1.0); 6 double out; 8 7 9 if (x >= pi*6.2/4.0){10 11 12 out = pi/2.0;8 if (x >= M_PI*6.2/4.0){ 9 double out_sin = 0.0; 10 double out_cos = 0.0; 11 out = M_PI/2.0; 13 12 14 15 16 13 // Explicitly writing factorial values triples the speed of the calculation 14 out_cos = 1./x - 2./pow(x,3) + 24./pow(x,5) - 720./pow(x,7); 15 out_sin = 1./pow(x,2) - 6./pow(x,4) + 120./pow(x,6) - 5040./pow(x,8); 17 16 18 19 20 21 17 out -= cos(x) * out_cos; 18 out -= sin(x) * out_sin; 19 return out; 20 } 22 21 23 24 22 // Explicitly writing factorial values triples the speed of the calculation 23 out = x - pow(x, 3)/18. + pow(x,5)/600. - pow(x,7)/35280. + pow(x,9)/3265920. - pow(x,11)/439084800.; 25 24 26 25 return out; 27 26 } -
sasmodels/models/lib/wrc_cyl.c
r13ed84c re7678b2 5 5 AlphaSquare(double x) 6 6 { 7 // Potentially faster. Needs proper benchmarking. 8 // add native_powr to kernel_template 9 //double t = native_powr( (1.0 + (x/3.12)*(x/3.12) + 10 // (x/8.67)*(x/8.67)*(x/8.67)),(0.176/3.0) ); 11 //return t; 12 7 13 return pow( (1.0 + (x/3.12)*(x/3.12) + 8 14 (x/8.67)*(x/8.67)*(x/8.67)),(0.176/3.0) ); … … 13 19 Rgsquarezero(double q, double L, double b) 14 20 { 15 return (L*b/6.0) * (1.0 - 1.5*(b/L) + 1.5*pow((b/L),2) - 16 0.75*pow((b/L),3)*(1.0 - exp(-2.0*(L/b)))); 21 const double r = b/L; 22 return (L*b/6.0) * 23 (1.0 - r*1.5 + 1.5*r*r - 0.75*r*r*r*(1.0 - exp(-2.0/r))); 17 24 } 18 25 … … 31 38 } 32 39 33 static double40 static inline double 34 41 sech_WR(double x) 35 42 { … … 40 47 a1long(double q, double L, double b, double p1, double p2, double q0) 41 48 { 42 double yy,C,C1,C2,C3,C4,C5,miu,Rg2; 43 double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15; 44 double E,pi; 45 double b2,b3,b4,q02,q03,q04,q05,Rg22; 46 47 pi = 4.0*atan(1.0); 48 E = 2.718281828459045091; 49 double C; 50 const double onehalf = 1.0/2.0; 49 51 50 52 if( L/b > 10.0) { … … 54 56 } 55 57 56 C1 = 1.22; 57 C2 = 0.4288; 58 C3 = -1.651; 59 C4 = 1.523; 60 C5 = 0.1477; 61 miu = 0.585; 62 63 Rg2 = Rgsquare(q,L,b); 64 Rg22 = Rg2*Rg2; 65 b2 = b*b; 66 b3 = b*b*b; 67 b4 = b3*b; 68 q02 = q0*q0; 69 q03 = q0*q0*q0; 70 q04 = q03*q0; 71 q05 = q04*q0; 72 73 t1 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + 74 (7.0*b2)/(15.0*q02*Rg2))) + (7.0*b2)/(15.0*q02*Rg2)))); 75 76 t2 = (2.0*b4*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + 77 (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - 78 tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))); 79 80 t3 = ((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + 81 C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + 82 C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu)))); 83 84 t4 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))); 85 86 t5 = (1.0/(b*p1*pow(q0,((-1.0) - p1 - p2)) - 87 b*p2*pow(q0,((-1.0) - p1 - p2)))); 88 89 t6 = (b*C*(((-((14.0*b3)/(15.0*q03*Rg2))) + 90 (14.0*b3*pow(E,(-((q02*Rg2)/b2))))/(15.0*q03*Rg2) + 91 (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*((11.0/15.0 + 92 (7.0*b2)/(15.0*q02*Rg2)))*Rg2)/b))); 93 94 t7 = (sqrt(Rg2)*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + 95 C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + 96 C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))*pow(sech_WR(((-C4) + 97 (sqrt(Rg2)*q0)/b)/C5),2)); 98 99 t8 = (b4*sqrt(Rg2)*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + 100 (q02*Rg2)/b2))*pow(sech_WR(((-C4) + (sqrt(Rg2)*q0)/b)/C5),2)); 101 102 t9 = (2.0*b4*(((2.0*q0*Rg2)/b - 103 (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*Rg2)/b))*((1.0 + 1.0/2.0*(((-1.0) - 104 tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))); 105 106 t10 = (8.0*b4*b*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + 107 (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + 108 (sqrt(Rg2)*q0)/b)/C5)))))); 109 110 t11 = (((-((3.0*C3*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 111 3.0/miu)))/miu)) - (2.0*C2*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 112 2.0/miu)))/miu - (C1*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 113 1.0/miu)))/miu)); 114 115 t12 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))); 116 117 t13 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + 118 (7.0*b2)/(15.0*q02* Rg2))) + 119 (7.0*b2)/(15.0*q02*Rg2)))); 120 121 t14 = (2.0*b4*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + 122 (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + 123 (sqrt(Rg2)*q0)/b)/C5)))))); 124 125 t15 = ((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + 126 C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + 127 C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu)))); 128 129 130 yy = (pow(q0,p1)*(((-((b*pi)/(L*q0))) +t1/L +t2/(q04*Rg22) + 131 1.0/2.0*t3*t4)) + (t5*((pow(q0,(p1 - p2))* 132 (((-pow(q0,(-p1)))*(((b2*pi)/(L*q02) +t6/L +t7/(2.0*C5) - 133 t8/(C5*q04*Rg22) + t9/(q04*Rg22) -t10/(q05*Rg22) + 1.0/2.0*t11*t12)) - 134 b*p1*pow(q0,((-1.0) - p1))*(((-((b*pi)/(L*q0))) + t13/L + 135 t14/(q04*Rg22) + 1.0/2.0*t15*((1.0 + tanh(((-C4) + 136 (sqrt(Rg2)*q0)/b)/C5))))))))))); 58 const double C1 = 1.22; 59 const double C2 = 0.4288; 60 const double C3 = -1.651; 61 const double C4 = 1.523; 62 const double C5 = 0.1477; 63 const double miu = 0.585; 64 65 const double Rg2 = Rgsquare(q,L,b); 66 const double Rg22 = Rg2*Rg2; 67 const double Rg = sqrt(Rg2); 68 const double Rgb = Rg*q0/b; 69 70 const double b2 = b*b; 71 const double b3 = b*b*b; 72 const double b4 = b3*b; 73 const double q02 = q0*q0; 74 const double q03 = q0*q0*q0; 75 const double q04 = q03*q0; 76 const double q05 = q04*q0; 77 78 const double Rg02 = Rg2*q02; 79 80 const double t1 = (b*C*((4.0/15.0 - pow((double)M_E,(-(Rg02/b2))) * 81 ((11.0/15.0 + (7.0*b2)/(15.0*Rg02))) + 82 (7.0*b2)/(15.0*Rg02)))); 83 84 const double t2 = (2.0*b4*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 85 Rg02/b2))*((1.0 + onehalf*(((-1.0) - 86 tanh((-C4 + Rgb/C5))))))); 87 88 const double t3 = ((C3*pow(Rgb,((-3.0)/miu)) + 89 C2*pow(Rgb,((-2.0)/miu)) + 90 C1*pow(Rgb,((-1.0)/miu)))); 91 92 const double t4 = ((1.0 + tanh(((-C4) + Rgb)/C5))); 93 94 const double t5 = (1.0/(b*p1*pow(q0,((-1.0) - p1 - p2)) - 95 b*p2*pow(q0,((-1.0) - p1 - p2)))); 96 97 const double t6 = (b*C*(((-((14.0*b3)/(15.0*q03*Rg2))) + 98 (14.0*b3*pow((double)M_E,(-(Rg02/b2))))/(15.0*q03*Rg2) + 99 (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*((11.0/15.0 + 100 (7.0*b2)/(15.0*Rg02)))*Rg2)/b))); 101 102 const double t7 = (Rg*((C3*pow(((Rgb)),((-3.0)/miu)) + 103 C2*pow(((Rgb)),((-2.0)/miu)) + 104 C1*pow(((Rgb)),((-1.0)/miu))))*pow(sech_WR(((-C4) + 105 Rgb)/C5),2)); 106 107 const double t8 = (b4*Rg*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 108 Rg02/b2))*pow(sech_WR(((-C4) + Rgb)/C5),2)); 109 110 const double t9 = (2.0*b4*(((2.0*q0*Rg2)/b - 111 (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*Rg2)/b))*((1.0 + onehalf*(((-1.0) - 112 tanh(((-C4) + Rgb)/C5)))))); 113 114 const double t10 = (8.0*b4*b*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 115 Rg02/b2))*((1.0 + onehalf*(((-1.0) - tanh(((-C4) + 116 Rgb)/C5)))))); 117 118 const double t11 = (((-((3.0*C3*Rg*pow(((Rgb)),((-1.0) - 119 3.0/miu)))/miu)) - (2.0*C2*Rg*pow(((Rgb)),((-1.0) - 120 2.0/miu)))/miu - (C1*Rg*pow(((Rgb)),((-1.0) - 121 1.0/miu)))/miu)); 122 123 const double t12 = ((1.0 + tanh(((-C4) + Rgb)/C5))); 124 125 const double t13 = (b*C*((4.0/15.0 - pow((double)M_E,(-(Rg02/b2)))*((11.0/15.0 + 126 (7.0*b2)/(15.0*q02* Rg2))) + 127 (7.0*b2)/(15.0*Rg02)))); 128 129 const double t14 = (2.0*b4*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 130 Rg02/b2))*((1.0 + onehalf*(((-1.0) - tanh(((-C4) + 131 Rgb)/C5)))))); 132 133 const double t15 = ((C3*pow(((Rgb)),((-3.0)/miu)) + 134 C2*pow(((Rgb)),((-2.0)/miu)) + 135 C1*pow(((Rgb)),((-1.0)/miu)))); 136 137 138 double yy = (pow(q0,p1)*(((-((b*M_PI)/(L*q0))) +t1/L +t2/(q04*Rg22) + 139 onehalf*t3*t4)) + (t5*((pow(q0,(p1 - p2))* 140 (((-pow(q0,(-p1)))*(((b2*M_PI)/(L*q02) +t6/L +t7/(2.0*C5) - 141 t8/(C5*q04*Rg22) + t9/(q04*Rg22) -t10/(q05*Rg22) + onehalf*t11*t12)) - 142 b*p1*pow(q0,((-1.0) - p1))*(((-((b*M_PI)/(L*q0))) + t13/L + 143 t14/(q04*Rg22) + onehalf*t15*((1.0 + tanh(((-C4) + 144 Rgb)/C5))))))))))); 137 145 138 146 return (yy); … … 142 150 a2long(double q, double L, double b, double p1, double p2, double q0) 143 151 { 144 double yy,C1,C2,C3,C4,C5,miu,C,Rg2; 145 double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,pi; 146 double E,b2,b3,b4,q02,q03,q04,q05,Rg22; 147 148 pi = 4.0*atan(1.0); 149 E = 2.718281828459045091; 152 double C; 153 const double onehalf = 1.0/2.0; 154 150 155 if( L/b > 10.0) { 151 156 C = 3.06/pow((L/b),0.44); … … 154 159 } 155 160 156 C1 = 1.22; 157 C2 = 0.4288; 158 C3 = -1.651; 159 C4 = 1.523; 160 C5 = 0.1477; 161 miu = 0.585; 162 163 Rg2 = Rgsquare(q,L,b); 164 Rg22 = Rg2*Rg2; 165 b2 = b*b; 166 b3 = b*b*b; 167 b4 = b3*b; 168 q02 = q0*q0; 169 q03 = q0*q0*q0; 170 q04 = q03*q0; 171 q05 = q04*q0; 172 173 t1 = (1.0/(b* p1*pow(q0,((-1.0) - p1 - p2)) - 174 b*p2*pow(q0,((-1.0) - p1 - p2)) )); 175 176 t2 = (b*C*(((-1.0*((14.0*b3)/(15.0*q03*Rg2))) + 177 (14.0*b3*pow(E,(-((q02*Rg2)/b2))))/(15.0*q03*Rg2) + 178 (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*((11.0/15.0 + 179 (7*b2)/(15.0*q02*Rg2)))*Rg2)/b)))/L; 180 181 t3 = (sqrt(Rg2)*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + 182 C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + 183 C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))* 184 pow(sech_WR(((-C4) +(sqrt(Rg2)*q0)/b)/C5),2.0))/(2.0*C5); 185 186 t4 = (b4*sqrt(Rg2)*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + 187 (q02*Rg2)/b2))*pow(sech_WR(((-C4) + 188 (sqrt(Rg2)*q0)/b)/C5),2))/(C5*q04*Rg22); 189 190 t5 = (2.0*b4*(((2.0*q0*Rg2)/b - 191 (2.0*pow(E,(-((q02*Rg2)/b2)))*q0*Rg2)/b))* 192 ((1.0 + 1.0/2.0*(((-1.0) - tanh(((-C4) + 193 (sqrt(Rg2)*q0)/b)/C5))))))/(q04*Rg22); 194 195 t6 = (8.0*b4*b*(((-1.0) + pow(E,(-((q02*Rg2)/b2))) + 196 (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1) - tanh(((-C4) + 197 (sqrt(Rg2)*q0)/b)/C5))))))/(q05*Rg22); 198 199 t7 = (((-((3.0*C3*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)),((-1.0) - 200 3.0/miu)))/miu)) - (2.0*C2*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)), 201 ((-1.0) - 2.0/miu)))/miu - (C1*sqrt(Rg2)*pow((((sqrt(Rg2)*q0)/b)), 202 ((-1.0) - 1.0/miu)))/miu)); 203 204 t8 = ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5))); 205 206 t9 = (b*C*((4.0/15.0 - pow(E,(-((q02*Rg2)/b2)))*((11.0/15.0 + 207 (7.0 *b2)/(15*q02*Rg2))) + (7.0*b2)/(15.0*q02*Rg2))))/L; 208 209 t10 = (2.0*b4*(((-1) + pow(E,(-((q02*Rg2)/b2))) + 210 (q02*Rg2)/b2))*((1.0 + 1.0/2.0*(((-1) - tanh(((-C4) + 211 (sqrt(Rg2)*q0)/b)/C5))))))/(q04*Rg22); 212 213 yy = ((-1.0*(t1* ((-pow(q0,-p1)*(((b2*pi)/(L*q02) + 214 t2 + t3 - t4 + t5 - t6 + 1.0/2.0*t7*t8)) - b*p1*pow(q0,((-1.0) - p1))* 215 (((-((b*pi)/(L*q0))) + t9 + t10 + 216 1.0/2.0*((C3*pow((((sqrt(Rg2)*q0)/b)),((-3.0)/miu)) + 217 C2*pow((((sqrt(Rg2)*q0)/b)),((-2.0)/miu)) + 218 C1*pow((((sqrt(Rg2)*q0)/b)),((-1.0)/miu))))* 219 ((1.0 + tanh(((-C4) + (sqrt(Rg2)*q0)/b)/C5)))))))))); 161 const double C1 = 1.22; 162 const double C2 = 0.4288; 163 const double C3 = -1.651; 164 const double C4 = 1.523; 165 const double C5 = 0.1477; 166 const double miu = 0.585; 167 168 const double Rg2 = Rgsquare(q,L,b); 169 const double Rg22 = Rg2*Rg2; 170 const double b2 = b*b; 171 const double b3 = b*b*b; 172 const double b4 = b3*b; 173 const double q02 = q0*q0; 174 const double q03 = q0*q0*q0; 175 const double q04 = q03*q0; 176 const double q05 = q04*q0; 177 const double Rg = sqrt(Rg2); 178 const double Rgb = Rg*q0/b; 179 const double Rg02 = Rg2*q02; 180 181 const double t1 = (1.0/(b* p1*pow(q0,((-1.0) - p1 - p2)) - 182 b*p2*pow(q0,((-1.0) - p1 - p2)) )); 183 184 const double t2 = (b*C*(((-1.0*((14.0*b3)/(15.0*q03*Rg2))) + 185 (14.0*b3*pow((double)M_E,(-(Rg02/b2))))/(15.0*q03*Rg2) + 186 (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*((11.0/15.0 + 187 (7*b2)/(15.0*Rg02)))*Rg2)/b)))/L; 188 189 const double t3 = (Rg*((C3*pow(((Rgb)),((-3.0)/miu)) + 190 C2*pow(((Rgb)),((-2.0)/miu)) + 191 C1*pow(((Rgb)),((-1.0)/miu))))* 192 pow(sech_WR(((-C4) +Rgb)/C5),2.0))/(2.0*C5); 193 194 const double t4 = (b4*Rg*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 195 Rg02/b2))*pow(sech_WR(((-C4) + 196 Rgb)/C5),2))/(C5*q04*Rg22); 197 198 const double t5 = (2.0*b4*(((2.0*q0*Rg2)/b - 199 (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*Rg2)/b))* 200 ((1.0 + onehalf*(((-1.0) - tanh(((-C4) + 201 Rgb)/C5))))))/(q04*Rg22); 202 203 const double t6 = (8.0*b4*b*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 204 Rg02/b2))*((1.0 + onehalf*(((-1) - tanh(((-C4) + 205 Rgb)/C5))))))/(q05*Rg22); 206 207 const double t7 = (((-((3.0*C3*Rg*pow(((Rgb)),((-1.0) - 208 3.0/miu)))/miu)) - (2.0*C2*Rg*pow(((Rgb)), 209 ((-1.0) - 2.0/miu)))/miu - (C1*Rg*pow(((Rgb)), 210 ((-1.0) - 1.0/miu)))/miu)); 211 212 const double t8 = ((1.0 + tanh(((-C4) + Rgb)/C5))); 213 214 const double t9 = (b*C*((4.0/15.0 - pow((double)M_E,(-(Rg02/b2)))*((11.0/15.0 + 215 (7.0*b2)/(15*Rg02))) + (7.0*b2)/(15.0*Rg02))))/L; 216 217 const double t10 = (2.0*b4*(((-1) + pow((double)M_E,(-(Rg02/b2))) + 218 Rg02/b2))*((1.0 + onehalf*(((-1) - tanh(((-C4) + 219 Rgb)/C5))))))/(q04*Rg22); 220 221 const double yy = ((-1.0*(t1* ((-pow(q0,-p1)*(((b2*M_PI)/(L*q02) + 222 t2 + t3 - t4 + t5 - t6 + onehalf*t7*t8)) - b*p1*pow(q0,((-1.0) - p1))* 223 (((-((b*M_PI)/(L*q0))) + t9 + t10 + 224 onehalf*((C3*pow(((Rgb)),((-3.0)/miu)) + 225 C2*pow(((Rgb)),((-2.0)/miu)) + 226 C1*pow(((Rgb)),((-1.0)/miu))))* 227 ((1.0 + tanh(((-C4) + Rgb)/C5)))))))))); 220 228 221 229 return (yy); … … 224 232 // 225 233 static double 226 a1short(double q, double L, double b, double p1short, double p2short, double q0) 227 { 228 double yy,Rg2_sh; 229 double t1,E,Rg2_sh2,Et1,Emt1,q02,q0p,b3; 230 double pi; 231 232 E = 2.718281828459045091; 233 pi = 4.0*atan(1.0); 234 Rg2_sh = Rgsquareshort(q,L,b); 235 Rg2_sh2 = Rg2_sh*Rg2_sh; 236 b3 = b*b*b; 237 t1 = ((q0*q0*Rg2_sh)/(b*b)); 238 Et1 = pow(E,t1); 239 Emt1 =pow(E,-t1); 240 q02 = q0*q0; 241 q0p = pow(q0,(-4.0 + p1short) ); 242 243 yy = ((1.0/(L*((p1short - p2short))*Rg2_sh2)* 234 a_short(double q, double L, double b, double p1short, 235 double p2short, double factor, double pdiff, double q0) 236 { 237 const double Rg2_sh = Rgsquareshort(q,L,b); 238 const double Rg2_sh2 = Rg2_sh*Rg2_sh; 239 const double b3 = b*b*b; 240 const double t1 = ((q0*q0*Rg2_sh)/(b*b)); 241 const double Et1 = exp(t1); 242 const double Emt1 = 1.0/Et1; 243 const double q02 = q0*q0; 244 const double q0p = pow(q0,(-4.0 + p1short) ); 245 246 double yy = ((factor/(L*(pdiff)*Rg2_sh2)* 244 247 ((b*Emt1*q0p*((8.0*b3*L - 8.0*b3*Et1*L - 2.0*b3*L*p2short + 245 248 2.0*b3*Et1*L*p2short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 246 2.0*b*Et1*L*p2short*q02*Rg2_sh - Et1* pi*q02*q0*Rg2_sh2 +247 Et1*p2short* pi*q02*q0*Rg2_sh2))))));249 2.0*b*Et1*L*p2short*q02*Rg2_sh - Et1*M_PI*q02*q0*Rg2_sh2 + 250 Et1*p2short*M_PI*q02*q0*Rg2_sh2)))))); 248 251 249 252 return(yy); 250 253 } 254 static double 255 a1short(double q, double L, double b, double p1short, double p2short, double q0) 256 { 257 258 double factor = 1.0; 259 return a_short(q, L, b, p1short, p2short, factor, p1short - p2short, q0); 260 } 251 261 252 262 static double 253 263 a2short(double q, double L, double b, double p1short, double p2short, double q0) 254 264 { 255 double yy,Rg2_sh; 256 double t1,E,Rg2_sh2,Et1,Emt1,q02,q0p; 257 double pi; 258 259 E = 2.718281828459045091; 260 pi = 4.0*atan(1.0); 261 Rg2_sh = Rgsquareshort(q,L,b); 262 Rg2_sh2 = Rg2_sh*Rg2_sh; 263 t1 = ((q0*q0*Rg2_sh)/(b*b)); 264 Et1 = pow(E,t1); 265 Emt1 =pow(E,-t1); 266 q02 = q0*q0; 267 q0p = pow(q0,(-4.0 + p2short) ); 268 269 //E is the number e 270 yy = ((-(1.0/(L*((p1short - p2short))*Rg2_sh2)* 271 ((b*Emt1*q0p*((8.0*b*b*b*L - 8.0*b*b*b*Et1*L - 2.0*b*b*b*L*p1short + 272 2.0*b*b*b*Et1*L*p1short + 4.0*b*L*q02*Rg2_sh + 4.0*b*Et1*L*q02*Rg2_sh - 273 2.0*b*Et1*L*p1short*q02*Rg2_sh - Et1*pi*q02*q0*Rg2_sh2 + 274 Et1*p1short*pi*q02*q0*Rg2_sh2))))))); 275 276 return (yy); 265 double factor = -1.0; 266 return a_short(q, L, b, p2short, p1short, factor, p1short-p2short, q0); 277 267 } 278 268 … … 301 291 { 302 292 // ORIGINAL 303 double result = 2.0*(exp(-arg) + arg -1.0)/( pow((arg),2));293 double result = 2.0*(exp(-arg) + arg -1.0)/(arg*arg); 304 294 305 295 // CONVERSION 1 from http://herbie.uwplse.org/ … … 333 323 Sexv(double q, double L, double b) 334 324 { 335 double yy,C1,C2,C3,miu,Rg2; 336 C1=1.22; 337 C2=0.4288; 338 C3=-1.651; 339 miu = 0.585; 340 341 Rg2 = Rgsquare(q,L,b); 342 343 yy = (1.0 - w_WR(q*sqrt(Rg2)))*Sdebye(q,L,b) + 344 w_WR(q*sqrt(Rg2))*(C1*pow((q*sqrt(Rg2)),(-1.0/miu)) + 345 C2*pow((q*sqrt(Rg2)),(-2.0/miu)) + 346 C3*pow((q*sqrt(Rg2)),(-3.0/miu))); 347 325 326 const double C1=1.22; 327 const double C2=0.4288; 328 const double C3=-1.651; 329 const double miu = 0.585; 330 const double qRg = q*sqrt(Rgsquare(q,L,b)); 331 const double x = pow(qRg, -1.0/miu); 332 333 double yy = (1.0 - w_WR(qRg))*Sdebye(q,L,b) + 334 w_WR(qRg)*x*(C1 + x*(C2 + x*C3)); 348 335 return (yy); 349 336 } … … 353 340 Sexvnew(double q, double L, double b) 354 341 { 355 double yy,C1,C2,C3,miu; 356 double del=1.05,C_star2,Rg2; 357 358 C1=1.22; 359 C2=0.4288; 360 C3=-1.651; 361 miu = 0.585; 342 double yy; 343 344 const double C1 =1.22; 345 const double C2 =0.4288; 346 const double C3 =-1.651; 347 const double miu = 0.585; 348 const double del=1.05; 349 const double qRg = q*sqrt(Rgsquare(q,L,b)); 350 const double x = pow(qRg, -1.0/miu); 351 362 352 363 353 //calculating the derivative to decide on the corection (cutoff) term? 364 354 // I have modified this from WRs original code 365 366 if( (Sexv(q*del,L,b)-Sexv(q,L,b))/(q*del - q) >= 0.0 ) { 367 C_star2 = 0.0; 368 } else { 369 C_star2 = 1.0; 370 } 371 372 Rg2 = Rgsquare(q,L,b); 373 374 yy = (1.0 - w_WR(q*sqrt(Rg2)))*Sdebye(q,L,b) + 375 C_star2*w_WR(q*sqrt(Rg2))*(C1*pow((q*sqrt(Rg2)),(-1.0/miu)) + 376 C2*pow((q*sqrt(Rg2)),(-2.0/miu)) + C3*pow((q*sqrt(Rg2)),(-3.0/miu))); 355 const double qdel = (Sexv(q*del,L,b)-Sexv(q,L,b))/(q*del - q); 356 const double C_star2 =(qdel >= 0.0) ? 0.0 : 1.0; 357 358 yy = (1.0 - w_WR(qRg))*Sdebye(q,L,b) + 359 C_star2*w_WR(qRg)* 360 x*(C1 + x*(C2 + x*C3)); 377 361 378 362 return (yy); … … 382 366 double Sk_WR(double q, double L, double b) 383 367 { 384 // 385 double p1,p2,p1short,p2short,q0; 386 double C,ans,q0short,Sexvmodify,pi; 387 388 pi = 4.0*atan(1.0); 389 390 p1 = 4.12; 391 p2 = 4.42; 392 p1short = 5.36; 393 p2short = 5.62; 394 q0 = 3.1; 395 396 q0short = fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0); 397 398 399 if(L/b > 10.0) { 400 C = 3.06/pow((L/b),0.44); 401 } else { 402 C = 1.0; 403 } 404 // 405 406 // 407 if( L > 4*b ) { // Longer Chains 408 if (q*b <= 3.1) { //Modified by Yun on Oct. 15, 409 410 Sexvmodify = Sexvnew(q, L, b); 411 412 ans = Sexvmodify + C * (4.0/15.0 + 7.0/(15.0*u_WR(q,L,b)) - 368 // 369 const double p1 = 4.12; 370 const double p2 = 4.42; 371 const double p1short = 5.36; 372 const double p2short = 5.62; 373 const double q0 = 3.1; 374 375 double q0short = fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0); 376 double Sexvmodify, ans; 377 378 const double C =(L/b > 10.0) ? 3.06/pow((L/b),0.44) : 1.0; 379 380 if( L > 4*b ) { // Longer Chains 381 if (q*b <= 3.1) { //Modified by Yun on Oct. 15, 382 Sexvmodify = Sexvnew(q, L, b); 383 ans = Sexvmodify + C * (4.0/15.0 + 7.0/(15.0*u_WR(q,L,b)) - 413 384 (11.0/15.0 + 7.0/(15.0*u_WR(q,L,b)))*exp(-u_WR(q,L,b)))*(b/L); 414 385 415 } else { //q(i)*b > 3.1 416 ans = a1long(q, L, b, p1, p2, q0)/(pow((q*b),p1)) + 417 a2long(q, L, b, p1, p2, q0)/(pow((q*b),p2)) + pi/(q*L); 386 } else { //q(i)*b > 3.1 387 ans = a1long(q, L, b, p1, p2, q0)/(pow((q*b),p1)) + 388 a2long(q, L, b, p1, p2, q0)/(pow((q*b),p2)) + M_PI/(q*L); 389 } 390 } else { //L <= 4*b Shorter Chains 391 if (q*b <= fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0) ) { 392 if (q*b<=0.01) { 393 ans = 1.0 - Rgsquareshort(q,L,b)*(q*q)/3.0; 394 } else { 395 ans = Sdebye1(q,L,b); 396 } 397 } else { //q*b > max(1.9/sqrt(Rgsquareshort(q(i),L,b)),3) 398 ans = a1short(q,L,b,p1short,p2short,q0short)/(pow((q*b),p1short)) + 399 a2short(q,L,b,p1short,p2short,q0short)/(pow((q*b),p2short)) + 400 M_PI/(q*L); 401 } 418 402 } 419 } else { //L <= 4*b Shorter Chains420 if (q*b <= fmax(1.9/sqrt(Rgsquareshort(q,L,b)),3.0) ) {421 if (q*b<=0.01) {422 ans = 1.0 - Rgsquareshort(q,L,b)*(q*q)/3.0;423 } else {424 ans = Sdebye1(q,L,b);425 }426 } else { //q*b > max(1.9/sqrt(Rgsquareshort(q(i),L,b)),3)427 ans = a1short(q,L,b,p1short,p2short,q0short)/(pow((q*b),p1short)) +428 a2short(q,L,b,p1short,p2short,q0short)/(pow((q*b),p2short)) +429 pi/(q*L);430 }431 }432 403 433 404 return(ans);
Note: See TracChangeset
for help on using the changeset viewer.