You are on page 1of 25

01.

Computational Physics
(Modeling, Numerical Methods, and Problem Solving)
What is Computational physics?
 Computational physics is the study and implementation
of numerical algorithms in order to solve problems in
physics for which a quantitative theory already exists. It is
often regarded as a subdiscipline of theoretical physics but
some consider it an intermediate branch between
theoretical and experimental physics.
 Physicists often have a very precise mathematical theory
describing how a system will behave. Unfortunately, it is
often the case that solving the theory's equations ab initio
(Latin-means from the beginning) in order to produce a
useful prediction is not practical. This is especially true
with quantum mechanics, where only a handful of simple
models have complete analytic solutions. In cases where
the systems only have numerical solutions, computational
methods are used.
Applications of computational physics
 Computation now represents an essential component of
modern research in accelerator physics, astrophysics,
fluid mechanics, lattice field theory/lattice gauge theory
(especially lattice quantum chromodynamics), plasma
physics and solid state physics. Computational solid
state physics, for example, uses density functional
theory to calculate properties of solids, a method similar
to that used by chemists to study molecules.
 Many other more general numerical problems fall loosely
under the domain of computational physics, although
they could easily be considered pure mathematics or
part of any number of applied areas.
 These include
 Solving differential equations
 Evaluating integrals
 Stochastic methods, especially Monte Carlo methods
 Specialized partial differential equation methods, for example the
finite difference method and the finite element method
 The matrix eigenvalue problem – the problem of finding
eigenvalues of very large matrices, and their corresponding
eigenvectors (eigenstates in quantum physics)
 The pseudo-spectral method
 All these methods (and several others) are used to calculate
physical properties of the modeled systems. Computational Physics
also encompasses the tuning of the software/hardware structure to
solve the problems (as the problems usually can be very large, in
processing power need or in memory requests).
Problem statement:
 Suppose that a bungee-jumping company hires you.
 Your task is to predict the velocity of a jumper as a
function of time during the free-fall.
 The information will be used as part of a larger analysis
to determine the length and required strength of the
bungee cord for jumpers of different mass.
 You know from your studies of physics that the
acceleration should be equal to the ratio of the force to
the mass (Newton’s second law).
1.1 A Simple Model
 A model (or so call mathematical model) can be
broadly defined as a formulation or
equation that expresses the essential
features of a physical system or process in
mathematical terms.
 Models can be represented by a functional
relationship between dependent variables,
independent variables, parameters, and
forcing functions.
Model Function
Dependent independent forcing 
 f  , parameters, 
variable  variables functions

•Dependent variable - a characteristic that usually


reflects the behavior or state of the system

•Independent variables - dimensions, such as time and
space, along which the system’s behavior is being
determined
•Parameters - constants reflective of the system’s
properties or composition
•Forcing functions - external influences acting upon the
system
Model Function Example
 Assuming a bungee jumper is in mid-
flight, an analytical model for the
jumper’s velocity, accounting for drag,
is

gm  gc 
vt  tanh d
t 
cd  m 
 Dependent variable - velocity v
 Independent variables - time t
 Parameters - mass m, drag coefficient
cd
 Forcing function - gravitational
acceleration g
Detail of analytical modeling

F  ma F  FD  FU
F FD  mg
a
m FU  cd v 2

dv F 2
 dv
g
cd v
dt m dt m
Advance technique in calculus

 gcd 
vt  
gm
tanh t 
cd  m 
Analytical Model Results
 Using a computer (or a calculator), the model can be used
to generate a graphical representation of the system. For
example, the graph below represents the velocity of a 68.1
kg jumper, assuming a drag coefficient of 0.25 kg/m

 9.81(0.25) 
vt  
9.81(68.1)
tanh t 
0.25  68.1 

t(s) v (m/s)
0 0
2 18.7292
4 33.1118
6 42.0762
8 46.9575
10 49.4214
12 50.6175
 51.6938
Numerical Modeling
 Some system models will be given as implicit
functions or as differential equations - these can
be solved either using analytical methods or
numerical methods.
 Example - the bungee jumper velocity equation
from before is the analytical solution to the
differential equation
dv cd 2
 g v
