1 | close all |
---|
2 | clear all |
---|
3 | |
---|
4 | R0=20; %mean radius. unit: Angstroms |
---|
5 | PDI=0.1; %unit: relative polydispersity |
---|
6 | volF=0.1; |
---|
7 | contrast=6e-6; %contrast,angstrom^-1, scattering length density difference |
---|
8 | |
---|
9 | Filename='testPolydisperseGaussianSphere.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 | FQ2=beta.*IQ; |
---|
60 | |
---|
61 | normQ=Q*R0*2; |
---|
62 | Sq=HSS_SQ(volF,normQ); |
---|
63 | |
---|
64 | figure |
---|
65 | loglog(Q,IQ,'bo-'); |
---|
66 | figure |
---|
67 | plot(Q,beta,'g*-'); |
---|
68 | figure |
---|
69 | plot(Q,Sq,'b.-'); |
---|
70 | figure |
---|
71 | Sq_eff=1+beta.*(Sq-1); |
---|
72 | plot(Q,Sq_eff,'gd-'); |
---|
73 | |
---|
74 | fileID=fopen(Filename,'w'); |
---|
75 | |
---|
76 | FileString=strcat('Filename:',Filename, '**R0=', num2str(R0),'**PDI=', num2str(PDI),... |
---|
77 | '**contrast',num2str(contrast), '**volF=',num2str(volF)); |
---|
78 | Outputformat='File format : Q, <FQ>, <FQ^2>, PQ, betaQ, SQ, SQ_Eff'; |
---|
79 | fprintf(fileID,'%s\n', FileString); |
---|
80 | fprintf(fileID,'%s\n', Outputformat); |
---|
81 | for i=1:length(Q) |
---|
82 | %file format : Q, <FQ>, <FQ^2>, PQ, betaQ, SQ, SQ_Eff |
---|
83 | fprintf(fileID,'%e\t%e\t%e\t%e\t%e\t%e\t%e\n',... |
---|
84 | Q(i),FQ(i),IQN(i),IQ(i),beta(i),Sq(i),Sq_eff(i)); |
---|
85 | end |
---|
86 | |
---|
87 | fclose(fileID) |
---|
88 | |
---|