spreadsheet techniques and problem solving for ches · pdf filespreadsheet techniques and...

38
AIChE Webinar Presentation Spreadsheet Techniques and Problem Solving for ChEs David E. Clough Professor Dept. of Chemical & Biological Engineering University of Colorado Boulder, CO 80309 Email: [email protected] 3:00 p.m. EST, 5:00 p.m. BRST, 3 December 2015 1 co-sponsored by the Associação Brasileira de Engenharia Química (ABEQ)

Upload: docong

Post on 28-Mar-2018

223 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

AIChE Webinar Presentation

Spreadsheet Techniques and Problem Solving for ChEs

David E. Clough Professor Dept. of Chemical & Biological Engineering University of Colorado Boulder, CO 80309

Email: [email protected]

3:00 p.m. EST, 5:00 p.m. BRST, 3 December 2015 1

co-sponsored by the Associação Brasileira de Engenharia Química (ABEQ)

Page 2: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

Spreadsheet Techniques and Problem Solving for ChEs

Outline of Presentation

• setting up Excel – a couple suggestions • selection, copying and moving – rapid techniques • creating formulas – using cell and range names • suggestions on creating engineering graphs

• case studies using Data Table • targeting calculations using Goal Seek • optimizing with constraints using Solver • curve-fitting with Data Analysis Regression

Part I: Creating engineering spreadsheets efficiently

Part II: ChE problem-solving scenarios

2

Page 3: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

Spreadsheet Techniques and Problem Solving for ChEs

Part I: Creating engineering spreadsheets efficiently • setting up Excel – a couple suggestions

3

o one worksheet in a new workbook

o move selection after enter – cancel it

o make sure you have Solver and Data Analysis add-ins

else

Page 4: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

Spreadsheet Techniques and Problem Solving for ChEs

Part I: Creating engineering spreadsheets efficiently • selection, copying and moving – rapid techniques

4

o making “jumps” around the spreadsheet

o selecting blocks of data quickly

o copying

o moving

double -click Ctrl-

F5 key

also

make selection Ctrl-c select

destination Enter also

edge with Ctrl

drag and drop

make selection Ctrl-x select

destination Enter also

adjoin Shift key to jump technique

also Ctrl-a or Ctrl-* for entire block

hold down Ctrl for selections that are not contiguous

Page 5: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

5 Spreadsheet Techniques and Problem Solving for ChEs

Part I: Creating engineering spreadsheets efficiently • selection, copying and moving – rapid techniques

o using Autofill for an adjacent index column

o creating a free-standing index column

double -click the

Fill Handle

can drag it out, but not useful for long columns

starting index

Page 6: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

6

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• creating formulas – using cell and range names

o build formulas using pointing – more reliable

o Enter mode and Edit mode

In Edit mode, can use End and Home also arrow keys to move within formula. In Enter mode, those keys point to cells.

start formula with =

status bar

point to “n”and click build rest of formula using pointing

double-click cell or F2

toggle between and with F2

Page 7: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

7

o cell addressing – relative, absolute and mixed

A1 relative $A$1 absolute A$1 relative column/absolute row $A1 absolute column/relative row

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• creating formulas – using cell and range names

F4

A1

$A$1

A$1

$A1

use the F4 key to cycle through the addressing modes

fill a table with single formula

note use of addressing

result in single cell

copy to entire table

see how addressing translated to reference the appropriate cells

Page 8: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

8

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• creating formulas – using cell and range names o creating names for cells and ranges of cells

formula references cell addresses have to back-trace to cells to see meaning of formula references

enter n in Name Box to create name “n” for cell B2

When not to use names? When you need to take advantage of cell addresses in copying formulas.

formula with names much easier to decipher (and debug) use names wherever possible!

Page 9: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

9

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• creating formulas – using cell and range names o introducing built-in functions (there are 100’s)

we find that Excel 2013 has the gamma function built in, so we proceed to use it with the argument 2.3, as an example

use the Insert Function button just to the left of the Formula Bar to find and insert functions

if we want to find out whether Excel has a built-in gamma function, type it in and click Go

Page 10: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

10

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• creating formulas – using cell and range names

Array formulas also allow for matrix calculations (multiplication, inverse, transpose, determinant)

o using array formulas – one-stop shopping

these ranges named V and T select destination range and type in single formula making reference to V and T

press Ctrl-Shift-Enter

