Skip to content

Commit

Permalink
Make nbands-epsopt-data-converge compatible with vasp5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Sep 11, 2023
1 parent befb0ff commit e709616
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions bin/nbands-epsopt-data-converge
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ rm -f data # delete data file if exists
# Note that we ignore off-diagonal elements in this script
n=0
shopt -s extglob
for i in {!(*_*),*_*}/CONTCAR
for i in {!(*_*),*_*}/OUTCAR
do
if ! [[ $i == "*_*/CONTCAR" ]]
if ! [[ $i == "*_*/OUTCAR" ]]
then
if ! [[ $i == "!(*_*)/CONTCAR" ]]
if ! [[ $i == "!(*_*)/OUTCAR" ]]
then

folder=${i/CONTCAR/}
folder=${i/OUTCAR/}
name=${folder//[\/]/} # folder name without slashes

n_atoms=$(sed '7q;d' $i | awk '{sum=0; for (i=1; i<=NF; i++) { sum+= $i } print sum}') # sum over row 7 of the CONTCAR
optic_dielectric_tensor=$(grep -s -A 3 "frequency dependent REAL DIELECTRIC FUNCTION (independent particle, no local field effects) density-density" $folder/OUTCAR | tail -1 | tr -d '\n') # tr is to remove the trailing newline
optic_dielectric_tensorX=$(grep -s -A 3 "frequency dependent REAL DIELECTRIC FUNCTION (independent particle, no local field effects) density-density" $folder/OUTCAR | tail -1 | awk '{print $2}' | tr -d '\n')
optic_dielectric_tensorY=$(grep -s -A 3 "frequency dependent REAL DIELECTRIC FUNCTION (independent particle, no local field effects) density-density" $folder/OUTCAR | tail -1 | awk '{print $3}' | tr -d '\n')
optic_dielectric_tensorZ=$(grep -s -A 3 "frequency dependent REAL DIELECTRIC FUNCTION (independent particle, no local field effects) density-density" $folder/OUTCAR | tail -1 | awk '{print $4}' | tr -d '\n')
# optic_dielectric_tensor=$(grep -s -A 3 "frequency dependent REAL DIELECTRIC FUNCTION (independent particle, no local field effects) density-density" $folder/OUTCAR | tail -1 | tr -d '\n') # tr is to remove the trailing newline
vasp_optics_string="frequency dependent REAL DIELECTRIC FUNCTION (independent particle, no local field effects)"
if grep -q "$vasp_optics_string density-density" "$folder/OUTCAR"; then
optic_dielectric_tensorX=$(grep -s -A 3 "$vasp_optics_string density-density" $folder/OUTCAR | tail -1 | awk '{print $2}' | tr -d '\n')
optic_dielectric_tensorY=$(grep -s -A 3 "$vasp_optics_string density-density" $folder/OUTCAR | tail -1 | awk '{print $3}' | tr -d '\n')
optic_dielectric_tensorZ=$(grep -s -A 3 "$vasp_optics_string density-density" $folder/OUTCAR | tail -1 | awk '{print $4}' | tr -d '\n')
else
optic_dielectric_tensorX=$(grep -s -A 3 "$vasp_optics_string" $folder/OUTCAR | tail -1 | awk '{print $2}' | tr -d '\n')
optic_dielectric_tensorY=$(grep -s -A 3 "$vasp_optics_string" $folder/OUTCAR | tail -1 | awk '{print $3}' | tr -d '\n')
optic_dielectric_tensorZ=$(grep -s -A 3 "$vasp_optics_string" $folder/OUTCAR | tail -1 | awk '{print $4}' | tr -d '\n')
fi

echo -n -e "$name\t$optic_dielectric_tensorX\t$optic_dielectric_tensorY\t$optic_dielectric_tensorZ" >> data

Expand Down

0 comments on commit e709616

Please sign in to comment.