You are on page 1of 8

Anurag Ranjak (2012CH70148)

CHL-392
MATLAB Programming of Polymerization
Processes using Monte Carlo Techniques
Monte Carlo Methods are methods that use random numbers and probability
statistics to solve a given problem. In simulating events, as in the case of this
paper, a random number is generated, the different events in this case are the
different reactions taking place which for the system that I have considered are
the 22 reactions taking place. Probability of each of these reactions taking place
is calculated based on the rate of the reaction, which is divided by the sum of all
rates to give the probability. Depending on the random number generated and its
proximity to one of the 22 reactions points one of the reactions is chosen and
simulated. After the simulation of reactions some important property has been
calculated.

Process by which Polymer Formation is taking place.


The following are the initiation steps involved in the polymerisation process. I is
the initiator and C the catalyst. MA and MB are the monomers in the reaction.

In

the Equilibrium and


Propagation step five
species
are involved. First
we have
dormant chains that
react again by
the free radical
mechanism. Then
we have growing free radical chain and
polymer
chain that is those chains which
grow
again. To simulate
each reactions
we will
Assign a
dormant

cell matrix denoted by { } to each of


and free radical chain.

So a cell matrix is an
array of vectors. Every
time we
add a monomer to a cell
matrix
we will increment the length
cell matrix and add one
more vector in the cell
matrix we will use indexing to keep track of whether
A(1) got added or B(0). In case of dormant chain
converting to free radical chain we will remove that
particular vector from the cell matrix of the dormant
chain and add it to the cell matrix for the free radical
chain. Dead chains are represented by a normal matrix
which is an nxn matrix.

dead
wont

the

of the

matrix is shifted
whether
normal

For the
followed.

Once free radicals terminate and give a


dead polymer the vector from the cell
from the cell matrix and indexed depending upon
A was added or B and then it is added to the
matrix P

purposes of simulation the following algorithm has been

Algorithm used for the code. The program has been simulated based on the time
of the reaction. Note that the reaction rate constants used can make a significant
difference to the time required to run the code. As I couldnt find the rate
constants through a literature survey, I have taken them as input from the user.
One drawback of the method used is that it makes use of dynamic arrays and
hence every time we have to allocate some value, Matlab makes a new array
copies the values of the older array into the new array and then assigns the new
value this makes the code computationally slower. A language which allows
dynamic array formation would have been better suited for the purposes of the
code. Conversion with time is plotted in the code

Examples of execution of various reaction types


The increment in time is calculated as and updated in every iteration.

Simulating the initiation reaction

Decrease the number of initiator molecules


Decrease the number of catalyst molecules
Increase the number of PR molecules

Xi = Xi-1;
Xc = Xc-1;
Xpr = Xpr +

1;

Increase the number of CX molecules

Xcx = Xcx +

1;

Simulating the equilibrium reaction

Decrease number of catalyst molecules


Xc = Xc -1;
Decrease number of dormant chains
Xra = Xra + 1;
Increase number of growing radical chains
Xda = Xda - 1;
Randomly select one chain from cell matrix Da and transfer
Xaa(u) = Xa;
To Ra
u = u + 1;
LEN = length(Da);
rvec = randsample(LEN,1);
Ra{Xra} = Da{rvec};
Da(rvec) = [];

Simulating the Propagation Reaction

Decrease the number of monomer A by one


Find the total number of Radical chains
Randomly choose one chain
randsample(LEN,1);

Xa = Xa -1;
LEN = length(Ra);
rvec =

Convert the obtained chain which is a cell matrix to

vec =

cell2mat(Ra(rvec));

To a normal matrix as it is easier to perform operations on it


Add the monomer to the particular chain specifying the
monomer - lvec = length(vec) + 1;
Added by index
vec(lvec) = 1 ;
Convert normal matrix to cell matrix form and add to Ra

Ra{rvec} = vec;
Simulating the cross-propagation reaction

Decrease the number of monomers B by one

Xb = Xb

-1;

Increase in the number of growing polymer radical B by 1


1;

Find the total number of Radical chains

Xrb = Xrb +
LEN =

length(Ra);

Randomly choose 1 chain


randsample(LEN,1);

Convert to cell matrix

rvec =
vec =

cell2mat(Ra(rvec));

Add the monomer to the particular chain


length(vec) + 1;

lvec =

Specify monomer added


vec(lvec) = 0;

Convert from normal matrix to a cell matrix and place it in Ra


vec;

Finally reduce the growing radical chains A

Rb(Xrb) =
Xra = Xra

-1;

Remove chain from Ra


= [];

Simulating the Termination Step

Ra(rvec)

Find length of Ra

LEN =

length(Ra);

Increase the number of dead polymers

rvec1 =

randsample(LEN,1);

Choose two random chains from Ra

rvec2 =

randsample(LEN,1);

Convert into normal matrices

vec1

=cell2mat(Ra(rvec1));

Summation of two growing radical chains take place


cell2mat(Ra(rvec2));

Reduce number of growing radical chains by 2

vec2 =
lvec1 =

length(vec1);

lvec2 =

length(vec2);

Xp = Xp

+ 1;

P(Xp) =

lvec1 +lvec2;
Xra -2

Xra =
Ra{rvec1} = [];
Ra{rvec2} = [];

Note on running the code


A plot of the reaction being chosen for execution is plotted along with time to
give a sense of how the entire system of reactions is proceeding. The time taken
by the code to run will depend on numerous factors such as the rate constants
used, the initial concentrations of monomers A and B which play a role in
deciding the more probable time. The paper mentioned initial concentrations but
the rate constants were not given properly I have input the information that was
available in the paper into the code but the rate constants have been left for the
user to input. If the time to be simulated is large then we will need a powerful
system to run the code as it was difficult to go beyond 100 times the starting
time increment on my laptop and upto that value only reactions 3 or 4 were
being chosen as the concentration of monomers was significant and the other
reactions had very less probability of happening as a result larger chain
formation was not taking place and only single R 1a or R1b were being formed the
number of such components have been output. Also average length vs time is
being stored in an array and can be plotted should the need arise and so can the
average concentration vs time which is also being calculated. A copy of the code
is attached with the file.
In the current code value of the reaction being executed is being printed with
time. To keep track of the simulation events.
Conversion defined by the percentage of monomers of A that react is also being
recorded and can be displayed by removing the comment command from the
statement and time is also being recorded, so if the code is simulated then it can

give the plot for conversion vs time. Similarly PDI, Molecular Weight Distribution
can also be done. I havent been able to do that because the data is not available
and due to the limited computing power.

You might also like