Download presentation
Presentation is loading. Please wait.
1
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 4 Programming and Software EXCEL and MathCAD
2
Last Time Software Packages Users StandardPower Limited to standard software capabilities Write your own macros and/or software
3
Last Time Computer Implementation Algorithm Flowchart Pseudocode Computer Program
4
Last Time Algorithms & Flowcharts Algorithm The step by step procedure that describes the implementation of a solution strategy. Flowchart The visual representation of an algorithm.
5
Last Time Pseudocode and Computer Code Computer Code Set of Instructions in a computer language that direct the computer to perform a certain task. Pseudocode Set of code-like instructions that express the flowchart in a narrative form
6
Last Time Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines
7
Last Time Logical Representation Sequence Computer code is to be implemented one instruction at a time Analytic Solution Enter g,m,c Enter time t Evaluate v Print t,v
8
Last Time Logical Representation Selection Computer code flow is split into branches based on a logical decision. Enter g,m,c Check if m=0 Print Error Message OK to continue
9
Last Time Logical Representation Repetition Implement instructions repeatedly
10
Last Time Modular Programming Module is a self contained and independent code segment Modules are designed to perform a specific, well designed task Functions return a single result Subroutines return several results
11
Example Consider Quadratic Equation With closed form solution
12
Example If a,b,c are given Compute x 1 and x 2 What Do I Need?
13
Example Ask user to input a,b,c Check if a=0 –Linear equation, this solution does not apply Check if a=0 and b=0 –Trivial Solution Check if b 2 -4ac=0 –Double Real Root
14
A Simple Model FuFu FDFD FiFi
15
Analytic vs Numerical Solution Start from Governing Equation Derivative = Slope
16
Analytic vs Numerical Solution Use Finite Difference to Approximate Derivative vivi titi t i+1 v i+1 True Slope Approximate Slope
17
Analytic vs Numerical Solution
18
Numerical Solution Slope New Value Old ValueStep Size Euler Method
19
Analytic vs Numerical Solution Algorithm 1.Input a sequence of time nodes i.e. Start Time, End Time, Time Step 2. Input model parameters i.e. m, c 4. Input initial velocity i.e. v(t=0) 3. Input forcing function i.e. g
20
Algorithm 5. Check if m=0 avoid division by 0 6. For each time node evaluate 7. Other secondary checks…
21
Excel and MathCAD EXCEL MathCAD-IMathCAD-II
22
Project # 1 – DUE 9/12/03 This is a group project. You form your own teams. Each team should consist of UP TO THREE students. Consider the parachutist problem. Write an Excel Spreadsheet solution using Visual Basic macros to calculate terminal velocities numerically for each of the following cases: Mass in the range of 0-100 Kg with step 10 For each mass vary the drag coefficient c in the range 0 to 20 with step 2 Plot the terminal velocity as a function of drag coefficient for each mass
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.