You are on page 1of 33

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn

C++ language and Feynman's Path Integral


Foundations on advanced programming
Scuola di Dottorato di Ricerca in Fisica XXV ciclo

Dott. Michele Tuttafesta

Universit degli Studi di Bari


March 2011

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Overview

Theoretical basis

Numerical calculation of the propagator

Energy levels and FFT

Wavefunctions

The C++ code: feynman1d

Results
Harmonic oscillator
Double well potential
Particle in a box
Morse potential
Lennard-Jones potential

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn

Be wise, discretize! (Mark Kac)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

Let's consider a quantum system described by a time-independent


Hamiltonian

H.

U (t , t0 ) = e

iH (t t0 )

(time evolution operator)

| (t )i = U (t , t0 ) | (t0 )i
(x , t ) = hx | (t )i =

dx 0 hx | U (t , t0 ) | x 0 i(x 0 , t0 )

G (x , t ; x 0 , t0 ) = hx | U (t , t0 ) | x 0 i

(propagator)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

Let's consider a quantum system described by a time-independent


Hamiltonian

H.

U (t , t0 ) = e

iH (t t0 )

(time evolution operator)

| (t )i = U (t , t0 ) | (t0 )i
(x , t ) = hx | (t )i =

dx 0 hx | U (t , t0 ) | x 0 i(x 0 , t0 )

G (x , t ; x 0 , t0 ) = hx | U (t , t0 ) | x 0 i

(propagator)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

Let's consider a quantum system described by a time-independent


Hamiltonian

H.

U (t , t0 ) = e

iH (t t0 )

(time evolution operator)

| (t )i = U (t , t0 ) | (t0 )i
(x , t ) = hx | (t )i =

dx 0 hx | U (t , t0 ) | x 0 i(x 0 , t0 )

G (x , t ; x 0 , t0 ) = hx | U (t , t0 ) | x 0 i

(propagator)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

Let's consider a quantum system described by a time-independent


Hamiltonian

H.

U (t , t0 ) = e

iH (t t0 )

(time evolution operator)

| (t )i = U (t , t0 ) | (t0 )i
(x , t ) = hx | (t )i =

dx 0 hx | U (t , t0 ) | x 0 i(x 0 , t0 )

G (x , t ; x 0 , t0 ) = hx | U (t , t0 ) | x 0 i

(propagator)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

Let's consider a quantum system described by a time-independent


Hamiltonian

H.

U (t , t0 ) = e

iH (t t0 )

(time evolution operator)

| (t )i = U (t , t0 ) | (t0 )i
(x , t ) = hx | (t )i =

dx 0 hx | U (t , t0 ) | x 0 i(x 0 , t0 )

G (x , t ; x 0 , t0 ) = hx | U (t , t0 ) | x 0 i

(propagator)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

The trace (in the coordinate space) of the time evolution operator
is equivalent to the space integral of

G , setting the initial and nal

states equal and moreover it can be expressed in terms of the


eigenvalues

{En }

tr [U (t , 0)]

of the system energy; in fact, setting

{|ni}

dxG (x , t ; x , 0)

dx

=
=

where

|hx | ni|2 e

iEn t
~

is a complete set of energy eigenstates.

t0 = 0

iEn t

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

The trace (in the coordinate space) of the time evolution operator
is equivalent to the space integral of

G , setting the initial and nal

states equal and moreover it can be expressed in terms of the


eigenvalues

{En }

tr [U (t , 0)]

of the system energy; in fact, setting

{|ni}

dxG (x , t ; x , 0)

dx

=
=

where

|hx | ni|2 e

iEn t
~

is a complete set of energy eigenstates.

t0 = 0

iEn t

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Theoretical basis

In 1942 R.P. Feynman demonstrated that

G (x , t ; x , t0 ) =
0

where

lim

N
t 0
N t =t t0
m

2 i ~t and

CN

dx1 dxN 1

N i t  xn +xn1 xn xn1 
Y
L
~
2 , t
n =1

L(x , x ) = 12 mx 2 V (x ) is the system

lagrangian using the prescription of midpoint rule.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Numerical calculation of the propagator

t0 , , tN ,
t = T /N , T = t t0 and space x0 , , xD , x = (x x 0 )/D
and the key of the method (D + 1) (D + 1) matrix

We consider an equidistant discretization of time

x +x x x
L m n, m n
Kn,m (t ) := C exp
~
2
t
So we can approximate G for a xed N (T = N t dened as a


i t



characteristic time) as a matrix

