Skip to content

Instantly share code, notes, and snippets.

View marl0ny's full-sized avatar

Mark Lamorena marl0ny

  • 04:26 (UTC -04:00)
View GitHub Profile
import numpy as np
from scipy.fft import dst, idst
from scipy.integrate import trapezoid
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# Constants
N: int = 512
X = np.arange(0, N, dtype=np.float64)
"""
This script numerically solves the linear and nonlinear Schrodinger equation
using the split operator method, and then shows a matplotlib animation of the
results.
References:
Split operator method:
James Schloss. The Split Operator Method - Arcane Algorithm Archive.
https://www.algorithm-archive.org/contents/split-operator_method/
split-operator_method.html
/* Numerically solve for the time-dependent Schrodinger equation in 2D,
using the split operator method. To build and run, type:
rustc qm2d_split_op.rs
./qm2d_split_op
This will output a series of bmp images which show each frame of the
simulation.
References:
"""
Simulation of coupled Fermions by explicitly constructing the Fermion
operators as matrices and then diagonalizing the subsequent Hamiltonian
to find the energies and energy eigenvectors.
The primary reference for this is Chapter 4 of
Introduction to Many Body Physics by Piers Coleman, pg 71 - 77 on the
Jordan-Wigner transformation.
P. Coleman, Simple examples of second quantization,
"""
Using the Chebyshev method purely with finite differences
to numerically integrate the Schrodinger equation in 1D.
This is primarily based on the following article:
Tal-Ezer H., Kosloff R. (1984).
An accurate and efficient scheme for propagating
the time dependent Schrodinger equation.
J. Chem. Phys. 81(9), 3967-3971.
import numpy as np
import matplotlib.pyplot as plt
from scipy.fft import dstn, idstn
N = 256 # Number of points
L = 45.0 # Simulation size
S = np.linspace(-L/2.0, L/2.0, N)
X, Y = np.meshgrid(S, S)
DX = S[1] - S[0] # Spatial step size
/*
Finding the energy eigenstates for a single particle 1D system with
Dirichlet boundary conditions,
by discretizing the Hamiltonian using finite differences.
This requires that you have Eigen, Spectra, and SDL installed.
Eigen: https://eigen.tuxfamily.org/index.php?title=Main_Page
Spectra: https://spectralib.org/
SDL: https://www.libsdl.org/
"""
Simulating coupled 1D Quantum Harmonic Oscillators.
This is based on the following article:
Scott C. Johnson and Thomas D. Gutierrez,
"Visualizing the phonon wave function",
American Journal of Physics 70, 227-237 (2002)
https://doi.org/10.1119/1.1446858
#!/usr/bin/python3
"""
Exponentiating the momentum terms found in the
dirac equation. The form of these momentum terms are
found on page 565 of
Principles of Quantum Mechanics by Ramamurti Shankar.
"""
from sympy import Matrix, Symbol, exp
import numpy as np
from splitstep import SplitStepMethod
import numpy as np
# Constants (Metric Units)
N = 64 # Number of points to use
L = 1e-8 # Extent of simulation (in meters)
X, Y, Z = np.meshgrid(L*np.linspace(-0.5, 0.5 - 1.0/N, N),
L*np.linspace(-0.5, 0.5 - 1.0/N, N),
L*np.linspace(-0.5, 0.5 - 1.0/N, N))
DX = X[1] - X[0] # Spatial step size