0% found this document useful (0 votes)
73 views32 pages

CHE317 Excel Lect4

This document provides an introduction to using Excel's Goal Seek and Solver tools to solve equations. It discusses how Goal Seek uses iterative techniques to find solutions to algebraic equations based on an initial guess. Solver is described as a more powerful version that can solve systems of equations and equations with constraints. Examples are provided of using both tools to solve sample equations like X^3 + 2X^2 - X + 1 = 0. The document also discusses using Solver to solve simultaneous linear and nonlinear equations, as well as equations of state.

Uploaded by

Ub Usoro
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)
73 views32 pages

CHE317 Excel Lect4

This document provides an introduction to using Excel's Goal Seek and Solver tools to solve equations. It discusses how Goal Seek uses iterative techniques to find solutions to algebraic equations based on an initial guess. Solver is described as a more powerful version that can solve systems of equations and equations with constraints. Examples are provided of using both tools to solve sample equations like X^3 + 2X^2 - X + 1 = 0. The document also discusses using Solver to solve simultaneous linear and nonlinear equations, as well as equations of state.

Uploaded by

Ub Usoro
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/ 32

CHE 317: COMPUTER PACKAGES FOR

CHEMICAL ENGINEERS

INTRODUCTION TO THE USE OF


EXCEL
(Lecture 4)
Instructors:
Prof. V.E Efeovbokhan and Engr. D. E. Babatunde
Solving Equations in Excel Using Goal Seek
• Goal Seek permits rapid solutions of algebraic
equations using iterative (i.e trial-and-error)
techniques, based upon a series of successive
approximations derived from an initial guess.
• The accuracy of each successive value is refined
until the values converge to a stable solution.
• In Goal Seek, it is necessary to define a cell for the
variable you want to change (X) and a cell for the
function you want to evaluate.
Note:
• Goal Seek will only work if you tell it to
evaluate some function until it reaches a
constant value.
• You cannot tell it to equal something that can
change, so for example you cannot do
something like this: X - X3 = 2X2 + 1 because
neither side is a constant.
• The easiest way around this is generally to
solve the function for zero and then use that
as the evaluating function.
• The proximity of the initial guess to the desired root
increases the likelihood of obtaining a converged
solution.
• Goal Seek is very useful for quickly solving any
formula for a single unknown value
• A warning message will be generated if the
computation does not converge or if an
inappropriate root (e.g. a complex root) is about to
be generated.
Example: Solve X3 +2X2 -X+1=0
• Step 1: Open a spreadsheet and enter the following
formula in cell B1.
= A1^3 + 2*A1^2 – A1 +1
Cell B1 is the equation that should be zero; and cell
A1 contains the variable that is repeated changed to
make this happen. Enter 2.0 into cell A1
• Step 2: Under “Tools”, choose “Goal Seek”. Or
Under “data”, click on “What if analysis” and choose
Goal Seek. When the dialog box appears, enter the
following as shown below:
• Step 3: Click OK. The answer appears in the
spreadsheet
Example: Solve X3 +2X2 -X+1=0
• The answers appears in the spreadsheet
- 2.54686 - 0.00035
Hence, the solution found is
- 2.54686 with a tiny error.
The test of whether the calculation is correct is shown
in cell B1 which is 3.5E-4, and very close to zero.
Solve sin(x) + x = 5 using Goal Seek
• If your guess is right and the result was correct,
then the solution has been found.
• If not, you could repeat by using a another guessed
value
• If it cannot find a solution it’s because the guess is
not sufficiently close or the equation is not solvable
Solving Equations in Excel Using
SOLVER
 A more powerful version of Goal Seek.
 Allows you to solve systems of equations, and
linear equations that you will come across from
mass and energy balances.
It operates under similar principles as Goal Seek.
And it can set constraints to the final solution
can restrict the solution to a range which makes
physical sense.
Solution of Solve X3 +2X2 -X+1=0 using
Excel’s Solver
You can solve the same problem using “solver”
option in excel
• Step 1: Enter the given equation in cell D3.
= C3^3 + 2*C3^2 – C3 +1
Cell D3 is the equation that should be zero; and
cell C3 contains the variable that is repeatedly
changed to make this happen. Enter – 2.5
into cell A1 as the initial guess
• Step 2: Under the “Tools” menu, click on
“Solver”. If the choice “solver” does not show,
choose Add-Ins and load Solver from the
Analysis ToolPak or the original Excel program
disk, OR go to the “data” tab and click on
“solver” at the far extreme right.
Solving X3 +2X2 -X+1=0 using Excel’s Solver

• Step 1 displayed
Solution of Solve X3 +2X2 -X+1=0 using
Excel’s Solver
Step 2 displayed
Solution of Solve X3 +2X2 -X+1=0 using
Excel’s Solver
Results:
• Cell A1 and B1 display:
-2.54682 4.06E-07
This time, it is much more accurate as the error
is extremely small.
Exercises

Class Work
1. Solve the equation sin x + x = 5 using Solver

Practice Exercises
1. Determine a real root for the equation

2. Find a positive real root for the equation


