Examples

  

Computational physics examples as IPython Notebooks.

Mechanics 6

  Simple Pendulum

animation, explicit euler method, ode

Simulates the simple pendulum and damped simple pendulum

  Projectile motion

explicit euler method, 4th order runge-kutta, ode, Big Bertha, set of odes

Computing the trajectory of a projectile moving through the air, subject to wind and air drag.

  Double Pendulum and Chaos

animation, differential equation, Lagrangian, Euler-Lagrange equations, chaos, phase space, odeint

Discusses the chaotic motion of the double pendulum using a phase-space diagram

  The Cavendish Experiment

gravity, newton, harmonic oscillator, cavendish, curve fitting

Analyzes data from the Cavendish experiment using curve fitting. The Gravitational Constant is estimated.

  Roller Coaster

animation, gravity, newton, 4th order runge-kutta, interpolation, cubic splines

The motion of a rolling object on an arbitrary track is analyzed.

  Stabilising an Inverted Pendulum on a Cart

animation, 4th order runge-kutta, system of equations

The 4th order Runge-Kutta method was used to integrate the equations of motion for the system, then the pendulum was stabilised on its inverted equilibrium point using a proportional gain controller and linear quadratic regulator.

Thermodynamics 2

  Martian Atmosphere

simpson's method, temperature, pressure

Computing planet Mars' atmospheric pressure profile from its temperature profile.

  One-dimensional Stationary Heat Equation

temperature, chebychev nodes

Solving the one-dimensional stationary heat equation with a Gaussian heat source by approximating the solution as a sum of Lagrange polynomials.

Astrophysics 7

  Precession of Mercury

space, einstein, gravity, 4th order runge-kutta, angular momentum, fortran, ode, extrapolation, f2py

Computes the precession of Mercury by linear extrapolation.

  Planetary Motion

space, explicit euler method, gravity, newton

Applying the explicit and implicit Euler methods and the fourth order Runge-Kutta method to calculate the trajectory of the Earth around the Sun.

  Lagrange Points

space, gravity, newton, 4th order runge-kutta, lagrange

Studying how a third mass behaves in the effective gravitational potential resulting from two opposing masses (here: Sun and Earth).

  General Relativity

space, einstein, gravity, newton, 4th order runge-kutta, angular momentum, differential equation, ode

Discussion of orbits in the Schwarzschild Geometry.

  Planetary Motion - Three Body Problem

animation, space, gravity, newton, embedded runge-kutta pair, angular momentum

Applying the fourth order Runge-Kutta method and the adaptive step size Runge-Kutta method to calculate the trajectories of three bodies.

  Gravity Assist

animation, gravity, newton, semi-implicit euler method

Explaining the concept and simulating gravitational slingshot of a spacecraft passing a planet.

  The Fate of Our Universe

space, gravity, ode

Solving the Friedmann equations to model the expansion of our universe.

Optics 3

  Diffraction in a Gradient-Index Optical Fiber

fermat's principle, diffraction, snell's law, refraction

Plotting the paths of light rays travelling through a gradient-index optical fiber.

  Image Filtering using Fourier Transform

discrete fourier transform, image filtering

Filters and analyzes images using Fourier transforms.

  Hybrid Images. Einstein-Monroe

einstein, discrete fourier transform, image filtering, rayleigh's criterion, star trek

Using Fourier transforms to filter and analyzing hybrid images.

Statistical Mechanics 3

  Ising Model in 1D and 2D

specific heat, magnetism, partition function, spin

Computing the internal energy, specific heat and magnetisation in the 1D and 2D Ising model. An analytical solution to the XY model is also provided.

  Introduction to Brownian Motion and Diffusion

animation, diffusion, einstein, random walk, brown

A brief introduction to Brownian motion and its connection with diffusion. A system of Brownian particles in 2D is simulated and visualised.

  Equilibrium Monte Carlo simulation of the 2D Ising model

magnetism, spin, monte carlo, fortran, f2py, metropolis, equilibrium, autocorrelation, ising

Using the Metropolis algorithm to approximate the magnetization and specific heat for a 2D Ising lattice.

Quantum Mechanics 11

  Numerical Determination of Eigenenergies for the Harmonic Oscillator

eigenenergy, harmonic oscillator, forward shooting, eigenstate

Using the method of forward shooting to determine numerically the eigenenergies of the quantum harmonic oscillator in one dimension.

  Band Structures and Newton's Method

schrödinger equation, bloch's theorem, newton's theorem

Using Newton's method to calculate the band structure for the simple Dirac comb potential in one dimension.

  The Size of a Hydrogen Atom - Monte Carlo Integration

monte carlo

Computing the size of the hydrogen atom using Monte Carlo integration.

  Eigenenergies of the Double-Well Potential

eigenenergy, forward shooting, eigenstate

Calculating the eigenenergies of the lowest states for a one-dimensional double-well potential.

  Hydrogen Molecule Ion

schrödinger equation

Employing Monte Carlo integration to determine the "shape" of the hydrogen molecule ion.

  Numerical Determination of Eigenenergies for an Asymmetric Potential

