Skip to content

Commit f3b836b

Browse files
authored
Merge pull request #3 from vpramod86/main
Added codes
2 parents e048820 + 1880fb0 commit f3b836b

File tree

13 files changed

+569
-27
lines changed

13 files changed

+569
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#SBATCH --job-name=hc
3+
#SBATCH --ntasks=1
4+
#SBATCH --cpus-per-task=1
5+
#SBATCH -t 1200:00:00
6+
##SBATCH --partition=LocalQ
7+
#SBATCH --mem=20GB
8+
9+
cd $SLURM_SUBMIT_DIR
10+
11+
DPATH=data
12+
13+
14+
export START_TIME=`date +%s.%3N`
15+
export TIME_LIMIT=`squeue -h -o %L -j $SLURM_JOB_ID`
16+
17+
# Calculate Pia(t)
18+
mpirun -np 1 python3 src/pulse_transp_Pia.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,transp_all.npz}} --maxtime 120e3 --transitions all
19+
mpirun -np 1 python3 src/pulse_transp_Pia.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,transp_resonant.npz}} --maxtime 120e3 --transitions resonant
20+
mpirun -np 1 python3 src/pulse_transp_Pia.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,transp_nonresonant.npz}} --maxtime 120e3 --transitions nonresonant
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
#SBATCH --job-name=hc
3+
#SBATCH --ntasks=1
4+
#SBATCH --cpus-per-task=1
5+
#SBATCH -t 1200:00:00
6+
##SBATCH --partition=LocalQ
7+
#SBATCH --mem=20GB
8+
9+
cd $SLURM_SUBMIT_DIR
10+
11+
DPATH1=data
12+
DPATH2=plots
13+
14+
time='0 5000 10000 15000 20000 25000 30000 55000 60000'
15+
16+
#mpirun -np 1 python3 src/pwt_eh.py $DPATH1/td-z-RPA/pulse/hcdist_nonresonant.npz $DPATH2/Pwt_eh_nonresonant.png >& log_pwteh_nonres
17+
#mpirun -np 1 python3 src/pwt_eh.py $DPATH1/td-z-RPA/pulse/hcdist_resonant.npz $DPATH2/Pwt_eh_resonant.png >& log_pwteh_res
18+
#
19+
#mpirun -np 1 python3 src/pwt.py $DPATH1/td-z-RPA/pulse/transp_nonresonant.npz $DPATH2/Pwt_nonresonant.png >& log_pwt_nonres
20+
#mpirun -np 1 python3 src/pwt.py $DPATH1/td-z-RPA/pulse/transp_resonant.npz $DPATH2/Pwt_resonant.png >& log_pwt_res
21+
22+
#mpirun -np 1 python3 src/jdos.py $DPATH1/td-z-RPA/pulse/transp_nonresonant.npz $DPATH2/jdos.dat
23+
#mpirun -np 1 python3 src/jdos_eh.py $DPATH1/td-z-RPA/pulse/transp_nonresonant.npz $DPATH2/jdos_eh.dat
24+
25+
#for t in $time
26+
#do
27+
# mpirun -np 1 python3 src/pw.py $DPATH1/td-z-RPA/pulse/transp_nonresonant.npz $DPATH2/Pw_nonresonant_$t.dat --time $t
28+
# mpirun -np 1 python3 src/pw.py $DPATH1/td-z-RPA/pulse/transp_resonant.npz $DPATH2/Pw_resonant_$t.dat --time $t
29+
#done

MetalNP_MoSe2_Flake/np_tmd_pict_codes/energy_decomposition/run_pp.sh

+26-25
Original file line numberDiff line numberDiff line change
@@ -16,68 +16,69 @@ time='6e3 7e3 8e3 9e3 10e3 11e3'
1616
export START_TIME=`date +%s.%3N`
1717
export TIME_LIMIT=`squeue -h -o %L -j $SLURM_JOB_ID`
1818