x + cos x = 1 + sin x
Solution to class work
Solve sin(x) + x = 5
Enter this formula into cell
D3
SOLVER for one unknown: sin(x) + x = 5
Initial guess
Click on ‘solve’
Solution to sin(x) + x = 5
Desired root
Negligible error
CARRYING OUT AN ITERATIVE PROCEDURE IN
EXCEL: Finding the Roots of Equations using
Newton-Raphson Approximation

Class Example
Workings
Solver method : simultaneous linear
equations
Determine the solution to the following system of
equations using Solver.
Solver method : simultaneous linear
equations
 Change equations to the form: f(x)=0
• F1(x): 3X1 + 2X2- X3 – 4 = 0
• F2(x): 2X1 - X2 + X3 – 3 = 0
• F3(x): X1 + X2 - 2X3 + 3 = 0
 Finding the sum of the squares of each:
• Y= F12 + F22 + F32
• Minimizing the sum of the squares

• If F1 = 0, F2 = 0 and F3 = 0, then Y will also equal zero.


• We will use Excel’s Solver feature to determine the
values of X1, X2 and X3 that make the target function, Y
zero.
Solver method : simultaneous linear
equations
Initial guess for X1

Enter this formula


in B6. Remember
to begin with “ = “

Y = F12 + F22 + F32


F1(X): 3X1+2X2-X3 = 4
F2(X): 2X1-X2+X3 = 3
F2X): X1+X2-2X3 = -3
Solving Simultaneous Nonlinear Equations
in Excel Using Solver

Class Exercise
Determine the solution to the following two
simultaneous nonlinear equations using Solver.
Restrict the range of the independent variables to
nonnegative values.
EQUATIONS OF STATE
• Solving equations of state allows us to find the specific volume
of a gaseous mixture of chemicals at a specified temperature
and pressure
• Without using equations of state, it would be virtually
impossible to design a chemical plant.
• By knowing this specific volume, you can determine the size –
and thus cost – of the plant, including the diameter of pipes,
the horsepower of compressors and pumps, and the diameter
of distillation towers and chemical reactors.
• Determining the specific volume is also the first step in
calculating the enthalpy and vapor–liquid properties of
mixtures.
• Calculating this enthalpy is especially important when making
energy balances to reduce energy use and help the
environment.
• To solve equations of state, you must solve algebraic equations
Determining the Specific Volume of Gaseous Mixture of
Chemicals at a Specified Temperature and Pressure: Van
der Waals Equation
- - - - - - - -- 1

Rearrange eqn.1 in the form f(x)=0

Calculate the constants for the given gas and apply either
goalseek or solver.
*It is very important to arrange your presentation properly
*NEAT PRESENTATION OF YOUR WORK IS VERY ESSENTIAL

Equation of State (EOS) Property Calculation

INPUT DATA

Chemical Name METHANE

Critical Temperature ( Tc ) 190.60 Deg K

Critical Pressure ( Pc ) 46.00 Bar

Accentric Factor (ω) 0.0080

Molecular Weight 16.043

Peng -
Robinson
Equation of State ( EOS ) (PR)

Pressure (P) 1.00 Bar

Temperature (T) 100.00 Deg K

RESULT
Molar Volume and Compressibility Factor from Van der
Waals Equation
Problem 1 B C D E F G

Value P Preduced V Z
P = Pressure in atm=Pr*Pc 56
V = molar volume in liters/g-mol 0.574892698 56 0.503 0.575084 0.871819
T= temperature in K 450
R= gas constant atm-liter/g-molK 0.08206
Tc= citical temp for ammonia 405.5
Pc=critcal pressure for ammonia 111.3

Preduced 4.043126685
Z=compressibilty factor=PV/RT 0.871827961

a 4.196945872
b 0.037371215

Value of RT 36.927
Value of P+a/V^2 68.69871519
Value of V-b 0.537521483
LHS 36.92703527
f(V)=0 3.52743E-05
Determining the Specific Volume of Gaseous Mixture of
Chemicals at a Specified Temperature and Pressure:
Redlich Kwong Equation

Rearrange equation in the form f(x)=0


LHS – RHS=0
SOLVER CAN NOW BE APPLIED

YOU MAY ALSO SOLVE for the RHS=P, since P is a constant


Molar Volume and Compressibility Factor from
REDLICH KWONG Equation

B C D E

Value
P = Pressure in atm=Pr*Pc 56
V = molar volume in liters/g-mol 0.68531
T= temperature in K 450
R= gas constant atm-liter/g-molK 0.08206
Tc= citical temp for ammonia 405.5
Pc=critcal pressure for ammonia 111.3

Preduced 4.04313
Z=compressibilty factor=PV/RT 1.03928

a 0.00362
b 0.0259

Value of RT/(V-b) 56
Value of a/(V+b)VT.5 0.00035
RHS 55.9996
LHS 56
f(V)=0 3.9E-07
Assignment

Using both goal seek and solver, find the specific


volume of n-butane at 500K and 18 atm
(i) If the Redlich-Kwong equation of state is applied

(ii) Van der Waals equation of state is applied

Given that R=0.082061 L.atm/gmol.K , Tc=425.2 K


and Pc=37.5 atm

You might also like