from chainTB import *
# lattice
tags = [b'a', b'b']
ri = [[0, 0], [1, 0]]
nx = 11
chain_tb = latticeTB(tags=tags, ri=ri, nor=2, ang=0.)
chain_tb.get_lattice(nx=nx, ny=1)
chain_tb.remove_sites([21])
# solve eigenvalue problem
eig_chain = eigChain(lat=chain_tb)
on = [.2j, -.2j]
eig_chain.set_onsite(on=on)
ta, tb = 2., 1.
eig_chain.set_hop_alt([2., 1.])
eig_chain.set_dim_defect(nx-1)
alpha = .95
eig_chain.set_disorder(alpha=alpha)
eig_chain.get_ham(compl_trans=True)
eig_chain.get_eig(eigenvec=True)
zero_mode = eig_chain.get_state_pola(b'a')
# plots
plot_chain = plotChain(sys=eig_chain)
fig_lat_hop = plot_chain.plt_chain_hop(ms=15, fs=20)
fig_spec = plot_chain.plt_spec(ms=20, pola_tag=b'a')
fig_zero_mode = plot_chain.plt_intensity1d(zero_mode, ms=20)
#propagation
prop_chain = propTB(lat=chain_tb, steps=1400, dz=0.1)
psi_init = np.ones(eig_chain.sites) / np.sqrt(eig_chain.sites)
prop_chain.get_prop(ham=eig_chain.ham, psi_init=psi_init, norm=True)
fig_prop = prop_chain.plt_prop1d()
plt.show()
# save figures
from collections import OrderedDict
save_chain = saveFigTB(sys=eig_chain, params=OrderedDict([('ta', ta), ('tb', tb), ('alpha', alpha)]), dir_name='chain', ext='png')
save_chain.save_fig(fig_lat_hop, 'lat_hop_dim')
save_chain.save_fig(fig_spec, 'spec_dim')
save_chain.save_fig(fig_zero_mode, 'zero_mode_dim')
save_chain.save_fig(fig_prop, 'prop_dim')