Runge-Kutta method in Excel VBA
Université d’Ottawa Faculté de génie Département de génie chimique et biologique
University of Ottawa Faculty of Engineering
Department of
Chemical and Biological Engineering
Fall 2019 1
CHG1371 PROJECT 2 DESCRIPTION
1. Background Consider the following system of three continuous stirred tanks, connected in series and filled with water:
To study the flow and mixing pattern in this system, salt was dissolved in the first tank to obtain a desired initial
salt concentration. Fresh water was then allowed to flow through the system, resulting in the dissolved salt to
flow through all three tanks and then eventually leaving the system. Each tank outlet stream is monitored with
an on-line thermal conductivity detector to provide instantaneous salt concentration measurements, 𝐶𝑆𝑖. By
plotting this data over time (Figure 1), we can determine how long it takes for all the salt to leave the system,
and the maximum salt concentrations held by each tank throughout the run.
Figure 1. Salt concentration measurements from the experimental system
0
50
100
150
200
250
300
350
400
450
0 20 40 60 80 100
Sa lt
C o
n ce
n tr
at io
n (
g/ L)
Time (s)
Cs1
Cs2
Cs3
500 L
𝐶𝑆1 (g/L)
250 L
𝐶𝑆2 (g/L)
1000 L
𝐶𝑆3 (g/L)
50 (L/s)
𝐶𝑆 = 0
50 (L/s)
𝐶𝑆1
50 (L/s)
𝐶𝑆2
50 (L/s)
𝐶𝑆3
CHG1371: Numerical Methods and Engineering Computation in Chemical Engineering
Winter 2020 2
It is also possible to numerically generate these salt concentration plots using differential equations. Assuming
that pure water is fed to the first tank and that each tank is perfectly mixed (i.e. the salt concentration in a tank
is uniform and equal to the concentration in the outlet stream from that tank), the following expressions for the
change in salt concentration over time can be determined for each tank:
𝑑𝐶𝑆1
𝑑𝑡 = −
�̇�
𝑉1 𝐶𝑆1 (Eq 1)
𝑑𝐶𝑆2
𝑑𝑡 =
�̇�
𝑉2 (𝐶𝑆1 − 𝐶𝑆2) (Eq 2)
𝑑𝐶𝑆3
𝑑𝑡 =
�̇�
𝑉3 (𝐶𝑆2 − 𝐶𝑆3) (Eq 3)
Here, 𝑉𝑖 and 𝐶𝑆𝑖 are the volume and salt concentration of each tank, and �̇� is the flowrate of water. The initial
salt concentration in tanks 1, 2 and 3 are 450 g/L, 0 g/L and 0 g/L, respectively. The tank volumes and water
flowrate are provided in the Block Flow Diagram.
2. Task For this project, you will determine the salt concentrations for each tank over time, by solving the system of
ordinary differential equations using a 2nd order or higher Runge-Kutta method. You will then compare and
discuss the differences between the numerical data with the experimental findings in Figure 1. The experimental
plot data is available in the provided Excel sheet. Hint – what is the solubility of salt in water?
The numerical solution must be solved in Microsoft Excel using VBA. The solution should be flexible and robust
enough that different parameters (e.g. different �̇�, 𝑉𝑖 and initial salt concentrations) could be easily changed
and a new solution would be automatically calculated.
3. Evaluation
A report will accompany the solution, a soft copy in .pdf format and must be submitted electronically prior to
the due date of Friday April 3rd, 2020 at 16:00. It is expected that the report should be about 6 pages, 1.5 spaced
and including figures, broken down as follows:
• 1 Page for Introduction/Background
• 2 Pages for VBA code design and Excel sheet set-up
• 2 Pages for Results/Discussion/Validation
• 1 Page for Improvements & Extensions/Conclusions
The VBA code should be included as text in an Appendix (not included in the number of pages). This project
should be done in groups of 2, and each member must share equal responsibility for the code and the report.
The deadline for joining a group on BrightSpace is March 20th, 2020 at 16:00. If you do not join a group by this
time, you will be randomly assigned. More information on the expectations of the report and the marking
scheme can be found in the Project Guidelines & Expectations document.