Simulation and visualization

of matrix hydrodynamics

 

github.com/klasmodin/quflow

Installation

git clone https://github.com/klasmodin/quflow.git
cd quflow
pip install .

With conda (recommended)

download the quflow conda environment file

then run the following command:

conda env create -f quflow-env.yaml
# Below only on Apple Silicon hardware:
conda install "libblas=*=*accelerate"

With pip

Basic concepts

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)

Basic concepts, continued

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 \)

\dot\omega + \{\psi,\omega\} = 0, \quad\Delta\psi = \omega

becomes

\dot W + \frac{1}{\hbar}[P,W] = 0, \quad\Delta_N P = W
\frac{2}{\sqrt{N^2-1}}

Hoppe-Yau Laplacian

Pre-processing

  • create initial state \(W_0\in\mathfrak{su}(N)\)
  • specify data filename (HDF5)
  • create QuSimulation object
  • specify parameters
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

Running simulation

  • move data file to cluster (optional)
  • adjust total simulation time (optional)
  • run the simulation
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)

Post-processing

  • move data file from cluster (optional)
  • plot and/or animate the data
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

Result for generic

smooth initial data

Results for generic vanishing momentum smooth initial data