G (Zxr , tk + N t ; xs , tk )
dx1 dx2 dxN 2 dxN 1 Kr ,1 K1,2 KN 2,N 1 KN 1,s
x

dx2 dx3 dxN 2 dxN 1 (K 2 )r ,2 K2,3 KN 2,N 1 KN 1,s

(x )

dx3 dx4 dxN 2 dxN 1 (K 3 )r ,3 K3,4 KN 2,N 1 KN 1,s


(x )N 1 (K N (t ))r ,s := Gr ,s (N t ) = Gr ,s (T )
2

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Numerical calculation of the propagator

t0 , , tN ,
t = T /N , T = t t0 and space x0 , , xD , x = (x x 0 )/D
and the key of the method (D + 1) (D + 1) matrix

We consider an equidistant discretization of time

x +x x x
L m n, m n
Kn,m (t ) := C exp
~
2
t
So we can approximate G for a xed N (T = N t dened as a


i t



characteristic time) as a matrix

G (Zxr , tk + N t ; xs , tk )
dx1 dx2 dxN 2 dxN 1 Kr ,1 K1,2 KN 2,N 1 KN 1,s
x

dx2 dx3 dxN 2 dxN 1 (K 2 )r ,2 K2,3 KN 2,N 1 KN 1,s

(x )

dx3 dx4 dxN 2 dxN 1 (K 3 )r ,3 K3,4 KN 2,N 1 KN 1,s


(x )N 1 (K N (t ))r ,s := Gr ,s (N t ) = Gr ,s (T )
2

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Numerical calculation of the propagator
One can obtain a propagator at a time
recursively by the composition law

Single path in a nite time


transition described by the
propagator Gr ,s (T ). The initial and
the nal positions xs and xr are
xed.
(a)

nT

multiple of

T,

G(nT ) = G(T )G((n 1)T )x

Single path in a nite time


transition described as a multiple of
a base one. The propagator is
obtained by the recursion
G(nT ) = G(T )G((n 1)T )x .
(b)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Energy levels and FFT
Setting

f (t ) = trU (t , 0) =

ne

f() =

1
2

iEn t

we calculate the transform

dt f (t )e i t

using the positive convention for the sign of the exponent in


so we should nd energy level values as peaks in the
where

= En /~.

f()

e i t

graph

Actually we calculate the discretized time

development of the trace in the interval

trU (nT , 0) =

D
X
i =0

Gii (nT )x ;

[T , (NT + 1)T ]

n = 1, , NT

We then perform an FFT (Fast Fourier Transform) using the


appropriate routine of the Gnu Scientic Library named

gsl_t_complex_radix2_backward (which adopts the above


required positive convention).

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Wavefunctions

The equation

(x , t ) =

dx 0 G (x , t ; x 0 , t0 )(x 0 , t0 )

can be discretized as follows

(xi , nT ) =
with

n = 1, , NT

and the

D
X
j =0

x Gij (nT )(xj , 0)

(D + 1 )

vector

(xj , 0)

given as input.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
The C++ code: feynman1d

The project les:


feynman1d.cpp (main function)
matrix.cpp (classes for complex matrices)
matrix.h
proplib.cpp (routines for propagator managing)
proplib.h

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Harmonic oscillator

xmin

-4

(a)

xmax

100

NT

256

T = NTTp

V (x )
1 x2
2

0.785

Energy spectrum - linear scale

(b)

x 0

( , )
 1

e 2 (x xs )

2 xs = 0.8

; = ;

Energy spectrum - log scale

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Harmonic oscillator

xmin

-4

xmax

(a)

100

NT

256

Transition amplitude

T = NTTp

0.785

V (x )
1 x2
2

x 0

( , )
 1

e 2 (x xs )

2 xs = 0.8

; = ;

Time evolution of wavefunction


norm |(x , t )|2 and potential energy
(b)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Double well potential

Test 1: minimal computational eort


xmin

-5

(a)

xmax

150

7.5

NT

128

0.838

Energy spectrum - linear scale.

V (x )
(x xm )2 (x + xm )2
= 0.02; xm = 2.5

(b)

x 0

( , )
 1

e 2 (x xs )

2 xs = 2

= ;

Energy spectrum - log scale.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Double well potential

Test 1: minimal computational eort


xmin

-5

xmax

(a)

150

7.5

NT

128

Potential energy

0.838

V (x )
(x xm )2 (x + xm )2
= 0.02; xm = 2.5

x 0

( , )
 1

e 2 (x xs )

Time evolution of wavefunction


norm
(b)

2 xs = 2

= ;

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Double well potential

Test 2: enhanced computational eort


