Group 9 Assignment 1
Group 9 Assignment 1
A Report Presented to
The Department of Chemical Engineering
By
Group 9
Group Members
*Corresponding Author:
Course Lecturer:
In the second problem, we were tasked with finding the root of nonlinear equations. For the first of
the two questions posed, the root of the given equation was found manually using both Newton-
Raphson’s and the interval bisection algorithms. This problem was also solved using Excel’s goal
seek functionality and by implementing the interval bisection algorithm from scratch in scilab.
Without doubt, the Newton-Raphson method bested the interval bisection method in converging to
a solution under 4 iterations compared to the interval bisection method which required 26 iterations
for the same level of accuracy. In the second of the two questions, we exploited scilab’s fsolve
function to find the volume of Nitrogen gas using van der Waals’ equation of state.
In the third problem, we derived a mechanistic model for the height of liquid in a liquid storage
tank. The modelling process was simplified via reasonable assumptions such as perfect mixing,
constant liquid density, and constant cross sectional area. A closed form expression for the
dynamic response of the liquid was obtained using linear analysis, after which the dynamic
response of the liquid level was determined numerically by implementing Euler’s explicit method
and Runge-Kutta method on scilab. For a flow coefficient of 10, the results of both methods
gradually became distinguishable as the step size increased. As a trivial exercise, we varied the
value of the flow coefficient and observed that for large values, Euler’s explicit method was less
stable than the Runge-Kutta method.
In the final question, we formulated an appropriate least squares problem to best fit a given
function to the rate coefficient and temperature data for a given reaction. The system of equations
generated was solved manually and programmatically. On obtaining the necessary parameters, we
observed that there was a clear difference in results obtained manually and programmatically, yet
the parameters obtained in both cases fitted the data quite well. This led us to conclude that the
difference in results was due to rounding error within the calculator.
Table of Contents
Attestation of Authorship 4
Contributions 5
1. Introduction 6
2. Results 8
2.1 Section 1 8
2.1.1 Cramer’s Rule 9
2.1.2 Matrix Inverse Method 11
2.1.3 Gaussian Elimination 13
2.1.4 Spreadsheet Solution 14
2.1.5 Scilab Solution 15
2.2 Question 2 17
2.2.1 Question 2a 17
2.2.1.1 Newton-Raphson Method 17
2.2.1.2 Interval Bisection Method 18
2.2.1.3 Spreadsheet Solution 20
2.2.1.4.Scilab Solution 20
2.2.2 Section 2b 22
2.2.2.1 Spreadsheet Solution 22
2.2.2.2 Scilab Solution 24
2.3 Section 3 27
2.3.1 Model Derivation 27
2.3.2 Explicit Euler’s Method 29
2.3.3 Runge-Kutta 4th Order Method 30
2.3.4 Comparison of the two Methods 31
2.4 Question 4 32
2.4.1 Manual Solution 32
2.4.2 Spreadsheet Solution 34
2.4.3 Scilab Solution 36
3. Discussion of Results 37
4. Conclusion 39
Attestation of Authorship
We hereby attest to the originality of our work and establish that we have not in any way copied or
reproduced the work of other groups or one that was previously submitted in the past years. All
parts of this report, including the solutions to the problems, and the attached spreadsheet and
program files, have been entirely developed by us without direct input (solution approaches were
only discussed with other groups) from any person other than those listed below.
Gabriel I. Kasali
170401008
Author Contribution
Mathematical modelling has always been an important activity in science and engineering because
of how it helps us formulate real-life situations in a mathematical form for the purpose of
understanding, modifying, and controlling them to suit our needs or to make decisions. For
example, one type of event which has occurred in several places around the world is the boiling
liquid expanding vapour explosion (BLEVE). In such cases, it is often important to estimate the
radiation levels at key distances from the event as well as projectiles from the rupture of the vessel
(Hangos, 2001). This is one area where predictive mathematical models can be used to estimate
the level of radiation at nominated distances from the BLEVE, thus providing input to planning
decisions.
Modelling can be done for a number of other reasons. To the chemical engineer,
mathematical modelling is valuable in the following areas:
● Process Design. For example a model could be used in conducting feasibility analysis of
novel designs.
● Process control, e.g examining regulatory control strategies and analysing dynamics for set
point changes or disturbances.
● Process safety, eg detecting hazardous operating regimes and estimating the accidental
release events
● Troubleshooting - identifying likely causes for quality problems as well as likely causes for
process deviations.
● Operator training
● Optimization
There are three broad classifications of models, namely, fundamental, empirical, and semi-
empirical models. The fundamental model describes physico-chemical processes using
engineering knowledge, and does not involve direct use of measurement data. Black box models,
on another hand, describe physico-chemical models using collected sets of measurement data and
do not require prior engineering knowledge of the system. Semi-empirical models are the most
practical process engineering models because they bring together the features of both
fundamental and empirical models. A good example of this is rate law for chemical kinetics.
2.1 Section 1
The figure below depicts a chemical engineering process application involving three reactors, A, B,
and C operating at steady state. Given the volumetric and mass flow rates into and out of the
reactors, we are interested in finding the concentration of the chemical species within them.
3
Volumetric flow rates(m / s):Q AB =40 , Q AC =80 , QBA =60 , QBA =20 ,QCout =150
Our solution approach to this problem shall be based upon the following details specified in
the problem and assumptions:
We now present the manual solution to these equations via three different approaches.
Where,
And
The adjugate of matrix A is the transpose of the matrix of cofactors of A and is obtained as follows
Thus,
2.1.3 Gaussian Elimination
In this approach, we transform the augmented matrix A into an upper triangular matrix through
elementary row operations and then obtain the complete solution via back substitution. The
augmented matrix is given below.
The first row operation seeks to turn the first entry in row 2 to zero as shown below
From here we quickly observe that
Next, we used the solver add-in program. On the solver dialogue box, cells B7 to B9 were
declared as cells whose values should be varied to arrive at the final solution. We also included
three constraints: that the values in cells C2 to C4 be the same as those in cells D2 to D4.
Because the concentration of the species cannot be a negative number, we ensured to tick the box
Finally, the Simplex LP solving method was selected since our set of equations were linear. With
these in place, the problem is solved by clicking the solve command on the dialog box. The
solution is presented in the last figure.
2.2.1 Question 2a
We want to determine the temperature of the material at RT using the Newton-Raphson algorithm.
The algorithm requires an initial guess value and is expressed as follows:
We must first express the equation given in the form f (T )=0 after which the derivative of this
function, f ' (T ) is computed. On substituting R0 and RT into the equation we have
Noting that the coefficients of T in f (T ) are very small, we could assume that powers of T higher
than 1 are negligible. Thus,
This exercise has provided for us a reasonable starting value and we can now employ the
algorithm to find T 1 .
This process is repeated three times and the results are shown below
In just 4 iterations, the Newton-Raphson method converges to a root with an error of about 10-8.
Compared to the next method we will see, this is much faster.
Because f(c) > f(a), a now takes on the value of c while b remains the same. Then we repeat the
process above. With 16 iterations, the final value of T is 260.21881°C with an error of 10-6.
s/N a b c f(a) f(b) f(c)
We assigned the value of T and RT to the cells B11 and B15 respectively. We also assigned cells
B6, B7, B8, B9 and B10 to the given fixed values of Ro, A, B, C, and D respectively. Using Excel’s
“goal seek”, we obtained the value of T = 261.2187 oC that made Eq. equal to 300.
2.2.1.4.Scilab Solution
Two functions were created, one to determine the residue, and another, which was an
implementation of the interval bisection algorithm that has been discussed earlier. The tolerance
was set to 10-6 and the program was run. After 16 iterations, the algorithm converged to a solution
2.2.2 Section 2b
In this problem, we are required to determine the volume of Nitrogen gas at 298 Kelvin and at
specified pressures using the van der Waals equation of state given by
In the excel spreadsheet below, the parameters specified in the problem were entered in the range
A1:C7 together with their values and their units. The pressure determination of the system for each
percentage above the base pressure was carried out in the range A10:I10. For instance, given the
base pressure of 13.5 atm, 15% above this pressure would be
15
(13.5)+13.5=15.525 atm
100
The formula for this can be seen in the text box (follow the arrow that emanates from cell C10).
Also note the use of absolute references because the formulas would be copied to other cells. In
the range A11:I11, the ideal gas volume was calculated, and the values obtained were passed
down to the range A12:I12 which were to be used as the starting values for the “goal seek”
approach.
Note: We do not want to paste the whole contents (including the formula) of the range A11:I11. To
paste only the values displayed, right click on the cell you want to paste in and from “Paste
options”, select “values”.
Using Eq.3.2.1, f (V ) was calculated in the cells B13 to I13. For readability, these cells were
merged with cells B14 to I14 respectively.
The final solution as well as the plot we generated are presented below.
2.2.2.2 Scilab Solution
The van der Waals equation of state was expanded and rearranged to the following form where
the right-hand side of the equation was 0.
The known parameters were instantiated, and using the equation above, a custom function was
created to return the residue obtained for a given pressure and volume. We want this residue to be
equal to zero as seen in the previous equation.
An informed guess for the real volume was made using the ideal gas equation of state. It was
proper to do this because the ideal gas EOS would give a reasonably fair approximation of the real
volume. Finally, the real volume was determined using the fsolve function for each pressure and
the result was plotted.
Below, we present the output on the scilab console and the plot that was generated.
2.3 Section 3
The schematic diagram below represents a liquid tank system where the inlet and outlet flows are
volumetric quantities.
Accumulation=Input−Output +Generation−Consumpt i on
Since the system involves no reactions, the generation and consumption terms are zero. Therefore
the material balance equation reduces to:
Accumulation=Input – Output
The mass of liquid is a product of its volume and its density. Thus, the flow of liquid in and out can
be represented by ρ q i∧ρq . Substituting these into the material balance equation, we have
Noting that V = A h and that the liquid density and the cross sectional area are constant terms
which can be brought out of the derivative, we have
dh
(c). Assuming A = 100cm2, and the steady state inflow, q i=10 c m3 / s. At steady state, =0.
dt
Therefore,
Taking Cv, the flow coefficient, as 10, then the steady state height becomes h=1 cm.
(d). If the operator of the tank suddenly changes the inlet flow from the initial steady state by 50%
and maintains it at the new value, then the liquid level is subjected to a dynamic response.
3
Assuming this change represents an increase in inlet flow, then q i=1.5∗10=15 c m /s . To obtain
the system transfer function, we must now linearize the differential equation about the steady-state
conditions (h , q i ¿
The deviation variables areh '=h−h∧qi '=qi−qi. Applying taylor series linearization method
presented below where f (h , qi )is the right hand side of Eq.2.3.1, the linearized differential
equation is given by Eq.2.3.3.
q i '=q i−q i=15−10=5 c m3 / s , h ' =h−h=h−1. Substituting all known parameters into Eq.2.3.3, we
have
Using Laplace transform to solve the ODE, we get
Using partial fractions to decompose the second term on the right side of the equation and then
taking inverse laplace transforms, the solution to the differential equation becomes
The above equation is a closed form expression for the dynamic response of the liquid level to the
operator’s command. . `
It can be observed that as the step size increases, the discrepancies between the two results
increases. And indeed, if we toggle around with the flow coefficient, we observe that for high
values, the explicit euler method becomes less stable. Thus, the runge-kutta method is more
accurate than the explicit euler method.
2.4 Question 4
Given the following data
We wish to use the method of least squares to best fit the following function to the data:
The coefficients C, b, and D are found by differentiating the sum of square residuals with respect to
each variable and setting the values equal to zero to obtain:
T(K) K*E^-20 In(T) 1/T In(K) (InT)^2 (1/ I/Tin(K) In(T)In( In(T)1/
T)^2*1 K) T
0^-6
❑
76.0761 0.01147 -459.262 527.234 13.257 -0.4863 - 0.0781
∑
❑
❑
1 9 3169.4 6
59
Entering these equations directly into the calculator, we obtain the following solution:
Having determined C, b, and D, the next task is to find the values of A and EA from the Arrhenius
equation. From the problem this has been provided as
Comparing this equation with equation with the equation of best fit we get that:
We tabulated the given values of K and T in our spreadsheet, then evaluated the values of ln(k),
1/T and ln(T) using Excel built-in functions.
We then added an add in called analysis Toolpak, which contains the regression analysis function
then we selected the regression function in the data analysis tools.
From the snapshot above, the intercept, X variable 1, and X variable 2, represent the parameters
C, b, and D. Therefore, C=−52.4427 , b=2.121598 ,
Ea
D=
R
Ea = RD
D = 2836.0617
In section 2, we evaluated the relationship between the resistance of a resistor and its temperature
which was a polynomial up to the sixth degree. We were tasked with finding the temperature of the
resistor for a resistance of 300 ohms. This was done manually using various methods including the
Newton-Raphson method, and the Interval bisection method. On evaluating the results obtained
using these two methods, we saw After four takes of the Newton Raphson method, we determined
the temperature to be 260.21868 oC. After the 15th iteration of the interval bisection method, we
determined that our T value was 260.21881oC. The Newton-Raphson method converged to a
solution with an error of order 10-8 in only 4 iterations, which is quite impressive. The interval
bisection method, on the other hand, was still unable to find a solution that is as close to Newton-
Raphson as possible after 16 iterations. In fact, 26 iterations would be required to get as close. We
stopped the interval bisection method at the fifteenth iteration because we believe that the results
obtained by the two methods will not differ significantly in practice.
We were also required to find the solution using a spreadsheet and SCILAB. For the spreadsheet,
we used the goal seek function and evaluated our T value to be 260.21870C. This value differs
from the answer we obtained using the Newton Rapson method by only 0.00011 whilst using
SCILAB we obtained a T value of 260.218811 0C. This answer is identical to what was obtained
using the Newton-Raphson method.
In section 2b, we were given the van der Waals equation which shows the relationship between
the Pressure and volume of a gas. The gas in question was nitrogen gas, and we were given the
necessary constants needed to evaluate the value of V for a given base pressure of 13.5 atm. We
obtained a V value of 2.6915 L. The calculations were repeated for incremental values of 15, 30,
45, 60, 75, 90, 105%, respectively. The values of pressure and volume were documented and
tabulated. A graph of pressure against was plotted and is attached to this report. From the graph,
we can see that Boyle’s law is preserved (P is inversely proportional to V).
Question 3 had us model a liquid tank system. Some assumptions were made in order to simplify
our model and increase its solvability. Mass balance was carried out around the tank and we
derived an expression to describe the relationship between the rate of change of the height of
water in the tank and the inlet flow rate. The model obtained is a lumped parameter, a non-linear
model. The ODE obtained was solved using Laplace transform and h(t) was evaluated to be 2 –
e^-0.05t
Explicit Euler’s method and Runge – Kutta 4th order method were used. In question 4, we were
given a linearized version of the Arrhenius equation and asked to use the method of the least
square to best fit a function of the form in(k) = C + bln(T) - D/T to the experimental data given to
us. Evaluating manually, we obtained C =-60.9316, b=3.2009, and D=2836.0617. After
determining our C, b and D values, we determined the values of A and Ea using numeric
computations. A was evaluated to be 3.449 × 10^-27 and Ea was evaluated to be 23,579 J/mole.
The difference in values using the spreadsheet method was negligible.
4. Conclusion
The purpose of this assignment was to apply the numerical methods we have been introduced to
in this course to solve real-world chemical engineering problems. From the data derived, it could
be seen that the difference in the answers was often less than 0.05. In real-world applications,
these differences could be negligible, as they would pose no real threat to problems they would be
applied to.
The graph of pressure against Volume which was plotted validated Boyle’s law, which states that
the pressure of a gas is inversely proportional to the volume it occupies.
In some cases, noticeable variations were observed, but this could be attributed to errors occurring
during approximation for the hand-solved solutions.