Numerical solutions to partial differential equations (PDEs) in discretised space and time for initial value and boundary value problems. Contains two classes, CH_Lattice and Poisson_Lattice, and one test script.
Simulates a water/oil mixture on a lattice. Uses the fast Fourier transform (FFT) to perform Laplacian and gradient calculations in parallel, and step the simulation forward using the Euler algorithm.
Simulates a water/oil mixture on a lattice. Uses either the Jacobi or the Gauss-Seidel algorithm to step the simulation forwards, and then sets a Dirchlecht boundary condition. The FFT is trivially utilised to step the Jacobi algorithm forward in time. A three-dimensional ''checkerboard'' pattern is used to update the lattice using the Gauss-Seidel algorithm, so that adjacent sites are updated using the FFT alternatingly.
The test script pde_test.py
illustrates the utility of these classes. It
is invoked with:
python3 pde_test.py [l] [m] [n] [phi_0] [max_iter] [mode]
The system arguments:
l
, m
, n
: (int) the dimensions of the lattice. n
parameter is not used by Cahn-Hilliard class instances but a ''dummy''
parameter may be supplied. 50x50x50 is sufficiently large to illustrate the
behaviour of both classes.
phi_0
: (float) intital scalar value with which to initalise the lattice.
Small random noise is added to this value on construction of an instance.
max_iter
: (int) the maximum number of iterations to which the simulation
will be run before exiting. Simulations on the Poisson lattice with a
mode
: (str) invokes one of several test cases for the simulation (see
descriptions below). Can be oildrop
, monopole
, wires
, or SOR
.
oildrop
: initalises and runs an animation of the Cahn-Hilliard oil/water
mixture. Values of
monopole
: initialises a Poisson_Lattice instance and solves the Poisson
equation using the Gauss-Seidel algorithm with over-relaxation for a single
charge at the center of the lattice. Once converged to the solution, plots the
a slice through the electric potential in the xy-plane and the resulting
electric field.
wires
: reappropriates the Poisson_Lattice to solve one of Maxwell's
equation, with some small changes, using the Gauss-Seidel algorithm with over-
relaxation for a current density along the z-axis. Plots the magnetic vector
potential
SOR
: tests a range of values for the over-relaxation parameter