19-
#mpirun -np 1 --oversubscribe python3 src/unocc.py $DPATH/{gs/gs.gpw,unocc/{unocc{.out,.gpw},eig.dat,ksd{.out,.ulm}}}
19+
#mpirun -np 1 python3 src/unocc.py $DPATH/{gs/gs.gpw,unocc/{unocc{.out,.gpw},eig.dat,ksd{.out,.ulm}}}
2020
#
21-
#mpirun -np 1 --oversubscribe python3 src/tdspec.py $DPATH/td-z-RPA/{dm.dat,abs.dat}
21+
#mpirun -np 1 python3 src/tdspec.py $DPATH/td-z-RPA/{dm.dat,abs.dat}
2222
#
23-
#mpirun -np 1 --oversubscribe python3 src/pulse.py $DPATH/td-z-RPA/pulse/pulse.pickle 4.14
23+
#mpirun -np 1 python3 src/pulse.py $DPATH/td-z-RPA/pulse/pulse.pickle 4.14
2424
#
25-
#mpirun -np 8 --oversubscribe python3 src/frho.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/{fdm.ulm,frho}}
25+
#mpirun -np 8 python3 src/frho.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/{fdm.ulm,frho}}
2626
#
27-
#mpirun -np 8 --oversubscribe python3 src/pulse_dm.py $DPATH/td-z-RPA/{dm.dat,pulse/{pulse.pickle,dm.dat}} --maxtime 30e3
27+
#mpirun -np 8 python3 src/pulse_dm.py $DPATH/td-z-RPA/{dm.dat,pulse/{pulse.pickle,dm.dat}} --maxtime 30e3
2828
#
29-
#mpirun -np 8 --oversubscribe python3 src/pulse_rho.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/{frho,pulse/{pulse.pickle,rho}}} --maxtime 30e3
29+
#mpirun -np 8 python3 src/pulse_rho.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/{frho,pulse/{pulse.pickle,rho}}} --maxtime 30e3
3030
#
31-
#mpirun -np 8 --oversubscribe python3 src/pulse_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,energy_all.npz}} --maxtime 30e3 --transitions all
32-
#mpirun -np 8 --oversubscribe python3 src/pulse_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,energy_resonant.npz}} --maxtime 30e3 --transitions resonant
33-
#mpirun -np 8 --oversubscribe python3 src/pulse_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,energy_nonresonant.npz}} --maxtime 30e3 --transitions nonresonant
31+
#mpirun -np 8 python3 src/pulse_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,energy_all.npz}} --maxtime 30e3 --transitions all
32+
#mpirun -np 8 python3 src/pulse_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,energy_resonant.npz}} --maxtime 30e3 --transitions resonant
33+
#mpirun -np 8 python3 src/pulse_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,energy_nonresonant.npz}} --maxtime 30e3 --transitions nonresonant
3434

3535
## Energy distributions as transition contribution maps
3636
for t in $time
3737
do
38-
mpirun -np 1 --oversubscribe python3 src/pulse_tcm.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,tcm_energy}} energy --time $t
38+
mpirun -np 1 python3 src/pulse_tcm.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,tcm_energy}} energy --time $t
3939
done
4040
#
4141
## Hot-carrier distributions
4242
for t in $time
4343
do
44-
mpirun -np 1 --oversubscribe python3 src/pulse_hcdist.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,hcdist_all_$t.npz}} --time $t --transitions all
45-
mpirun -np 1 --oversubscribe python3 src/pulse_hcdist.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,hcdist_resonant_$t.npz}} --time $t --transitions resonant
44+
mpirun -np 1 python3 src/pulse_hcdist.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,hcdist_all_$t.npz}} --time $t --transitions all
45+
mpirun -np 1 python3 src/pulse_hcdist.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho,hcdist_resonant_$t.npz}} --time $t --transitions resonant
4646
done
4747
#
4848
#### Spatial atomic weights
49-
#mpirun -np 16 --oversubscribe python3 src/atomweight.py $DPATH/unocc/{unocc.gpw,atomweight.npz} --eig_limits -6 6
49+
#mpirun -np 16 python3 src/atomweight.py $DPATH/unocc/{unocc.gpw,atomweight.npz} --eig_limits -6 6
5050
#
5151
#### Spatial hot-carrier density
5252