Page 11: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

11

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• suggestions on creating engineering graphs o options with scatter plots

o moving charts to their own sheet

avoid artificial smoothing options use markers only for experimental data use markers and straight lines for pattern recognition use straight lines only for analytical functions or hundreds of data

scatter plots are the best choice for engineering graphs whenever feasible, move charts to their own sheet

– formatting and presentation is much better

data

data

avoid

avoid

data

Page 12: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

12

o adding a data series to the graph

o using a secondary y-axis

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• suggestions on creating engineering graphs

many users don’t realize that you can select a new data series on the spreadsheet, copy and paste it onto the chart, and it is added automatically

if one or more series on the plot don’t work well with the scale required on the left, assign them to a secondary scale on the right

Page 13: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

13

Part I: Creating engineering spreadsheets efficiently

Spreadsheet Techniques and Problem Solving for ChEs

• suggestions on creating engineering graphs o annotating graphs

0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

0 10 20 30 40 50 60 70 80 90 100

Heat

Cap

acity

(kJ/

(kg*

K)

%HNO3 by wt

Heat Capacity of Nitric Acid Solutions

Notice the inflectionin the curve here

add text boxes, arrows pointing to features of the graph, shapes such as ellipses reformat these to suit

Page 14: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

14

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• case studies using Data Table

Spreadsheet calculation

involving one to many cells

Input cell

Result cell

Set of input values

Corres- ponding result values

typically create graph of result vs input

Page 15: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

15

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• case studies using Data Table o identifying the input cell(s) and output cell

o creating the range(s) of input values

o entering the study “pointer” formula

input cell output

cell

one-way case study

Page 16: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

16

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• case studies using Data Table o selecting the study range, invoking Data Table

notice the range selected includes F2

the Data Table is “live” -- change the temperature and the values will update

Page 17: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

17

o graphical interpretation of the case study

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• case studies using Data Table

0

0.5

1

1.5

2

2.5

10 12 14 16 18 20 22 24 26 28 30

Pres

sure

(atm

)

Volume (L)

Case Study of Ideal Gas Law -- Pressure versus Volume

Temperature = 32 degF

Note: two-way case studies are possible and can be depicted in a surface or contour plot

Page 18: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

18

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• targeting calculations using Goal Seek o the “back-solving” scenario

spreadsheet calculation

involving one or more cells

input cell

output cell

target value

compare

Goal Seek

adjust

Page 19: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

19

Part II: ChE problem-solving scenarios

o putting Goal Seek to work

Spreadsheet Techniques and Problem Solving for ChEs

• targeting calculations using Goal Seek

2

adjust V to get a pressure of 2 atm

Page 20: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

20

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• targeting calculations using Goal Seek o using Goal Seek for equation solving

o Solver as an alternative target value is zero ( )f x 0=

2

Page 21: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

21

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• optimizing with constraints using Solver o adjusting multiple cells to achieve an objective

o constraint-free optimization

performance calculation

n-1 constraints

n input cells performance

result

n = 1

Page 22: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

22

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• optimizing with constraints using Solver

r

h1

h2

cyl 1A 2 rhπ=

2 2cone 2A r r hπ= +

Costcyl = $1000/m2

Costcone = $1500/m2

Total Volume = 25 m3

Total Height = 5 m

Minimize total cost

2cyl 1V r hπ=

2cone 2

1V r h3π=

Three inputs: r, h1 and h2 Two constraints: total volume and total height One performance objective: total cost

Page 23: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

23

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• optimizing with constraints using Solver

Adjust h1, h2 and r to minimize TotalCost while keeping TotalHt = 5 and Volume = 25

Page 24: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

24

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• optimizing with constraints using Solver o setting Solver parameters

o adding constraints

Page 25: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

25

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• optimizing with constraints using Solver

Click Solve

Optimized design

Page 26: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

26

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o using Trendline – its limitations and pitfalls

to add a Trendline, right-click a data point and click Add Trendline

Page 27: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

27

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o using Trendline – its limitations and pitfalls

Here, pick a polynomial fit and adjust the order until the fitted curve “looks good.” Check to display the model equation on the chart. We advise against displaying R2, since it is a misleading statistic for goodness of fit.

Page 28: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

28

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o using Trendline – its limitations and pitfalls

Visual fit appears good for 5th-order polynomial.

Be cautious in manually copying model equation to use in calculations – precision of display will cause (big!) round-off errors.

Statistical information on regression is not available.

Flexibility in specifying model structure is very limited.

Page 29: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

29

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o Data Analysis Regression – allowable models

Models must be linear in the parameters being fitted. Generally, ( ) ( ) ( )0 0 1 2 m 1 1 1 2 m n n 1 2 my a f x ,x , ,x a f x ,x , ,x a f x ,x , ,x= + + +

Example allowable linear models: n

0 1 ny a a x a x= + + +Polynomials:

0 1 1 2 2 12 1 2y a a x a x a x x= + + +Response surface: (multilinear) Models nonlinear in parameters can’t be handled:

( )BA

T CP T 10−

+=e.g., Antoine’s Eqn (can by Solver)

Page 30: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

30

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o step-wise regression using Data Analysis

Create an array of the “X-input variable” (%HNO3) to powers 1 through 6

Set up the Regression dialog as shown Include Labels and Residuals

Page 31: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

31

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o step-wise regression using Data Analysis

From Regression output, find term with highest P-value (2nd-order term)

This model would not have been found using Trendline.

Run Regression again, eliminating the 2nd-order column from the X-input range. Continue eliminating the highest P-value until all are less than, for example, 5%.

Notice result has intercept, first-order, 4th,5th, and 6th order – not a conventional polynomial fit.

Page 32: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

32

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression

-2.0E-02

-1.5E-02

-1.0E-02

-5.0E-03

0.0E+00

5.0E-03

1.0E-02

1.5E-02

2.0E-02

2.0

2.5

3.0

3.5

4.0

4.5

0 10 20 30 40 50 60 70 80 90 100

Resi

dual

Val

ues

Heat

Cap

acity

(kJ/

(kg*

K)

%HNO3 by wt

Heat Capacity of Nitric Acid Solutions

Data

Model

Residuals

7 4 9 5 11 6y 4.192 0.04263x 3.171 10 x 5.451 10 x 2.480 10 x− − −= − + × − × + ×

o step-wise regression using Data Analysis Model curve shown with data and residuals plotted on secondary axis Model equation embedded on graph using equation typesetter

Page 33: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

33

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o nonlinear regression – use of Solver

Start by creating a graph to test models

-4.000

-3.000

-2.000

-1.000

0.000

1.000

2.000

3.000

4.000

0 50 100 150 200 250 300 350

Log10 Vapor Pressure vs Temperature

Page 34: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

34

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o nonlinear regression – use of Solver

Choose an initial set of parameters and compute model predictions Add this curve to the graph

Make sure the initial estimates are such that the model curve is “in the ballpark” of the data, as shown here.

-4.000

-3.000

-2.000

-1.000

0.000

1.000

2.000

3.000

4.000

5.000

6.000

0 50 100 150 200 250 300 350

Log10 Vapor Pressure vs Temperature

Page 35: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

35

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression o nonlinear regression – use of Solver Compute the

differences between the predictions and data in the Error column – sum the squares of this column in SSE

Set up Solver Parameters to minimize SSE by adjusting Antoine parameters.

Page 36: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

36

o nonlinear regression – use of Solver

Part II: ChE problem-solving scenarios

Spreadsheet Techniques and Problem Solving for ChEs

• curve-fitting with Data Analysis Regression

Solver’s minimization of SEE performs a nonlinear regression resulting in a “snapping” of the model curve onto the data.

Page 37: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

37

Spreadsheet Techniques and Problem Solving for ChEs

• use names instead of cell addresses wherever possible • take the time to learn efficient techniques • try array formulas – they improve reliability • recognize the problem-solving scenarios --

especially case studies, targeting and optimization • we have left out many topics – especially VBA

Windup: A Few Key Points

Page 38: Spreadsheet Techniques and Problem Solving for ChEs · PDF fileSpreadsheet Techniques and Problem Solving for ChEs Part I: Creating engineering spreadsheets efficiently • setting

38

Want to go more in depth on spreadsheets?

Consider enrolling in the AIChE E-learning courses

Spreadsheet Problem-Solving for ChEs Spreadsheet Programming for ChEs – Excel’s VBA

or attend the AIChE in-person versions available as • 1-day offerings or a 2-day combo package • public offerings at major city locations in the U.S. and abroad as arranged with AIChE • in-house, private offerings for your organization Thanks for your attention. Now, questions??