160 likes | 590 Views
ChE 250 Numeric Methods. Lecture #1, Chapra Chapters 1 &2 20070119. Outline. Chapter 1 “Mathematical Modeling and Engineering Problem Solving” Parachutist and Newton’s 2 nd Law Chapter 2 “Programming and Software” Structured, Modular Matlab & Excel.
E N D
ChE 250 Numeric Methods Lecture #1, Chapra Chapters 1 &2 20070119
Outline • Chapter 1 “Mathematical Modeling and Engineering Problem Solving” • Parachutist and Newton’s 2nd Law • Chapter 2 “Programming and Software” • Structured, Modular • Matlab & Excel
“Mathematical Modeling and Engineering Problem Solving” • What is a math model? • Describes a natural process in mathematical terms • Idealizes and simplifies reality • Yields reproducible results which can be used to make predictions • Example is Newton’s 2nd Law
“Mathematical Modeling and Engineering Problem Solving” • What is a math model? • Parachutist and Newton’s 2nd Law • Describes motion in terms of the forces acting on a body and the parameter mass • Idealizes and Simplifies by only considering the dominate forces and assuming that mass is constant • Makes predictions of motion for a specific set of forces. • F=ma • F=ma=mg=m(9.8m/s2)
“Mathematical Modeling and Engineering Problem Solving” • What is a math model? • Parachutist and Newton’s 2nd Law • Refining the parachutist problem • Now we consider both the downward pull of the gravity and the resistive drag force. • F=ma • F=Fd+Fu Fd=mg • Fu=cv where c is the drag coefficient and v is velocity • -cv+mg=ma
“Mathematical Modeling and Engineering Problem Solving” • What is a math model? • Parachutist and Newton’s 2nd Law • Refining the parachutist problem • Analytical solution • Solve the differential equation • Boundary condition v=0 @t=0 • Downward coordinates • v=gm/c(1-exp(-tc/m))
“Mathematical Modeling and Engineering Problem Solving” • What is a math model? • Parachutist and Newton’s 2nd Law • Refining the parachutist problem • Analytical solution • Finite difference (Euler’s method) • Assume that dv/dt=Δv/Δt • In terms of increments ‘steps’
“Mathematical Modeling and Engineering Problem Solving” • What is a math model? • Parachutist and Newton’s 2nd Law • Refining the parachutist problem • Analytical solution • Finite difference • Excel solutions • Easily obtained for this problem • Terminal Velocity • Analytical 53.39 • Extra credit: find the numeric limit and number of steps • E-mail spreadsheet by Friday, midnight.
“Programming and Software” • Structured Programming • Good style habits for programming • Makes the code easy to understand to someone other than the developer • (i.e. a teacher who is grading your work) • Control structures • Sequence • Selection • Repetition
“Programming and Software” • Structured Programming • Logical Structures • Sequence • Usually obvious in programming that the code is executed starting at the top and working down • Selection • If/Then/ElseIf/Else/EndIf • SelectCase/EndSelect • Repetition • For/Next
“Programming and Software” • Structured Programming • Logical Structures • Modular Programming • Divide the program into independent modules that can be tested separately • Each module should have a separate well-defined purpose • e.g. Function or subroutines • Functions return a single result (could be matrix or array) • Subroutines return a number of outputs • Modules allow you to develop a ‘library’ of tools that can be used on future projects
“Programming and Software” • Structured Programming • Logical Structures • Modular Programming • Excel and VBA • Excel is great for numeric solutions both in the spreadsheeting and in the programming modules using Visual Basic for Applications (VBA) • Cell formula • =$B$8*(1-EXP($B$9*E8)) • =I10+(H11-H10)*($B$3-$B$2/$B$1*I10)
“Programming and Software” • Structured Programming • Logical Structures • Modular Programming • Excel and VBA • Excel is great for numeric solutions both in the spreadsheeting and in the programming modules using Visual Basic for Applications (VBA) • Cell formula • =$B$8*(1-EXP($B$9*E8)) • =I10+(H11-H10)*($B$3-$B$2/$B$1*I10)
“Programming and Software” • Structured Programming • Logical Structures • Modular Programming • Excel and VBA • Matlab • Also Scilab is available for free download • Very similar to Matlab environment, but there are some differences in function calls=
Preparation for Jan 22nd • Reading • Chapra Chapter 3: Approximations and Round-Off Errors • Homework problem set #1 • 1.2, 1.4, 1.6, 1.11 • 2.1, 2.8 • 3.2, 3.4, 3.7