1 | close all |
---|
2 | clear all |
---|
3 | |
---|
4 | R0=20; %mean radius. unit: Angstroms |
---|
5 | PDI=0.15; %unit: relative polydispersity |
---|
6 | volF=0.1; |
---|
7 | contrast=6e-6; %contrast,angstrom^-1, scattering length density difference |
---|
8 | |
---|
9 | Filename='testPolydisperseGaussianSphere2.dat'; |
---|
10 | |
---|
11 | Q=[0.001:0.001:0.8]; |
---|
12 | |
---|
13 | N=10; |
---|
14 | |
---|
15 | deltaR=R0*PDI; |
---|
16 | SplitN=100; |
---|
17 | R=[R0/N:deltaR/SplitN:R0+5*deltaR]; |
---|
18 | |
---|
19 | FGaussian=1/sqrt(2*pi*deltaR^2)*exp(-(R-R0).^2/2/deltaR^2); |
---|
20 | |
---|
21 | Ni=FGaussian*deltaR/SplitN; |
---|
22 | %trapz(R,FGaussian) |
---|
23 | %sum(FGaussian*deltaR/SplitN) |
---|
24 | sum(Ni) |
---|
25 | |
---|
26 | |
---|
27 | Vi=4*pi*R.^3/3; |
---|
28 | AverageVolume=sum(Ni.*Vi); |
---|
29 | |
---|
30 | |
---|
31 | IQN=zeros(size(Q)); |
---|
32 | %IQ=sphereFormFactor(Q,R0); |
---|
33 | |
---|
34 | for i=1:length(R) |
---|
35 | IQN=IQN+Ni(i)*Vi(i)^2*contrast^2*sphereFormFactor(Q,R(i)); |
---|
36 | %IQ=1*AverageVolume^2*contrast^2*sphereFormFactor(Q,R0); |
---|
37 | %IQ=sphereFormFactor(Q,R(500)); |
---|
38 | end |
---|
39 | |
---|
40 | IQ=volF/AverageVolume*IQN; |
---|
41 | |
---|
42 | IQ=IQ*1e8; %convert from A^-1 to cm^-1 |
---|
43 | loglog(Q,IQ,'b.-') |
---|
44 | |
---|
45 | FQ=zeros(size(Q)); |
---|
46 | |
---|
47 | for i=1:length(R) |
---|
48 | FQ=FQ+Ni(i)*Vi(i)*contrast*3*(sin(Q*R(i)) - Q*R(i).*cos(Q*R(i))) ./ (Q*R(i)).^3; |
---|
49 | end |
---|
50 | |
---|
51 | beta=FQ.^2./IQN; |
---|
52 | figure |
---|
53 | semilogx(Q,beta,'g*-'); |
---|
54 | |
---|
55 | %stop |
---|
56 | |
---|
57 | NormIQN=IQN/IQN(1); |
---|
58 | |
---|
59 | FileString=strcat('Filename:',Filename, '**R0=', num2str(R0),'**PDI=', num2str(PDI),... |
---|
60 | '**contrast',num2str(contrast), '**volF=',num2str(volF)); |
---|
61 | Outputformat='File format : Q, <FQ>, <FQ>^2, <FQ^2>, betaQ, SQ, SQ_Eff'; |
---|
62 | |
---|
63 | FQ2=beta.*IQ; |
---|
64 | |
---|
65 | normQ=Q*R0*2; |
---|
66 | Sq=HSS_SQ(volF,normQ); |
---|
67 | |
---|
68 | figure |
---|
69 | loglog(Q,IQ,'bo-'); |
---|
70 | figure |
---|
71 | plot(Q,beta,'g*-'); |
---|
72 | figure |
---|
73 | plot(Q,Sq,'b.-'); |
---|
74 | figure |
---|
75 | Sq_eff=1+beta.*(Sq-1); |
---|
76 | plot(Q,Sq_eff,'gd-'); |
---|
77 | |
---|
78 | fileID=fopen(Filename,'w'); |
---|
79 | fprintf(fileID,'%s\n\r', FileString); |
---|
80 | fprintf(fileID,'%s\n\r', Outputformat); |
---|
81 | for i=1:length(Q) |
---|
82 | %file format : Q, <FQ>, <FQ>^2, <FQ^2>, betaQ, SQ, SQ_Eff |
---|
83 | fprintf(fileID,'%e\t%e\t%e\t%e\t%e\t%e\t%e\n\r',... |
---|
84 | Q(i),FQ(i),FQ2(i),IQ(i),beta(i),Sq(i),Sq_eff(i)); |
---|
85 | end |
---|
86 | |
---|
87 | fclose(fileID) |
---|
88 | |
---|