|
| 1 | +from wave_train.hamilton.bath_map_1 import Bath_Map_1 |
| 2 | +from wave_train.dynamics.tdse import TDSE |
| 3 | +from wave_train.io.load import Load |
| 4 | +from wave_train.io.logging import TeeLogger |
| 5 | +from os.path import basename, splitext |
| 6 | +import numpy as np |
| 7 | +import matplotlib.pyplot as plt |
| 8 | + |
| 9 | +def bath_map_1_tdse(batch_mode): |
| 10 | + # Detect name of this script file (without extension) |
| 11 | + base_name = basename(__file__) |
| 12 | + my_file = splitext(base_name)[0] |
| 13 | + |
| 14 | + # logging instance: will be initialized with |
| 15 | + # class for logging to both console and logfile |
| 16 | + logger = None |
| 17 | + if not batch_mode: |
| 18 | + logger = TeeLogger(log_file=my_file + ".log") |
| 19 | + |
| 20 | + # Set up the excitonic Hamiltonian for a chain |
| 21 | + hamilton = Bath_Map_1( |
| 22 | + n_site=50, # number of sites |
| 23 | + eta = 0.5, # coupling between TLS and first bath site |
| 24 | + s = 1, # type of spectral density function: s<1 sub-ohmic, s=1 ohmic, s>1 super-ohmic |
| 25 | + omega_c = 10, # cut-off frequency of spectral density function |
| 26 | + omega_0 = 1 # eigenfrequency of the TLS |
| 27 | + ) |
| 28 | + |
| 29 | + # Set up TT representation of the Hamiltonian |
| 30 | + hamilton.get_TT( |
| 31 | + n_basis=2, # size of electronic basis set |
| 32 | + qtt=False # using quantized TT format |
| 33 | + ) |
| 34 | + |
| 35 | + # Set up TDSE solver |
| 36 | + dynamics = TDSE( |
| 37 | + hamilton=hamilton, # choice of Hamiltonian, see above |
| 38 | + num_steps=10, # number of main time steps |
| 39 | + step_size=0.1, # size of main time steps |
| 40 | + sub_steps=1, # number of sub steps |
| 41 | + solver='vp', # can be 'se' (symmetrized Euler) or 'sm' (Strang-Marchuk splitting) or ... |
| 42 | + normalize=0, # whether|how to normalize the solution, can be 0|2 |
| 43 | + max_rank=5, # max rank of solution |
| 44 | + repeats=15, # number of sweeps (implicit ODE solvers only!) |
| 45 | + threshold=1e-8, # threshold in ALS decomposition |
| 46 | + save_file=my_file+'.pic', # if not None, generated data will be saved to this file |
| 47 | + load_file=None, # if not None, reference data will be loaded from this file |
| 48 | + compare=None # How to do the comparison with reference data |
| 49 | + ) |
| 50 | + |
| 51 | + # Set up initial state |
| 52 | + dynamics.fundamental(list(np.eye(hamilton.n_site)[0,:])) # fundamental excitation near center of chain |
| 53 | + # dynamics.gaussian() |
| 54 | + # dynamics.sec_hyp(w_0=0.2) |
| 55 | + |
| 56 | + # Batch mode |
| 57 | + if batch_mode: |
| 58 | + dynamics.solve() # Solve TDSE *without* visualization |
| 59 | + |
| 60 | + # Interactive mode: Setup animated visualization |
| 61 | + else: |
| 62 | + from wave_train.graphics.factory import VisualTDSE |
| 63 | + graphics = VisualTDSE( |
| 64 | + dynamics=dynamics, # choice of dynamics (EoM), see above |
| 65 | + plot_type='Populations', # select your favorite plot type |
| 66 | + plot_expect=True, # toggle plotting of expectation values |
| 67 | + figure_pos=(100, 50), # specifying position (x,y) of upper left of figure [in pixels] |
| 68 | + figure_size=(1050, 450), # specifying size (w,h) of figure [in pixels] |
| 69 | + image_file=my_file+'.png', # if not None, image (last frame) will be written to this file |
| 70 | + movie_file=my_file+'.mp4', # if not None, animation will be written to this file |
| 71 | + snapshots=False, # save each snapshot |
| 72 | + frame_rate=1, # frames per second in mp4 animation file |
| 73 | + plot_style={}, # additional plot style information |
| 74 | + ).create() |
| 75 | + graphics.solve() # Solve TDSE *with* visualization |
| 76 | + |
| 77 | + |
| 78 | +if __name__ == '__main__': |
| 79 | + bath_map_1_tdse(batch_mode=False) |
| 80 | + |
| 81 | + |
| 82 | +dynamics = Load( |
| 83 | + file_name='tdse_1', |
| 84 | + file_type = 'pic' |
| 85 | +) |
| 86 | +#print(dynamics.qu_numbr) |
| 87 | +plt.figure() |
| 88 | +for i in range(1,100,10): |
| 89 | + plt.plot(dynamics.qu_numbr[:,i]) |
| 90 | +plt.show() |
| 91 | + |
| 92 | +#print(dynamics.qu_sig_1) |
| 93 | + |
| 94 | + |
0 commit comments