In [1]:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
import matplotlib.pyplot as plt
import os
%matplotlib inline



In [2]:
csvFolder = '/home/alessio/k-nokick/csv'

file1 = 'Report_b-pulseAlongX_0.22_0000_populations.csv'
file2 = 'Report_b-pulseAlongX_0.22_0000_regions.csv'
file3 = 'Report_m-only_IR_longer_with_nac_2_1_0000_populations.csv'
file4 = 'Report_m-only_IR_longer_with_nac_2_1_0000_regions.csv'
file5 = 'Report_z-from_S1_without_pulse_0000_populations.csv'
file6 = 'Report_z-from_S1_without_pulse_0000_regions.csv'
file7 = 'Report_m-only_IR_longer_with_nac_2_1_phase_pi_0000_populations.csv'
file8 = 'Report_m-only_IR_longer_with_nac_2_1_phase_pi_0000_regions.csv'
file9 = 'Report_m-only_IR_longer_with_nac_2_1_inverted_phase_0000_populations.csv'
file10 = 'Report_m-only_IR_longer_with_nac_2_1_inverted_phase_0000_regions.csv'

In [3]:
df1 = pd.read_csv(os.path.join(csvFolder,file1))
df2 = pd.read_csv(os.path.join(csvFolder,file2))
df3 = pd.read_csv(os.path.join(csvFolder,file3))
df4 = pd.read_csv(os.path.join(csvFolder,file4))
df5 = pd.read_csv(os.path.join(csvFolder,file5))
df6 = pd.read_csv(os.path.join(csvFolder,file6))
df7 = pd.read_csv(os.path.join(csvFolder,file7))
df8 = pd.read_csv(os.path.join(csvFolder,file8))
df9 = pd.read_csv(os.path.join(csvFolder,file9))
df10 = pd.read_csv(os.path.join(csvFolder,file10))

In [4]:
df8


Out[4]:
Unnamed: 0 FC reactants products fs
0 0 1.000000 1.133342e-17 1.405162e-35 0.000000
1 1 0.999989 2.600343e-11 4.242803e-27 1.250000
2 2 0.999957 4.555106e-10 2.153700e-21 2.500000
3 3 0.999903 1.306577e-09 6.227287e-17 3.750000
4 4 0.999826 1.484696e-09 3.146551e-14 4.999999
5 5 0.999667 1.173373e-09 5.103834e-13 6.249999
6 6 0.998464 1.680231e-09 8.774073e-12 7.499999
7 7 0.979883 4.076152e-09 5.643404e-11 8.749999
8 8 0.858704 1.278592e-08 3.023847e-10 9.999999
9 9 0.732966 4.169383e-08 8.144204e-10 11.249999
10 10 0.764446 5.734282e-08 1.697485e-09 12.499999
11 11 0.755275 9.622842e-08 3.743439e-09 13.749999
12 12 0.755360 2.027788e-07 7.401155e-09 14.999998
13 13 0.755376 4.128341e-07 1.531416e-08 16.249998
14 14 0.755286 7.823663e-07 5.440795e-08 17.499998
15 15 0.755217 1.382141e-06 2.838875e-07 18.749998
16 16 0.755188 2.346552e-06 6.210466e-07 19.999998
17 17 0.755207 3.981266e-06 2.047287e-06 21.249998
18 18 0.755259 6.458625e-06 6.081295e-06 22.499998
19 19 0.755341 1.064815e-05 1.347407e-05 23.749998
20 20 0.755451 1.694872e-05 2.815377e-05 24.999997
21 21 0.755581 2.654071e-05 5.443656e-05 26.249997
22 22 0.755717 4.013650e-05 9.586311e-05 27.499997
23 23 0.755857 7.136335e-05 1.547228e-04 28.749997
24 24 0.755985 2.083763e-04 2.340268e-04 29.999997
25 25 0.756098 5.039989e-04 3.688049e-04 31.249997
26 26 0.756187 1.059240e-03 6.818474e-04 32.499997
27 27 0.756252 2.048342e-03 1.275721e-03 33.749996
28 28 0.756292 3.218768e-03 1.893254e-03 34.999996
29 29 0.756318 4.241066e-03 2.330339e-03 36.249996
... ... ... ... ... ...
131 131 0.758008 7.262194e-02 4.414002e-02 163.749983
132 132 0.757875 7.303429e-02 4.481249e-02 164.999983
133 133 0.757750 7.391218e-02 4.492200e-02 166.249983
134 134 0.757639 7.491235e-02 4.461963e-02 167.499982
135 135 0.757544 7.569929e-02 4.441133e-02 168.749982
136 136 0.757480 7.619934e-02 4.428990e-02 169.999982
137 137 0.757462 7.651451e-02 4.442457e-02 171.249982
138 138 0.757496 7.678040e-02 4.484046e-02 172.499982
139 139 0.757575 7.700461e-02 4.515205e-02 173.749982
140 140 0.757683 7.735151e-02 4.517610e-02 174.999982
141 141 0.757797 7.787842e-02 4.484714e-02 176.249981
142 142 0.757912 7.848208e-02 4.431533e-02 177.499981
143 143 0.758016 7.904796e-02 4.379204e-02 178.749981
144 144 0.758122 7.949141e-02 4.312588e-02 179.999981
145 145 0.758232 7.986377e-02 4.245172e-02 181.249981
146 146 0.758349 8.015772e-02 4.225691e-02 182.499981
147 147 0.758467 8.036169e-02 4.248592e-02 183.749981
148 148 0.758551 8.075006e-02 4.270842e-02 184.999981
149 149 0.758604 8.118014e-02 4.251235e-02 186.249980
150 150 0.758647 8.152177e-02 4.233252e-02 187.499980
151 151 0.758680 8.180090e-02 4.221193e-02 188.749980
152 152 0.758700 8.198624e-02 4.228255e-02 189.999980
153 153 0.758727 8.218418e-02 4.229951e-02 191.249980
154 154 0.758745 8.240722e-02 4.224597e-02 192.499980
155 155 0.758763 8.265067e-02 4.203009e-02 193.749980
156 156 0.758749 8.318625e-02 4.167763e-02 194.999980
157 157 0.758707 8.375082e-02 4.161957e-02 196.249979
158 158 0.758650 8.404058e-02 4.186883e-02 197.499979
159 159 0.758600 8.408603e-02 4.212376e-02 198.749979
160 160 0.758572 8.386747e-02 4.222701e-02 199.999479

