# ----------------------------------------------------------------------------------
#   Automatic test: computation of U in CRPA for SrVO3 for t2g and eg orbitals
#     2/3
#   Parameters are not converged
#   T. Applencourt and B. Amadon
#
# ----------------------------------------------------------------------------------
ndtset 1
jdtset 4 

#==================================================================================
############ Parameters common to all DATASETS
#==================================================================================
##### CONVERGENCE PARAMETERS
nstep     15
nline     5          #Number of LINE minimisations
nnsclo    2          #Number of Non-Self Consistent LOops
ecut      4.0        # Maximal kinetic energy cut-off, in Hartree
pawecutdg 5.0        #(60)PAW - Energy CUToff for the Double Grid ( need only when usepaw=1=)
tolvrs   1.0d-10    
mqgrid 1000
mqgriddg 1000

occopt    3          #OCCupation OPTion
tsmear    0.0036749  #Temperature of SMEARing
#diemix    0.2       #model DIElectric MIXing factor
#prtdos1   1
#
##### PHYSICAL PARAMETERS
natom 5 ntypat 3 typat 1 2 3 3 3
znucl  23.0 38.0 8.0
# V Sr O*3
xred 0.00 0.00 0.00  #vectors (X) of atom positions in REDuced coordinates
     0.50 0.50 0.50
     0.50 0.00 0.00
     0.00 0.50 0.00
     0.00 0.00 0.50
acell   3*7.2605
rprim 1.0 0.0 0.0    #Real space PRIMitive translations
      0.0 1.0 0.0
      0.0 0.0 1.0

ngkpt 2 2 2          #K - PoinTs grid : Real space LATTice
nshiftk 1            #No shift
shiftk
      0 0 0
istwfk *1

#For all the dataset
nsym 1
icutcoul 6
nband 27

#==================================================================================
############ FIRST DATASET: First dataset with all the symetries to compute DEnsity
#==================================================================================
nsym1 0


#==================================================================================
############ SECOND DATASET: Read density and produce wavefunctions with nsym=1
#==================================================================================
#Bug with the convergence of the DEN file
getden2 1
nstep2     10
nnsclo2 5
nline2 5

#==================================================================================
############ THIRD DATASET: Read Wfc and produce KSS file
#==================================================================================
#  Definitions of parameters for the calculation of the KSS file
getwfk3 2
nbandkss3 -1         # Number of bands in KSS file (-1 means the maximum possible)

kssform 3
# == LDA+DMFT
usedmft3 1
dmftbandi3 21
dmftbandf3 25
dmft_nwlo3 100
dmft_nwli3 200000
dmft_iter3 0

# == LDA+U
usepawu    1        # LDA+U is used.
dmatpuopt  1        # choose expression of the density matrix
lpawu      2 -1 -1
upawu      0.0000000000000000  0.0  0.0  eV
f4of2_sla  0.0  0.0  0.0
jpawu      0.0000000000000000  0.0  0.0  eV

#==================================================================================
############ FOURTH DATASET:  Calculation of the screening (epsilon^-1 matrix)
#==================================================================================
 optdriver4     3     # Screening calculation
# getwfk4        3    # Obtain KSS file from previous dataset
 ecutwfn4       3.0   # Cut-off energy of the planewave set to represent the wavefunctions. It would be more convenient to keep the default ecut value.
 ecuteps4       3.0   # Cut-off energy of the planewave set to represent the dielectric matrix. It is important to adjust this parameter.
# ppmfrq4   16.1 eV   # Imaginary frequency where to calculate the screening
 nfreqre4       1
 nfreqim4       0
 awtr4          1     
 ucrpa_bands4  21 25  # crpa bands
 ucrpa4         1      # For the calcul of U
 inclvkb4       0
 fftgw4         0

#==================================================================================
############ FIFTH DATASET: Calculation of the Self-Energy matrix elements (GW corrections)
#==================================================================================
 optdriver5  4      # Self-Energy calculation
 ucrpa5      1      # For the calcul of U
# getwfk5     3      # Obtain KSS file from dataset 1
 irdwfk5     1
# getscr5     4      # Obtain SCR file from previous dataset
 irdscr5     1     
 ecutwfn5    2.0    # Planewaves to be used to represent the wavefunctions. It would be ore convenient to keep the default ecut value.
 ecutsigx5   2.0    # Dimension of the G sum in Sigma_x. It would be better to keep the default ecut value.
                    #(the dimension in Sigma_c is controlled by ecuteps)
 ppmodel  3         # in order to use only one frequency
 gwcalctyp5 2
 nkptgw5      0     # All k-points 
 nfreqsp5 1
 freqspmax5 1 eV
 freqspmin5 0 eV

## After modifying the following section, one might need to regenerate the pickle database with runtests.py -r
#%%<BEGIN TEST_INFO>
#%% [setup]
#%% executable = abinit
#%% test_chain = t23.in, t24.in, t25.in
#%% exclude_hosts = ibm@ibm8
#%% need_cpp_vars = !HAVE_MPI_IO_DEFAULT, !HAVE_NETCDF_DEFAULT
#%% [files]
#%% files_to_test = 
#%%   t24.out, tolnlines=   12,   tolabs=  2.0e-3,  tolrel= 2.0e-3, fld_options = -medium
#%% psp_files= 23v.paw, 38sr.paw, 8o.paw 
#%% [shell] 
#%% post_commands = 
#%%   ww_mv t24o_DS4_SCR t25i_DS5_SCR
#%% [paral_info]
#%% max_nprocs = 4
#%% [extra_info]
#%% keywords = GW, DMFT, cRPA
#%% authors = T. Applencourt, B. Amadon
#%% description = Test the calculation of dielectric function in constrained RPA for SrVO3. Uses KSS file from test 23
#%% topics = CRPA
#%%<END TEST_INFO>
