This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Single particle quantum mechanics in 1D using the split-operator method. | |
References: | |
https://www.algorithm-archive.org/contents/ | |
split-operator_method/split-operator_method.html | |
https://en.wikipedia.org/wiki/Split-step_method | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
N = 256 # Controls the grid size. | |
L = 8 | |
X, Y = np.meshgrid(np.linspace(-L/2, L/2, N, dtype=float), | |
np.linspace(-L/2, L/2, N, dtype=float)) | |
DX = X[0, 1] - X[0, 0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Cranck-Nicolson method for the Schrödinger equation in 2D. | |
Jacobi iteration can be used to solve for the system of equations that occurs | |
when using the Cranck-Nicolson method. This is following an | |
article found here https://arxiv.org/pdf/1409.8340 by Sadovskyy et al., | |
where the Cranck-Nicolson method with Jacobi iteration is | |
used to solve the Ginzburg-Landau equations, which is similar to | |
the Schrödinger equation but contains nonlinear terms and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numpy.linalg import eigh | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d.art3d import Poly3DCollection | |
from skimage import measure | |
n: int = 256 | |
length: float = 64 | |
x: np.ndarray = np.linspace(-length/2, length/2-length/(n), n, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Lorentz transform of 4-vector field. Reference: | |
- Introduction to Electrodynamics by Griffiths, chapter 10-12 | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
import sympy as sp | |
from sympy.parsing.sympy_parser import parse_expr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
2D fluid simulation using the Lattice-Boltzmann algorithm, | |
based on the Fluid Dynamics Simulation by Daniel Schroeder: | |
- https://physics.weber.edu/schroeder/fluids/ | |
- http://physics.weber.edu/schroeder/javacourse/LatticeBoltzmann.pdf | |
Still need to check if the implementation is correct. | |
SDL is a prerequisite. Compile with the following commands: | |
g++ -c -I<include path> fluid2d.cpp; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Plots and animations of single particle quantum mechanics phenomena in 1D | |
by discretizing the Hamiltonian. This method is described here: | |
https://wiki.physics.udel.edu/phys824/Discretization_of_1D_continuous_Hamiltonian | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
from numpy.linalg import eigh, eig | |
n = 512 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
My attempt at implementing a math parser, using the Shunting-yard algorithm | |
as described by its Wikipedia page: | |
https://en.wikipedia.org/wiki/Shunting-yard_algorithm | |
Currently it's a mess, and there are definitely things that I could simplify. | |
""" | |
import math | |
class Token: |
NewerOlder