161 rows × 5 columns


In [12]:
df5.iloc[[300,-1]]


Out[12]:
Unnamed: 0 count steps fs Norm Deviation Kinetic Potential Total Total deviation Xpulse ... Zpulse 0 1 2 3 4 5 6 7 8
300 300 300 60000 30.030054 0.009390 0.281326 5.398734 5.680060 0.108587 0.0 ... 0.0 30.0301 0.000014 0.976988 0.003981 0.000151 0.000143 0.000028 0.000002 1.370550e-06
2000 2000 2000 399999 200.199861 0.076487 0.558801 4.377786 4.936587 0.852059 0.0 ... 0.0 200.1999 0.100718 0.736761 0.014818 0.000440 0.000103 0.000031 0.000005 6.156560e-07

2 rows × 21 columns


In [13]:
a = df5.iloc[[300,-1]]['Total']
a


Out[13]:
300     5.680060
2000    4.936587
Name: Total, dtype: float64

In [14]:
def calcola(df,end_of_pulse_step,end_of_dyns_step,label):
    
    time = df.iloc[end_of_pulse_step]['fs']
    time2 = df.iloc[end_of_dyns_step]['fs']
    
    # population in S_0 labeled 1 in the graph
    a = df.iloc[[end_of_pulse_step,end_of_dyns_step]]['1']
    
    # this is the gain in population of S_0
    da = a.iloc[1] - a.iloc[0]
    
    # this is the population of S_1
    b = df.iloc[end_of_pulse_step]['2']
    
    # this is the ratio... how much S_1 goes back to S_0
    c = da/b
    
    total_initial = df.iloc[0]['Total']
    total_final = df.iloc[end_of_dyns_step]['Total']
    total = total_final - total_initial
    
    string = '{}\ntime of end pulse -> {:8.3f} fs\ntime of end dyn -> {:8.3f} fs\ngain in population S0 at the end_step: {:8.5f}\nS1 population after pulse: {:8.5f}\nRatio: {:8.5f}\nTotal = {:6.3f} Hartree\n\n'
        
    print(string.format(label,time,time2,da,b,c,total))
    return c
    
final_frame = 1400
    
aa = calcola(df1,300,final_frame,'UV')
bb = calcola(df3,300,final_frame,'IR')
cc = calcola(df7,300,final_frame,'IR_pi')
dd = calcola(df9,300,final_frame,'IR_INV')
#dd = calcola(df5,0,final_frame,'FC')

print (bb/aa)
print (aa/bb)
#print (bb/cc)


UV
time of end pulse ->   15.015 fs
time of end dyn ->   70.070 fs
gain in population S0 at the end_step:  0.00906
S1 population after pulse:  0.52335
Ratio:  0.01730
Total =  3.168 Hartree


