Scripts - Alcyone cluster

Last modified by alldritt@helsinki_fi on 2024/02/07 06:22

ERKALE input files for a number of .xyz-files

here is an example script to create necessary input files for H2O-HCl clusters from .xyz files:

script for creating ERKALE input files
#!/bin/bash

for fname in $( ls *.xyz -1 | awk -F "." '{print $1}');
do

mkdir $fname

#count charges for charge card
nO=`grep 'O ' $fname.xyz | wc -l`
nH=`grep 'H ' $fname.xyz | wc -l`
nCl=`grep 'Cl' $fname.xyz | wc -l`

char=$(( $nH-2*$nO-$nCl ))

cat >help.inp <</.
#
#Ground state:
#
System $fname.xyz
Basis basis.gbs
Method gga_x_rpbe-gga_c_pbe
Direct true
Charge $char
MaxIter 200

# Relax convergence settings to match those used by erkale_xrs
DeltaEmax 1e-6
DeltaPrms 1e-6
DeltaPmax 1e-5
DFTDelta 100

# Use broyden accelerator
UseDIIS false
UseADIIS false
UseBroyden true
/.

mv help.inp $fname/gsrun

#
#XRS calculation, done in xrs/ subdirectory:
#
mkdir $fname/xrs

#awk '{if (FNR == 3) sub(/O/,"O-Xc");print}' $fname.xyz > $fname/$fname-xrs.xyz

sed 's/O          0.00000        0.00000        0.00000/O-Xc       0.00000        0.00000        0.00000/g' $fname.xyz > $fname/$fname-xrs.xyz

cat >help.inp <</.
System ../$fname-xrs.xyz
Method gga_x_rpbe-gga_c_pbe
Basis ../basis.gbs
Direct true
Charge $char
MaxIter 200

LoadChk ../erkale.chk
XRSMethod TP
XRSLocalize 1
XRSAugment 1
XRSQval 1.5
/.
mv help.inp $fname/xrs/xrsrun

mkdir $fname/fch
#
#FCH calculation, done in fch/ subdirectory:
#
cat >help.inp <</.
System ../$fname-xrs.xyz
Method gga_x_rpbe-gga_c_pbe
Basis ../basis.gbs
Direct true
Charge $char
MaxIter 200

LoadChk ../erkale.chk
XRSLocalize 1
XRSMethod XCH
/.

mv help.inp $fname/fch/fchrun

cp $fname.xyz $fname

done

Basis set

those input files rely on basis sets in a file basis.gbs such as this one:

submit script for ERKALE on Alcyone
# Hydrogen: aug-cc-pVDZ
H       0
S   3   1.00
       1.3010000000000000e+01          1.9685000000000001e-02
       1.9620000000000000e+00          1.3797699999999999e-01
       4.4460000000000000e-01          4.7814800000000002e-01
S   1   1.00
       1.2200000000000000e-01          1.0000000000000000e+00
S   1   1.00
       2.9739999999999999e-02          1.0000000000000000e+00
P   1   1.00
       7.2699999999999998e-01          1.0000000000000000e+00
P   1   1.00
       1.4099999999999999e-01          1.0000000000000000e+00
****
# Oxygen: aug-cc-pVDZ
O       0
S   8   1.00
       1.1720000000000000e+04          7.1000000000000002e-04
       1.7590000000000000e+03          5.4700000000000000e-03
       4.0080000000000001e+02          2.7837000000000001e-02
       1.1370000000000000e+02          1.0480000000000000e-01
       3.7030000000000001e+01          2.8306199999999998e-01
       1.3270000000000000e+01          4.4871899999999998e-01
       5.0250000000000004e+00          2.7095200000000003e-01
       1.0129999999999999e+00          1.5458000000000000e-02
S   8   1.00
       1.1720000000000000e+04          -1.6000000000000001e-04
       1.7590000000000000e+03          -1.2630000000000000e-03
       4.0080000000000001e+02          -6.2670000000000000e-03
       1.1370000000000000e+02          -2.5715999999999999e-02
       3.7030000000000001e+01          -7.0924000000000001e-02
       1.3270000000000000e+01          -1.6541100000000000e-01
       5.0250000000000004e+00          -1.1695500000000000e-01
       1.0129999999999999e+00          5.5736799999999997e-01
S   1   1.00
       3.0230000000000001e-01          1.0000000000000000e+00
S   1   1.00
       7.8960000000000002e-02          1.0000000000000000e+00
P   3   1.00
       1.7699999999999999e+01          4.3018000000000001e-02
       3.8540000000000001e+00          2.2891300000000001e-01
       1.0460000000000000e+00          5.0872799999999996e-01
P   1   1.00
       2.7529999999999999e-01          1.0000000000000000e+00
P   1   1.00
       6.8559999999999996e-02          1.0000000000000000e+00
D   1   1.00
       1.1850000000000001e+00          1.0000000000000000e+00
D   1   1.00
       3.3200000000000002e-01          1.0000000000000000e+00
****
# Excited oxygen: IGLO-III
O       1
S   5   1.00
       3.0664503000000001e+04          2.1413899999999999e-04
       4.5732013999999999e+03          1.6779799999999999e-03
       1.0295524000000000e+03          8.8814700000000007e-03
       2.8590474000000000e+02          3.7281340000000003e-02
       9.0369653000000000e+01          1.2518867000000000e-01
S   1   1.00
       3.1219577999999998e+01          1.0000000000000000e+00
S   1   1.00
       1.1607766000000000e+01          1.0000000000000000e+00
S   1   1.00
       4.5927594999999997e+00          1.0000000000000000e+00
S   1   1.00
       1.2711716000000000e+00          1.0000000000000000e+00
S   1   1.00
       4.7214017000000003e-01          1.0000000000000000e+00
S   1   1.00
       1.7896534000000000e-01          1.0000000000000000e+00
P   2   1.00
       7.8702943000000005e+01          4.2415999999999999e-03
       1.8409261000000001e+01          2.9868459999999999e-02
P   1   1.00
       5.7530834999999998e+00          1.0000000000000000e+00
P   1   1.00
       2.1107114000000000e+00          1.0000000000000000e+00
P   1   1.00
       8.3712087000000002e-01          1.0000000000000000e+00
P   1   1.00
       3.3907630000000000e-01          1.0000000000000000e+00
P   1   1.00
       1.3226309999999999e-01          1.0000000000000000e+00
D   1   1.00
       1.3999999999999999e+00          1.0000000000000000e+00
D   1   1.00
       3.4999999999999998e-01          1.0000000000000000e+00
****
Cl 0
S   11   1.00
 1.2790000000e+05   2.4114871589e-04
 1.9170000000e+04   1.8709167624e-03
 4.3630000000e+03   9.7080975316e-03
 1.2360000000e+03   3.9314601560e-02
 4.0360000000e+02   1.2592976281e-01
 1.4570000000e+02   2.9933568218e-01
 5.6810000000e+01   4.2187850515e-01
 2.3230000000e+01   2.3719678610e-01
 6.6440000000e+00   1.9152759743e-02
 2.5750000000e+00  -3.3478605239e-03
 5.3710000000e-01   9.2986648054e-04
S   11   1.00
 1.2790000000e+05  -6.7686212145e-05
 1.9170000000e+04  -5.2025272713e-04
 4.3630000000e+03  -2.7567404766e-03
 1.2360000000e+03  -1.1119859194e-02
 4.0360000000e+02  -3.8474810515e-02
 1.4570000000e+02  -9.9182958838e-02
 5.6810000000e+01  -2.0078096801e-01
 2.3230000000e+01  -1.2991762475e-01
 6.6440000000e+00   5.0789732803e-01
 2.5750000000e+00   6.0887203408e-01
 5.3710000000e-01   4.2027000220e-02
S   11   1.00
 1.2790000000e+05   3.7727423964e-05
 1.9170000000e+04   2.9134554353e-04
 4.3630000000e+03   1.5343024395e-03
 1.2360000000e+03   6.2554500584e-03
 4.0360000000e+02   2.1485486905e-02
 1.4570000000e+02   5.6985552489e-02
 5.6810000000e+01   1.1586478291e-01
 2.3230000000e+01   8.4709741013e-02
 6.6440000000e+00  -4.0364106838e-01
 2.5750000000e+00  -7.5234173436e-01
 5.3710000000e-01   1.1750870665e+00
S   1   1.00
 1.9380000000e-01   1.0000000000e+00
S   1   1.00
 6.0800000000e-02   1.0000000000e+00
P   7   1.00
 4.1760000000e+02   5.2607254496e-03
 9.8330000000e+01   3.9840057071e-02
 3.1040000000e+01   1.6468334447e-01
 1.1190000000e+01   3.8738867539e-01
 4.2490000000e+00   4.5715068248e-01
 1.6240000000e+00   1.5166210332e-01
 5.3220000000e-01   1.8164626404e-03
P   7   1.00
 4.1760000000e+02  -2.2919789638e-03
 9.8330000000e+01  -1.7208759795e-02
 3.1040000000e+01  -7.5043672871e-02
 1.1190000000e+01  -1.7725041746e-01
 4.2490000000e+00  -2.4469114416e-01
 1.6240000000e+00   1.4281709332e-01
 5.3220000000e-01   9.2503549398e-01
P   1   1.00
 1.6200000000e-01   1.0000000000e+00
P   1   1.00
 4.6600000000e-02   1.0000000000e+00
D   1   1.00
 3.6520000000e+00   1.0000000000e+00
D   1   1.00
 6.0300000000e-01   1.0000000000e+00
D   1   1.00
 1.9800000000e-01   1.0000000000e+00
****

Run calculations

here is an exsample submit script for the Alcyone SLURM queue system:

submit script for ERKALE on Alcyone
#!/bin/bash
#SBATCH -J erkale_xrs
#SBATCH -N 1
#SBATCH -n 6
#SBATCH -t 120:00:00
#SBATCH --mail-type=ALL
#SBATCH -o job.out
#SBATCH -e job.err
#SBATCH -p 2G_short_par

#-------------------------------------------------------
#
# First check that we have enough disk space on /tmp.
# If not the script exits with status 64. The status
# is also shown in the email message sent on job
# completion.
#
# The limit (in %) is given in shell variable tmplimit
# (note: it is an integer).
#
#-------------------------------------------------------

tmplimit=80

space=`df /tmp | awk '!/Filesystem/ && /%/ {sub("%","",$5); print $5+0;}'`
echo
echo "Disk space usage on /tmp on computation node:" $space "%"

if test 0$space -ge $tmplimit
then
   echo
   echo "qsub script check:"
   echo "File space on tmp on node" `hostname` "dangerously low. Aborting job."
   echo "Please ask an administrator to clean up /tmp on that node."
   echo
    df /tmp
   echo
   exit 64
fi



#-------------------------------------------------------
# Create the computation work directory.
#
# Naming pattern is '/tmp/<USERNAME>/__<CWD>_<N>/',
# where <CWD> is the trailing part of the current
#             directory and
#       <ID>  is the process ID of the current shell
#             (just to get a unique name).
#-------------------------------------------------------

sd=`pwd`
prefix=/tmp/$USER
if [ ! -d $prefix ]; then
   mkdir $prefix
fi
cd=${sd/$HOME/}
cd=${cd//\//__}
cd=$prefix/${cd}_${SLURM_JOB_ID}
mkdir $cd

#-------------------------------------------------------
# Copy stuff to running directory
#-------------------------------------------------------

rsync -avu $sd/ $cd/

echo "Date:                   " `date`
echo "Submission directory:   " $sd
echo "Running directory:      " `pwd`
echo "Host:                   " `hostname`
echo "JOB_ID:                 " $SLURM_JOB_ID

cd $cd

#-------------------------------------------------------
# Run the program and copy the results
#-------------------------------------------------------

PATH=$PATH:/scratch/csahle/erkale/erkale/bin
export PATH

export ERKALE_LIBRARY=/scratch/csahle/erkale/build/erkale/basis

# Ground-state run
if [ ! -f erkale.chk ]; then
 erkale_omp gsrun &> erkale.stdout

if [ -f erkale.chk ]; then
  h5repack erkale.chk erkale.new.chk
  ls -lh erkale.chk erkale.new.chk
  mv erkale.new.chk erkale.chk
fi
fi

rsync -avu $cd/ $sd/

# Excited state
if [ ! -d xrs ]; then
 mkdir xrs
fi

cd xrs
if [ ! -f erkale_xrs.chk ]; then
 erkale_xrs_omp xrsrun &> erkale_xrs.stdout
if [ -f erkale_xrs.chk ]; then
  h5repack erkale_xrs.chk erkale_xrs.new.chk
  ls -lh erkale_xrs.chk erkale_xrs.new.chk
  mv erkale_xrs.new.chk erkale_xrs.chk
fi
fi
cd ..

rsync -avu $cd/ $sd/

# Energy correction
if [ ! -d fch ]; then
 mkdir fch
fi

cd fch
if [ ! -f erkale_xrs.chk ]; then
 erkale_xrs_omp fchrun &> erkale_xrs.stdout
if [ -f erkale_xrs.chk ]; then
  h5repack erkale_xrs.chk erkale_xrs.new.chk
  ls -lh erkale_xrs.chk erkale_xrs.new.chk
  mv erkale_xrs.new.chk erkale_xrs.chk
fi
fi
cd ..

rsync -avu $cd/ $sd/

#-------------------------------------------------------
# Cleanup, i.e. remove the computation work directory.#
# This is important. Otherwise /tmp would gradually
# fill up.
#-------------------------------------------------------

cd $sd/
rm -rf $cd

Collecting the runs

the following script can be run to apply the DELTA-KS correction in the same way the makeruns.sh creates the input files:

submit script for ERKALE on Alcyone
#!/bin/bash

for fname in $( ls *.xyz -1 | awk -F "." '{print $1}'); do
  if [[ -f $fname/xrs/dipole.dat && -f $fname/fch/dipole.dat ]]; then
   echo $fname

if [[ -f $fname/fch/erkale_xrs.stdout ]];then

   # Get Delta-KS energy
   E=`grep "Absolute energy correction" $fname/fch/erkale_xrs.stdout | awk '{print $9}'`
   # Get TP energy
   Et=`head -n 1 $fname/xrs/dipole.dat | awk '{print $1}'`

   # Correction is
   corr=`echo "$E $Et"|awk '{printf("%e",$1-$2)}'`;

    cat $fname/xrs/dipole.dat | awk -v c=$corr '{printf("%e %e\n",$1,$2)}' > $fname/xrs/dip.dat
    cat $fname/xrs/dipole.dat | awk -v c=$corr '{printf("%e %e\n",$1+c,$2)}' > $fname/xrs/dip-corr.dat

    cat $fname/xrs/trans_four-1.50.dat | awk -v c=$corr '{printf("%e %e\n",$1,$2)}' > $fname/xrs/q1.50.dat
    cat $fname/xrs/trans_four-1.50.dat | awk -v c=$corr '{printf("%e %e\n",$1+c,$2)}' > $fname/xrs/q1.50-corr.dat

    touch -r $fname/xrs/dipole.dat $fname/xrs/dip.dat
    touch -r $fname/xrs/dipole.dat $fname/xrs/dip-corr.dat

    touch -r $fname/xrs/trans_four-1.50.dat $fname/xrs/q1.50.dat
    touch -r $fname/xrs/trans_four-1.50.dat $fname/xrs/q1.50-corr.dat
else
 echo $fname'/fch/erkale_xrs.stdout does not exist'
fi
  fi
done