Changeset 593 for sans/XOP_Dev/SANSAnalysis
- Timestamp:
- Nov 4, 2009 1:28:03 PM (13 years ago)
- Location:
- sans/XOP_Dev/SANSAnalysis/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/XOP_Dev/SANSAnalysis/lib/libSphere.c
r554 r593 2124 2124 } 2125 2125 2126 // scattering from a uniform sphere with a Gaussian size distribution 2127 // 2128 double 2129 FuzzySpheres(double dp[], double q) 2130 { 2131 double pi,x; 2132 double scale,rad,pd,sig,rho,rhos,bkg,delrho,sig_surf,f2,bes,vol,f; //my local names 2133 double va,vb,zi,yy,summ,inten; 2134 int nord=20,ii; 2135 2136 pi = 4.0*atan(1.0); 2137 x= q; 2138 2139 scale=dp[0]; 2140 rad=dp[1]; 2141 pd=dp[2]; 2142 sig=pd*rad; 2143 sig_surf = dp[3]; 2144 rho=dp[4]; 2145 rhos=dp[5]; 2146 delrho=rho-rhos; 2147 bkg=dp[6]; 2148 2149 2150 va = -4.0*sig + rad; 2151 if (va<0) { 2152 va=0; //to avoid numerical error when va<0 (-ve q-value) 2153 } 2154 vb = 4.0*sig +rad; 2155 2156 summ = 0.0; // initialize integral 2157 for(ii=0;ii<nord;ii+=1) { 2158 // calculate Gauss points on integration interval (r-value for evaluation) 2159 zi = ( Gauss20Z[ii]*(vb-va) + vb + va )/2.0; 2160 // calculate sphere scattering 2161 // 2162 //handle q==0 separately 2163 if (x==0.0) { 2164 f2 = 4.0/3.0*pi*zi*zi*zi*delrho*delrho*1.0e8; 2165 f2 *= exp(-0.5*sig_surf*sig_surf*x*x); 2166 f2 *= exp(-0.5*sig_surf*sig_surf*x*x); 2167 } else { 2168 bes = 3.0*(sin(x*zi)-x*zi*cos(x*zi))/(x*x*x)/(zi*zi*zi); 2169 vol = 4.0*pi/3.0*zi*zi*zi; 2170 f = vol*bes*delrho; // [=] A 2171 f *= exp(-0.5*sig_surf*sig_surf*x*x); 2172 // normalize to single particle volume, convert to 1/cm 2173 f2 = f * f / vol * 1.0e8; // [=] 1/cm 2174 } 2175 2176 yy = Gauss20Wt[ii] * Gauss_distr(sig,rad,zi) * f2; 2177 yy *= 4.0*pi/3.0*zi*zi*zi; //un-normalize by current sphere volume 2178 2179 summ += yy; //add to the running total of the quadrature 2180 2181 2182 } 2183 // calculate value of integral to return 2184 inten = (vb-va)/2.0*summ; 2185 2186 //re-normalize by polydisperse sphere volume 2187 inten /= (4.0*pi/3.0*rad*rad*rad)*(1.0+3.0*pd*pd); 2188 2189 inten *= scale; 2190 inten += bkg; 2191 2192 return(inten); //scale, and add in the background 2193 } 2194 2195 -
sans/XOP_Dev/SANSAnalysis/lib/libSphere.h
r453 r593 30 30 double FCC_ParaCrystal(double dp[], double q); 31 31 double SC_ParaCrystal(double dp[], double q); 32 double FuzzySpheres(double dp[], double q); 32 33 33 34 //function prototypes
Note: See TracChangeset
for help on using the changeset viewer.