IR
time of end pulse ->   15.015 fs
time of end dyn ->   70.070 fs
gain in population S0 at the end_step:  0.00303
S1 population after pulse:  0.07488
Ratio:  0.04045
Total =  2.532 Hartree


IR_pi
time of end pulse ->   15.015 fs
time of end dyn ->   70.070 fs
gain in population S0 at the end_step:  0.00307
S1 population after pulse:  0.07674
Ratio:  0.03998
Total =  2.529 Hartree


IR_INV
time of end pulse ->   15.015 fs
time of end dyn ->   70.070 fs
gain in population S0 at the end_step:  0.00260
S1 population after pulse:  0.09137
Ratio:  0.02842
Total =  2.492 Hartree


2.33800933863
0.427714288168

In [15]:
normalize = True

if normalize:
    FC_norm = df6['products'] + df6['reactants']
    IR_norm = df4['products'] + df4['reactants']
    UV_norm = df2['products'] + df2['reactants']
    IR2norm = df8['products'] + df8['reactants']
    IR3norm = df10['products'] + df10['reactants']
else:
    FC_norm,IR_norm,UV_norm = 1.0,1.0,1.0
    
FC_ratio = np.nan_to_num(df6['products']/df6['reactants'])*FC_norm
FC_fs = df6['fs']
IR_ratio = (df4['products']/df4['reactants'])*IR_norm
IR_fs = df4['fs']
IR2ratio = (df8['products']/df8['reactants'])*IR2norm
IR2fs = df8['fs']
IR3ratio = (df10['products']/df10['reactants'])*IR3norm
IR3fs = df10['fs']
UV_ratio = (df2['products']/df2['reactants'])*UV_norm
UV_fs = df2['fs']



IR_ratio.shape, IR2ratio.shape


Out[15]:
((161,), (161,))

In [16]:
import matplotlib
matplotlib.rcParams.update({'font.size': 22})

fig , [ax0,ax1,ax2] = plt.subplots(3, 1,sharex = True,figsize=(20,30))
fig.subplots_adjust(hspace=0)

ax0.plot(FC_fs,np.cumsum(FC_ratio),label='int FC')
ax0.plot(IR_fs,np.cumsum(IR_ratio),label='int IR')
ax0.plot(UV_fs,np.cumsum(UV_ratio),label='int UV')
ax0.plot(IR2fs,np.cumsum(IR2ratio),label='int IR2')
ax0.plot(IR3fs,np.cumsum(IR3ratio),label='int IR3')
ax0.set_title('Products/Reactants integral')
ax0.set_ylabel('sum of ratios')
ax0.legend()

ax1.plot(FC_fs,FC_ratio,label='FC')
ax1.plot(IR_fs,IR_ratio,label='IR')
ax1.plot(UV_fs,UV_ratio,label='UV')
ax1.plot(IR2fs,IR2ratio,label='IR2')
ax1.plot(IR3fs,IR3ratio,label='IR3')
ax1.set_title('Products/Reactants ratio')
ax1.set_ylabel('ratio')
ax1.legend()

ax2.plot(FC_fs,np.gradient(FC_ratio),label='derivative FC')
ax2.plot(IR_fs,np.gradient(IR_ratio),label='derivative IR')
ax2.plot(UV_fs,np.gradient(UV_ratio),label='derivative UV')
ax2.plot(IR2fs,np.gradient(IR2ratio),label='derivative IR2')
ax2.plot(IR3fs,np.gradient(IR3ratio),label='derivative IR3')
ax2.set_xlabel('fs')
ax2.set_title('Products/Reactants derivative')
ax2.set_ylabel('Derivative of ratio with time')
ax2.legend()


Out[16]:
<matplotlib.legend.Legend at 0x7f3aa39f6438>

In [9]:
import matplotlib
matplotlib.rcParams.update({'font.size': 22})

fig , ax1 = plt.subplots(1, 1,sharex = True,figsize=(20,10))
fig.subplots_adjust(hspace=0)

ax1.plot(FC_fs,FC_ratio,label='FC')
ax1.plot(IR_fs,IR_ratio,label='IR')
ax1.plot(UV_fs,UV_ratio,label='UV')
ax1.plot(IR2fs,IR2ratio,label='IR2')
ax1.plot(IR3fs,IR3ratio,label='IR3')
ax1.set_title('Products/Reactants ratio')
ax1.set_ylabel('ratio')
ax1.legend()
ax1.set_xlabel('fs')


Out[9]:
Text(0.5,0,'fs')

In [10]:
df4.iloc[-1]['products']/df4.iloc[-1]['reactants']


Out[10]:
0.51352774361586107

In [74]:
df2.iloc[-1]['products']/df2.iloc[-1]['reactants']


Out[74]:
0.56782917687196044