#!/bin/bash
# 
# Parallel script produced by bolt
#        Resource: ARCHER2 (HPE Cray EX (128-core per node))
#    Batch system: Slurm
#
# bolt is written by EPCC (http://www.epcc.ed.ac.uk)
#
#SBATCH --nodes=4
#SBATCH --tasks-per-node=128
#SBATCH --cpus-per-task=1
#SBATCH --job-name=p_-8.5
#SBATCH --account=e89-ic_m
#SBATCH --partition=standard
#SBATCH --qos=standard
#SBATCH --time=02:0:0
module  load castep
p='-8'

###########################################################################

cat > TiO2_unit_geom.$p.cell << EOF
%BLOCK lattice_cart
   4.64413000000000   0.00000000000000   0.00000000000000
   0.00000000000000   4.64413000000000   0.00000000000000
   0.00000000000000   0.00000000000000   2.95853700000000
%ENDBLOCK lattice_cart

%BLOCK positions_frac
  O       0.30500000000000   0.30500000000000   0.0000000000000  ! // O
  O      -0.30500000000000  -0.30500000000000   0.0000000000000  ! // O
  O       0.19500000000000   0.80500000000000   0.5000000000000  ! // O
  O       0.80500000000000   0.19500000000000   0.5000000000000  ! // O
  Ti      0.00000000000000   0.00000000000000   0.0000000000000  ! // Ti
  Ti      0.50000000000000   0.50000000000000   0.5000000000000  ! // Ti
%ENDBLOCK positions_frac

symmetry_generate

kpoint_mp_grid : 4 4 8

%BLOCK SPECIES_POT
NCP
%ENDBLOCK SPECIES_POT

%BLOCK EXTERNAL_PRESSURE
GPa
$p  0.0000000000    0.0000000000
    $p              0.0000000000
                    $p
%ENDBLOCK EXTERNAL_PRESSURE
snap_to_symmetry
EOF

cat > TiO2_unit_geom.$p.param << EOF
task          : geometryoptimisation
fix_occupancy : true
opt_strategy  : speed
num_dump_cycles : 0
xc_functional  : LDA
cut_off_energy : 1350 eV
elec_energy_tol : 1.0e-12 ev
ELEC_EIGENVALUE_TOL : 1.0e-12 eV
ELEC_FORCE_TOL : 1e-6 eV/ang
GEOM_FORCE_TOL : 1e-4 ev/ang
GEOM_STRESS_TOL : 0.001 GPa
GEOM_DISP_TOL : 5.0e-4 ang
GEOM_ENERGY_TOL : 5.0e-6 eV
POPN_CALCULATE : true
GEOM_MAX_ITER : 600
MAX_SCF_CYCLES : 600
write_cell_structure : T
EOF

srun --distribution=block:block --hint=nomultithread castep.mpi TiO2_unit_geom.$p

cp TiO2_unit_geom.$p-out.cell TiO2_unit_phonon.$p.cell

cat >> TiO2_unit_phonon.$p.cell << EOF
phonon_kpoint_mp_grid 7 7 13
snap_to_symmetry
EOF

cat > TiO2_unit_phonon.$p.param << EOF
task PHONON+EFIELD
iprint : 1
#continuation : default
PHONON_SUM_RULE_METHOD : none
PHONON_CALC_LO_TO_SPLITTING : FALSE
#PHONON_FINE_METHOD : INTERPOLATE
cut_off_energy    : 1350 eV
opt_strategy      : speed
num_dump_cycles   : 0
xc_functional     : LDA
elec_energy_tol : 1.0e-12 ev
ELEC_EIGENVALUE_TOL : 1.0e-12 eV
ELEC_FORCE_TOL : 1e-6 eV/ang
PHONON_ENERGY_TOL : 1.0e-6 eV/ang**2
EFIELD_ENERGY_TOL : 1.0e-6 ang**3
fix_occupancy : true
MAX_SCF_CYCLES : 600
EFIELD_MAX_CYCLES : 600
PHONON_MAX_CYCLES : 600
EOF
srun --distribution=block:block --hint=nomultithread castep.mpi TiO2_unit_phonon.$p
