Skip to content

Commit

Permalink
Merge pull request #16 from PGelss/PauliMatrices
Browse files Browse the repository at this point in the history
Pauli matrices
  • Loading branch information
bsch63 authored Sep 27, 2023
2 parents 3d3044e + 85bd0d1 commit 15ad695
Show file tree
Hide file tree
Showing 20 changed files with 419 additions and 136 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = wave_train
version = 1.0.10
version = 1.0.11
author = Jerome Riedel, Patrick Gelß, Burkhard Schmidt
author_email = burkhard.schmidt@fu-berlin.de
description = Numerical quantum mechanics of chain-like systems based on tensor trains
Expand Down
94 changes: 94 additions & 0 deletions test_scripts/Bath_Map_1/tdse_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from wave_train.hamilton.bath_map_1 import Bath_Map_1
from wave_train.dynamics.tdse import TDSE
from wave_train.io.load import Load
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
import numpy as np
import matplotlib.pyplot as plt

def bath_map_1_tdse(batch_mode):
# Detect name of this script file (without extension)
base_name = basename(__file__)
my_file = splitext(base_name)[0]

# logging instance: will be initialized with
# class for logging to both console and logfile
logger = None
if not batch_mode:
logger = TeeLogger(log_file=my_file + ".log")

# Set up the excitonic Hamiltonian for a chain
hamilton = Bath_Map_1(
n_site=50, # number of sites
eta = 0.5, # coupling between TLS and first bath site
s = 1, # type of spectral density function: s<1 sub-ohmic, s=1 ohmic, s>1 super-ohmic
omega_c = 10, # cut-off frequency of spectral density function
omega_0 = 1 # eigenfrequency of the TLS
)

# Set up TT representation of the Hamiltonian
hamilton.get_TT(
n_basis=2, # size of electronic basis set
qtt=False # using quantized TT format
)

# Set up TDSE solver
dynamics = TDSE(
hamilton=hamilton, # choice of Hamiltonian, see above
num_steps=10, # number of main time steps
step_size=0.1, # size of main time steps
sub_steps=1, # number of sub steps
solver='vp', # can be 'se' (symmetrized Euler) or 'sm' (Strang-Marchuk splitting) or ...
normalize=0, # whether|how to normalize the solution, can be 0|2
max_rank=5, # max rank of solution
repeats=15, # number of sweeps (implicit ODE solvers only!)
threshold=1e-8, # threshold in ALS decomposition
save_file=my_file+'.pic', # if not None, generated data will be saved to this file
load_file=None, # if not None, reference data will be loaded from this file
compare=None # How to do the comparison with reference data
)

# Set up initial state
dynamics.fundamental(list(np.eye(hamilton.n_site)[0,:])) # fundamental excitation near center of chain
# dynamics.gaussian()
# dynamics.sec_hyp(w_0=0.2)

# Batch mode
if batch_mode:
dynamics.solve() # Solve TDSE *without* visualization

# Interactive mode: Setup animated visualization
else:
from wave_train.graphics.factory import VisualTDSE
graphics = VisualTDSE(
dynamics=dynamics, # choice of dynamics (EoM), see above
plot_type='Populations', # select your favorite plot type
plot_expect=True, # toggle plotting of expectation values
figure_pos=(100, 50), # specifying position (x,y) of upper left of figure [in pixels]
figure_size=(1050, 450), # specifying size (w,h) of figure [in pixels]
image_file=my_file+'.png', # if not None, image (last frame) will be written to this file
movie_file=my_file+'.mp4', # if not None, animation will be written to this file
snapshots=False, # save each snapshot
frame_rate=1, # frames per second in mp4 animation file
plot_style={}, # additional plot style information
).create()
graphics.solve() # Solve TDSE *with* visualization


if __name__ == '__main__':
bath_map_1_tdse(batch_mode=False)


dynamics = Load(
file_name='tdse_1',
file_type = 'pic'
)
#print(dynamics.qu_numbr)
plt.figure()
for i in range(1,100,10):
plt.plot(dynamics.qu_numbr[:,i])
plt.show()

