Changeset 0420af7 in sasmodels
- Timestamp:
- Jan 21, 2016 4:17:17 PM (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:
- 0da2a01
- Parents:
- 6458608
- Location:
- sasmodels/models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/hollow_cylinder.c
r07e72e6 r0420af7 114 114 double norm,volume; //final calculation variables 115 115 116 if (core_radius >= radius || radius >= length) { 117 return NAN; 118 } 119 116 120 delrho = solvent_sld - sld; 117 121 lower = 0.0; … … 132 136 } 133 137 134 //FIXME: Factor of two difference135 138 double Iqxy(double qx, double qy, double radius, double core_radius, double length, double sld, 136 139 double solvent_sld, double theta, double phi) -
sasmodels/models/hollow_cylinder.py
rd18f8a8 r0420af7 64 64 """ 65 65 66 from numpy import inf66 from numpy import pi, inf 67 67 68 68 name = "hollow_cylinder" … … 92 92 source = ["lib/J1.c", "lib/gauss76.c", "hollow_cylinder.c"] 93 93 94 def ER(radius, core_radius, length): 95 if radius == 0 or length == 0: 96 return 0.0 97 len1 = radius 98 len2 = length/2.0 99 term1 = len1*len1*2.0*len2/2.0 100 term2 = 1.0 + (len2/len1)*(1.0 + 1/len2/2.0)*(1.0 + pi*len1/len2/2.0) 101 ddd = 3.0*term1*term2 102 diam = pow(ddd, (1.0/3.0)) 103 return diam 104 105 def VR(radius, core_radius, length): 106 vol_core = pi*core_radius*core_radius*length 107 vol_total = pi*radius*radius*length 108 vol_shell = vol_total - vol_core 109 return vol_shell, vol_total 110 94 111 # parameters for demo 95 112 demo = dict(scale=1.0,background=0.0,length=400.0,radius=30.0,core_radius=20.0, … … 97 114 radius_pd=.2, radius_pd_n=9, 98 115 length_pd=.2, length_pd_n=10, 116 core_radius_pd=.2, core_radius_pd_n=9, 99 117 theta_pd=10, theta_pd_n=5, 100 118 ) … … 109 127 # Parameters for unit tests 110 128 tests = [ 111 [{"radius" : 30.0},0.00005,1764.926] 129 [{"radius" : 30.0},0.00005,1764.926], 130 [{},'VR',1.8], 131 [{},0.001,1756.76] 112 132 ] -
sasmodels/models/lib/Si.c
rdcef2ee r0420af7 1 int factorial(int f);2 1 double Si(double x); 3 2 4 // integral of sin(x)/x : approximated to w/i1%3 // integral of sin(x)/x Taylor series approximated to w/i 0.1% 5 4 double Si(double x) 6 5 { 7 6 int i; 8 int nmax= 6;7 int nmax=10; 9 8 double out; 10 9 long power; … … 16 15 out = pi/2.0; 17 16 18 for (i=0; i<nmax-2; i+=1) { 19 out_cos += pow(-1.0, i) * (double)factorial(2*i) / pow(x, 2*i+1); 20 out_sin += pow(-1.0, i) * (double)factorial(2*i+1) / pow(x, 2*i+2); 21 } 17 // Explicitly writing factorial values triples the speed of the calculation 18 out_cos = 1/x - 2/pow(x,3) + 24/pow(x,5) - 720/pow(x,7) + 40320/pow(x,9); 19 out_sin = 1/x - 6/pow(x,4) + 120/pow(x,6) - 5040/pow(x,8) + 362880/pow(x,10); 22 20 23 21 out -= cos(x) * out_cos; … … 26 24 } 27 25 28 out = 0.0; 26 // Explicitly writing factorial values triples the speed of the calculation 27 out = x - pow(x, 3)/18 + pow(x,5)/600 - pow(x,7)/35280 + pow(x,9)/3265920; 29 28 30 for (i=0; i<nmax; i+=1) { 31 if (i==0) { 32 out += x; 33 continue; 34 } 35 36 power = pow(x,(2 * i + 1)); 37 out += pow(-1.0, i) * power / ((2.0 * (double)i + 1.0) * (double)factorial(2 * i + 1)); 38 39 //printf ("Si=%g %g %d\n", x, out, i); 40 } 41 29 //printf ("Si=%g %g\n", x, out); 42 30 return out; 43 31 } 44 45 int factorial(int f)46 {47 if ( f == 0 )48 return 1;49 return(f * factorial(f - 1));50 }
Note: See TracChangeset
for help on using the changeset viewer.