0% found this document useful (0 votes)
14 views

Matlab

The document provides the code to model the concentration of H2O2 in a tank over time. The code derives the differential equation, calculates the flow rate to achieve steady state concentration, integrates the equation numerically over time, and plots the results. It also includes a function to determine the time to reach 90% of the target concentration.

Uploaded by

ASAD AYUB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Matlab

The document provides the code to model the concentration of H2O2 in a tank over time. The code derives the differential equation, calculates the flow rate to achieve steady state concentration, integrates the equation numerically over time, and plots the results. It also includes a function to determine the time to reach 90% of the target concentration.

Uploaded by

ASAD AYUB
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Construct the material balance for H2O2and derive the differential equation for the
evolution of the number of moles of H2O2in the tank.

Answer:

Given that,
𝐴𝑐𝑐𝑢𝑚𝑎𝑙𝑎𝑡𝑖𝑜𝑛 = 𝐼𝑛 − 𝑂𝑢𝑡 + 𝐺𝑒𝑛𝑒𝑟𝑎𝑡𝑖𝑜𝑛

Which translates to the equation below


𝑑𝑛(𝑡)
= 𝐶1(𝑡) ∗ 𝑉1(𝑡) − 𝐶𝑜𝑢𝑡(𝑡) ∗ 𝑉𝑜𝑢𝑡(𝑡) + (𝑟𝐴)
𝑑𝑡

Where,
𝑉𝑜𝑢𝑡 = 𝑉1(𝑡) + 𝑉2(𝑡)
𝑛
( )
𝐶𝑜𝑢𝑡 = 𝐶 𝑡 =
𝑉
−𝑟𝐴 = 𝑘 ∗ 𝐶(𝑡) ∗ 𝑉

