-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_example.py
More file actions
139 lines (110 loc) · 5.09 KB
/
Copy pathmain_example.py
File metadata and controls
139 lines (110 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
"""Example calculation of a single-exciton 1D Holstein chain system."""
import sys
import os
import numpy
from paces.config import devices
from paces.models import holstein
from paces.core.time_evolution import CoeffSaveParams, ExpmParams, TimeEvoParams
# This makes relative paths refer to the location of this script:
if os.path.dirname(sys.argv[0]) != '':
os.chdir(os.path.dirname(sys.argv[0]))
####################################################################################################
# General config settings
####################################################################################################
# configure device and memory settings; the defaults will select a single GPU for everything:
devices.configure()
###############################
# debugging verbosity (for printing to stdout):
debug_verb = 6
###############################
# directory in which the data will be saved:
# (this directory has to be created before running this code!)
dirname = "results/example"
# name of the parameter file to save to:
params_file = os.path.join(dirname, "paces_holstein_test_params.log")
####################################################################################################
# Model-specific Hilbert-space and Hamiltonian settings
####################################################################################################
# Hilbert space parameters:
nchain = 25 # number of sites on the Holstein chain
max_ho_dim = 128 # we use this max. phonon mode dimension for each site
###############################
# Hamiltonian parameters:
term_param_dict = {
"diag": dict(
eps_sys = -1.0, # on-site energy of an exciton (this is just a constant shift)
hbar_omega = 1.0, # energy of a single phonon
delta_eps = 0.0, # excitonic energy bias between neighboring sites on the chain
),
"hopping": dict(
J = 1.0, # excitonic hopping parameter
),
"vib_coupling": dict(
g = 4.0, # vibronic coupling parameter
),
}
###############################
# Initial state position:
initpos = nchain//2
# Proportion of maxstates to occupy with the initial basis set:
fillfac = 0.1
###############################
# list of observables to compute:
obs_list = ["n_pho", "n_exc", "total_energy"]
####################################################################################################
# General time-evolution settings
####################################################################################################
###############################
# general parameters for the time evolution:
te_params = TimeEvoParams(
maxstates = int(8e6), # nominal truncation number at each timestep
enlarge_steps = 1, # max. neighbor degree is enlarge_steps + 1
diagnostics = True, # whether to save extra diagnostic data to file
shuffle_seed = 0, # seed used for pseudo-randomized shuffling to avoid bias
)
###############################
# how often to save the coefficients:
coeff_save_obj = CoeffSaveParams(save_every=200, save_first=True, save_last=True)
###############################
# timeline parameters:
timeline_params = {
"t_array": numpy.arange(0.00, 5.05, 0.05), # timesteps which will be computed
"coeff_save_obj": coeff_save_obj,
}
###############################
# parameters to use for the matrix exponentiation, we leave them at their defaults:
expm_params = ExpmParams()
####################################################################################################
# End of parameter input, start of calculations
####################################################################################################
with devices.vector_dev:
##############################################################
# Generate the fundamental Hilbert space:
hamobj = holstein.Hamiltonian(
nchain = nchain,
max_ho_dims = [max_ho_dim,]*nchain,
use_terms = term_param_dict,
debug_verb = debug_verb,
)
##############################################################
# Initialize the general time_evolution object:
te = holstein.TimeEvolution(
hamobj,
holstein.Observables,
obs_list,
dirname,
te_params,
expm_params,
params_file,
)
##############################################################
# Create an initial basis set consisting of 0 phonons everywhere and a localized particle:
te.create_nonuniform_basis([1,]*nchain, minpos=initpos, maxpos=initpos+1)
# Enlarge the initial basis set:
te.grow_optimal_basis(fillfac=fillfac)
# Create the initial vector in this basis:
te.create_initial_vector(vector_coeffs=[1], vector_coo=[[initpos,] + nchain*[0,]],
auto_normalize=True)
##############################################################
# Calculate the actual timeline:
te.generate_timeline(**timeline_params)