1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion=6.1 |
---|
3 | |
---|
4 | //////////////////////////////////////////////// |
---|
5 | // GaussUtils.ipf is not required (no smearing calculation done) PlotUtils.ipf should be included |
---|
6 | //////////////////////////////////////////////// |
---|
7 | // this function is for the hard sphere structure factor |
---|
8 | // |
---|
9 | // |
---|
10 | // 06 NOV 98 SRK |
---|
11 | //////////////////////////////////////////////// |
---|
12 | |
---|
13 | Proc PlotHardSphereStruct(num,qmin,qmax) |
---|
14 | Variable num=128,qmin=0.001,qmax=0.3 |
---|
15 | Prompt num "Enter number of data points for model: " |
---|
16 | Prompt qmin "Enter minimum q-value (A^-1) for model: " |
---|
17 | Prompt qmax "Enter maximum q-value (A^-1) for model: " |
---|
18 | |
---|
19 | Make/O/D/n=(num) xwave_hss,ywave_hss |
---|
20 | //xwave_hss = (x+1)*((qmax-qmin)/num) |
---|
21 | xwave_hss = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
22 | Make/O/D coef_hss = {50,0.2} |
---|
23 | make/o/t parameters_hss = {"Radius (A)","vol fraction"} |
---|
24 | Edit parameters_hss,coef_hss |
---|
25 | Variable/G root:g_hss |
---|
26 | g_hss := HardSphereStruct(coef_hss,ywave_hss,xwave_hss) |
---|
27 | // ywave_hss := HardSphereStruct(coef_hss,xwave_hss) |
---|
28 | Display ywave_hss vs xwave_hss |
---|
29 | ModifyGraph marker=29,msize=2,mode=4 |
---|
30 | Label bottom "q (A\\S-1\\M)" |
---|
31 | Label left "Structure Factor" |
---|
32 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
33 | |
---|
34 | AddModelToStrings("HardSphereStruct","coef_hss","parameters_hss","hss") |
---|
35 | End |
---|
36 | |
---|
37 | //AAO version |
---|
38 | Function HardSphereStruct(cw,yw,xw) : FitFunc |
---|
39 | Wave cw,yw,xw |
---|
40 | |
---|
41 | #if exists("HardSphereStructX") |
---|
42 | yw = HardSphereStructX(cw,xw) |
---|
43 | #else |
---|
44 | yw = fHardSphereStruct(cw,xw) |
---|
45 | #endif |
---|
46 | return(0) |
---|
47 | End |
---|
48 | |
---|
49 | /////////////////////////////////////////////////////////// |
---|
50 | // no smeared version is calculated - it is simply not appropriate |
---|
51 | |
---|
52 | /////////////////////////////////////////////////////////////// |
---|
53 | // unsmeared model calculation |
---|
54 | /////////////////////////// |
---|
55 | Function fHardSphereStruct(w,x) : FitFunc |
---|
56 | Wave w |
---|
57 | Variable x |
---|
58 | |
---|
59 | // SUBROUTINE HSSTRCT: CALCULATES THE STRUCTURE FACTOR FOR A |
---|
60 | // DISPERSION OF MONODISPERSE HARD SPHERES |
---|
61 | // IN THE PERCUS-YEVICK APPROXIMATION |
---|
62 | // |
---|
63 | // REFS: PERCUS,YEVICK PHYS. REV. 110 1 (1958) |
---|
64 | // THIELE J. CHEM PHYS. 39 474 (1968) |
---|
65 | // WERTHEIM PHYS. REV. LETT. 47 1462 (1981) |
---|
66 | // |
---|
67 | // Input variables are: |
---|
68 | //[0] radius |
---|
69 | //[1] volume fraction |
---|
70 | |
---|
71 | Variable r,phi,struc |
---|
72 | r = w[0] |
---|
73 | phi = w[1] |
---|
74 | |
---|
75 | // Local variables |
---|
76 | Variable denom,dnum,alpha,fbeta,gamm,q,a,asq,ath,afor,rca,rsa |
---|
77 | Variable calp,cbeta,cgam,prefac,c,vstruc |
---|
78 | // COMPUTE CONSTANTS |
---|
79 | // |
---|
80 | DENOM = (1.0-PHI)^4 |
---|
81 | DNUM = (1.0 + 2.0*PHI)^2 |
---|
82 | ALPHA = DNUM/DENOM |
---|
83 | fBETA = -6.0*PHI*((1.0 + PHI/2.0)^2)/DENOM |
---|
84 | GAMM = 0.50*PHI*DNUM/DENOM |
---|
85 | // |
---|
86 | // CALCULATE THE STRUCTURE FACTOR |
---|
87 | // |
---|
88 | // loop over q-values used to be here |
---|
89 | // DO 10 I=1,NPTSM |
---|
90 | Q = x // q-value for the calculation is passed in as variable x |
---|
91 | A = 2.0*Q*R |
---|
92 | // IF(A.LT.1.0D-10) A = 1.0D-10 |
---|
93 | ASQ = A*A |
---|
94 | ATH = ASQ*A |
---|
95 | AFOR = ATH*A |
---|
96 | RCA = COS(A) |
---|
97 | RSA = SIN(A) |
---|
98 | CALP = ALPHA*(RSA/ASQ - RCA/A) |
---|
99 | CBETA = fBETA*(2.0*RSA/ASQ - (ASQ - 2.0)*RCA/ATH - 2.0/ATH) |
---|
100 | CGAM = GAMM*(-RCA/A + (4.0/A)*((3.0*ASQ - 6.0)*RCA/AFOR + (ASQ - 6.0)*RSA/ATH + 6.0/AFOR)) |
---|
101 | PREFAC = -24.0*PHI/A |
---|
102 | C = PREFAC*(CALP + CBETA + CGAM) |
---|
103 | VSTRUC = 1.0/(1.0-C) |
---|
104 | STRUC = VSTRUC |
---|
105 | // 10 CONTINUE |
---|
106 | |
---|
107 | RETURN Struc |
---|
108 | End |
---|
109 | // End of HardSphereStruct |
---|