Computational Methods II (CI2-221)
Dr Maarten van Reeuwijk
[email protected]The role of computing in Civil Engineering
Civil engineers provide quantitative solutions to qualitative problems in
the areas of design, construction and maintenance of the natural and built
environment;
People are going to look at you to provide them with answers!
Civil engineers rely on mathematical models to provide the answers that
they are expected to answer;
Many mathematical models do not have analytical solutions and can
thus only be approximated numerically.
Computational Methods II (CI2-221/MvR)
Page 2
Course outline CI2-221
Optimization (10 hrs). Dr Onof
Numerical differentiation, integration, and ordinary differential
equations (20 hours). Dr van Reeuwijk
Introduction to Finite Element Methods (10 hours). Dr Phillips
Computational Methods II (CI2-221/MvR)
Page 3
Learning objectives
At the end of this part of the course, you should be able to use MATLAB to
plot and manipulate data stored in higher dimensional arrays;
Be able to create vectorised algorithms;
perform numerical differentiation in more than one dimension;
perform numerical integration in more than one dimension on nontrivial integration domains;
confidently solve Ordinary Differential Equations numerically, and
know how to convert higher order ODEs in a system of first-order ODEs
be able to identify the sources of error in numerical approximations.
Computational Methods II (CI2-221/MvR)
Page 4
Outline of this part of course
Hours
Topic
10
Vectorisation, Numerical differentiation and
integration in more than one dimension
10
Numerical integration of Ordinary differential
equations
2 x 2 (Spring term)
In-class coursework [60 percent of marks]
The most efficient way to learn about this material is to apply it to practical
problems. For this reason the grade is based on coursework only. There is
no exam.
Computational Methods II (CI2-221/MvR)
Page 5
Note about tutorials & in-class coursework
In-class coursework exercises are scheduled in the spring term
You will have access to all lecture notes and the tutorial solutions during
the in-class coursework exercise;
However, the volume of work is only doable within the time given with
sufficient practice.
Therefore: keep up with the tutorials and really try to do them yourself:
you only learn what works from looking through worked solutions (and not
the most important thing: what does NOT work).
Computational Methods II (CI2-221/MvR)
Page 6
MATLAB site license
Go to www.imperial.ac.uk/ict
Click on software / MATLAB
Follow the instructions for students (involves filling out a form and sending it
to ICT)
More information can be found on the course website on Blackboard
Computational Methods II (CI2-221/MvR)
Page 7
VLE: Blackboard Learn
Computational Methods II (CI2-221/MvR)
Page 8
Ren Magritte
1898-1967
Page 9
Computational Methods II (CI2-221/MvR)
Mathematical modelling of the real world
Real world
Mathematical model
Assumptions
Simplifications
dv
= F
dt
x
m
y
Correspondence
Fg=mg
Disagreement
A model will never describe every aspect of the real world;
A model will contain artefacts that have no corresponding pattern in the real
world.
Computational Methods II (CI2-221/MvR)
Page 10
Analytical solutions of mathematical models
An analytical solution is the most
powerful answer possible. It does not
only give the solution to the problem,
but also the dependence of the solution
on all the parameters (here: g) and the
initial conditions (here: x0 and v0).
If you have the choice, always choose
an analytical solution above a
numerical solution.
dv
= mg
dt
dv = g dt
v v0 = gt
dy
=v
dt
dy = (v
+ gt )dt
y y0 = v0t + 12 gt 2
y = y0 + v0t + 12 gt 2
Page 11
Computational Methods II (CI2-221/MvR)
Numerical solutions of mathematical models
In many situations, analytical solutions
do not exist. This occurs in particular
when the model has:
nonlinearities (such as quadratic
friction),
forces which cannot be written as
simple functions (such as a
height-dependent forcing due to
wind).
Arbitrary function
Quadratic friction
[nonlinear term]
dv
= mg c v v F ( y )
dt
Prevents explicit
analytical solutions
for the
mathematical model
Computational Methods II (CI2-221/MvR)
Page 12
Numerical models
Computers are very good with calculations, but cannot deal with continuous
functions. Convert to the function to a discrete series:
v
v2
v1
vn
v0
vn+1
t
tn
Approximate slope:
tn+1
dv vn +1 vn
dt
t
Computational Methods II (CI2-221/MvR)
Page 13
Numerical models
Advantages:
can obtain numerical answers to any problem, no matter how difficult
(nonlinearities, geometry, arbitrary forcing);
Flexible easy to add new physics;
Disadvantages:
How accurate are the answers?
Am I looking at a numerical artefact or is this real?
Can only study one initial condition and parameter setting at the
time. Need to run several simulations to get dependencies.
Computational Methods II (CI2-221/MvR)
Page 14
Numerical modeling of the real world
Mathematical model
Real world
Continuous
Correspondence
Disagreement
dv
= F
dt
y
Fg=mg
Numerical model
Discrete
vn+1 = vn + f(yn, vn)t
Computational Methods II (CI2-221/MvR)
CI2-221
Page 15
General remarks
This is a course on performing engineering computations, not a
programming course!
However, engineering computation requires understanding of
The computer language (MATLAB);
The numerical algorithm itself;
The physics of the problem you are studying (how do you decide that
what you have programmed is correct?).
CI221 is a great opportunity to consolidate your acquired knowledge of
Civil Engineering, physics and mathematics to solve some realistic
problems.
This course builds up; doing the first tutorials thoroughly will save you
significant amounts of time later on.
Computational Methods II (CI2-221/MvR)
Page 16
Tutorial: Jumping Jack
Use last years MATLAB knowledge
to help out your cousin Jack
Calculate vertical velocity and
acceleration of car using numerical
differentiation.
One new MATLAB function:
gradient (suitable ONLY for
equidistant ly sampled data, use
diff for more general case).
Example:
x = linspace(0, 2*pi);
y = sin(x);
dx = x(2) - x(1);
% calculate step size
dydx = gradient(y, dx); % determine dy/dx
The advantage of gradient is that dydx has exactly the same array size
as y (as opposed to diff) This makes the results very easy to use.
Computational Methods II (CI2-221/MvR)
Page 17