-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.m
More file actions
64 lines (55 loc) · 2.15 KB
/
Copy pathmain.m
File metadata and controls
64 lines (55 loc) · 2.15 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
function [Mn, Mw, PDI,weight,T_unit, avg_T, avg_DB, DB, dist_to_core, avg_DTC] = main(rate_ratio, feed_ratio,conversion)
%------------------------------------------
%Input:
%rate_ratio: reaction rate ratio, Kthf:Kegde
%feed_ratio: EGDE:THF
%conversion: final conversion where the reaction is terminated
%------------------------------------------
%output:
% Mn: Number average molecular weight
% Mw: Weight average molecular weight
% PDI: Polymer dispersity index
% weight: molecular weight of every polymer chain
% T_unit: Terminal units of every polymer chain
% avg_T: Average terminal units per chain
% avg_DB: Average degree of branching per chain
% DB: Degree of branching, recorded by every chain
% dist_to_core: distance to the core of every chain
% avg_DTC: average distance to the core
% set reaction rate constant ratio, kTHF: kPO
global RATE_RATIO
RATE_RATIO = rate_ratio;
%set reactant numbers, EGDE and THF
global FEED_RATIO %EGDE:THF
FEED_RATIO = feed_ratio;
global EGDE_NUM
EGDE_NUM = 2000;
global THF_NUM
THF_NUM = EGDE_NUM / FEED_RATIO;
init_eff = 1; %initiation efficiency is set to 1 as default
% represent EGDE chains using structure arrays
% inserted_THF -- how many THF are in chain i
% inserted_chain_pos -- the position where other chains inserts,array is
% used because muptile chains could be inserted
% inserted_chain_serial -- the serial number of above chains
% chain_inserting -- the serial number of the chain which chain i
% inserts into
% polymer_num -- records the number of the polymer the chain belongs to, one chain
% could only belong to one polymer
global chain;
for i = 1:EGDE_NUM * init_eff
chain(i).inserted_THF = 0;
chain(i).inserted_chain_pos = [];
chain(i).inserted_chain_serial = [];
chain(i).chain_inserting = 0;
chain(i).polymer_num = 0;
end
%conduct reactions, record parameters
rng('default');
rng('shuffle'); %generate different random sequence
reaction(conversion);
%demonstrate final results
[Mn,Mw,PDI,weight,T_unit,DB,dist_to_core] = result();
avg_T = mean(T_unit); % average number of terminal units per chain
avg_DB = mean(DB); % average degree of branching
avg_DTC = mean(dist_to_core); % average distance to the core