0% found this document useful (0 votes)
10 views10 pages

Chemical Engineering Computing Kyambogo University Lecture 10

The document outlines a lecture on Computing for Chemical Engineering II at Kyambogo University, focusing on the use of Excel's Solver for solving linear and nonlinear programming problems relevant to chemical engineering. It includes examples of linear programming, constraints, and practical applications in optimizing crude oil processing in a petroleum refinery. The lecture also discusses the simplex method and introduces nonlinear programming techniques using Excel's generalized reduced gradient method.

Uploaded by

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

Chemical Engineering Computing Kyambogo University Lecture 10

The document outlines a lecture on Computing for Chemical Engineering II at Kyambogo University, focusing on the use of Excel's Solver for solving linear and nonlinear programming problems relevant to chemical engineering. It includes examples of linear programming, constraints, and practical applications in optimizing crude oil processing in a petroleum refinery. The lecture also discusses the simplex method and introduces nonlinear programming techniques using Excel's generalized reduced gradient method.

Uploaded by

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

KYAMBOGO UNIVERSITY

FACULTY OF ENGINEERING
DEPARTMENT OF MINING, CHEMICAL & PETROLEUM
ENGINEERING
BACHELOR OF SCIENCE IN CHEMICAL AND PROCESS ENGINEERING
Course Code and Name: SCE 2202 COMPUTING FOR CHEMICAL ENGINEERING II
Course Level: YR II, SEM II (2023/2024)
Course Credit: 3 CU
Lecturer: Dr. Dan Egesa

Assisting Lecturer: Joshua Ocoun (Eng.)

SCE 2202 Lecture 10 (26 th March 2024)


Lecture 09 Command window correction:
>> C = fsolve (‘CSTR’, C0) the m-file CSTR, is called with apostrophe’s
‘CSTR’

EXCEL Recap: Use of Solver in Chemical Engineering


Solver in Excel can be used to find solutions to both linear and Non Linear Programming problems.
As we have seen in Engineering Mathematics, we can solve Linear Programming problems which
are even practical to a Chemical Engineer.
We can also solve nonlinear problems Using Excel like we did in MATLAB. A Typical example
is the problem we solved last week in lecture 9 involving a continuous flow stirred tank reactor.

Linear Programming
Linear programming involves an objective function (Gain or loss) and a Constraint (equality or
inequality) that specifies the availability of resources or the lack of resources. If we have an
Engineering problem, our task is to maximize or minimize the objective function while satisfying
all the constraints. The objective function and the constraints are both linear functions of unknown
variables.
Many Engineering problems can be formulated as Linear Programs.
Example 1.0
Maximize 𝑦 = 3𝑥 1 + 2𝑥 2 … (𝑖) 𝑠𝑢𝑏𝑗𝑒𝑐𝑡 𝑡𝑜 𝑥 2 − 𝑥 1 ≤ 3 … (𝑖𝑖 )𝑎𝑛𝑑 𝑥1 + 𝑥 2 ≤ 7 … (𝑖𝑖𝑖)

It’s very important for as to indicate a lower limit for the Constraints so the we limit our solution.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
Any values can be suggested depending on what the engineer wants. For this case we any can
choose;
𝑥 1 ≥ 0,0.1,0.2, … ,1, 2 … 𝑒𝑡𝑐 𝑎𝑛𝑑 𝑥 2 ≥ 0, 0.1, 0.2, … 𝑒𝑡𝑐
Let’s choose 𝑥 1 ≥ 0 and 𝑥 2 ≥ 0 as our lower constraint limits.
George Dantzig perfected the so-called simplex algorithm for solving LP problems, which we use
today. We use the same method in solver to solve Linear Programming Problems.
In the simplex method we start with an initial guess, called the basic solution. The initial value is
that value that satisfies all the constraints. Therefore that value should be within the range of the
constraints. Another method of solving LP is called polynomial time (Research about it).
Solution:
Step 1: we write a spreadsheet as below;

Equations (i), (ii), and (iii) are written as shown in the Spreadsheet. With the initial conditions of
𝑥 1and 𝑥 2 indicated as shown above.

We can now start solver. From the menu in Excel, Click on Data and then Solver (Note that, if
solver is not installed you go to File, Options and add it in).

Click on Solver.
As shown below we click on Objective is to maximize 𝑦 = 3𝑥 1 + 2𝑥 2 , so we click on ‘Max’ in
solver, choose the ‘Simplex LP’ method, click on Add, to add the Constraints,

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
Press Okay and then cancel to stop adding in the constraints. Then all will be fed in and then we
can solve the LP problem.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
We then click on solve and;

