[ae3ce4e] | 1 | // header for SphereFit.c |
---|
[6a2c931] | 2 | #if defined(_MSC_VER) |
---|
| 3 | #include "winFuncs.h" |
---|
| 4 | #endif |
---|
[ae3ce4e] | 5 | |
---|
| 6 | /* IGOR Fit Functions */ |
---|
| 7 | double MultiShell(double dp[], double q); |
---|
| 8 | double PolyMultiShell(double dp[], double q); |
---|
| 9 | double SphereForm(double dp[], double q); |
---|
| 10 | double CoreShellForm(double dp[], double q); |
---|
| 11 | double PolyCoreForm(double dp[], double q); |
---|
| 12 | double PolyCoreShellRatio(double dp[], double q); |
---|
| 13 | double VesicleForm(double dp[], double q); |
---|
| 14 | double SchulzSpheres(double dp[], double q); |
---|
| 15 | double PolyRectSpheres(double dp[], double q); |
---|
| 16 | double PolyHardSphereIntensity(double dp[], double q); |
---|
| 17 | double BimodalSchulzSpheres(double dp[], double q); |
---|
| 18 | double GaussPolySphere(double dp[], double q); |
---|
| 19 | double LogNormalPolySphere(double dp[], double q); |
---|
| 20 | double BinaryHS(double dp[], double q); |
---|
| 21 | double BinaryHS_PSF11(double dp[], double q); |
---|
| 22 | double BinaryHS_PSF12(double dp[], double q); |
---|
| 23 | double BinaryHS_PSF22(double dp[], double q); |
---|
[6e93a02] | 24 | double OneShell(double dp[], double q); |
---|
| 25 | double TwoShell(double dp[], double q); |
---|
| 26 | double ThreeShell(double dp[], double q); |
---|
| 27 | double FourShell(double dp[], double q); |
---|
| 28 | double PolyOneShell(double dp[], double q); |
---|
| 29 | double PolyTwoShell(double dp[], double q); |
---|
| 30 | double PolyThreeShell(double dp[], double q); |
---|
| 31 | double PolyFourShell(double dp[], double q); |
---|
| 32 | double BCC_ParaCrystal(double dp[], double q); |
---|
| 33 | double FCC_ParaCrystal(double dp[], double q); |
---|
| 34 | double SC_ParaCrystal(double dp[], double q); |
---|
| 35 | double FuzzySpheres(double dp[], double q); |
---|
[ae3ce4e] | 36 | |
---|
| 37 | //function prototypes |
---|
| 38 | double F_func(double qr); |
---|
| 39 | double MultiShellGuts(double q,double rcore,double ts,double tw,double rhocore,double rhoshel,int num); |
---|
| 40 | double fnt2(double yy, double zz); |
---|
| 41 | double fnt3(double yy, double pp, double zz); |
---|
| 42 | double SchulzSphere_Fn(double scale, double ravg, double pd, double rho, double rhos, double x); |
---|
| 43 | int ashcroft(double qval, double r2, double nf2, double aa, double phi, double *s11, double *s22, double *s12); |
---|
[6e93a02] | 44 | double BCC_Integrand(double w[], double qq, double xx, double yy); |
---|
| 45 | double BCCeval(double Theta, double Phi, double temp1, double temp3); |
---|
| 46 | double SphereForm_Paracrystal(double radius, double delrho, double x); |
---|
| 47 | double FCC_Integrand(double w[], double qq, double xx, double yy); |
---|
| 48 | double FCCeval(double Theta, double Phi, double temp1, double temp3); |
---|
| 49 | double SC_Integrand(double w[], double qq, double xx, double yy); |
---|
| 50 | double SCeval(double Theta, double Phi, double temp3, double temp4, double temp5); |
---|
| 51 | |
---|
| 52 | |
---|
[ae3ce4e] | 53 | |
---|
[34c2649] | 54 | static double |
---|
| 55 | gammln(double xx) { |
---|
| 56 | double x,y,tmp,ser; |
---|
| 57 | static double cof[6]={76.18009172947146,-86.50532032941677, |
---|
| 58 | 24.01409824083091,-1.231739572450155, |
---|
| 59 | 0.1208650973866179e-2,-0.5395239384953e-5}; |
---|
| 60 | int j; |
---|
| 61 | |
---|
| 62 | y=x=xx; |
---|
| 63 | tmp=x+5.5; |
---|
| 64 | tmp -= (x+0.5)*log(tmp); |
---|
| 65 | ser=1.000000000190015; |
---|
| 66 | for (j=0;j<=5;j++) ser += cof[j]/++y; |
---|
| 67 | return -tmp+log(2.5066282746310005*ser/x); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | static double |
---|
| 71 | LogNormal_distr(double sig, double mu, double pt) |
---|
| 72 | { |
---|
| 73 | double retval,pi; |
---|
| 74 | |
---|
| 75 | pi = 4.0*atan(1.0); |
---|
| 76 | retval = (1.0/ (sig*pt*sqrt(2.0*pi)) )*exp( -0.5*(log(pt) - mu)*(log(pt) - mu)/sig/sig ); |
---|
| 77 | return(retval); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | static double |
---|
| 81 | Gauss_distr(double sig, double avg, double pt) |
---|
| 82 | { |
---|
| 83 | double retval,Pi; |
---|
| 84 | |
---|
| 85 | Pi = 4.0*atan(1.0); |
---|
| 86 | retval = (1.0/ (sig*sqrt(2.0*Pi)) )*exp(-(avg-pt)*(avg-pt)/sig/sig/2.0); |
---|
| 87 | return(retval); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | static double SchulzPoint(double x, double avg, double zz) { |
---|
| 91 | double dr; |
---|
| 92 | dr = zz*log(x) - gammln(zz+1.0)+(zz+1.0)*log((zz+1.0)/avg)-(x/avg*(zz+1.0)); |
---|
| 93 | return (exp(dr)); |
---|
| 94 | }; |
---|
[6e93a02] | 95 | |
---|