Therefore
𝑑𝑛(𝑡) 𝑛
= 𝐶1(𝑡) ∗ 𝑉1(𝑡) − [𝑉1(𝑡) + 𝑉2(𝑡)] − 𝑘 ∗ 𝐶(𝑡) ∗ 𝑉
𝑑𝑡 𝑉
= 𝐶1(𝑡) ∗ 𝑉1(𝑡) 𝑛(𝑡) 𝑛(𝑡)
− [𝑉1(𝑡) + 𝑉2(𝑡)] − 𝑘 )𝑉
𝑉
( 𝑉
𝑛(𝑡)
= 𝐶1(𝑡) ∗ 𝑉1(𝑡) − [𝑉1(𝑡) + 𝑉2(𝑡)] − 𝑘 ∗ 𝑛(𝑡)
𝒅𝒏(𝒕) 𝑉 𝒏(𝒕)
∴ = 𝑪𝟏(𝒕) ∗ 𝑽𝟏(𝒕) − [𝑽𝟏(𝒕) + 𝑽𝟐(𝒕)] − 𝒌 ∗ 𝒏(𝒕)
𝒅𝒕 𝑽

2.
From the differential equation find the flow rate of the second stream such that the steady
state concentration of H2O2 in the tank is 4M.

Answer:
𝑑𝑛
(𝑡)
Assume steady-state, therefore, =0
𝑑𝑡
Hence,
𝑛(𝑡)
0 = 𝐶1(𝑡) ∗ 𝑉1(𝑡) − [𝑉1(𝑡) + 𝑉2(𝑡)] − 𝑘 ∗ 𝑛(𝑡)
𝑛(𝑡) 𝑉
[𝑉1(𝑡) + 𝑉2(𝑡)] = 𝐶1(𝑡) ∗ 𝑉1(𝑡) − 𝑘 ∗ 𝑛(𝑡)
𝑉
𝐶1(𝑡) ∗ 𝑉1(𝑡) 𝑘 ∗ 𝑛(𝑡)
[𝑉1 (𝑡) + 𝑉2 (𝑡)] = − ()
𝑛(𝑡)⁄ 𝑛 𝑡 ⁄
𝑉 𝑉
𝑽𝟐 𝑪𝟏(𝒕) ∗ 𝑽𝟏(𝒕) (𝒕) − 𝒌 ∗ 𝑽
(𝒕) = 𝑪𝟐(𝒕) −𝑽
𝟏
3.
Develop the code required to integrate the differential equation (use 1s for the time step).
Using multiplot construct a plot of the following form:
a.
Evolution of the molar flow rate of H2O2 into the tank
b.
The target concentration of H2O2 in the tank Evolution of the actual concentration of H2O2
in the tank
c. Evolution of the molar flow rate of H2O2 out of the tank end
d.
Evolution of the molar rate at which H2O2 is lost via decomposition

Answer:

(CHANGE LABEL FOR 3RD GRAPH INTO MOLE AND THE LABLE TO LOSS
CONCNETRATION)
(Refer to the Matlab workbook for the answers for the following tasks)
4.
Include a function in your code that determines the time (in minutes) it takes the system from
start-up to reach 90% of the target concentration. Provide this time in the document.

(Refer to the Matlab workbook for the answers for the following tasks under “Command
Window”)
(INCLUDE THE COMMAND WINDOW SS HERE)
5.
Line Function
1 To clear all variables
Resets and deletes figures and all graphics objects whose handles are not hidden
2
Initial conditions in the dilution system which includes:
- The overall volume of the tank;
- Volumetric flowrate of the first stream (H2O2 inlet stream);
- Initial concentration of H2O2 in the first inlet stream;
- Initial concentration in the tank;
4-14 - Desired (i.e set point) concentration;
- Initial time;
- Time step;
- Rate constant;
- Initial moles of H2O2 in the tank;
- Volumetric flowrate of the second stream (water inlet stream).
16 For loop iterations where “i” ranges from 1 to 1000
18 Molar flowrate of H2O2 entering the dilution system
Change in molar concentration flowrate of H2O2 in the system using the
19-20
equation derived from Task 1
21 Change in time
Final molar concentration flowrate of H2O2 at the outlet stream after dilution in the
22 tank
23 Loss of H2O2 due to decomposition from metal ions
25 End Function
27-29 While loop function to complete Task 4
30 End while loop function
fprint function to print desired information on the “Command Window” which in this
32
case was the time taken to achieve 90% of the desired concentration
Graph plot function representing the change in molar flowrate of H2O2 inlet
34-40 stream entering the tank over time
Graph plot function representing the change in molarity of H2O2 in the dilution tank over
time
42-50 (Line 45: Reference line. refline function was not used because the line
was not able to be customised to achieve a red, dash line to indicate set point
concentration)
52-59 Graph plot function representing the change in concentration of H2O2
6. Provide the code with line numbers
(CHANGE FPRINTF TO THE ONE THAT TOMMY SEND TO (I+1)/60)

1 clear
2 clf
3
4 %Initial conditions
5 V=1000; %volume of tank [L]
6 V1(1)=0.5; %Flowrate 1 [L/s]
7 C1(1)=6; %Concentration of H2O2[mol/L]
8 C(1)=0; %Concentration in tank[mol/L]
9 C_sp=4; %Set concentration [mol/L]
10 t(1)=0; %Initial time [s]
11 dt=1; %Time step [s]
12 k=0.00015; %Rate constant [s^-1]
13 n(1)=C(1)*V; %moles in tank
14 V2(1)=(C1(1)*V1(1)/C_sp)-V1(1)-k*V; %Flowrate 2 [L/s]
15
16 for i=1:10000
17
18 n_inlet(i+1)=C1(1)*V1(1);
19 n(i+1)=n(i)+(V1(1)*C1(1)-(V1(1)+...
20 V2(1))/(V/n(i))-k*n(i))*dt;
21 t(i+1) =t(i)+dt;
22 n_out1et(i+1)=((V1(1)+V2(1))/(V/n(i)))*dt;
23 n_loss(i+1)=(k*n(i))*dt;
24
25 end
26
27 i=1;
28 while n(i)<0.9*C_sp*V
29 i=i+1;
30 end
31
32 fprintf('time to achieve 0.9 concentration: %.2f minutes.\n',(i+1)/60)
33
34 subplot(3,1,1)
35 plot(t,n_inlet,'y', 'Linewidth', 2)
36 ylim([0 5])
37 ylabel('Moles (mol/s)')
38 xlabel('Time (s)')
39 title('Molar Flowrate in the Tank')
40 legend('Molar Flowrate')
41
42 subplot(3,1,2)
43 plot(t,n/V,'g','Linewidth', 2)
44 hold on
45 plot([0 10000],[C_sp C_sp],'--r','Linewidth', 2)
46 ylim([0 5])
47 ylabel('Molarity (M)')
48 xlabel('time (s)')
49 title('Change of Molarity Over Time')
50 legend('Molarity (M)','Set Point Concentration (M)')
51
52 subplot(3,1,3)
53 plot(t,n_out1et,'r','Linewidth', 2)
54 hold on
55 plot(t,n_loss,'Linewidth', 2)
56 ylabel('Concentration (mol/L)')
57 xlabel('time (s)')
58 title('Change in concentration over time')
59 legend('Concentration without loss','Concentration with loss' )

You might also like