-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.m
More file actions
97 lines (85 loc) · 2.89 KB
/
example.m
File metadata and controls
97 lines (85 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
% Some simple examples using functions to evaluate
% phase behavior of random copolymers of wormlike chains
% kmaxwlc.m and s2invwlc
% -> use kmaxgc.m and s2invgc.m for Gaussian chains
% -> use kmaxrr.m and s2invrr.m for perfectly rigid rods
% (expect rigid rod functions to be relatively slow with
% large number of monomers)
addpath('functions')
%close all
clear
% Example 1: plot density-density correlations vs wavevector at different CHI
N=100; % total of 100 monomers
NM=0.1; % each monomer has 0.1 Kuhn steps
LAM=-0.75; % anti-correlated random copolymer
FA=0.5; % equal chemical composition
% find spinodal CHIS
[kval,sval]=kmaxwlc(N,NM,FA,LAM);
CHIS=0.5*sval;
CHI=CHIS*[0 0.2 0.4 0.6 0.8];
RM=sqrt(r2wlc(NM)); % end-to-end distance of a monomers
K0=1e-2; % minimum wavevector
KF=1e2; % maximum wavevector
NK=201; % number of wavevectors
K=transpose(logspace(log10(K0),log10(KF),NK))/RM;
% evaluate s2inv
[SINV]=s2invwlc(N,NM,FA,LAM,K);
figure;hold
for I=1:length(CHI)
COL=(I-1)/(length(CHI)-1);
loglog(RM*K,1./(-2*CHI(I)+SINV),'-','LineWidth',2,'Color',[COL 0 1-COL])
end
xlabel('R_Mq');ylabel('S(q)')
set(gca,'xscale','log');set(gca,'yscale','log');
axis([K0 KF 1e-4 1e-1]);box on
saveas(gcf,'example_figures/example1.png')
% Example 2: find spinodal vs. fraction of A monomers
N=100; % total of 100 monomers
NM=10; % each monomer has 10 Kuhn steps
LAM=0; % ideal random copolymer
FAV = linspace(0.1,0.9,101);
CHIS = zeros(length(FAV),1);
for ii = 1:length(FAV)
FA = FAV(ii);
[kval,sval,d2gam2]=kmaxwlc(N,NM,FA,LAM);
CHIS(ii)=0.5*sval; % spinodal
end
figure;plot(FAV,CHIS*NM,'k-','linewidth',2)
xlabel('f_A');ylabel('\chi_S v N_M');box on
saveas(gcf,'example_figures/example2.png')
% Example 3: find critical wavemode and spinodal vs. chemical correlation
N=100; % total of 100 monomers
NM=100; % each monomer has 100 Kuhn steps
FA=0.5; % equal chemical composition
RM=sqrt(r2wlc(NM)); % end-to-end distance of a monomers
LAMV = linspace(-1,.99,501);
KS = zeros(length(LAMV),1);
CHIS = zeros(length(LAMV),1);
D2S = zeros(length(LAMV),1);
for ii = 1:length(LAMV)
LAM = LAMV(ii);
[kval,sval,d2gam2]=kmaxwlc(N,NM,FA,LAM);
KS(ii)=kval;
CHIS(ii)=0.5*sval; % spinodal
D2S(ii)=1/(sval^2*RM^2)*d2gam2;
end
figure;plot(LAMV,RM*KS)
xlabel('f_A');ylabel('R_Mq^*')
figure;plot(LAMV,CHIS*NM)
xlabel('f_A');ylabel('\chi_Sv')
figure;plot(LAMV,D2S/NM);
% Example 4: find peak sharpness vs. chemical correlation
N=100; % total of 100 monomers
NM=100; % each monomer has 100 Kuhn steps
FA=0.5; % equal chemical composition
CHI=0./NM; % Flory-Huggins parameter
RM=sqrt(r2wlc(NM)); % end-to-end distance of a monomers
LAMV = linspace(-1,.99,501);
D2GAM2 = zeros(length(LAMV),1);
for ii = 1:length(LAMV)
LAM = LAMV(ii)
[kval,sval,d2gam2]=kmaxwlc(N,NM,FA,LAM);
D2GAM2(ii)=d2gam2./(sval^2*RM^2);
end
figure;plot(LAMV,D2GAM2/NM)
xlabel('\lambda');ylabel('Peak sharpness')