This is how the files for the STM calculation within the Efective Atom model need to be prepared:

(A) prepare input files with different positions of the Effective Atom (local platform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1. start from the <input.inp> file that contains He1 species above the surface somewhere

2. create a copy of that file <1.inp> in which the poisions x,y,z of the He1 are replaced by XXX YYY ZZZ, e.g.

       He1   0.0 0.0 3.5

is replaced by

       He1   XXX YYY ZZZ

3. Run tetr and read <input.inp>, go to EA menu option and run it. There:

     - define the box within which the grid is going to be defined; this is done by defining:
         Cp - the corner point of the box
	 Up - the upper Z height of the box (Zupper)
	 Vp - the vectors along the two in-plane sides of the box, both starting from Cp
	      The 3rd vector of the box is defined perpendicular to the plane of the surface and between Cp(3) and
	      Zupper

     - define the grid within the box
     - using S will generate all directories with files <xyz> containing coordinates of the He1 species. It will
       also place there an input file as well with the correct geometry, however, in the case of CP2K this file
       needs editing and hence cannot be directly used.
     - tetr will also create the file <for_lev00.dat> with the information on the grid chosen and the box to be
       used by <lev00> when previewing the image.

4. Edit the script <run_prep_input> to include all grid points starting from 0.

5. Run the script. It will place in each directory N1.N2.N3 of the grid the correct CP2K input file <input.inp> that has the
   required position of the He1 species. 

(B) Run the CP2K simulations and prepare the necessary file for the current simulation (HPC platform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6. tar/gzip the directories and scp the archive to an HPC.

7. Run all simulations using <job_run_cp2k> script, e.g.

#!/bin/bash -l
#$ -P Gold
#$ -A KCL_Kantorovitch
#$ -l h_rt=12:00:00
#$ -N cp2k_test
#$ -pe mpi 20
#$ -cwd

module purge
module load gerun
module load gcc-libs
module load compilers/gnu/4.9.2
module load mpi/openmpi/3.1.4/gnu-4.9.2
module load openblas/0.3.7-openmp/gnu-4.9.2
module load cp2k/7.1/ompi/gnu-4.9.2

export OMP_NUM_THREADS=1


for d1 in 0 1 2 3 4
do
  for d2 in 0 1 2 3 4
  do
    for d3 in 0 1 2 3 4
    do

        cd $d1.$d2.$d3

#..... run CP2K
    
        gerun cp2k.popt -inp input.inp > output.out  

#..... collect all file names of the KS Hamiltonian

        ls Gold-KS_MAT-1_0_*Log > names.dat

#...... determine the KS Hamiltonian file from the last iteration

        ~/bin/lastname > 0
        echo 'last name found is ' `cat 0`

#...... move it to a fixed name; remove the rest of the files

        mv `cat 0` Gold-KS_MAT_last.Log
        rm Gold-KS_MAT-1*.Log
        rm *bak*
        rm cp2k*

        cd ..

    done
  done
done


This script uses a F90 code <lastname> (the source - <names.f90>) that picks up the KS Hamiltonian file from the last
iteration - in the case if the print out is made every iteration.

If only the file from the last iteration is printed by CP2K, the script requires a simple modification (to move that
file into the fixed name <Gold-KS_MAT_last.Log>):

#!/bin/bash -l
#$ -P Gold
#$ -A KCL_Kantorovitch
#$ -l h_rt=12:00:00
#$ -N cp2k_test
#$ -pe mpi 20
#$ -cwd

module purge
module load gerun
module load gcc-libs
module load compilers/gnu/4.9.2
module load mpi/openmpi/3.1.4/gnu-4.9.2
module load openblas/0.3.7-openmp/gnu-4.9.2
module load cp2k/7.1/ompi/gnu-4.9.2

export OMP_NUM_THREADS=1


for d1 in 0 1 2 3 4
do
  for d2 in 0 1 2 3 4
  do
    for d3 in 0 1 2 3 4
    do

        cd $d1.$d2.$d3

#..... run CP2K
    
        gerun cp2k.popt -inp input.inp > output.out  

#...... move it to a fixed name; remove the rest of the files

        mv  Gold-KS_MAT-1_0.Log Gold-KS_MAT_last.Log
        rm *bak*
        rm cp2k*

        cd ..

    done
  done
done


8. Extract the KS Hamiltonian file and the eigenvectors/eigenvalues by running the script <run_python_script>.
   It relies on a few python scripts:    <ks_ham.cp2k.py>,  <wf_coeff_cp2k.py> and <wfn_gs.py>.
   This script creates in each directory two files: <tot_ks.dat> with the full Hamiltonian matrix (we if fact only
   need its 1st row or column, so this step needs to be modified) and <eigenvalues_eigenvectors.dat> that contains
   the LCAO coefficients and KS energies.


#!/bin/bash -l

module purge

    
#...... run the scripts to extract necessary files

module load gcc-libs
module load python3

for d1 in 0 1 2 3 4
do
  for d2 in 0 1 2 3 4
  do
    for d3 in 0 1 2 3 4
    do

        cd $d1.$d2.$d3
        echo '......................> ' $d1.$d2.$d3

        mv  Gold-KS_MAT-1_0.Log Gold-KS_MAT_last.Log
        python3 ~/bin/ks_ham_cp2k.py
        echo 'creating the eigen-vectors/values ...'
        python3 ~/bin/wfn_gs.py
        echo 'removing garbage ..'
    
#...... archive
    echo '... archiving ..'
    gzip *Log tot* eigen*

    cd ..

    done
  done
done

[Include the move line if it is absent in the job file.] 

9. Run <>run_extract_clean> script that creates a temporary directory <tmp> with all information needed to calculate
   the current (hopefully, this directory is smaller in size than the directory with all CP2K runs).

10. Go into <tmp> and tar/gzip everything; scp-copy it to the local computer platform to the same directory where
    all the input files were prepared by tetr (see A). Remove <tmp> entirely. Clean the directory with all the CP2K
    files if necessary.


(C) Claculation of the current (local platform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

11. Un-tar the archive file. You should have in each subdirectory N1.N2.N3 of the grid: <input.inp> of CP2K, as well as
    the KS Hamiltonian matrix and the eigenvalues/vectors in the files  <tot_ks.dat> and <eigenvalues_eigenvectors.dat>,
    respectively (gunzip them if necessary).

12. Run separately the clean surface (withot He1) to extract the value of the chemical potential. 

13. Edit the <input.dat> file, especially by putting in the value of the chemical potential and the required values of
    Gr and Ea parameters. 

14. Run the script <run_current> that would create the file <current.dat> with all the values of the current from each
    of the directory, something like this:

# plot of the current vs z of the He atom 
0 0 0 6.318714964813027E-002
0 0 1 0.413616560810557
0 0 2 4.233095158921797E-003
0 0 3 3.688743327850073E-006
0 0 4 2.338825239116674E-010
0 1 0 6.306286248128982E-002
.................

    where in the first three columns the grid is shown, the current - in the 4-th column. The input parameters
    for the calculations (temperature, Gamma and EA on-site energy) are in <input.dat> file, while the bias voltage
    value is given  explcitily in the script <run_current> in the command:

    curr tot_ks.dat eigenvalues_eignevectors.dat 1.0 > ../tmp

    (1.0 Volt is the bias in this example).

13. Run lev00:
     - choose C (CP2K),
     - give the name of the CP2K input file,
     - skip reading the CP2K output file
     - skip reading the CP2K cube file (the electronic density)
     - choose D option (twice)
     - choose  EA option of the density menu, where: use I to set up the value of the current (if the constant current
       mode) or the value of Z (constant height mode); use Ci to calculate the image; use Vi to preview it.
       Spectroscopy: using XY, Cs, Vs. All other options are self-explnatory (e.g., Ex for the exponential fit).
       

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

(D) Values of the parameters Gr, Ea: you must run a series of calculations with the fixed X and Y and many Z values
    of He1 to fit the parameters to the experimental current-vs-z dependence. This would follow a simplified sequence
    of steps from above.
    
    