5353
for t in $time
5454
do
55-
mpirun -np 16 --oversubscribe python3 src/pulse_hcdns.py $DPATH/{unocc/{unocc.gpw,ksd.ulm,atomweight.npz},td-z-RPA/pulse/{pulse.pickle,rho,he1dns_engt1eV_$t.cube}} electrons --time $t --energy_limits 1 10
56-
mpirun -np 16 --oversubscribe python3 src/pulse_hcdns.py $DPATH/{unocc/{unocc.gpw,ksd.ulm,atomweight.npz},td-z-RPA/pulse/{pulse.pickle,rho,hh1dns_$t.cube}} holes --time $t --energy_limits -10 0
55+
mpirun -np 16 python3 src/pulse_hcdns.py $DPATH/{unocc/{unocc.gpw,ksd.ulm,atomweight.npz},td-z-RPA/pulse/{pulse.pickle,rho,he1dns_engt1eV_$t.cube}} electrons --time $t --energy_limits 1 10
56+
mpirun -np 16 python3 src/pulse_hcdns.py $DPATH/{unocc/{unocc.gpw,ksd.ulm,atomweight.npz},td-z-RPA/pulse/{pulse.pickle,rho,hh1dns_$t.cube}} holes --time $t --energy_limits -10 0
5757
done
5858

59+
5960
# Generate cube files
60-
#mpirun -np 1 --oversubscribe python3 src/generate_cubefiles.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_resonant/ --transitions resonant 'gs'
61-
#mpirun -np 1 --oversubscribe python3 src/generate_cubefiles.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_nonresonant/ --transitions nonresonant 'gs'
61+
#mpirun -np 1 python3 src/generate_cubefiles.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_resonant/ --transitions resonant 'gs'
62+
#mpirun -np 1 python3 src/generate_cubefiles.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_nonresonant/ --transitions nonresonant 'gs'
6263
##
6364
## Generate weights of occupied and unoccupied Kohn-Sham states
64-
#mpirun -np 1 --oversubscribe python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_resonant/ 'gs' --transitions resonant $DPATH/unocc/weights_resonant/{occ_np.dat,unocc_np.dat} --lx '-' --ly '-' --lz '31.7'
65-
#mpirun -np 1 --oversubscribe python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_resonant/ 'gs' --transitions resonant $DPATH/unocc/weights_resonant/{occ_full.dat,unocc_full.dat} --lx '-' --ly '-' --lz '-'
65+
#mpirun -np 1 python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_resonant/ 'gs' --transitions resonant $DPATH/unocc/weights_resonant/{occ_np.dat,unocc_np.dat} --lx '-' --ly '-' --lz '31.7'
66+
#mpirun -np 1 python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_resonant/ 'gs' --transitions resonant $DPATH/unocc/weights_resonant/{occ_full.dat,unocc_full.dat} --lx '-' --ly '-' --lz '-'
6667
#
67-
#mpirun -np 1 --oversubscribe python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_nonresonant/ 'gs' --transitions nonresonant $DPATH/unocc/weights_nonresonant/{occ_np.dat,unocc_np.dat} --lx '-' --ly '-' --lz '31.7'
68-
#mpirun -np 1 --oversubscribe python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_nonresonant/ 'gs' --transitions nonresonant $DPATH/unocc/weights_nonresonant/{occ_full.dat,unocc_full.dat} --lx '-' --ly '-' --lz '-'
68+
#mpirun -np 1 python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_nonresonant/ 'gs' --transitions nonresonant $DPATH/unocc/weights_nonresonant/{occ_np.dat,unocc_np.dat} --lx '-' --ly '-' --lz '31.7'
69+
#mpirun -np 1 python3 src/weights_wfs.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/pulse.pickle} $DPATH/unocc/cube_files_nonresonant/ 'gs' --transitions nonresonant $DPATH/unocc/weights_nonresonant/{occ_full.dat,unocc_full.dat} --lx '-' --ly '-' --lz '-'
6970
##
7071
#### Weighted transition probability
71-
#mpirun -np 1 --oversubscribe python3 src/weighted_transp.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho}} $DPATH/unocc/weights_resonant/{occ_full.dat,unocc_full.dat,occ_np.dat,unocc_np.dat} $DPATH/td-z-RPA/pulse/wtp_resonant.npz --maxtime 30e3 --transitions resonant
72+
#mpirun -np 1 python3 src/weighted_transp.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho}} $DPATH/unocc/weights_resonant/{occ_full.dat,unocc_full.dat,occ_np.dat,unocc_np.dat} $DPATH/td-z-RPA/pulse/wtp_resonant.npz --maxtime 30e3 --transitions resonant
7273
##
7374
### Weighted transition probability distribution of partial processes
74-
#mpirun -np 1 --oversubscribe python3 src/weighted_transp_dist.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho}} $DPATH/unocc/weights_resonant/{occ_full.dat,unocc_full.dat,occ_np.dat,unocc_np.dat} $DPATH/td-z-RPA/pulse/wtp_dist_resonant_25.npz --time 25e3 --transitions resonant
75+
#mpirun -np 1 python3 src/weighted_transp_dist.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho}} $DPATH/unocc/weights_resonant/{occ_full.dat,unocc_full.dat,occ_np.dat,unocc_np.dat} $DPATH/td-z-RPA/pulse/wtp_dist_resonant_25.npz --time 25e3 --transitions resonant
7576
##
7677
#### Weighted energy
77-
#mpirun -np 1 --oversubscribe python3 src/weighted_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho}} $DPATH/unocc/weights_nonresonant/{occ_full.dat,unocc_full.dat,occ_np.dat,unocc_np.dat} $DPATH/td-z-RPA/pulse/wtenergy_nonresonant.npz --maxtime 30e3 --transitions nonresonant
78+
#mpirun -np 1 python3 src/weighted_energy.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{pulse.pickle,rho}} $DPATH/unocc/weights_nonresonant/{occ_full.dat,unocc_full.dat,occ_np.dat,unocc_np.dat} $DPATH/td-z-RPA/pulse/wtenergy_nonresonant.npz --maxtime 30e3 --transitions nonresonant
7879