We can press OK, and solver will disappear but the solution will remain.
In the solution, 𝑥1 = 2 𝑎𝑛𝑑 𝑥2 = 5 are the maximum values we can use within the given constraints and
the maximum value of ‘y’ within the constraints is 16.
This is how solver, obtains solutions to linear programming problems.

Practical Chemical Engineering Problem in Linear Programming:


A petroleum refinery has six different types of crude oil and it needs to process all of them while
maximizing profit. The crudes and their percentage volume cuts are shown in the table.
Crude Name Kingfisher-2009 BAKKEN-2016 MEDANITO-2023 Basrah-Heavy Doba-blend AASGARD BLEND-2023

Butane and Lighter IBP 1.0122 6.0 1.8 6.65 0.4 13.1

Light Naphtha (LN) 2.4948 8.5 6.5 7.20 1.4 16.4


Heavy Naphtha (HN) 6.203 17.7 7.1 4.65 7.1 18.3

Kerosene (KE) 3.1156 11.1 12.5 8.65 11.9 10.7


Light Gasoline (LG) 13.897 10.3 10.6 16.25 8.6 7.5

Heavy Gasoline (HG) 4.916 9.4 8.7 4.35 0.001 6.9


Aviation Fuel 29.879 7.9 8.6 20.90 0.001 5.9

Diesel 5.225 2.5 8.4 5.40 0.001 1.9


Vacuum Residue 1 (Furnace Oil) 68.361 22.7 2.7 4.10 0.001 13.7

Vacuum Residue 2 (Lubricating Oil) 38.482 8.5 33.2 51.45 37.1 5.7
Grease 33.257 4.4 9.7 30.55 33.5 2.7
LOSSES 0.01 0 0.02 0.15 0.011 0.15
AVAILABILITY IN 10,000BARRELS/DAY 60 25 30 45 50 35

Crude Cuts Cut yield by volume (%)


The Operating/Processing costs of each of the Crude cuts and their daily demand is given in the
Table below.
PRODUCT Processing Cost Selling Price Minimum Daily Demand
(PC)(UGX/ Barrel) (SP)(UGX/Barrel) (10000Barrel/day)
Butane and Lighter IBP 110,000/= 115,000/= 40.1
Light Naphtha ( LN) 122,000/= 125,000/= 2.3
Heavy Naphtha ( HN) 125,000/= 130,050/= 6
Kerosene ( KE) 150,000/= 165,450/= 15
Light Gasoline ( LG) 202,540/= 208,350/= 32
Heavy Gasoline ( HG) 203,500/= 210.500/= 35
Aviation Fuel 214,225/= 217,215/= 38
Diesel 175,275/= 180,360/= 18

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
Vacuum Residue 1 ( Furnace Oil) 220,000/= 221,750/= 3.5
Vacuum Residue 2 ( Lubricating Oil) 233,700/= 234,810/= 6.5
Grease 256,000/= 260,010/= 4.5

Determine the Optimum Processing capacity for each of the crudes, while maximizing profits.
Solution:
Let 𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 ,𝑥 5 ,𝑥 6 represent the amount of each crude to be processed.
𝑃𝑟𝑜𝑓𝑖𝑡 (𝑥1,2,3,4,5,6) = [(𝑆𝑃1,2,3,4,5 − 𝑃𝐶1,2,3,4,5,6) × %𝑦𝑖𝑒𝑙𝑑 𝑜𝑓 (𝐼𝐵𝑃 + 𝐿𝑁 + 𝐻𝑁 + 𝐾𝐸 + 𝐿𝐺 + 𝐻𝐺 + 𝐴𝑉 + 𝐷𝑙 + 𝑉𝑅1 + 𝑉𝑅2 + 𝐺𝑆) 1,2,3,4,5,6] × 10000

Respectively. (The 10000 can be chosen to be put now or later on in the solution.)
With this we can obtain the Objective Function y. The objective function is an equation that
mathematically describes the linear problem. The Constraints provide the limits.

We can go to excel feed in the values and obtain the net profit for each of the crudes as below.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
From the spreadsheet above we have our objective function written as below;
𝑦 = 6,187,748,150𝑥1 + 5,451,605,000𝑥2 + 5,288,680,000𝑥3 + 6,135,775,000𝑥4 + 4,514,088,250𝑥5 + 5,017,365,000𝑥6

From there we identify the constraints;


1. Crude availability
2. Market Demand
3. Nonnegativity (This should always be there in this case)

Crude availability Constraints:


