In [1]:
import quantumpropagator as qp
import matplotlib.pyplot as plt
from matplotlib import cm
import matplotlib
from ipywidgets import interact,fixed #, interactive, fixed, interact_manual
import ipywidgets as widgets
import os
import glob
import pandas as pd
%matplotlib notebook
#%matplotlib ipympl
plt.rcParams.update({'font.size': 10})
In [2]:
#%matplotlib ipympl
import glob
runs = ['UVx','UVz']
for run in runs:
folder = '/home/alessio/w-August-Run/OUTPUTS/newbonds/{}'.format(run)
files_ob = sorted(glob.glob('{}/*1.csv'.format(folder)))
files_nb = sorted(glob.glob('{}/*2.csv'.format(folder)))
list_dfs_old = []
list_dfs_new = []
for i in range(len(files_ob)): # all wavefunctions
name_old = files_ob[i]
name_new = files_nb[i]
data_old = pd.read_csv(name_old, names=['fs','old_bond_popu','old_bond_cohe','old_bond_core_popu','old_bond_core_cohe','old_bond_inactive_popu','old_bond_inactive_cohe','old_bond_active_popu','old_bond_active_cohe'])
data_new = pd.read_csv(name_new, names=['fs','new_bond_popu','new_bond_cohe','new_bond_core_popu','new_bond_core_cohe','new_bond_inactive_popu','new_bond_inactive_cohe','new_bond_active_popu','new_bond_active_cohe'])
list_dfs_old.append(data_old)
list_dfs_new.append(data_new)
frame_old = pd.concat(list_dfs_old, axis=0, ignore_index=True)
frame_new = pd.concat(list_dfs_new, axis=0, ignore_index=True)
frame_new.drop('fs', axis=1, inplace=True)
all_final = pd.concat([frame_old,frame_new],axis=1)
all_final.to_csv('/home/alessio/w-August-Run/OUTPUTS/newbonds/{}_inbetweenbonds_new_way_2020.txt'.format(run))
#files_ob,files_nb
In [3]:
for run in runs:
file = '/home/alessio/w-August-Run/OUTPUTS/newbonds/{}_inbetweenbonds_new_way_2020.txt'.format(run)
fig, [[ax0,ax1],[ax2,ax3],[ax4,ax5],[ax6,ax7]] = plt.subplots(4,2,figsize=(10,10))
all_final = pd.read_csv(file)
ax0.plot(all_final['fs'],all_final['old_bond_popu'])
ax0.plot(all_final['fs'],all_final['new_bond_popu'])
ax0.set_title('Population term total')
ax1.plot(all_final['fs'],all_final['old_bond_cohe'])
ax1.plot(all_final['fs'],all_final['new_bond_cohe'])
ax1.set_title('Coherence term total')
ax2.plot(all_final['fs'],all_final['old_bond_core_popu'])
ax2.plot(all_final['fs'],all_final['new_bond_core_popu'])
ax2.set_title('Population term - core')
ax3.plot(all_final['fs'],all_final['old_bond_core_cohe'])
ax3.plot(all_final['fs'],all_final['new_bond_core_cohe'])
ax3.set_title('Coherence term - core')
ax4.plot(all_final['fs'],all_final['old_bond_inactive_popu'])
ax4.plot(all_final['fs'],all_final['new_bond_inactive_popu'])
ax4.set_title('Population term - inactive')
ax5.plot(all_final['fs'],all_final['old_bond_inactive_cohe'])
ax5.plot(all_final['fs'],all_final['new_bond_inactive_cohe'])
ax5.set_title('Coherence term - inactive')
ax6.plot(all_final['fs'],all_final['old_bond_active_popu'])
ax6.plot(all_final['fs'],all_final['new_bond_active_popu'])
ax6.set_title('Population term - active')
ax6.set_xlabel('fs')
ax7.plot(all_final['fs'],all_final['old_bond_active_cohe'])
ax7.plot(all_final['fs'],all_final['new_bond_active_cohe'])
ax7.set_title('Coherence term - active')
ax7.set_xlabel('fs')
#fig.canvas.layout.height = '1200px'
fig.tight_layout()
In [62]:
labelz = ['UV(x)','UV(z)']
plt.rcParams.update({'font.size': 22})
for i, run in enumerate(runs):
file = '/home/alessio/w-August-Run/OUTPUTS/newbonds/{}_inbetweenbonds_new_way_2020.txt'.format(run)
lwt = 3
all_final = pd.read_csv(file)
fig, axes = plt.subplots(3,3,figsize=(10,10))
plt.subplots_adjust(hspace=0)
ax0 = plt.subplot2grid((3, 3), (0, 0), colspan = 3, rowspan=1)
ax0.set_xticks([])
ax1 = plt.subplot2grid((3, 3), (1, 0), colspan = 3, rowspan=2)
normalization = all_final['old_bond_popu'] + all_final['new_bond_popu']
y1=all_final['old_bond_popu']/normalization
y2=all_final['new_bond_popu']/normalization
ax1.plot(all_final['fs'],y1,color='r', lw=lwt)
ax1.plot(all_final['fs'],y2,color='b', lw=lwt)
# ax1.annotate(labelz[i],(175,0.538))
# ax1.annotate('Old\nbond', (25,0.53), color='r')
# ax1.annotate('New\nbond', (25,0.47), color='b')
yy1=all_final['old_bond_cohe']
yy2=all_final['new_bond_cohe']
ax0.plot(all_final['fs'],yy1,color='r', lw=lwt, ls = ':')
ax0.plot(all_final['fs'],yy2,color='b', lw=lwt, ls = ':')
# ax1.set_xlabel('Time (fs)')
# ax1.set_ylabel('Normalized electronic density')
# #fig.canvas.layout.height = '1200px'
fig.tight_layout()
output = '/STORE/alessio/things/OneDrive/Liege/u-3dPropagation_manuscript/Report/images/FIGURE4/inbetw_{}.png'.format(i)
fig.savefig(output)
In [26]:
# FT of the in_between_bonds curve.
from scipy import signal
def pythonfft(signal_time,signal,pad_length):
'''
fast fourier transform
signal_time :: np.array(double) <- the time array in femtoseconds
signal :: np.array(double) <- the signal in hartree
pad_length :: the length of the padding to increase resolution
returns :: frequencies in eV and the positive side of the signal fft
'''
signal_fft = np.fft.fft(np.pad(signal,(0,pad_length)))
time_au = qp.fromFsToAu(signal_time)
dt = time_au[1]- time_au[0]
frequancies_from_routine = np.fft.fftfreq(time_au.size + pad_length)
time_au_max = np.amax(time_au)
frequencies = qp.fromHartoEv(frequancies_from_routine*2*np.pi/dt)
indexes = np.where(frequancies_from_routine>=0)
return(frequencies[indexes],signal_fft[indexes])
dt = all_final['fs'][1]-all_final['fs'][0]
pad_l = 100
timefs = np.linspace(0,200,401 + pad_l + pad_l)
new = all_final['old_bond_cohe']
#new = all_final['new_bond_popu']
at_zero = new - new[0] + 0.3
at_zero_padded = np.pad(at_zero,pad_l)
window = signal.gaussian(timefs.shape[0], std=90)
tot_signal_windowed = at_zero_padded * window
ft, ft_eV = pythonfft(timefs,at_zero_padded,10000)
fig, [ax0,ax1] = plt.subplots(2,1,figsize=(10,10))
print(timefs.shape, at_zero_padded.shape)
ax0.plot(timefs, tot_signal_windowed)
ax0.plot(timefs, window)
ax1.plot(ft,np.abs(ft_eV))
#ax1.set_xlim(0,1)
fig.canvas.layout.height = '900px'
fig.tight_layout()
In [2]:
fol = '/home/alessio/Desktop/Dropbox/USA/bet/'
subfolders = sorted([dir for dir in os.listdir(fol) if os.path.isdir(os.path.join(fol,dir)) and dir != os.path.join(fol,'.ipynb_checkpoints')])
print(''.join(['{} -> {}\n'.format(a,b) for a,b in enumerate(subfolders)]))
In [3]:
i_want = [0]
selected = [ subfolders[i] for i in i_want ]
In [4]:
viridis = cm.get_cmap('hsv',12)
colors = viridis(np.linspace(0,1, len(i_want)+1))
def graph_between_bonds(folder_list):
fig, [ax0,ax1] = plt.subplots(2,1,figsize=(10,10))
for i, this_folder in enumerate(folder_list):
abs_path = os.path.join(fol,this_folder)
fir_file = os.path.join(abs_path, 'list_first.dat')
sec_file = os.path.join(abs_path, 'list_second.dat')
population_file = os.path.join(abs_path, 'outputPopul')
dataP = pd.read_csv(population_file, delim_whitespace=True, header=None)
fir = np.loadtxt(fir_file)
sec = np.loadtxt(sec_file)
norm = 0.317460*0.317460*0.317460
ax0.plot(fir[:,0],fir[:,1]*norm, color=colors[i], ls='-', label='{} single bond'.format(this_folder))
ax0.plot(sec[:,0],sec[:,1]*norm, color=colors[i], ls='--', label='{} double bond'.format(this_folder))
ax1.plot(dataP[0],dataP[2], color=colors[i], ls='-', label=r'{} $S_1$'.format(this_folder))
ax1.set_ylim([0,1.01])
ax0.legend()
ax1.legend()
ax0.set_title(this_folder)
ax0.set_xlabel('fs')
ax0.set_ylabel('Fraction of 50 electrons')
fig.tight_layout()
graph_between_bonds(selected)
In [2]:
file_geom = '/home/alessio/densities/prova_bonds_cylinder/geoms.p'
geoms = qp.pickleLoad(file_geom)
In [11]:
%%bash
/home/alessio/prova_bonds_cylinder/graphs/sync.sh
In [12]:
folddat = '/home/alessio/prova_bonds_cylinder/graphs'
files_dat = glob.glob(folddat + '/old/*.dat')
files_dat = glob.glob(folddat + '/0.6/*.dat')
#files_dat = glob.glob(folddat + '/new_withr_c-0.6-r_s-0.6-cs-0.0/*.dat')
matplotlib.rcParams.update({'font.size': 12})
data = [ np.loadtxt(i) for i in files_dat ]
fig, ax0 = plt.subplots(1,1,figsize = (10,8))
colors = ['b','r','g','c']
labels = ['single','double','C9 sphere','C8 sphere']
for i, this_data in enumerate(data):
ax0.plot(this_data[:,0],this_data[:,1], label='UV {}'.format(labels[i]), color=colors[i])
ax0.set_xlabel("fs")
ax0.set_ylabel('Fraction of 50 electrons')
ax0.legend()
fig.tight_layout()
In [21]:
filename = '/home/alessio/prova_bonds_cylinder/second_first.p'
#filename = '/home/alessio/prova_bonds_cylinder/CANCELLAMI/r-0.6-cyc-0.6/r-0.6-cyc-0.6-lists.p'
diction = qp.pickleLoad(filename)
selection = diction['list_1']
new_index = 32590
geom = flat_geoms[new_index]
new_first = selection[new_index]
selected_grids = list_of_points_in_3d[new_first]
qp.saveTraj(np.array([geom]),['C','C','C','H','H','H','H','C','C','C','C','H','H','H','H'],'/home/alessio/prova_bonds_cylinder/new_norb', True)
n_gridpoints, _ = selected_grids.shape
atomT = ['H']*n_gridpoints
qp.saveTraj(np.array([selected_grids]), atomT, '/home/alessio/prova_bonds_cylinder/new_first',True)
In [2]:
%%bash
/home/alessio/densities/From_pinot/sync.sh
In [3]:
#folddat = '/home/alessio/densities/From_pinot/calculationZ/r_c-1.6-non-overlapping/ALL'
folddat = '/home/alessio/densities/From_pinot/calculationZ/r_c_1.4-non-overlapping/ALL'
# folddat = '/home/alessio/densities/From_pinot/calculationZ/r_c-1.2-non-overlapping/ALL'
# folddat = '/home/alessio/densities/From_pinot/calculationZ/r_c-1.0-non-overlapping/ALL'
subfolders = sorted([dir for dir in os.listdir(folddat) if os.path.isdir(os.path.join(folddat,dir))])
print(''.join(['{} -> {}\n'.format(a,b) for a,b in enumerate(subfolders)]))
In [17]:
select_these = [0]
lts = ['-',':','--']
fol_lab = ['UV', 'IR INV','IR LONG', 'IR NOR', 'P1', 'P2', 'P3', 'P4', 'P5', 'FC-excite', 'To excite', 'shit', 'UV-excite', 'FC']
#fol_lab = ['UV','IR LONG', 'IR INV']
fig, ax0 = plt.subplots(1,1,figsize = (18,8))
for ii,i in enumerate(select_these):
subdir = os.path.join(folddat,subfolders[i])
files_dat = sorted([ os.path.join(subdir,x) for x in os.listdir(subdir) if x[-4:] == '.dat' and x[0] == 'l'])
#print(files_dat)
data = [ np.loadtxt(i) for i in files_dat ]
colors = ['r','b']
labels = ['red','blue']
for j, this_data in enumerate(data):
ax0.plot(this_data[:,0],this_data[:,1], label='{} {}'.format(fol_lab[i], labels[j]), color=colors[j],linestyle=lts[ii])
#ax0.set_xlim([0,40])
ax0.set_xlabel("fs")
ax0.set_ylabel('Fraction of 4 electrons')
ax0.legend()
fig.tight_layout()
In [5]:
select_these = [0,3,13]
lts = ['-',':','--']
fol_lab = ['UV', 'IR INV','IR LONG', 'IR NOR', 'P1', 'P2', 'P3', 'P4', 'P5', 'FC-excite', 'To excite', 'shit', 'UV-excite', 'FC']
fig, ax0 = plt.subplots(1,1,figsize = (15,8))
for ii,i in enumerate(select_these):
subdir = os.path.join(folddat,subfolders[i])
files_dat = [ os.path.join(subdir,x) for x in os.listdir(subdir) if x[-4:] == '.dat']
data = [ np.loadtxt(i) for i in files_dat ]
colors = ['b','r','k','dimgray']
labels = ['Blue','red','C9 sphere','C8 sphere']
for j, this_data in enumerate(data):
ax0.plot(this_data[:,0],this_data[:,1], label='{} {}'.format(fol_lab[i], labels[j]), color=colors[j],linestyle=lts[ii])
#ax0.set_xlim([0,60])
ax0.set_xlabel("fs")
ax0.set_ylabel('Fraction of 4 electrons')
ax0.legend()
fig.tight_layout()
In [18]:
In [44]:
typez = 'ALL'
folddats = ['/home/alessio/densities/From_pinot/calculationZ/r_c-1.6-non-overlapping/{}/b-UV-0.22_0000'.format(typez),
'/home/alessio/densities/From_pinot/calculationZ/r_c_1.4-non-overlapping/{}/b-UV-0.22_0000'.format(typez),
'/home/alessio/densities/From_pinot/calculationZ/r_c-1.2-non-overlapping/{}/b-UV-0.22_0000'.format(typez),
'/home/alessio/densities/From_pinot/calculationZ/r_c-1.0-non-overlapping/{}/b-UV-0.22_0000'.format(typez)]
lts = ['-',':','--','-.']
fol_lab = ['1.6','1.4','1.2','1.0']
fig, ax0 = plt.subplots(1,1,figsize = (15,8))
for ii,i in enumerate(folddats):
files_dat = [ os.path.join(i,x) for x in os.listdir(i) if x[-4:] == '.dat']
data = [ np.loadtxt(i) for i in files_dat ]
colors = ['b','r']
labels = ['Blue','red']
for j, this_data in enumerate(data):
ax0.plot(this_data[:,0],this_data[:,1], label='{} {}'.format(fol_lab[ii], labels[j]), color=colors[j],linestyle=lts[ii])
ax0.set_xlabel("fs")
ax0.set_ylabel('Fraction of 50 electrons')
ax0.legend()
fig.tight_layout()
In [45]:
typez = 'ACTIVE'
folddats = ['/home/alessio/densities/From_pinot/calculationZ/r_c-1.6-non-overlapping/{}/b-UV-0.22_0000'.format(typez),
'/home/alessio/densities/From_pinot/calculationZ/r_c_1.4-non-overlapping/{}/b-UV-0.22_0000'.format(typez),
'/home/alessio/densities/From_pinot/calculationZ/r_c-1.2-non-overlapping/{}/b-UV-0.22_0000'.format(typez),
'/home/alessio/densities/From_pinot/calculationZ/r_c-1.0-non-overlapping/{}/b-UV-0.22_0000'.format(typez)]
lts = ['-',':','--','-.']
fol_lab = ['1.6','1.4','1.2','1.0']
fig, ax0 = plt.subplots(1,1,figsize = (15,8))
for ii,i in enumerate(folddats):
files_dat = [ os.path.join(i,x) for x in os.listdir(i) if x[-4:] == '.dat']
data = [ np.loadtxt(i) for i in files_dat ]
colors = ['b','r']
labels = ['Blue','red']
for j, this_data in enumerate(data):
ax0.plot(this_data[:,0],this_data[:,1], label='{} {}'.format(fol_lab[ii], labels[j]), color=colors[j],linestyle=lts[ii])
ax0.set_xlabel("fs")
ax0.set_ylabel('Fraction of 50 electrons')
ax0.legend()
fig.tight_layout()
In [5]:
files = glob.glob('/home/alessio/dox/Alessio-Francoise/Results_MD_October2019/UV/*overl*')
files
Out[5]:
In [12]:
files_uv = '/home/alessio/dox/Alessio-Francoise/Results_MD_October2019/UV/UV.txt'
bbb = pd.read_csv(files_uv, index_col=0)
list(bbb.columns)
Out[12]:
In [6]:
dfs = [ pd.read_csv(x, index_col=0) for x in files]
In [22]:
fig, ax0 = plt.subplots(1,1,figsize = (10,6))
ind = 1
x = dfs[ind]['Time']
norm = dfs[ind]['Old bond'] + dfs[ind]['New Bond']
norm = 1
for y_label in ['Old bond', 'New Bond']:
y = dfs[ind][y_label]
ax0.plot(x,y/norm, label=y_label)
ax1 = ax0.twinx()
ax1.set_ylim(0.41,0.46)
ax1.plot(bbb['fs'], bbb['S0'])
ax0.set_xlabel('fs')
ax0.legend()
fig.tight_layout()
In [ ]: