Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ plotIRC --reactant_dir irc_r/ --product_dir irc_p/ \
|------|-------------|---------|
| `add-MODECAR` | Add MODECAR displacements to a POSCAR, output xyz animation. | `add-MODECAR --poscar POSCAR --modecar MODECAR` |
| `freq2mode` | Generate MODECAR and mass-weighted MODECAR from a frequency calculation. | `freq2mode -i 0` |
| `getPOTCAR` | Generate POTCAR with same order of elements as specified in POSCAR. | `getPOTCAR -r` |
| `kgrid2kspacing` | Get KSPACING equivalent for the current POSCAR+KPOINTS. | `kgrid2kspacing` |
| `kspacing2kgrid` | Get k-point grid for a given KSPACING and the current POSCAR. | `kspacing2kgrid 0.15` |
| `mixed_interpolate` | Geodesic interpolation for the molecule + IDPP for the surface. | `mixed_interpolate` |
| `poscar2nbands` | Compute the recommended NBANDS for LOBSTER from POSCAR/INCAR/POTCAR. | `poscar2nbands` |
| `xyz2POSCAR` | Insert molecule from .xyz file into a cell from a POSCAR. | `xyz2POSCAR mol.xyz POSCAR_with_cell` |

## Post-processing tools

Expand All @@ -141,6 +143,7 @@ plotIRC --reactant_dir irc_r/ --product_dir irc_p/ \
| `elf2cube` | Convert ELFCAR files to cube files. | `elf2cube ELFCAR --output elf` |
| `freq2jmol` | Write JMol-compatible xyz files for all vibrational modes. | `freq2jmol --directory ./` |
| `neb2movie` | Convert VASP NEB images to an ASE ext-xyz movie (like `nebmovie.pl`). | `neb2movie --output neb.xyz` |
| `plotHOMA_withPBC` | Calculate and plot HOMA from coordinates, including pbc. | `plotHOMA_withPBC POSCAR` |
| `plotIRC` | Plot VASP IRC calculations in both directions, shift-compatible. | `plotIRC -r irc_r/ -p irc_p/ -t ts/` |
| `plotNEB` | Plot VASP+VTST NEB results (reads `spline.dat` + `neb.dat`). | `plotNEB --unit eV --file neb.png` |
| `plot_neb_movie` | Create presentation images for NEB using VMD and plotNEB. | `plot_neb_movie` |
Expand Down
134 changes: 134 additions & 0 deletions src/tools4vasp/bash_scripts/getPOTCAR.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash

# The only thing you need to change: The path to the POTCARs!
POTDIR='/PUT/PATH/TO/POTCARS/HERE/'

# Some general variables
myPWD=$(pwd)
decision='0'

# Function for how to use the script
function usage
{
echo " "
echo "* DESCRIPTION : This scripts reads the POSCAR file and creats the POTCAR file of corresponding elements in order."
echo " "
echo "* USAGE: $(basename "$0") [-h|--help|-rnspdbcSHgG]"
echo " -h | --help : For help."
echo " -r : If you want the recommended default potentials (see IMPORTANT)"
echo " -n : If you want no extension of the POTCAR (minimal valence)"
echo " -s : If you want the _sv extension of the POTCAR (semicore p and s states in valence)"
echo " -p : If you want the _pv extension of the POTCAR (semicore p states in valence)"
echo " -d : If you want the _d extension of the POTCAR (semicore d states in valence)"
echo " -b : If you want the _2 extension of the POTCAR (some 4f electrons of Lanthanides are frozen)"
echo " -c : If you want the _3 extension of the POTCAR (some 4f electrons of Lanthanides are frozen)"
echo " -S : If you want the _s extension of the POTCAR (soft potential)"
echo " -H : If you want the _h extension of the POTCAR (hard potential)"
echo " -g : If you want the _GW extension of the POTCAR (opt. for unoccupied states)"
echo " -G : If you want the _sv_GW extension of the POTCAR (see _sv & _GW)"
echo " "
echo "* IMPORTANT : It uses the following extensions as the recommended default potentials (-r):"
echo " None : H, He, Be, B, C, N, O, F, Ne, Mg, Al, Si, P, S, Cl, Ar, Fr, Co,"
echo " Ni, Cu, Zn, As, Se, Br, Kr, Pd, Ag, Cd, Sb, Te, I, Xe, La, Ce,"
echo " Re, Os, Ir, Pt, Au, Hg, At, Rn, Ac, Th, Pa, U, Np, Pu, Am, Cm"
echo " sv : Li, K, Ca, Sc, Ti, V, Rb, Sr, Y, Zr, Nb, Mo, Cs, Ba, W, Fr, Ra"
echo " pv : Na, Cr, Mn, Tc, Ru, Rh, Hf, Ta"
echo " d : Ga, Ge, In, Sn, Tl, Pb, Bi, Po"
echo " 2 : Eu, Yb"
echo " 3 : Pr, Nd, Pm, Sm, Gd, Tb, Dy, Ho, Er, Tm, Lu"
echo " "
echo "* NOTE : To create the POTCAR you must need the POSCAR file. You first have to move to"
echo " the folder that contains the POSCAR. It can't create POTCAR from external path."
echo " "
echo "--------------- Enjoy. Have a good day. ---------------"
echo " "
exit 0
}

# Function for what changes when the options are read in
function readoptions
{
OPTIND=1
while getopts :rnspdbcSHgG options; do
case $options in
r) decision='1' ;;
n) extension='' ;;
s) extension='_sv' ;;
p) extension='_pv' ;;
d) extension='_d' ;;
b) extension='_2' ;;
c) extension='_3' ;;
S) extension='_s' ;;
H) extension='_h' ;;
g) extension='_GW' ;;
G) extension='_sv_GW' ;;
\?) printf "\n\e[38;5;1m* Error: Invalid option %s. Use -h for help. \e[0m\n\n" "$1"; exit 1 ;;
esac
done
}

# Check if help is needed, if there are no or too many options given, and change variables according to options
if [ -n "$2" ]; then
printf "\n\e[38;5;1m* Error: Only one option allowed at a time! Use -h for help. \e[0m\n\n"
exit 1
elif [ -n "$1" ]; then
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
usage
elif [ "$1" == "-" ]; then
printf "\n\e[38;5;1m* Error: Invalid option '-'. Use -h for help. \e[0m\n\n"
exit 1
elif [[ "$1" == -* ]]; then
if [[ ${#1} -gt 2 ]]; then
printf "\n\e[38;5;1m* Error: Only one option allowed at a time! You passed combined options %s. Use -h for help. \e[0m\n\n" "$1"
exit 1
else
readoptions "$@"
fi
else
printf "\n\e[38;5;1m* Error: Invalid option %s. Use -h for help. \e[0m\n\n" "$1"
exit 1
fi
else
printf "\n\e[38;5;1m* Error: You must specify one option! Use -h for help. \e[0m\n\n"
exit 1
fi

# Definition of recommended default options
declare -A element_group=(
[H]="" [He]="" [Be]="" [B]="" [C]="" [N]="" [O]="" [F]="" [Ne]="" [Mg]="" [Al]="" [Si]="" [P]="" [S]="" [Cl]="" [Ar]="" [Fr]="" [Co]="" [Ni]="" [Cu]="" [Zn]="" [As]="" [Se]="" [Br]="" [Kr]=""
[Pd]="" [Ag]="" [Cd]="" [Sb]="" [Te]="" [I]="" [Xe]="" [La]="" [Ce]="" [Re]="" [Os]="" [Ir]="" [Pt]="" [Au]="" [Hg]="" [At]="" [Rn]="" [Ac]="" [Th]="" [Pa]="" [U]="" [Np]="" [Pu]="" [Am]="" [Cm]=""
[Li]="_sv" [K]="_sv" [Ca]="_sv" [Sc]="_sv" [Ti]="_sv" [V]="_sv" [Rb]="_sv" [Sr]="_sv" [Y]="_sv" [Zr]="_sv" [Nb]="_sv" [Mo]="_sv" [Cs]="_sv" [Ba]="_sv" [W]="_sv" [Fr]="_sv" [Ra]="_sv"
[Na]="_pv" [Cr]="_pv" [Mn]="_pv" [Tc]="_pv" [Ru]="_pv" [Rh]="_pv" [Hf]="_pv" [Ta]="_pv"
[Ga]="_d" [Ge]="_d" [In]="_d" [Sn]="_d" [Tl]="_d" [Pb]="_d" [Bi]="_d" [Po]="_d"
[Eu]="_2" [Yb]="_2"
[Pr]="_3" [Nd]="_3" [Pm]="_3" [Sm]="_3" [Gd]="_3" [Tb]="_3" [Dy]="_3" [Ho]="_3" [Er]="_3" [Tm]="_3" [Lu]="_3"
)

# Execution of creating the POTCAR
if [ -f POSCAR ]; then # Check if POSCAR exists
if [ -s POTCAR ]; then # Check if old POTCAR already exists
printf "\n\e[38;5;9;4m* Warning:\e[0m Hi %s, you already have an old POTCAR. I am deleting it and creating the new one.\n\n" "$(whoami)"
rm POTCAR
fi
ATOMS=$(sed -n '6p' POSCAR) && nA=$(wc -w <<< "$ATOMS") # Get elements
NUMBERS=$(sed -n '7p' POSCAR) && nN=$(wc -w <<< "$NUMBERS") # Get number of atoms
if [ "$nA" -ne "$nN" ]; then # Check if number of elements in line 6 and 7 match
printf "\n\e[38;5;1m* Error: Number of elements in line 6 (elements) and line 7 (count) do not match: %s vs. %s \e[0m \n\n" "$nA" "$nN"
exit 1
fi
echo "POTCAR for these elements will be created (in order): $ATOMS"
for element in $ATOMS
do
if [ "$decision" == "1" ]; then # Check if recommended default potentials should be used
extension="${element_group[$element]}" # Assign extension for each element
fi
if [ ! -d "$POTDIR$element$extension" ]; then # Check if element with extension actually exists
printf "\n\e[38;5;1m* Error: %s does not exist.\e[0m \n\n" "$(printf '%q' "$POTDIR$element$extension")"
exit 1
fi
cat "$POTDIR$element$extension/POTCAR" >> "$myPWD/POTCAR" # Important part: attach the POTCARs to each other in order
done
else
printf "\n\e[38;5;1m* Error: No POSCAR file here! POSCAR file is mandatory. Please move to the file containing the POSCAR. \e[0m\n\n"
fi

Loading
Loading