eigenenergy, forward shooting, eigenstate, schrödinger equation

Using a forward-shooting method to determine the eigenenergies and eigenfunctions of an asymmetric potential in one dimension.

  Eigenenergies Through Matrix Diagonalization

harmonic oscillator

The eigenenergies of a system are found by discretizing the Schrödinger equation and finding the eigenvalues of the resulting matrix.

  One-Dimensional Wave Propagation

animation, schrödinger equation, tunneling, scattering

A one-dimensional wave-packet is propagated forward in time for various different potentials.

  Solving the Time-Dependent Schrödinger equation

animation, eigenenergy, eigenstate, schrödinger equation, tunneling, scattering, ehrenfest's theorem

The Time-Dependent Schrödinger equation is solved by expressing the solution as a linear combination of (stationary) solutions of the Time-Independent Schrödinger equation.

  Modeling Atoms, Molecules, and Crystals in One Dimension

spin, hemmer, eigenenergy, eigenstate, schrödinger equation, waves

Solving the time independent Schrödinger equation in one dimension using matrix diagonalisation for five different potentials.

  Numerical calculation of the Clebsch-Gordan Coefficients

angular momentum, spin, implementation

Computing the Clebsch-Gordan Coefficients for two particles with quantized spin. External contribution

Electromagnetism 5

  Electric fields and potentials from point charges

magnetism, electricity, coulomb

Calculates and plots the electric fields and potentials around an arbitrary number of point charges.

  Quadrupole Mass Spectrometer

magnetism, 4th order runge-kutta, voltage, electricity

Using numerical tools to describe and analyse a quadrupole mass spectrometer.

  Resistor Network

resistance, voltage

Calculating the total current propagating through a resistor network.

  Uniform Magnetic Field

magnetism, explicit euler method, ode, Lorentz' law

Solving Lorentz force law for a charged particle traveling in a uniform magnetic field using Euler's method.

  Magnetic Mirror

embedded runge-kutta pair, integration, set of odes

The trajectory of a charged particle propagating in a non-uniform magnetic field is calculated by solving the Lorentz force law using an embedded Runge-Kutta pair. The results show that the particle is mirrored.

Fluid Mechanics 3

  Euler Equations for Inviscid Flow

An introduction to the compressible Euler equations and methods for solving them numerically.

  Oil Spill

integration, interpolation

Simulating movement of an oil spill outside the norwegian west-coast simplified as dissolvment of a chemical.

  Linear Wave Propagation

trapezoidal method, waves, Fourier transform

An introduction to studying linear surface waves on an infinite domain. In particular, the problem of finding the time evolution of a small perturbation of the surface of an inviscid and incompressible fluid.

Chemistry 3

  Lennard-Jones Potential

explicit euler method, lennard-jones potential

A simple physical model that approximates the interaction between a pair of neutral atoms or molecules.

  Self-avoiding random walk in 2D

random walk, polymer, hemmer

Self-avoiding random walks on the square lattice are performed using random sampling. The probability distribution of how many steps a random walker uses before it traps itself is studied. The notebook is based on an article by S. and P. C. Hemmer.

  Diffusion Limited Aggregation

diffusion, random walk, witten, fractal, box counting, sander

Describing aggregation using random walk and estimating its fractal dimension

Biophysics 3

  Tomography

image filtering, radiation, attenuation

Introduces concepts related to computer tomography (CT) and uses this to create a sinogram from a picture and computes the direct back projection.

  The Fiber Bundle Bridge Model

polymer, hemmer, hansen, lennard-jones potential, sparse matrix, nygård, elasticity

Simulates the disentanglement of a polymer from a surface using an increasing electric field

  Bak-Sneppen model in Julia

basic, Julia

The Bak-Sneppen model of evolution is a simple model describing the evolution of an ecosystem. It offers a surprising amount of insight given its simplicity. This notebook does not deep dive into the model, but illustrates the basics using the Julia programming language.

Waves and Acoustics 3

  Doppler Effect

speed of sound, doppler, discrete fourier transform

Calculating the speed of a passing train by Fourier analysis of the corresponding sound file.

  Sloshing

simpson's method, newton, euler, eigenvalue, poisson's equation, integration, interpolation

Analyzing sloshing using a numerical approach based on a linear model, which reduces the problem to a Steklov eigenvalue problem.

  Simple Sound Filtering

discrete fourier transform, nyquist-shannon sampling theorem, music, sound filtering, beat

Programming with sounds and using Fourier transforms to filter sound signals.

Particle and Nuclear Physics 2

  Half-Life Measurements

radiation, radioactive decay, curve fitting

Introduces curve fitting in Python and uses this to estimate the half-life of the Ba-137m isotope.

  Electron Positron Annihilation

monte carlo, electroweak, pythia, feynman diagrams, photon, historgram, neutrino

Uses the event generator Pythia 8.230 to compute the energy spectrum from electron positron annihilation at the Z resonance.

Modern 1

  Seam Carving

Julia

Seam carving is an algorithm for content-aware resizing of an image. This notebook presents the algorithm and tries to provide some insight into its workings.