xmin

-6

(a)

xmax

200

16

NT

512

0.393

Energy spectrum - linear scale.

V (x )
(x xm )2 (x + xm )2
= 0.02; xm = 2.5

(b)

x 0

( , )
 1

e 2 (x xs )

2 xs = 2

= ;

Energy spectrum - log scale.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Double well potential

Test 2: enhanced computational eort


xmin

-6

xmax

(a)

200

16

NT

512

Potential energy

0.393

V (x )
(x xm )2 (x + xm )2
= 0.02; xm = 2.5

x 0

( , )
 1

e 2 (x xs )

Time evolution of wavefunction


norm
(b)

2 xs = 2

= ;

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Particle in a box

xmin

xmax

3
4

3
4

100

70

NT

512

0.0897

Energy spectrum - log scale. The


vertical arrows show theoretical peaks

(a)

V (x )

(b)

x
x

| |<
| |

3
4
3
4

x 0

( , )
 1

e 2 ( x xs )
= 10; xs = 0.5

Transition amplitude

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Particle in a box

xmin

xmax

3
4

3
4

100

70

NT

512

0.0897

V (x )

x
x

| |<
| |

3
4
3
4

x 0

( , )
 1

e 2 ( x xs )
= 10; xs = 0.5

First steps in the time evolution of (b) Time evolution of wavefunction


wavefunction norm.
norm up to a nearly stationary state

(a)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Morse potential

It is a convenient model for


the potential energy of a
diatomic molecule and has the
following expression

V (r ) = d
where

e a(r re )

2

is the distance

between the atoms,

re

is the

equilibrium bond distance,

is the well depth (dened


relative to the dissociated
atoms), and

a controls the

width of the potential (the


smaller

a the larger the well).

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Morse potential

It is a convenient model for


the potential energy of a
diatomic molecule and has the
following expression

V (r ) = d
where

e a(r re )

2

is the distance

between the atoms,

re

is the

equilibrium bond distance,

is the well depth (dened


relative to the dissociated
atoms), and

a controls the

width of the potential (the


smaller

a the larger the well).

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Morse potential

xmin

-2.5

(a)

xmax

100

NT

256

Energy spectrum - linear scale.

1.05

V (x )

8 1 e x4


2

x 0

( , )
 1

e 2 (x xs )

2 xs = 0.8

= ;

Energy spectrum - log scale.


Theoretical numeric data are on graph
top.
(b)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Morse potential

xmin

-2.5

xmax

100

NT

256

1.05

V (x )

8 1 e x4


2

x 0

( , )
 1

e 2 (x xs )
= 2; xs = 0.8

Morse potential compared with the (b) Time evolution of wavefunction


harmonic one.
norm

(a)

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Lennard-Jones potential
It is a mathematically simple model
that approximates the interaction
between a pair of neutral atoms or
molecules. The base expression is

V (x ) = d
where



 x 6
xm 12
m
2
x
x

is the distance between

the atoms,

xm

bond distance,

is the equilibrium

is the well depth

(dened relative to the dissociated


atoms). Moreover one can write

xm = 2 6 , where is a

characteristic dimension of the


atoms.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Lennard-Jones potential
It is a mathematically simple model
that approximates the interaction
between a pair of neutral atoms or
molecules. The base expression is

V (x ) = d
where



 x 6
xm 12
m
2
x
x

is the distance between

the atoms,

xm

bond distance,

is the equilibrium

is the well depth

(dened relative to the dissociated


atoms). Moreover one can write

xm = 2 6 , where is a

characteristic dimension of the


atoms.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Lennard-Jones potential

xmin

-2.37

(a)

xmax

9.55

100

NT

256

1.05

V (xh)
i
d p(x )12 2p(x )6 + d
p(x ) = x +xmxm ; d = 8; xm = 24

x 0

( , )
 1

e 2 (x xs )
= 2; xs = 0.8

Energy spectrum - linear scale. (b) Energy spectrum - log scale.


Dash line and numeric data on
graph top refer to Morse potential.

Theoretical basis Numerical calculation of the propagator Energy levels and FFT Wavefunctions The C++ code: feyn
Lennard-Jones potential

xmin

-2.37

xmax

9.55

100

NT

256

1.05

V (xh)
i
d p(x )12 2p(x )6 + d
x
p(x ) = x +mxm ; d = 8; xm = 24

x 0

( , )
 1

e 2 (x xs )
= 2; xs = 0.8

Lennard-Jones potential compared (b) Time evolution of wavefunction


with the harmonic one.
norm
(a)

You might also like