#print(dynamics.qu_sig_1)


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.qcmd import QCMD
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_qcmd(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=15, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # homogeneous chain/ring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.qcmd import QCMD
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -17,7 +17,7 @@ def coupled_qcmd(batch_mode):
# Define properties of chain/ring system

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=15, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # Homogeneous chain/ring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.qcmd import QCMD
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_qcmd(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=41, # number of sites
periodic=True, # periodic boundary conditions
homogen=True, # Homogeneous chain/ring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.qcmd import QCMD
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_qcmd(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=41, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # Homogeneous chain/ring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.tdse import TDSE
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_tdse(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=15, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # homogeneous chain/ring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.tdse import TDSE
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_qe_1(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=3, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # homogeneous chain/ring
Expand All @@ -39,7 +39,7 @@ def coupled_qe_1(batch_mode):

# Set up TDSE solver
dynamics = TDSE(
hamilton=hamilton, # choice of Hamiltonian, see above
hamilton=hamilton, # choice of Hamiltonian, see above
num_steps=50, # number of main time steps
step_size=20, # size of main time steps
sub_steps=None, # dummy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.tdse import TDSE
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_qe_2(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=3, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # homogeneous chain/ring
Expand All @@ -39,7 +39,7 @@ def coupled_qe_2(batch_mode):

# Set up TDSE solver
dynamics = TDSE(
hamilton=hamilton, # choice of Hamiltonian, see above
hamilton=hamilton, # choice of Hamiltonian, see above
num_steps=50, # number of main time steps
step_size=20, # size of main time steps
sub_steps=20, # number of sub steps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.qcmd import QCMD
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_qe_3(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled exciton-phonon Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=3, # number of sites
periodic=False, # periodic boundary conditions
homogen=True, # homogeneous chain/ring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wave_train.hamilton.coupled import Coupled
from wave_train.hamilton.exc_pho_coupling import Exc_Pho_Coupling
from wave_train.dynamics.tise import TISE
from wave_train.io.logging import TeeLogger
from os.path import basename, splitext
Expand All @@ -15,7 +15,7 @@ def coupled_tise(batch_mode):
logger = TeeLogger(log_file=my_file + ".log")

# Set up the coupled excitonic-phononic Hamiltonian for a chain
hamilton = Coupled(
hamilton = Exc_Pho_Coupling(
n_site=5, # number of sites
periodic=True, # periodic boundary conditions
homogen=True, # homogeneous chain/ring
Expand Down
8 changes: 4 additions & 4 deletions wave_train/dynamics/qu_cl_mech.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, hamilton):
# Quantum subsystem
self.norm = np.zeros(self.num_steps + 1) # norm of state vector
self.auto = np.zeros(self.num_steps + 1, dtype=complex) # autocorrelation
self.ex_numbr = np.zeros((self.num_steps + 1, self.hamilton.n_site)) # quantum number for excitons
self.q1_numbr = np.zeros((self.num_steps + 1, self.hamilton.n_site)) # quantum number for 1st sub-system

# Classical subsystem
self.position = np.zeros((self.num_steps + 1, self.hamilton.n_site)) # position
Expand Down Expand Up @@ -91,16 +91,16 @@ def observe(self, i, iterations=0):
for j in range(self.hamilton.n_site):
self.position[i, j] = self.pos[j]
self.momentum[i, j] = self.mom[j]
self.ex_numbr[i, j] = np.abs(self.psi[j]) ** 2
self.q1_numbr[i, j] = np.abs(self.psi[j]) ** 2

print(str("%4d" % j) + ' | ' + str("%10f" % self.ex_numbr[i, j]) + ' | ' + str("%10f" % self.position[i, j]) + ' | ' + str(
print(str("%4d" % j) + ' | ' + str("%10f" % self.q1_numbr[i, j]) + ' | ' + str("%10f" % self.position[i, j]) + ' | ' + str(
"%10f" % self.momentum[i, j]) )


# Footer of table with site-specific information
print(43 * '-')
print(' sum' +
' | ' + str("%10f" % np.sum(self.ex_numbr[i, :])) +
' | ' + str("%10f" % np.sum(self.q1_numbr[i, :])) +
' | ' + str("%10f" % np.sum(self.position[i, :])) +
' | ' + str("%10f" % np.sum(self.momentum[i, :])) )
print (' ')
Expand Down
Loading

0 comments on commit 15ad695

Please sign in to comment.