𝑥 1 ≤ 60 , 𝑥 2 ≤ 25 , 𝑥 3 ≤ 30 , 𝑥 4 ≤ 45 , 𝑥 5 ≤ 50, 𝑥 6 ≤ 35
Market Demand Constraints:
1.0122𝑥1 + 6𝑥 2 + 1.8𝑥 3 + 6.65𝑥 4 + 0.4𝑥 5 + 13.1𝑥 6 ≤ 40.1 … (1)
2.4948𝑥1 + 8.5𝑥 2 + 6.5𝑥 3 + 7.2𝑥 4 + 1.4𝑥 5 + 16.4𝑥 6 ≤ 2.3 … (2)
.
.
𝑪𝒍𝒂𝒔𝒔 𝑨𝒔𝒔𝒏 𝟏: 𝑐𝑜𝑚𝑝𝑙𝑒𝑡𝑒 𝑡ℎ𝑒𝑠𝑒 𝑐𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠 𝑢𝑝𝑡𝑜 𝐶𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡 (11) 𝑎𝑛𝑑 𝑤𝑟𝑖𝑡𝑒 𝑖𝑛 𝐸𝑥𝑐𝑒𝑙 … (11)
(1 mark)
Non negativity Constraints:
𝑪𝒍𝒂𝒔𝒔 𝑨𝒔𝒔𝒏 𝟐:𝑤𝑟𝑖𝑡𝑒 𝑑𝑜𝑤𝑛 𝑡ℎ𝑒 𝑛𝑜𝑛 𝑛𝑒𝑔𝑎𝑡𝑖𝑣𝑖𝑡𝑦 𝑐𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡𝑠 𝑜𝑛 𝑝𝑎𝑝𝑒𝑟 𝑎𝑛𝑑 𝑖𝑛 𝐸𝑥𝑐𝑒𝑙
(1/2 mark)

We can now go ahead and present everything in Excel, invoke solver and find the solution, as
shown below.
Our initial guess is zero.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
According to solver’s solution, it is optimal to process 1293.8𝑏𝑎𝑟𝑟𝑒𝑙𝑠/𝑑𝑎𝑦 of BAKKEN-2016,
1610.5𝑏𝑎𝑟𝑟𝑒𝑙𝑠/𝑑𝑎𝑦, and 93.5𝑏𝑎𝑟𝑟𝑒𝑙𝑠/𝑑𝑎𝑦 of Aasgard Blend-2023: while not processing any of
the remaining crudes available.

Due to their less vol (%) yield cuts in certain side draws, Kingfisher-2009, basrah-heavy and Doba-
Blend would not be processed at optimal conditions. (Satisfying Price, and Demand constraints).
The values may change over time, due to other conditions, and calculations can be made again.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
Class Assignment 3 (1/2 mark)
Identify the Optimal volume for, IBP, LN, HN, KE, LG, HG, AF, DL, VR1, VR2, GR etc in
barrels/day, from the solution in excel above.

Non Linear Programming


With non-linear programming, the Objective function and the Constraints, are usually non-linear.
The Simplex method may not guarantee a solution to these problems. Different methods have been
developed and excel uses the generalized reduced gradient method (GRG Nonlinear).
Example 3:
Minimize; 𝑦 = 3𝑥 12 + 2𝑥 22 + 𝑥 32 − 2𝑥 1 𝑥 2 − 4𝑥 1 − 5𝑥 2 subject to;
𝑥1 + 𝑥2 + 𝑥3 = 3
𝑥 12 + 5𝑥 2 = 5
𝑥 1,2,3 ≥ 0
Solution:
Let Initial guess be 𝑥 1 = 1, 𝑥 2 = 0, 𝑥 3 = 0

Individual Assignment 13 (5 marks)


A steel alloy blend is being made at roofing UG ltd, and it’s required, that 1kg to contain, at least 30% C,
25% Pb and the rest Iron Fe. The process involves mixing a number of available alloys as below;
Available alloy C(%wt) Pb(%wt) Fe(%wt) Cost (UGX/kg)
1 20 20 60 23340
2 10 40 50 24507
3 40 50 10 29175
4 50 30 20 31120
Find the Cheapest Blend using the Data above.

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
Non Linear Practical Chemical Engineering Problem
If we recall the previous lecture 09, when we solved a problem in MATLAB involving, a CSTR
(Continuous Stirred tank reactor), the same problem can be solved using solver since it’s a Non-Linear
problem with constraints.

Below is a ScreenShot of the Prob in Lecture 09;

With this we can solve the problem Using Solver as shown below:
We use the sum of squares method to create an our Objective function y and then without constraints we

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.
solve. We can also use VBA to solve the same problem but; due to time we might not do that. Students are
advised to research on this and always find a simpler method to solve your Engineering problems.

Always check your formulas before invoking solver. The problem has no Constraints. A graph is not needed
in this case.

End**

Dr. Dan Egesa (all assignments should to be submitted in time)


Joshua Ocoun (Eng.) 2023/2024Adc Yr.

You might also like