Changeset 975ec8e in sasview for sansmodels/src/libigor
- Timestamp:
- Aug 14, 2009 5:58:58 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d5bd424
- Parents:
- cad821b
- Location:
- sansmodels/src/libigor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/libigor/libCylinder.c
r96b59384 r975ec8e 80 80 double va,vb; //upper and lower integration limits 81 81 double summ,zi,yyy,answer,vell; //running tally of integration 82 double summj,vaj,vbj,zij,arg ; //for the inner integration82 double summj,vaj,vbj,zij,arg, si; //for the inner integration 83 83 84 84 Pi = 4.0*atan(1.0); … … 114 114 //now calculate outer integral 115 115 arg = q*length*zi/2; 116 yyy = Gauss76Wt[i] * answer * sin(arg) * sin(arg) / arg / arg; 116 if (arg == 0){ 117 si = 1; 118 }else{ 119 si = sin(arg) * sin(arg) / arg / arg; 120 } 121 yyy = Gauss76Wt[i] * answer * si; 117 122 summ += yyy; 118 123 } … … 155 160 double va,vb; //upper and lower integration limits 156 161 double summ,zi,yyy,answer,vell; //running tally of integration 157 double summj,vaj,vbj,zij,arg ; //for the inner integration162 double summj,vaj,vbj,zij,arg,si; //for the inner integration 158 163 159 164 Pi = 4.0*atan(1.0); … … 189 194 //now calculate outer integral 190 195 arg = q*length*zi/2; 191 yyy = Gauss76Wt[i] * answer * sin(arg) * sin(arg) / arg / arg; 196 if (arg == 0){ 197 si = 1; 198 }else{ 199 si = sin(arg) * sin(arg) / arg / arg; 200 } 201 yyy = Gauss76Wt[i] * answer * si; 192 202 summ += yyy; 193 203 } … … 893 903 return(inten+bkg); 894 904 } 895 905 /* LamellarFFX : calculates the form factor of a lamellar structure - no S(q) effects included 906 -NO polydispersion included 907 */ 908 double lamellar_kernel(double dp[], double q){ 909 double scale,del,sld_bi,sld_sol,contr,bkg; //local variables of coefficient wave 910 double inten, qval,Pq; 911 double Pi; 912 913 914 Pi = 4.0*atan(1.0); 915 scale = dp[0]; 916 del = dp[1]; 917 sld_bi = dp[2]; 918 sld_sol = dp[3]; 919 bkg = dp[4]; 920 qval = q; 921 contr = sld_bi -sld_sol; 922 923 Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)); 924 925 inten = 2.0*Pi*scale*Pq/(qval*qval); //this is now dimensionless... 926 927 inten /= del; //normalize by the thickness (in A) 928 929 inten *= 1.0e8; // 1/A to 1/cm 930 931 return(inten+bkg); 932 } 896 933 /* LamellarPSX : calculates the form factor of a lamellar structure - with S(q) effects included 897 934 ------- … … 1682 1719 { 1683 1720 // local variables 1684 double aa,bb,u2,ut2,uq,ut,vc,vt, gfnc,gfnt,gfn2,pi43,gfn,Pi;1721 double aa,bb,u2,ut2,uq,ut,vc,vt,siq,sit,gfnc,gfnt,gfn2,pi43,gfn,Pi; 1685 1722 1686 1723 Pi = 4.0*atan(1.0); … … 1695 1732 vc = pi43*aa*bb*bb; 1696 1733 vt = pi43*trmaj*trmin*trmin; 1697 gfnc = 3.0*(sin(uq)/uq/uq - cos(uq)/uq)/uq*vc*delpc; 1698 gfnt = 3.0*(sin(ut)/ut/ut - cos(ut)/ut)/ut*vt*delps; 1734 if (uq == 0){ 1735 siq = 1/3; 1736 }else{ 1737 siq = (sin(uq)/uq/uq - cos(uq)/uq)/uq; 1738 } 1739 if (ut == 0){ 1740 sit = 1/3; 1741 }else{ 1742 sit = (sin(ut)/ut/ut - cos(ut)/ut)/ut; 1743 } 1744 gfnc = 3.0*siq*vc*delpc; 1745 gfnt = 3.0*sit*vt*delps; 1699 1746 gfn = gfnc+gfnt; 1700 1747 gfn2 = gfn*gfn; … … 1714 1761 { 1715 1762 // local variables 1716 double aa,bb,u2,ut2,uq,ut,vc,vt, gfnc,gfnt,tgfn,gfn4,pi43,Pi;1763 double aa,bb,u2,ut2,uq,ut,vc,vt,siq,sit,gfnc,gfnt,tgfn,gfn4,pi43,Pi; 1717 1764 1718 1765 Pi = 4.0*atan(1.0); … … 1726 1773 vc = pi43*aa*aa*bb; 1727 1774 vt = pi43*trmaj*trmaj*trmin; 1728 gfnc = 3.0*(sin(uq)/uq/uq - cos(uq)/uq)/uq*vc*delpc; 1729 gfnt = 3.0*(sin(ut)/ut/ut - cos(ut)/ut)/ut*vt*delps; 1775 if (uq == 0){ 1776 siq = 1/3; 1777 }else{ 1778 siq = (sin(uq)/uq/uq - cos(uq)/uq)/uq; 1779 } 1780 if (ut == 0){ 1781 sit = 1/3; 1782 }else{ 1783 sit = (sin(ut)/ut/ut - cos(ut)/ut)/ut; 1784 } 1785 gfnc = 3.0*siq*vc*delpc; 1786 gfnt = 3.0*sit*vt*delps; 1730 1787 tgfn = gfnc+gfnt; 1731 1788 gfn4 = tgfn*tgfn; … … 1744 1801 1745 1802 Pq = Sk_WR(q,zi,lb); //does not have cross section term 1746 Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 1747 1803 if (qr !=0){ 1804 Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 1805 } //else Pk *=1; 1748 1806 vcyl=Pi*radius*radius*zi; 1749 1807 Pq *= vcyl*vcyl; … … 1764 1822 1765 1823 Pq = Sk_WR(q,Lc,Lb); //does not have cross section term 1766 Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 1824 if (qr !=0){ 1825 Pq *= (2.0*NR_BessJ1(qr)/qr)*(2.0*NR_BessJ1(qr)/qr); 1826 } 1767 1827 1768 1828 vcyl=Pi*zi*zi*Lc; … … 1811 1871 // dum is the dummy variable for the integration (theta) 1812 1872 1813 double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2, t1,t2,retval;1873 double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2,si1,si2,be1,be2,t1,t2,retval; 1814 1874 double Pi; 1815 1875 … … 1825 1885 sinarg1 = qq*length*cos(dum); 1826 1886 sinarg2 = qq*(length+facthick)*cos(dum); 1827 1828 t1 = 2.0*vol1*dr1*sin(sinarg1)/sinarg1*NR_BessJ1(besarg1)/besarg1; 1829 t2 = 2.0*vol2*dr2*sin(sinarg2)/sinarg2*NR_BessJ1(besarg2)/besarg2; 1887 if (besarg1 == 0){ 1888 be1 = 0.5; 1889 }else{ 1890 be1 = NR_BessJ1(besarg1)/besarg1; 1891 } 1892 if (besarg2 == 0){ 1893 be2 = 0.5; 1894 }else{ 1895 be2 = NR_BessJ1(besarg2)/besarg2; 1896 } 1897 if (sinarg1 == 0){ 1898 si1 = 1; 1899 }else{ 1900 si1 = sin(sinarg1)/sinarg1; 1901 } 1902 if (besarg2 == 0){ 1903 si2 = 1; 1904 }else{ 1905 si2 = sin(sinarg2)/sinarg2; 1906 } 1907 1908 t1 = 2.0*vol1*dr1*si1*be1; 1909 t2 = 2.0*vol2*dr2*si2*be2; 1830 1910 1831 1911 retval = ((t1+t2)*(t1+t2))*sin(dum); … … 1839 1919 { 1840 1920 1841 double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2, t1,t2,retval;1921 double dr1,dr2,besarg1,besarg2,vol1,vol2,sinarg1,sinarg2,si1,si2,be1,be2,t1,t2,retval; 1842 1922 double Pi; 1843 1923 … … 1854 1934 sinarg2 = qq*(length+thick)*cos(dum); 1855 1935 1856 t1 = 2.0*vol1*dr1*sin(sinarg1)/sinarg1*NR_BessJ1(besarg1)/besarg1; 1857 t2 = 2.0*vol2*dr2*sin(sinarg2)/sinarg2*NR_BessJ1(besarg2)/besarg2; 1936 if (besarg1 == 0){ 1937 be1 = 0.5; 1938 }else{ 1939 be1 = NR_BessJ1(besarg1)/besarg1; 1940 } 1941 if (besarg2 == 0){ 1942 be2 = 0.5; 1943 }else{ 1944 be2 = NR_BessJ1(besarg2)/besarg2; 1945 } 1946 if (sinarg1 == 0){ 1947 si1 = 1; 1948 }else{ 1949 si1 = sin(sinarg1)/sinarg1; 1950 } 1951 if (besarg2 == 0){ 1952 si2 = 1; 1953 }else{ 1954 si2 = sin(sinarg2)/sinarg2; 1955 } 1956 1957 t1 = 2.0*vol1*dr1*si1*be1; 1958 t2 = 2.0*vol2*dr2*si2*be2; 1858 1959 1859 1960 retval = ((t1+t2)*(t1+t2))*sin(dum); … … 1906 2007 1907 2008 //Local variables 1908 double totald,dr1,dr2,besarg1,besarg2, area,sinarg1,sinarg2,t1,t2,retval,sqq,dexpt;2009 double totald,dr1,dr2,besarg1,besarg2,be1,be2,si1,si2,area,sinarg1,sinarg2,t1,t2,retval,sqq,dexpt; 1909 2010 double Pi; 1910 2011 int kk; … … 1923 2024 sinarg2 = qq*(length+thick)*cos(dum); 1924 2025 1925 t1 = 2*area*(2*length)*dr1*(sin(sinarg1)/sinarg1)*(NR_BessJ1(besarg1)/besarg1); 1926 t2 = 2*area*dr2*(totald*sin(sinarg2)/sinarg2-2*length*sin(sinarg1)/sinarg1)*(NR_BessJ1(besarg2)/besarg2); 2026 if (besarg1 == 0){ 2027 be1 = 0.5; 2028 }else{ 2029 be1 = NR_BessJ1(besarg1)/besarg1; 2030 } 2031 if (besarg2 == 0){ 2032 be2 = 0.5; 2033 }else{ 2034 be2 = NR_BessJ1(besarg2)/besarg2; 2035 } 2036 if (sinarg1 == 0){ 2037 si1 = 1; 2038 }else{ 2039 si1 = sin(sinarg1)/sinarg1; 2040 } 2041 if (besarg2 == 0){ 2042 si2 = 1; 2043 }else{ 2044 si2 = sin(sinarg2)/sinarg2; 2045 } 2046 2047 t1 = 2*area*(2*length)*dr1*(si1)*(be1); 2048 t2 = 2*area*dr2*(totald*si2-2*length*si1)*(be2); 1927 2049 1928 2050 retval =((t1+t2)*(t1+t2))*sin(dum); … … 1937 2059 // end of loop for S(q) 1938 2060 sqq=1.0+2.0*sqq/N; 2061 1939 2062 retval *= sqq; 1940 2063 … … 2016 2139 nu = nua/a; 2017 2140 arg = qq*a*sqrt(1+dum*dum*(nu*nu-1)); 2018 2019 retval = (sin(arg)-arg*cos(arg))/(arg*arg*arg); 2141 if (arg == 0){ 2142 retval =1/3; 2143 }else{ 2144 retval = (sin(arg)-arg*cos(arg))/(arg*arg*arg); 2145 } 2020 2146 retval *= retval; 2021 2147 retval *= 9; … … 2032 2158 arg1 = qq*rshell*sqrt(1-dum*dum); //1=shell (outer radius) 2033 2159 arg2 = qq*rcore*sqrt(1-dum*dum); //2=core (inner radius) 2034 lam1 = 2*NR_BessJ1(arg1)/arg1; 2035 lam2 = 2*NR_BessJ1(arg2)/arg2; 2160 if (arg1 == 0){ 2161 lam1 = 1; 2162 }else{ 2163 lam1 = 2*NR_BessJ1(arg1)/arg1; 2164 } 2165 if (arg2 == 0){ 2166 lam2 = 1; 2167 }else{ 2168 lam2 = 2*NR_BessJ1(arg2)/arg2; 2169 } 2170 //Todo: Need to check psi behavior as gamma goes to 1. 2036 2171 psi = 1/(1-gamma*gamma)*(lam1 - gamma*gamma*lam2); //SRK 10/19/00 2037 2038 2172 sinarg = qq*length*dum/2; 2039 t2 = sin(sinarg)/sinarg; 2173 if (sinarg == 0){ 2174 t2 = 1; 2175 }else{ 2176 t2 = sin(sinarg)/sinarg; 2177 } 2040 2178 2041 2179 retval = psi*psi*t2*t2; … … 2084 2222 arg += cc*cc*dy*dy; 2085 2223 arg = q*sqrt(arg); 2086 val = 9 * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ) * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ); 2087 2224 if (arg == 0){ 2225 val = 1; // as arg --> 0, val should go to 1.0 2226 }else{ 2227 val = 9 * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ) * ( (sin(arg) - arg*cos(arg))/(arg*arg*arg) ); 2228 } 2088 2229 return (val); 2089 2230 … … 2099 2240 // h is the HALF-LENGTH of the cylinder = L/2 (A) 2100 2241 2101 double besarg,bj,retval,d1,t1,b1,t2,b2 ; //Local variables2242 double besarg,bj,retval,d1,t1,b1,t2,b2,siarg,be,si; //Local variables 2102 2243 2103 2244 2104 2245 besarg = qq*rr*sin(theta); 2105 2246 siarg = qq * h * cos(theta); 2106 2247 bj =NR_BessJ1(besarg); 2107 2248 2108 2249 //* Computing 2nd power */ 2109 d1 = sin( qq * h * cos(theta));2250 d1 = sin(siarg); 2110 2251 t1 = d1 * d1; 2111 2252 //* Computing 2nd power */ … … 2113 2254 t2 = d1 * d1 * 4.0 * sin(theta); 2114 2255 //* Computing 2nd power */ 2115 d1 = qq * h * cos(theta);2256 d1 = siarg; 2116 2257 b1 = d1 * d1; 2117 2258 //* Computing 2nd power */ 2118 2259 d1 = qq * rr * sin(theta); 2119 2260 b2 = d1 * d1; 2120 retval = t1 * t2 / b1 / b2; 2261 if (besarg == 0){ 2262 be = sin(theta); 2263 }else{ 2264 be = t2 / b2; 2265 } 2266 if (siarg == 0){ 2267 si = 1; 2268 }else{ 2269 si = t1 / b1; 2270 } 2271 retval = be * si; 2121 2272 2122 2273 return (retval); … … 2136 2287 2137 2288 arg = qq*ra*sqrt((1+nu*nu)/2+(1-nu*nu)*cos(theta)/2); 2138 2139 retval = 2*NR_BessJ1(arg)/arg; 2289 if (arg == 0){ 2290 retval = 1; 2291 }else{ 2292 retval = 2*NR_BessJ1(arg)/arg; 2293 } 2140 2294 2141 2295 //square it -
sansmodels/src/libigor/libCylinder.h
rae3ce4e r975ec8e 34 34 double EllipCylKernel(double qq, double ra,double nu, double theta); 35 35 double TriaxialKernel(double q, double aa, double bb, double cc, double dx, double dy); 36 double lamellar_kernel(double dp[], double q); 36 37 double PPKernel(double aa, double mu, double uu); 37 38 double HolCylKernel(double qq, double rcore, double rshell, double length, double dum); -
sansmodels/src/libigor/libSphere.c
rae3ce4e r975ec8e 14 14 { 15 15 double scale,radius,delrho,bkg; //my local names 16 double bes,f,vol,f2,pi ;17 16 double bes,f,vol,f2,pi,qr; 17 18 18 pi = 4.0*atan(1.0); 19 19 scale = dp[0]; … … 21 21 delrho = dp[2]; 22 22 bkg = dp[3]; 23 //handle q==0 separately 24 if(q==0){ 25 f = 4.0/3.0*pi*radius*radius*radius*delrho*delrho*scale*1.0e8 + bkg; 26 return(f); 23 24 qr = q*radius; 25 if(qr == 0){ 26 bes = 1.0; 27 }else{ 28 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 27 29 } 28 29 bes = 3.0*(sin(q*radius)-q*radius*cos(q*radius))/(q*q*q)/(radius*radius*radius); 30 30 31 vol = 4.0*pi/3.0*radius*radius*radius; 31 32 f = vol*bes*delrho; // [=] A-1 32 33 // normalize to single particle volume, convert to 1/cm 33 34 f2 = f * f / vol * 1.0e8; // [=] 1/cm 34 35 35 36 return(scale*f2+bkg); //scale, and add in the background 36 37 } … … 43 44 double scale,rcore,thick,rhocore,rhoshel,rhosolv,bkg; //my local names 44 45 double bes,f,vol,qr,contr,f2; 45 46 46 47 pi = 4.0*atan(1.0); 47 48 x=q; 48 49 49 50 scale = dp[0]; 50 51 rcore = dp[1]; … … 57 58 qr=x*rcore; 58 59 contr = rhocore-rhoshel; 59 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 60 if(qr == 0){ 61 bes = 1.0; 62 }else{ 63 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 64 } 60 65 vol = 4.0*pi/3.0*rcore*rcore*rcore; 61 66 f = vol*bes*contr; … … 63 68 qr=x*(rcore+thick); 64 69 contr = rhoshel-rhosolv; 65 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 70 if(qr == 0){ 71 bes = 1.0; 72 }else{ 73 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 74 } 66 75 vol = 4.0*pi/3.0*pow((rcore+thick),3); 67 76 f += vol*bes*contr; 68 77 69 78 // normalize to particle volume and rescale from [A-1] to [cm-1] 70 79 f2 = f*f/vol*1.0e8; 71 80 72 81 //scale if desired 73 82 f2 *= scale; 74 83 // then add in the background 75 84 f2 += bkg; 76 85 77 86 return(f2); 78 87 } … … 88 97 pi = 4.0*atan(1.0); 89 98 x= q; 90 99 91 100 scale = dp[0]; 92 101 rcore = dp[1]; … … 99 108 qr=x*rcore; 100 109 contr = rhocore-rhoshel; 101 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 110 if(qr == 0){ 111 bes = 1.0; 112 }else{ 113 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 114 } 102 115 vol = 4.0*pi/3.0*rcore*rcore*rcore; 103 116 f = vol*bes*contr; … … 105 118 qr=x*(rcore+thick); 106 119 contr = rhoshel-rhosolv; 107 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 120 if(qr == 0){ 121 bes = 1.0; 122 }else{ 123 bes = 3.0*(sin(qr)-qr*cos(qr))/(qr*qr*qr); 124 } 108 125 vol = 4.0*pi/3.0*pow((rcore+thick),3); 109 126 f += vol*bes*contr; 110 127 111 128 // normalize to the particle volume and rescale from [A-1] to [cm-1] 112 129 //note that for the vesicle model, the volume is ONLY the shell volume 113 130 vol = 4.0*pi/3.0*(pow((rcore+thick),3)-pow(rcore,3)); 114 131 f2 = f*f/vol*1.0e8; 115 132 116 133 //scale if desired 117 134 f2 *= scale; 118 135 // then add in the background 119 136 f2 += bkg; 120 137 121 138 return(f2); 122 139 } … … 135 152 double zp3,vpoly; 136 153 double s2y, arg1, arg2, arg3, drh1, drh2; 137 154 138 155 pi = 4.0*atan(1.0); 139 156 qq= q; … … 145 162 drho2 = dp[5]-dp[6]; //shell-solvent 146 163 bkg = dp[7]; 147 148 zz = (1.0/sig)*(1.0/sig) - 1.0; 149 164 165 zz = (1.0/sig)*(1.0/sig) - 1.0; 166 150 167 h=qq; 151 168 152 169 drh1 = drho1; 153 170 drh2 = drho2; … … 157 174 zp3 = zz + 3.; 158 175 vpoly = 4*pi/3*zp3*zp2/zp1/zp1*pow((corrad+del),3); 159 160 176 177 161 178 // remember that h is the passed in value of q for the calculation 162 179 y = h *del; … … 179 196 c8 = c4 - .5 + g * cy - g * .5 * g * (y * y + 1.) * c2y; 180 197 c9 = g * sy * (1. - g * cy); 181 198 182 199 tb = log(zp1 * zp1 / (zp1 * zp1 + x * 4. * x)); 183 200 tb1 = exp(zp1 * .5 * tb); 184 201 tb2 = exp(zp2 * .5 * tb); 185 202 tb3 = exp(zp3 * .5 * tb); 186 203 187 204 t1 = c1 + c2 * x + c3 * x * x * zp2 / zp1; 188 205 t2 = tb1 * (c4 * cos(arg1) + c7 * sin(arg1)); … … 199 216 // then add in the background 200 217 form += bkg; 201 218 202 219 return(form); 203 220 } … … 218 235 double ka2,r1,heff; 219 236 double hh,k; 220 237 221 238 pi = 4.0*atan(1.0); 222 239 k= q; 223 240 224 241 rad = dp[0]; // radius (A) 225 242 z2 = dp[1]; //polydispersity (0<z2<1) … … 228 245 bkg = dp[4]; 229 246 sigma = 2*rad; 230 247 231 248 zz=1.0/(z2*z2)-1.0; 232 249 bb = sigma/(zz+1.0); 233 250 cc = zz+1.0; 234 251 235 252 //*c Compute the number density by <r-cubed>, not <r> cubed*/ 236 253 r1 = sigma/2.0; … … 264 281 d5=pow((pi/capd),2)*((rho/k)*(chi-1.0)+0.5*k*t2); 265 282 d6=pow((pi/capd),2)*(rho/k)*(chi2-s2); 266 283 267 284 e1=pow((pi/capd),2)*pow((rho/k/k),2)*((chi-1.0)*(chi2-s2)-(chi1-s1)*(chi1-s1)-(k*s1-pp)*(k*s3-p2)+pow((k*s2-p1),2)); 268 285 ee=1.0-(2.0*pi/capd)*(1.0+0.5*pi*t3/capd)*(rho/k/k/k)*(k*s1-pp)-(2.0*pi/capd)*rho/k/k*((chi1-s1)+(0.25*pi*t2/capd)*(chi2-s2))-e1; 269 286 y1=pow((pi/capd),2)*pow((rho/k/k),2)*((k*s1-pp)*(chi2-s2)-2.0*(k*s2-p1)*(chi1-s1)+(k*s3-p2)*(chi-1.0)); 270 yy = (2.0*pi/capd)*(1.0+0.5*pi*t3/capd)*(rho/k/k/k)*(chi+0.5*k*k*s2-1.0)-(2.0*pi*rho/capd/k/k)*(k*s2-p1+(0.25*pi*t2/capd)*(k*s3-p2))-y1; 271 287 yy = (2.0*pi/capd)*(1.0+0.5*pi*t3/capd)*(rho/k/k/k)*(chi+0.5*k*k*s2-1.0)-(2.0*pi*rho/capd/k/k)*(k*s2-p1+(0.25*pi*t2/capd)*(k*s3-p2))-y1; 288 272 289 capl=2.0*pi*cont*rho/k/k/k*(pp-0.5*k*(s1+chi1)); 273 290 capl1=2.0*pi*cont*rho/k/k/k*(p1-0.5*k*(s2+chi2)); 274 291 capmu=2.0*pi*cont*rho/k/k/k*(1.0-chi-0.5*k*p1); 275 292 capmu1=2.0*pi*cont*rho/k/k/k*(s1-chi1-0.5*k*p2); 276 293 277 294 h1=capl*(capl*(yy*d1-ee*d6)+capl1*(yy*d2-ee*d4)+capmu*(ee*d1+yy*d6)+capmu1*(ee*d2+yy*d4)); 278 295 h2=capl1*(capl*(yy*d2-ee*d4)+capl1*(yy*d3-ee*d5)+capmu*(ee*d2+yy*d4)+capmu1*(ee*d3+yy*d5)); 279 296 h3=capmu*(capl*(ee*d1+yy*d6)+capl1*(ee*d2+yy*d4)+capmu*(ee*d6-yy*d1)+capmu1*(ee*d4-yy*d2)); 280 297 h4=capmu1*(capl*(ee*d2+yy*d4)+capl1*(ee*d3+yy*d5)+capmu*(ee*d4-yy*d2)+capmu1*(ee*d5-yy*d3)); 281 298 282 299 //* This part computes the second integral in equation (1) of the paper.*/ 283 300 284 301 hint1 = -2.0*(h1+h2+h3+h4)/(k*k*k*(ee*ee+yy*yy)); 285 302 286 303 //* This part computes the first integral in equation (1). It also 287 304 // generates the KC approximated effective structure factor.*/ 288 305 289 306 pq=4.0*pi*cont*(sin(k*sigma/2.0)-0.5*k*sigma*cos(k*sigma/2.0)); 290 307 hint2=8.0*pi*pi*rho*cont*cont/(k*k*k*k*k*k)*(1.0-chi-k*p1+0.25*k*k*(s2+chi2)); 291 308 292 309 ka=k*(sigma/2.0); 293 310 // … … 297 314 ka2=ka*ka; 298 315 //* 299 // heff is PY analytical solution for intensity divided by the 316 // heff is PY analytical solution for intensity divided by the 300 317 // form factor. happ is the KC approximated effective S(q) 301 318 302 319 //******************* 303 320 // add in the background then return the intensity value 304 321 305 322 return(hh+bkg); //scale, and add in the background 306 323 } … … 315 332 double scale,ravg,pd,bkg,rho,rhos; //my local names 316 333 double scale2,ravg2,pd2,rho2; //my local names 317 334 318 335 x= q; 319 336 320 337 scale = dp[0]; 321 338 ravg = dp[1]; … … 328 345 rhos = dp[8]; 329 346 bkg = dp[9]; 330 347 331 348 pq = SchulzSphere_Fn( scale, ravg, pd, rho, rhos, x); 332 349 pq += SchulzSphere_Fn( scale2, ravg2, pd2, rho2, rhos, x); 333 350 // add in the background 334 351 pq += bkg; 335 352 336 353 return (pq); 337 354 } … … 344 361 double x,pq; 345 362 double scale,ravg,pd,bkg,rho,rhos; //my local names 346 363 347 364 x= q; 348 365 349 366 scale = dp[0]; 350 367 ravg = dp[1]; … … 356 373 // add in the background 357 374 pq += bkg; 358 375 359 376 return(pq); 360 377 } … … 367 384 double aa,at1,at2,rt1,rt2,rt3,t1,t2,t3; 368 385 double v1,v2,v3,g1,pq,pi,delrho,zz; 369 386 370 387 pi = 4.0*atan(1.0); 371 388 delrho = rho-rhos; 372 zz = (1.0/pd)*(1.0/pd) - 1.0; 373 389 zz = (1.0/pd)*(1.0/pd) - 1.0; 390 374 391 zp1 = zz + 1.0; 375 392 zp2 = zz + 2.0; … … 381 398 // 382 399 aa = (zz+1)/x/ravg; 383 400 384 401 at1 = atan(1.0/aa); 385 402 at2 = atan(2.0/aa); … … 387 404 // calculations are performed to avoid large # errors 388 405 // - trick is to propogate the a^(z+7) term through the g1 389 // 406 // 390 407 t1 = zp7*log10(aa) - zp1/2.0*log10(aa*aa+4.0); 391 408 t2 = zp7*log10(aa) - zp3/2.0*log10(aa*aa+4.0); … … 399 416 v3 = -2.0*zp1*rt3*sin(zp2*at2); 400 417 g1 = (v1+v2+v3); 401 418 402 419 pq = log10(g1) - 6.0*log10(zp1) + 6.0*log10(ravg); 403 420 pq = pow(10,pq)*8*pi*pi*delrho*delrho; 404 421 405 422 // 406 // beta factor is not used here, but could be for the 423 // beta factor is not used here, but could be for the 407 424 // decoupling approximation 408 // 425 // 409 426 // g11 = g1 410 427 // gd = -zp7*log(aa) 411 428 // g1 = log(g11) + gd 412 // 429 // 413 430 // t1 = zp1*at1 414 431 // t2 = zp2*at1 415 432 // g2 = sin( t1 ) - zp1/sqrt(aa*aa+1)*cos( t2 ) 416 433 // g22 = g2*g2 417 // beta = zp1*log(aa) - zp1*log(aa*aa+1) - g1 + log(g22) 434 // beta = zp1*log(aa) - zp1*log(aa*aa+1) - g1 + log(g22) 418 435 // beta = 2*alog(beta) 419 436 420 437 //re-normalize by the average volume 421 438 vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*ravg*ravg*ravg; … … 423 440 //scale, convert to cm^-1 424 441 pq *= scale * 1.0e8; 425 442 426 443 return(pq); 427 444 } … … 435 452 double scale,rad,pd,cont,bkg; //my local names 436 453 double inten,h1,qw,qr,width,sig,averad3; 437 454 438 455 pi = 4.0*atan(1.0); 439 456 x= q; 440 457 441 458 scale = dp[0]; 442 459 rad = dp[1]; // radius (A) … … 444 461 cont = dp[3]; // contrast (A^-2) 445 462 bkg = dp[4]; 446 463 447 464 // as usual, poly = sig/ravg 448 465 // for the rectangular distribution, sig = width/sqrt(3) 449 466 // width is the HALF- WIDTH of the rectangular distrubution 450 467 451 468 sig = pd*rad; 452 469 width = sqrt(3.0)*sig; 453 470 454 471 //x is the q-value 455 472 qw = x*width; … … 463 480 h1+= 3.0*qw*(sin(qr)*sin(qw))*(sin(qr)*sin(qw)); 464 481 h1 -= 6.0*qr*cos(qr)*sin(qr)*cos(qw)*sin(qw); 465 482 466 483 // calculate P(q) = <f^2> 467 484 inten = 8.0*pi*pi*cont*cont/width/pow(x,7)*h1; 468 485 469 486 // beta(q) would be calculated as 2/width/x/h1*h2*h2 470 // with 487 // with 471 488 // h2 = 2*sin(x*rad)*sin(x*width)-x*rad*cos(x*rad)*sin(x*width)-x*width*sin(x*rad)*cos(x*width) 472 489 473 490 // normalize to the average volume 474 491 // <R^3> = ravg^3*(1+3*pd^2) 475 492 // or... "zf" = (1 + 3*p^2), which will be greater than one 476 493 477 494 averad3 = rad*rad*rad*(1.0+3.0*pd*pd); 478 495 inten /= 4.0*pi/3.0*averad3; … … 483 500 // then add in the background 484 501 inten += bkg; 485 502 486 503 return(inten); 487 504 } … … 497 514 double va,vb,zi,yy,summ,inten; 498 515 int nord=20,ii; 499 516 500 517 pi = 4.0*atan(1.0); 501 518 x= q; 502 519 503 520 scale=dp[0]; 504 521 rad=dp[1]; … … 509 526 delrho=rho-rhos; 510 527 bkg=dp[5]; 511 528 512 529 va = -4.0*sig + rad; 513 530 if (va<0) { … … 515 532 } 516 533 vb = 4.0*sig +rad; 517 534 518 535 summ = 0.0; // initialize integral 519 536 for(ii=0;ii<nord;ii+=1) { … … 525 542 yy *= yy; 526 543 yy *= Gauss20Wt[ii] * Gauss_distr(sig,rad,zi); 527 544 528 545 summ += yy; //add to the running total of the quadrature 529 546 } 530 547 // calculate value of integral to return 531 548 inten = (vb-va)/2.0*summ; 532 549 533 550 //re-normalize by polydisperse sphere volume 534 551 inten /= (4.0*pi/3.0*rad*rad*rad)*(1.0+3.0*pd*pd); 535 552 536 553 inten *= 1.0e8; 537 554 inten *= scale; 538 555 inten += bkg; 539 556 540 557 return(inten); //scale, and add in the background 541 558 } … … 550 567 double va,vb,zi,yy,summ,inten; 551 568 int nord=76,ii; 552 569 553 570 pi = 4.0*atan(1.0); 554 571 x= q; 555 572 556 573 scale=dp[0]; 557 574 rad=dp[1]; //rad is the median radius … … 562 579 delrho=rho-rhos; 563 580 bkg=dp[5]; 564 581 565 582 va = -3.5*sig + mu; 566 583 va = exp(va); … … 570 587 vb = 3.5*sig*(1.0+sig) +mu; 571 588 vb = exp(vb); 572 589 573 590 summ = 0.0; // initialize integral 574 591 for(ii=0;ii<nord;ii+=1) { … … 580 597 yy *= yy; 581 598 yy *= Gauss76Wt[ii] * LogNormal_distr(sig,mu,zi); 582 599 583 600 summ += yy; //add to the running total of the quadrature 584 601 } 585 602 // calculate value of integral to return 586 603 inten = (vb-va)/2.0*summ; 587 604 588 605 //re-normalize by polydisperse sphere volume 589 606 r3 = exp(3.0*mu + 9.0/2.0*sig*sig); // <R^3> directly 590 607 inten /= (4.0*pi/3.0*r3); //polydisperse volume 591 608 592 609 inten *= 1.0e8; 593 610 inten *= scale; 594 611 inten += bkg; 595 612 596 613 return(inten); 597 614 } … … 599 616 static double 600 617 LogNormal_distr(double sig, double mu, double pt) 601 { 618 { 602 619 double retval,pi; 603 620 604 621 pi = 4.0*atan(1.0); 605 622 retval = (1/ (sig*pt*sqrt(2.0*pi)) )*exp( -0.5*(log(pt) - mu)*(log(pt) - mu)/sig/sig ); … … 609 626 static double 610 627 Gauss_distr(double sig, double avg, double pt) 611 { 628 { 612 629 double retval,Pi; 613 630 614 631 Pi = 4.0*atan(1.0); 615 632 retval = (1.0/ (sig*sqrt(2.0*Pi)) )*exp(-(avg-pt)*(avg-pt)/sig/sig/2.0); … … 627 644 double sld1,sld2,sld3,zp1,zp2,zp3,vpoly; 628 645 double pi43,c1,c2,form,volume,arg1,arg2; 629 646 630 647 pi = 4.0*atan(1.0); 631 648 x= q; 632 649 633 650 scale = dp[0]; 634 651 corrad = dp[1]; … … 639 656 sld3 = dp[6]; 640 657 bkg = dp[7]; 641 642 zz = (1.0/sig)*(1.0/sig) - 1.0; 658 659 zz = (1.0/sig)*(1.0/sig) - 1.0; 643 660 shlrad = corrad + thick; 644 661 drho1 = sld1-sld2; //core-shell … … 648 665 zp3 = zz + 3.; 649 666 vpoly = 4.0*pi/3.0*zp3*zp2/zp1/zp1*pow((corrad+thick),3); 650 667 651 668 // the beta factor is not calculated 652 669 // the calculated form factor <f^2> has units [length^2] 653 670 // and must be multiplied by number density [l^-3] and the correct unit 654 671 // conversion to get to absolute scale 655 672 656 673 pi43=4.0/3.0*pi; 657 674 pp=corrad/shlrad; … … 659 676 c1=drho1*volume; 660 677 c2=drho2*volume; 661 678 662 679 arg1 = x*shlrad*pp; 663 680 arg2 = x*shlrad; 664 681 665 682 form=pow(pp,6)*c1*c1*fnt2(arg1,zz); 666 683 form += c2*c2*fnt2(arg2,zz); 667 684 form += 2.0*c1*c2*fnt3(arg2,pp,zz); 668 685 669 686 //convert the result to [cm^-1] 670 687 671 688 //scale the result 672 689 // - divide by the polydisperse volume, mult by 10^8 … … 674 691 form *= 1.0e8; 675 692 form *= scale; 676 693 677 694 //add in the background 678 695 form += bkg; 679 696 680 697 return(form); 681 698 } … … 689 706 { 690 707 double z1,z2,z3,u,ww,term1,term2,term3,ans; 691 708 692 709 z1=zz+1.0; 693 710 z2=zz+2.0; … … 699 716 term3=1.0+cos(z3*ww)/pow((1.0+4.0*u*u),(z3/2.0)); 700 717 ans=(4.50/z1/pow(yy,6))*(z1*(1.0-term1-term2)+yy*yy*z2*term3); 701 718 702 719 return(ans); 703 720 } … … 709 726 double 710 727 fnt3(double yy, double pp, double zz) 711 { 728 { 712 729 double z1,z2,z3,yp,yn,up,un,vp,vn,term1,term2,term3,term4,term5,term6,ans; 713 730 714 731 z1=zz+1.0; 715 732 z2=zz+2.0; … … 729 746 ans=4.5/z1/pow(yy,6); 730 747 ans *=(z1*(term1-term2)+yy*yy*pp*z2*(term3+term4)+z1*(term5-term6)); 731 748 732 749 return(ans); 733 750 } … … 752 769 double psf11,psf12,psf22; 753 770 double phi1,phi2,phr,a3; 754 double v1,v2,n1,n2,qr1,qr2,b1,b2 ;771 double v1,v2,n1,n2,qr1,qr2,b1,b2,sc1,sc2; 755 772 int err; 756 773 757 774 pi = 4.0*atan(1.0); 758 775 x= q; … … 765 782 rhos = dp[6]; 766 783 bgd = dp[7]; 767 768 784 785 769 786 phi = phi1 + phi2; 770 787 aa = r1/r2; … … 775 792 // calculate the PSF's here 776 793 err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 777 794 778 795 // /* do form factor calculations */ 779 796 780 797 v1 = 4.0*pi/3.0*r1*r1*r1; 781 798 v2 = 4.0*pi/3.0*r2*r2*r2; 782 799 783 800 n1 = phi1/v1; 784 801 n2 = phi2/v2; 785 802 786 803 qr1 = r1*x; 787 804 qr2 = r2*x; 788 789 b1 = r1*r1*r1*(rho1-rhos)*4.0*pi*(sin(qr1)-qr1*cos(qr1))/qr1/qr1/qr1; 790 b2 = r2*r2*r2*(rho2-rhos)*4.0*pi*(sin(qr2)-qr2*cos(qr2))/qr2/qr2/qr2; 805 806 if (qr1 == 0){ 807 sc1 = 1.0/3.0; 808 }else{ 809 sc1 = (sin(qr1)-qr1*cos(qr1))/qr1/qr1/qr1; 810 } 811 if (qr2 == 0){ 812 sc2 = 1.0/3.0; 813 }else{ 814 sc2 = (sin(qr2)-qr2*cos(qr2))/qr2/qr2/qr2; 815 } 816 b1 = r1*r1*r1*(rho1-rhos)*4.0*pi*sc1; 817 b2 = r2*r2*r2*(rho2-rhos)*4.0*pi*sc2; 791 818 inten = n1*b1*b1*psf11; 792 819 inten += sqrt(n1*n2)*2.0*b1*b2*psf12; … … 794 821 ///* convert I(1/A) to (1/cm) */ 795 822 inten *= 1.0e8; 796 823 797 824 inten += bgd; 798 825 799 826 return(inten); 800 827 } … … 808 835 double phi1,phi2,phr,a3; 809 836 int err; 810 837 811 838 pi = 4.0*atan(1.0); 812 839 x= q; … … 827 854 // calculate the PSF's here 828 855 err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 829 856 830 857 return(psf11); //scale, and add in the background 831 858 } … … 839 866 double phi1,phi2,phr,a3; 840 867 int err; 841 868 842 869 pi = 4.0*atan(1.0); 843 870 x= q; … … 858 885 // calculate the PSF's here 859 886 err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 860 887 861 888 return(psf12); //scale, and add in the background 862 889 } … … 870 897 double phi1,phi2,phr,a3; 871 898 int err; 872 899 873 900 pi = 4.0*atan(1.0); 874 901 x= q; 875 902 876 903 r2 = dp[0]; 877 904 r1 = dp[1]; … … 890 917 // calculate the PSF's here 891 918 err = ashcroft(x,r2,nf2,aa,phi,&psf11,&psf22,&psf12); 892 919 893 920 return(psf22); //scale, and add in the background 894 921 } … … 898 925 { 899 926 // variable qval,r2,nf2,aa,phi,&s11,&s22,&s12 900 927 901 928 // calculate constant terms 902 929 double s1,s2,v,a3,v1,v2,g11,g12,g22,wmv,wmv3,wmv4; … … 905 932 double c11,c22,c12,f12,f22,ttt1,ttt2,ttt3,ttt4,yl,y13; 906 933 double t21,t22,t23,t31,t32,t33,t41,t42,yl3,wma3,y1; 907 934 908 935 s2 = 2.0*r2; 909 936 s1 = aa*s2; … … 926 953 gm1=(v1*a1+a3*v2*a2)*.5; 927 954 gm12=2.*gm1*(1.-aa)/aa; 928 //c 955 //c 929 956 //c calculate the direct correlation functions and print results 930 957 //c 931 958 // do 20 j=1,npts 932 959 933 960 yy=qval*s2; 934 961 //c calculate direct correlation functions … … 941 968 t3=gm1*((4.*ay*ay2-24.*ay)*sin(ay)-(ay2*ay2-12.*ay2+24.)*cos(ay)+24.)/ay3; 942 969 f11=24.*v1*(t1+t2+t3)/ay3; 943 970 944 971 //c ------c22 945 972 y2=yy*yy; … … 949 976 tt3=gm1*((4.*y3-24.*yy)*sin(yy)-(y2*y2-12.*y2+24.)*cos(yy)+24.)/ay3; 950 977 f22=24.*v2*(tt1+tt2+tt3)/y3; 951 978 952 979 //c -----c12 953 980 yl=.5*yy*(1.-aa); … … 969 996 ttt4=a1*(t41+t42)/y1; 970 997 f12=ttt1+24.*v*sqrt(nf2)*sqrt(1.-nf2)*a3*(ttt2+ttt3+ttt4)/(nf2+(1.-nf2)*a3); 971 998 972 999 c11=f11; 973 1000 c22=f22; 974 1001 c12=f12; 975 1002 *s11=1./(1.+c11-(c12)*c12/(1.+c22)); 976 *s22=1./(1.+c22-(c12)*c12/(1.+c11)); 977 *s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12)); 978 1003 *s22=1./(1.+c22-(c12)*c12/(1.+c11)); 1004 *s12=-c12/((1.+c11)*(1.+c22)-(c12)*(c12)); 1005 979 1006 return(err); 980 1007 } … … 989 1016 // bragg peaks arise naturally from the periodicity of the sample 990 1017 // resolution smeared version gives he most appropriate view of the model 991 1018 992 1019 Warning: 993 1020 The call to WaveData() below returns a pointer to the middle … … 1004 1031 double fval,voli,ri,sldi; 1005 1032 double pi; 1006 1007 pi = 4.0*atan(1.0); 1008 1033 1034 pi = 4.0*atan(1.0); 1035 1009 1036 x= q; 1010 1037 scale = dp[0]; … … 1016 1043 num = dp[6]; 1017 1044 bkg = dp[7]; 1018 1045 1019 1046 //calculate with a loop, two shells at a time 1020 1047 1021 1048 ii=0; 1022 1049 fval=0; 1023 1050 1024 1051 do { 1025 1052 ri = rcore + (double)ii*ts + (double)ii*tw; … … 1033 1060 ii+=1; //do 2 layers at a time 1034 1061 } while(ii<=num-1); //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03) 1035 1062 1036 1063 fval *= fval; //square it 1037 1064 fval /= voli; //normalize by the overall volume 1038 1065 fval *= scale*1e8; 1039 1066 fval += bkg; 1040 1067 1041 1068 return(fval); 1042 1069 } … … 1068 1095 double fval,ri,pi; 1069 1096 double avg,pd,zz,lo,hi,r1,r2,d1,d2,distr; 1070 1071 pi = 4.0*atan(1.0); 1097 1098 pi = 4.0*atan(1.0); 1072 1099 x= q; 1073 1100 1074 1101 scale = dp[0]; 1075 1102 avg = dp[1]; // average (total) outer radius … … 1081 1108 rhoshel = dp[7]; 1082 1109 bkg = dp[8]; 1083 1110 1084 1111 zz = (1.0/pd)*(1.0/pd)-1.0; 1085 1112 1086 1113 //max radius set to be 5 std deviations past mean 1087 1114 hi = avg + pd*avg*5.0; 1088 1115 lo = avg - pd*avg*5.0; 1089 1116 1090 1117 maxPairs = trunc( (hi-rcore+tw)/(ts+tw) ); 1091 1118 minPairs = trunc( (lo-rcore+tw)/(ts+tw) ); 1092 1119 minPairs = (minPairs < 1) ? 1 : minPairs; // need a minimum of one 1093 1120 1094 1121 ii=minPairs; 1095 1122 fval=0; … … 1104 1131 r1 = r2; 1105 1132 d1 = d2; 1106 1133 1107 1134 ri = (double)ii*(ts+tw) - tw + rcore; 1108 1135 fval += SchulzPoint(ri,avg,zz) * MultiShellGuts(x, rcore, ts, tw, rhocore, rhoshel, ii) * (4*pi/3*ri*ri*ri); … … 1116 1143 first = 0; 1117 1144 } while(ii<=maxPairs); 1118 1145 1119 1146 fval /= 4*pi/3*avg*avg*avg; //normalize by the overall volume 1120 1147 fval /= distr; 1121 1148 fval *= scale; 1122 1149 fval += bkg; 1123 1150 1124 1151 return(fval); 1125 1152 } … … 1127 1154 double 1128 1155 MultiShellGuts(double x,double rcore,double ts,double tw,double rhocore,double rhoshel,int num) { 1129 1156 1130 1157 double ri,sldi,fval,voli,pi; 1131 1158 int ii; 1132 1159 1133 1160 pi = 4.0*atan(1.0); 1134 1161 ii=0; 1135 1162 fval=0; 1136 1163 1137 1164 do { 1138 1165 ri = rcore + (double)ii*ts + (double)ii*tw; … … 1146 1173 ii+=1; //do 2 layers at a time 1147 1174 } while(ii<=num-1); //change to make 0 < num < 2 correspond to unilamellar vesicles (C. Glinka, 11/24/03) 1148 1175 1149 1176 fval *= fval; 1150 1177 fval /= voli; 1151 1178 fval *= 1e8; 1152 1179 1153 1180 return(fval); // this result still needs to be multiplied by scale and have background added 1154 1181 } … … 1156 1183 static double 1157 1184 SchulzPoint(double x, double avg, double zz) { 1158 1185 1159 1186 double dr; 1160 1187 1161 1188 dr = zz*log(x) - gammln(zz+1)+(zz+1)*log((zz+1)/avg)-(x/avg*(zz+1)); 1162 1189 return (exp(dr)); … … 1165 1192 static double 1166 1193 gammln(double xx) { 1167 1194 1168 1195 double x,y,tmp,ser; 1169 1196 static double cof[6]={76.18009172947146,-86.50532032941677, … … 1171 1198 0.1208650973866179e-2,-0.5395239384953e-5}; 1172 1199 int j; 1173 1200 1174 1201 y=x=xx; 1175 1202 tmp=x+5.5; … … 1182 1209 double 1183 1210 F_func(double qr) { 1184 return(3*(sin(qr) - qr*cos(qr))/(qr*qr*qr)); 1185 } 1186 1211 double sc; 1212 if (qr == 0){ 1213 sc = 1.0; 1214 }else{ 1215 sc=(3*(sin(qr) - qr*cos(qr))/(qr*qr*qr)); 1216 } 1217 return sc; 1218 } 1219
Note: See TracChangeset
for help on using the changeset viewer.