git clone https://github.com/klasmodin/quflow.git
cd quflow
pip install .
conda env create -f quflow-env.yaml
# Below only on Apple Silicon hardware:
conda install "libblas=*=*accelerate"
Classical
function \(\omega:S^2\to\mathbb{R}\)
spherical harmonics \(\omega = \sum_{l=0}^\infty\sum_{m=-l}^l\omega^{lm}Y_{lm}\)
Quantized
complex matrix \(W\in\mathfrak{u}(N)\)
matrix harmonics \(W = \sum_{l=0}^N\sum_{m=-l}^l\omega^{lm}T_{lm}\)
import quflow as qf
omega = np.random.randn(10)
N = 512
W = qf.shr2mat(omega, N)
qf.plot(W)
vorticity form of 2-D Euler
Classical | Matrix correspondence |
---|---|
Poisson bracket | Scaled commutator |
Poisson equation | Matrix equation |
\(\{\omega,\psi\}\)
\(\frac{1}{\hbar}[W,P]\)
\(\Delta\psi = \omega \)
\(\Delta_N P = W \)
becomes
Hoppe-Yau Laplacian
import quflow as qf
N = 128
W0 = qf.shr2mat(np.random.randn(10), N)
filename = "basic_euler_N_{}.hdf5".format(N)
# Create simulation object associated with `filename`
mysim = qf.QuSimulation(filename, overwrite=True, state=W0,
loggers={'energy':qf.energy_euler,
'enstrophy':qf.enstrophy})
# Set parameters
mysim['dt'] = 0.5*qf.hbar(N) # scale by hbar to get independence of N
mysim['simtime'] = 5.0
mysim['inner_time'] = 0.2 # how often to write output
mysim['hamiltonian'] = qf.solve_poisson # which Hamiltonian to use
import quflow as qf
N = 128
filename = "basic_euler_N_{}.hdf5".format(N)
# Read simulation object associated with `filename`
mysim = qf.QuSimulation(filename)
# Adjust simulation time if needed
mysim['simtime'] = 10.0
# Run the simulation
qf.solve(mysim)
(repeat the above to continue simulation longer)
import quflow as qf
N = 128
filename = "basic_euler_N_{}.hdf5".format(N)
# Read simulation object associated with `filename`
mysim = qf.QuSimulation(filename)
# Plot the last state
# ('fun' is the output of function, 'mat' is the pure matrix)
qf.plot(mysim['fun', -1])
# Create animation of the entire simulation
anim = qf.create_animation(filename.replace(".hdf5",".mp4"), mysim['fun', :])
anim