dt m
where the change in velocity is determined by
the gravitational forces acting on the jumper
versus the drag force.
Numerical Methods
 To solve the problem using a numerical
method, note that the time rate of change
of velocity can be approximated as:
dv v vti 1   vti 
 
dt t ti 1  ti
detail of numerical methods
vti 1   vti 
 g  vti 
cd 2

ti 1  ti m
 2
vti 1   vti    g  vti   ti 1  ti 
cd
 m  t(s) v (m/s)
0 0
2 19.6200
t0  0, t1  2, v0  0 : 4 36.4137
6 46.2983
 0.25 2 
v  0  9.81  0  x 2  19.62 m/s 8 50.1802
 68.1  10 51.3123

t1  2, t 2  4, v1  19.62m/s : 12 51.6008
 51.6938

v  19.62  9.81 
0.25
19.622  x 2  36.4137 m/s
 68.1 

Numerical Results
 As shown in later chapters, the efficiency and
accuracy of numerical methods will depend
upon how the method is applied.
 Applying the previous method in 2 s intervals
yields:
Solving a problem in physics
 Problem statement defines the problem
 Formulation of the solution the model (physical law or
laws)
 Programming (of numerical solution) algorithm
(accuracy, length of calculations, difficulty in programming)
 Interpretation of the solution errors (or bugs).
 Can be verified by substituting the solution back in the question,
compared with a known solution of a similar problem, different
numerical methods.
1.2 Representation of Numbers on a Computer
Decimal and binary representation

 Computers store and process numbers in binary form. Each binary digit
(1 or 0) is called a bit.
Floating point representation
 To accommodate large and small numbers, real numbers are written
in floating point representation. Decimal floating point representation
(also called scientific notation) has the form: d.ddddd x 10P
 6519.23  6.51923 x 10 3
decimal point mantissa order of
 0.00000391  3.91 x 10 -6

 Binary floating point, power of 2 is called the exponent.


Binary has the form: 1.bbbbbb x 2bbb
 Example:
Storing a number in computer memory
 The computer stores the values of the exponent and the mantissa
separately, while the leading 1 in front of the decimal point is not stored.
 Single-precision 32 bits (4 bytes) 1:8:23
 Double-precision 64 bits (8 bytes) 1:11:52

 A bias means that a constant is added to the value of the exponent- to


avoid using one of the bits for the sign of the exponent (since the
exponent can be positive or negative)
 If 11 bits2047, 1024=bias, exponent 4 =1024+4=1028
 -1023 = 0
 0 = 1024
 1023 = 2047
 The smallest positive number in double-precision is:
2-1023 ≈ 1.1 x 10-308
 Gap between smallest number and zero-cause an underflow
error (same way for negative number)
 The largest positive number in double-precision is:
21024 ≈ 1.1 x 10308
 Larger then this- causes overflow error

 Not every number can be accurately written in binary form


 Interval between numbers that can represented-
Double-precision 2-52 ~=2.22 x 10 -16
(defined as the machine epsilon) eps in MATLAB command
1.3 Errors in Numerical Solutions
 round-off errors
 truncation errors total error

2.3.1 Round-Off Errors


 2/3= 0.6666 or 0.6667
chopping rounding
 Example, consider the quadratic equation:
x2 - 100.0001x + 0.01 = 0
exact solutions are x1 = 100 and x2 = 0.0001
Use quadratic formula:
Mathematical expressions
Activity:
1.3.2 Truncation Errors
 Occur when the numerical methods used for solving a
mathematical problem use an approximate mathematical
procedure.
 Example: the numerical evaluation of sin (x)- using Taylor’s
series expansion
1.3.3 Total Error
1.4 Computers and Programming
 Solving physical system problems that cannot solved
analytically.
 Can store a large quantity of numbers and can execute
mathematical operations with these numbers very quickly.
 Machine language
 low-level – assember
 higher level – C, C++, FORTRAN

 Algorithm a plan, step-by-step instructions on how to


carry out the solution
 Computer programs or computer code, is a set of
commands that are to be executed by the computer.
 Different programming languages use different syntax for the
commands.

You might also like