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

Tutorial 3

Uploaded by

rena
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 views12 pages

Tutorial 3

Uploaded by

rena
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/ 12

CHBE 230 - Tutorial 3

CHBE 230
Tutorial 3 - Additional problems

Learning objectives
Learn and understand how to use various root-finding
methods to solve an engineering problem
Learn how to use a minimum finding method to solve
an engineering problem
CHBE 230 - Tutorial 3

Case study: ballistic trajectory with linear drag

z
v0
zmax
z0

x
xmax

Questions:
1. Compute the distance to touch the ground xmax
2. Compute the maximum height zmax
CHBE 230 - Tutorial 3

What should we do ?

Formulate the trajectory problem and solve the problem


analytically

Compute xmax as a root-finding problem

Compute zmax as another root-finding problem

Compute zmax as a minimum finding problem


CHBE 230 - Tutorial 3

Analytical solutions
c
vx (t) = vx0 e mt

m ⇣ m ⌘ c
vz (t) = g + vz0 + g e mt
c c
m c
x(t) = vx0 (1 e t )
m
c
m m⇣ m ⌘ c
z(t) = z0 gt + vz0 + g (1 e mt )
c c c
CHBE 230 - Tutorial 3

Step 1: Preamble and variables


Create a directory/folder and name it Tutorial3

In this folder, create a new Jupyter notebook and call it


Tutorial3-CaseStudy.ipynb

In the first cell, copy & paste the Matlibplot preamble


that we have been using in any notebook

In the next cell, import the required Python packages


(again by copy & paste from an existing notebook),
which packages do we need ?

Identify the variables and define them in your code,


assign them all a value
CHBE 230 - Tutorial 3

Answers to step 1
required Python packages
numpy
matplotlib and matplotlib.pyplot
our own root_finding

Variables: Let’s all take


mass m m=1
gravity g g = 9.81
drag coefficient c c = 0.4
initial x velocity vx0 vx0 = 10
initial z velocity vz0 vz0 = 7
initial z position z0 z0 = 5
CHBE 230 - Tutorial 3

Step 2: Plotting the trajectory


Create an additional variable tend and assign a value
of 2 for the set of other parameters considered
Define the 4 functions x(t), z(t), vx(t), vz(t)
Create a numpy array called tplot containing discrete
values of time from 0 to tend. Let’s use 1001 values
Compute x(t) and z(t) at the discrete values of time by
vectorized computations and store the values in 2
numpy arrays xplot and zplot
Plot zplot versus xplot. For this, copy & paste the
block of instructions to plot a function from an existing
notebook and adapt it to your needs
CHBE 230 - Tutorial 3

Step 3: Computing xmax


Formulate the problem:
when x(t)=xmax, we have z(t)=0, i.e., the object has
hit the ground
we need to determine t̃ such that z(t̃) = 0 and
then compute xmax = x(t̃)
z(t̃) = 0 is a root finding problem

Solve z(t̃) = 0 with the false position method with a=0,


b=2 and tol=10-8

Report the value of t̃ and the number of iterations


needed for convergence

Compute xmax = x(t̃) and report its value


CHBE 230 - Tutorial 3

Step 4: Computing zmax as a root finding problem


Formulate the problem:
when z(t)=zmax, we have vz(t)=0, i.e., the object has
0 vertical velocity
we need to determine t̃ such that vz (t̃) = 0 and
then compute zmax = z(t̃)
vz (t̃) = 0 is a root finding problem

Solve vz (t̃) = 0 with the Secant method with initial


guess =1, h=10-6 and tol=10-5

Report the value of t̃ and the number of iterations


needed for convergence

Compute zmax = z(t̃) and report its value


CHBE 230 - Tutorial 3

Step 5: Computing zmax as a minimum finding problem


A bracketing method similar to the Bisection method for
root finding is able to determine the minimum of a
function f over an interval [a,b] by returning a sub-
interval in which this minimum is attained.

This method was not discussed in class but is available


in your python package root_finding and its
construction is detailed in the appendix of Lecture 3’s
slides for your curiosity

The method is called golden_minimum as it uses the


golden number to shrink the interval at each iteration
CHBE 230 - Tutorial 3

Here we will only use the method, its usage is similar to


the Bisection method or the False position method. It
takes the same input parameters as the Bisection
method or the False position method and returns xmin
the location of the minimum and fmin the minimum of the
function in the interval [a,b]

(xmin, fmin) = golden_minimum(function, a, b, tol=1e-5,


max_iter=100, conv_hist=True, with_plot=False)
CHBE 230 - Tutorial 3

We would like to compute zmax using


golden_minimum but z(t) has a maximum and not a
minimum. Fortunately we can write zmax = - min ( - z(t) )

Define a function that returns - z(t)

Call golden_minimum with a=0, b=2 and tol=10-8

Report the values of tmax and zmax where zmax=z(tmax)

Check that you get the same values as at Step 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy