# Crystalline silicon 
# Preparatory run for BS calculations
#
# There are four datasets specified in this input:
# 1) Ground-state calculation to get the density.
# 2) NSCF run to generate the WFK file on a symmetric k-mesh (4x4x4, gamma-centered) 
# 3) NSCF run to generate another WFK file on a shifted 4x4x4 k-mesh that breaks the symmetry of the BZ sampling
# 4) SCR calculation with the WFK file generated in the second dataset 
#
ndtset 4

# Definition of the k-point grid
kptopt 1             # Option for the automatic generation of k points,
ngkpt  4 4 4         # This mesh is too coarse for optical properties.
nshiftk 1
shiftk  0.0 0.0 0.0  # Gamma-centered k-mesh

# Dataset1: self-consistent calculation
#
tolvrs1 1.0d-8
prtden1 1

# Dataset2: definition of parameters for the calculation of the WFK file on the symmetric k-mesh.
#
iscf2    -2       # NSCF run
getden2  1        # Read previous density file
tolwfr2  1.0d-8  
nband2    105     # bands treated in the CG algorithm
nbdbuf2    5      # The last five states are excluded from the converge check
                  # to facilitate the convergence 

# Dataset3: calculation of the WFK file on the shifted k-mesh to break the symmetry.
#
iscf3    -2                
getden3   1
tolwfr3  1.0d-8  
nband3    15               # Here we can reduce the number of bands since this WFK file 
                           # will be used to construct the transition space 
nbdbuf3    5               
chksymbreak3 0             # To skip the check on the k-mesh.
shiftk3    0.11 0.21 0.31  # This shift breaks the symmetry of the k-mesh.

# Dataset3: creation of the screening (eps^-1) matrix
#
optdriver4 3
gwpara4    2
inclvkb4   2
awtr4      1
symchi4    1
getwfk4    2
ecuteps4   6
ecutwfn4   12
nband4    100  # This value leads to well converged QP energies, see the first GW tutorial
nfreqre4   1   # Only the static limit is needed for standard BSE calculations.
nfreqim4   0

# VARIABLES COMMON TO THE DIFFERENT DATASETS

# Definition of the unit cell: fcc
acell 3*10.217         # This is equivalent to   10.217 10.217 10.217
rprim  0.0  0.5  0.5   # FCC primitive vectors (to be scaled by acell)
       0.5  0.0  0.5
       0.5  0.5  0.0

# Definition of the atom types
ntypat 1         # There is only one type of atom
znucl 14         # The keyword "zatnum" refers to the atomic number of the
                 # possible type(s) of atom. The pseudopotential(s)
                 # mentioned in the "files" file must correspond
                 # to the type(s) of atom. Here, the only type is Silicon.

# Definition of the atoms
natom 2           # There are two atoms
typat 1 1         # They both are of type 1, that is, Silicon.
xred              # Reduced coordinate of atoms
   0.0  0.0  0.0
   0.25 0.25 0.25

# Definition of the planewave basis set 
ecut 12         # Maximal kinetic energy cut-off, in Hartree

istwfk *1
nstep  50      # Maximal number of SCF cycles
diemac 12.0


 pp_dirpath "$ABI_PSPDIR"
 pseudos "Pseudodojo_nc_sr_04_pw_standard_psp8/Si.psp8"

##############################################################
# This section is used only for regression testing of ABINIT #
##############################################################
#%%<BEGIN TEST_INFO>
#%% [setup]
#%% executable = abinit
#%% test_chain = tbs_1.abi, tbs_2.abi, tbs_3.abi, tbs_4.abi
#%% [files]
#%% files_to_test = 
#%%   tbs_1.abo,  tolnlines= 20, tolabs=  1.1e-2,    tolrel=  4.0e-2
#%% [shell]
#%% post_commands =
#%%  ww_cp tbs_1o_DS3_WFK tbs_2i_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_2i_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_3i_DS1_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_3i_DS1_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_3i_DS2_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_3i_DS2_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_3i_DS3_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_3i_DS3_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_3i_DS4_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_3i_DS4_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_3i_DS5_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_3i_DS5_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_4i_DS1_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_4i_DS1_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_4i_DS2_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_4i_DS2_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_4i_DS3_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_4i_DS3_SCR;
#%%  ww_cp tbs_1o_DS3_WFK tbs_4i_DS4_WFK;
#%%  ww_cp tbs_1o_DS4_SCR tbs_4i_DS4_SCR; 
#%% [paral_info]
#%% max_nprocs = 4
#%% [extra_info]
#%% authors = M. Giantomassi
#%% keywords = GW, BSE
#%% description = 
#%%  Crystalline silicon 
#%%  Preparatory run for BS calculations
#%% 
#%%  There are four datasets specified in this input:
#%%  1) Ground-state calculation to get the density.
#%%  2) NSCF run to generate the WFK file on a symmetric k-mesh (4x4x4, gamma-centered) 
#%%  3) NSCF run to generate another WFK file on a shifted 4x4x4 k-mesh that breaks the symmetry of the BZ sampling
#%%  4) SCR calculation with the WFK file generated in the second dataset 
#%%<END TEST_INFO>