7980
# Induced charge density
8081
for t in $time
8182
do
82-
mpirun -np 1 --oversubscribe python3 src/ind.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{rho,indden_t}} --time $t
83+
mpirun -np 1 python3 src/ind.py $DPATH/{unocc/{unocc.gpw,ksd.ulm},td-z-RPA/pulse/{rho,indden_t}} --time $t
8384
done

MetalNP_MoSe2_Flake/np_tmd_pict_codes/energy_decomposition/src/ind.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def ind_den(gpw_fpath, ksd_fpath, pulse_rho_dpath, ofpath, time):
2929
rho_MM_0 = read_rho(pulse_rho_dpath, 0, "")
3030
rho_MM_t = read_rho(pulse_rho_dpath, time, "")
3131
rho_up = rho_MM_t - rho_MM_0
32-
rho_g = ksd.get_density(calc.wfs, rho_up.imag)
32+
rho_g = ksd.get_density(calc.wfs, rho_up.real)
3333
t_fs = time/1000 # time from as to fs
3434
write(f'{ofpath}/ind_{t_fs:.2f}fs.cube', calc.atoms, data=rho_g)
3535

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import os
2+
import sys
3+
from pathlib import Path
4+
import numpy as np
5+
from gpaw.tddft.units import au_to_fs
6+
import matplotlib.pyplot as plt
7+
from numba import njit, prange
8+
9+
def gauss_iaw(energy, energy_i, energy_a, sigma):
10+
denergy_iaw = energy - (energy_a - energy_i)
11+
norm = 1.0 / (sigma * np.sqrt(2 * np.pi))
12+
giaw = norm * np.exp(-0.5 * denergy_iaw**2 / sigma**2)
13+
return giaw
14+
15+
def calc_jdos(transp_fpath, out_fpath):
16+
transp = np.load(transp_fpath)
17+
file_output = open(out_fpath, "w")
18+
19+
energy_i = transp["energy_i"]
20+
energy_a = transp["energy_a"]
21+
22+
sigma = 0.07 # broadening in eV
23+
24+
energy = np.arange(0, 5, 0.01)
25+
26+
jdos = np.zeros(len(energy))
27+
28+
for w in prange(len(energy)):
29+
sum = 0
30+
for a in range(len(energy_a)):
31+
for i in range(len(energy_i)):
32+
sum += gauss_iaw(energy[w], energy_i[i], energy_a[a], sigma)
33+
jdos[w] = sum
34+
35+
# Normalize jdos
36+
jdos = jdos / (len(energy_a)*len(energy_i))
37+
38+
file_output = open(out_fpath, "w")
39+
40+
file_output.write("# Joint DOS\n")
41+
file_output.write(f"# energy jdos(w)\n")
42+
43+
for w in prange(len(energy)):
44+
file_output.write(str(energy[w])+" "+str(jdos[w])+"\n")
45+
46+
file_output.close()
47+
48+
49+
if __name__ == '__main__':
50+
import argparse
51+
from argparse_util import ExistingPathType, FilePathType, IntOrStrType
52+
53+
parser = argparse.ArgumentParser()
54+
parser.add_argument('transp_fpath', type=FilePathType)
55+
parser.add_argument('out_fpath', type=FilePathType)
56+
57+
args = parser.parse_args()
58+
59+
calc_jdos(args.transp_fpath, args.out_fpath)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import os
2+
import sys
3+
from pathlib import Path
4+
import numpy as np
5+
from gpaw.tddft.units import au_to_fs
6+
import matplotlib.pyplot as plt
7+
from numba import njit, prange
8+
9+
def gauss_iaw(energy, energy_i, energy_a, sigma):
10+
denergy_iaw = energy - energy_a - energy_i
11+
norm = 1.0 / (sigma * np.sqrt(2 * np.pi))
12+
giaw = norm * np.exp(-0.5 * denergy_iaw**2 / sigma**2)
13+
return giaw
14+
15+
def calc_jdos(transp_fpath, out_fpath):
16+
transp = np.load(transp_fpath)
17+
file_output = open(out_fpath, "w")
18+
19+
energy_i = transp["energy_i"]
20+
energy_a = transp["energy_a"]
21+
22+
sigma = 0.07 # broadening in eV
23+
24+
energy = np.arange(-5, 5, 0.01)
25+
26+
jdos = np.zeros(len(energy))
27+
28+
for w in prange(len(energy)):
29+
sum = 0
30+
for a in range(len(energy_a)):
31+
for i in range(len(energy_i)):
32+
sum += gauss_iaw(energy[w], energy_i[i], energy_a[a], sigma)
33+
jdos[w] = sum
34+
35+
file_output = open(out_fpath, "w")
36+
37+
file_output.write("# Joint DOS\n")
38+
file_output.write(f"# energy jdos(w)\n")
39+
40+
for w in prange(len(energy)):
41+
file_output.write(str(energy[w])+" "+str(jdos[w])+"\n")
42+
43+
file_output.close()
44+
45+
46+
if __name__ == '__main__':
47+
import argparse
48+
from argparse_util import ExistingPathType, FilePathType, IntOrStrType
49+
50+
parser = argparse.ArgumentParser()
51+
parser.add_argument('transp_fpath', type=FilePathType)
52+
parser.add_argument('out_fpath', type=FilePathType)
53+
54+
args = parser.parse_args()
55+
56+
calc_jdos(args.transp_fpath, args.out_fpath)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
import sys
3+
import numpy as np
4+
sys.path.insert(0, os.path.dirname(__file__))
5+
6+
7+
def pulse_transp(pulse, time_t, gpw_fpath, ksd_fpath, pulse_rho_dpath,
8+
ofpath, transitions):
9+
from gpaw.tddft.units import au_to_eV
10+
from rhoanalysis.transp_Pia import TransPCalculator
11+
12+
frequency = pulse.omega0 * au_to_eV
13+
sigma = pulse.sigma * au_to_eV
14+
Wlow = frequency - 2 * sigma
15+
Whigh = frequency + 2 * sigma
16+
17+
if transitions == 'all':
18+
flt = None
19+
elif transitions == 'resonant':
20+
flt = [('w', (Wlow, Whigh))]
21+
elif transitions == 'nonresonant':
22+
flt = [('w', (0, Wlow)), 'or', ('w', (Whigh, np.inf))]
23+
24+
a = TransPCalculator(time_t, pulse, gpw_fpath, ksd_fpath, pulse_rho_dpath)
25+
a.run(outfpath=ofpath, flt=flt)
26+
27+
28+
if __name__ == '__main__':
29+
import argparse
30+
from argparse_util import ExistingPathType, FilePathType
31+
32+
parser = argparse.ArgumentParser()
33+
parser.add_argument('gpw_fpath', type=ExistingPathType)
34+
parser.add_argument('ksd_fpath', type=ExistingPathType)
35+
parser.add_argument('pulse_fpath', type=ExistingPathType)
36+
parser.add_argument('pulse_rho_dpath', type=ExistingPathType)
37+
parser.add_argument('out_fpath', type=FilePathType)
38+
parser.add_argument('--time', type=float, nargs='+')
39+
parser.add_argument('--maxtime', type=float, default=30e3)
40+
parser.add_argument('--transitions', default='all',
41+
choices=['all', 'resonant', 'nonresonant'])
42+
args = parser.parse_args()
43+
44+
from pulse import read_pulse, pulse_time_grid
45+
pulse = read_pulse(args.pulse_fpath)
46+
time_t = pulse_time_grid(args.time, args.maxtime)
47+
48+
pulse_transp(pulse, time_t, args.gpw_fpath, args.ksd_fpath,
49+
args.pulse_rho_dpath, args.out_fpath,
50+
transitions=args.transitions)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
import sys
3+
from pathlib import Path
4+
import numpy as np
5+
from gpaw.tddft.units import au_to_fs
6+
import matplotlib.pyplot as plt
7+
from numba import njit, prange
8+
9+
def gauss_iaw(energy, energy_i, energy_a, sigma):
10+
denergy_iaw = energy - (energy_a - energy_i)
11+
norm = 1.0 / (sigma * np.sqrt(2 * np.pi))
12+
giaw = norm * np.exp(-0.5 * denergy_iaw**2 / sigma**2)
13+
return giaw
14+
15+
def calc_pw(transp_fpath, time, out_fpath):
16+
transp = np.load(transp_fpath)
17+
file_output = open(out_fpath, "w")
18+
19+
energy_i = transp["energy_i"]
20+
energy_a = transp["energy_a"]
21+
22+
Pia_t = transp["transp"]
23+
24+
sigma = 0.07 # broadening in eV
25+
26+
energy = np.arange(0, 5, 0.1)
27+
28+
dt = 20 # time step used
29+
30+
t = int(int(time)/dt)
31+
32+
Pw = np.zeros(len(energy))
33+
34+
for w in range(len(energy)):
35+
sum = 0
36+
for a in range(len(energy_a)):
37+
for i in range(len(energy_i)):
38+
giaw = gauss_iaw(energy[w], energy_i[i], energy_a[a], sigma)
39+
sum += Pia_t[t, i, a] * giaw
40+
Pw[w] = sum
41+
42+
file_output.write(f"# P(w) computed at {t} fs \n")
43+
44+
for w in range(len(energy)):
45+
file_output.write(str(energy[w])+" "+str(Pw[w])+"\n")
46+
file_output.close()
47+
48+
49+
if __name__ == '__main__':
50+
import argparse
51+
from argparse_util import ExistingPathType, FilePathType, IntOrStrType
52+
53+
parser = argparse.ArgumentParser()
54+
parser.add_argument('transp_fpath', type=FilePathType)
55+
parser.add_argument('out_fpath', type=FilePathType)
56+
parser.add_argument('--time', type=int)
57+
58+
args = parser.parse_args()
59+
60+
calc_pw(args.transp_fpath, args.time, args.out_fpath)

0 commit comments

Comments
 (0)