# Getting started

The objective of this tutorial is to give a basic idea of how Octopus works.

### Generating the input file

With a text editor, create a text file called inp containing the following text:


CalculationMode = gs

%Coordinates
'H' | 0 | 0 | 0
%

Spacing = 0.25 * angstrom


This is the simplest example of an Octopus input file:

• CalculationMode = gs : This variable defines the run mode – please consult the manual for the full list of the possible run modes. In this case we set it to gs, which instructs the code to start a ground-state calculation.

• %Coordinates: The entry is not just the definition of a variable, but rather of a full set of them – a “block” of variables. The beginning of a block is marked by the %identifier line, and ended by a % line. In this case the identifier is %Coordinates, where we list the atoms or species in our calculation and its coordinates, one per line. In this case, we put a single hydrogen atom in the center of our simulation box.

• Spacing = 0.25*angstrom: As you should know, Octopus works in a real-space regular cubic mesh. This variable defines the spacing between points, a key numerical parameter, in some ways equivalent to the energy cutoff in plane-wave calculations.

• Radius = 4.0*angstrom: The radius of the sphere that defines the simulation box.

The reason this input file can be so simple is that Octopus comes with default values for the simulation parameters, and a set of default pseudopotentials for several elements (for properly converged calculations you might need to adjust these parameters, though).

To get a general idea of the format of the Octopus input file, go and read the page about the Input file in the manual.

The documentation for each input variable can be found in the variable reference online, and can also be accessed via the oct-help utility.

### Running Octopus

Once you have written your input file, run the octopus command (using mpirun and perhaps a job script if you are using the parallel version). If everything goes correctly, you should see several lines of output in the terminal (if you don’t, there must be a problem with your installation). As this is probably the first time you run Octopus, we will examine the most important parts of the output.

• First there is an octopus drawn in ASCII art, the copyright notice and some information about the octopus version you are using and the system where you are running:



<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
___
.-'   '.
/         \
|         ;
|         |           ___.--,
_.._     |0) ~ (0) |    _.---'__.-( (_.
__.--'_.. '.__.\    '--. \_.-' ,.--'     ""
( ,.--'   ',__ /./;   ;, '.__.'    __
_) )  .---.__.' / |   |\   \__..--""  """--.,_
---' .'.''-._.-'_./  /\ '.  \ _.-~~~~~~-._-.__.'
| |  .' _.-' |  |  \  \  '.               ~---
\ \/ .'     \  \   '. '-._)
\/ /        \  \    =.__~-.
jgs  / /\         ) )    / / "".\
, _.-'.'\ \        / /    ( (     / /
--~   ) )    .-'.'      '.'.  | (
(/    ( (          ) )  '-;
'-;         (-'

This program is free software; you can redistribute it and/or modify
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

Running octopus

Version                : maya
Commit                 : ab6cce78a013c99ccb2784512df020dd9aac3c98
Build time             : Mon Sep 12 11:18:16 CEST 2022
Configuration options  : maxdim3 sse2 avx libxc_fxc libxc_kxc
Optional libraries     :
Architecture           : x86_64
C compiler             : gcc
C compiler flags       : -g -gdwarf -Wall -O2 -march=native -ftest-coverage -fprofile-arcs
C++ compiler           : g++
C++ compiler flags     : -g -gdwarf -Wall -O2 -march=native -ftest-coverage -fprofile-arcs
Fortran compiler       : gfortran (GCC version 10.2.1 20210110)
Fortran compiler flags : -g -gdwarf -Wall -Wno-maybe-uninitialized -O2 -march=native -fbacktrace -ffpe-trap=invalid

The octopus is swimming in poppyseed (Linux)

Calculation started on 2022/09/15 at 09:37:12

Note that it also gives you the revision number, the compiler, and the compiler flags used. You should always include this information when submitting a bug report!

• The type of calculation it was asked to perform:



************************** Calculation Mode **************************
Input: [CalculationMode = gs]
**********************************************************************


• The spatial dimensions and the periodicity of the system:



******************************* Space ********************************
Octopus will run in 3 dimension(s).
Octopus will treat the system as periodic in 0 dimension(s).
**********************************************************************


• The species and pseudopotentials it is using:



****************************** Species *******************************
Species 'H'
type             : pseudopotential
file             : '/home/luedersm/Octopus_foss-2020b/share/octopus/pseudopotentials/PSF/H.psf'
file format      : PSF
valence charge   : 1.0
atomic number    :   1
form on file     : semilocal
orbital origin   : calculated
lmax             : 0
llocal           : 0
projectors per l : 1
total projectors : 0
application form : local
orbitals         : 16
bound orbitals   :  1

**********************************************************************


• After some other output, Octopus prints information about the grid: as we didn’t say anything in the input file, Octopus used the parameters recommended for this pseupopotential:



******************************** Grid ********************************
Simulation Box:
Type = minimum
Main mesh:
Spacing [b] = ( 0.472, 0.472, 0.472)    volume/point [b^3] =      0.10544
# inner mesh =      17077
# total mesh =      30461
Grid Cutoff [H] =    22.110166    Grid Cutoff [Ry] =    44.220331
**********************************************************************


• The level of theory and, in the case of (TD)DFT, the approximation to the exchange-correlation term:



**************************** Theory Level ****************************
Input: [TheoryLevel = kohn_sham]

Exchange-correlation:
Exchange
Slater exchange (LDA)
[1] P. A. M. Dirac, Math. Proc. Cambridge Philos. Soc. 26, 376 (1930)
[2] F. Bloch, Z. Phys. 57, 545 (1929)
Correlation
Perdew & Zunger (Modified) (LDA)
[1] J. P. Perdew and A. Zunger, Phys. Rev. B 23, 5048 (1981), modified to improve the matching between the low- and high-rs

Input: [SICCorrection = sic_none]
**********************************************************************


• At this point, Octopus tries to read the wave-functions from a previous calculation. As there are none, it will give a warning.


** Warning:
**   Could not find 'restart/gs' directory for restart.
**   No restart information will be read.

** Warning:
**   Starting from scratch!


• Now Octopus commences the calculation. To get a reasonable starting point for the DFT calculation, the initial wavefunctions are calculated as a Linear Combination of Atomic Orbitals (LCAO).



Info: Performing initial LCAO calculation with      1 orbitals.
Info: Getting Hamiltonian matrix elements.
ETA: .......1......2.......3......4......5.......6......7.......8......9......0

Eigenvalues [H]
#st  Spin   Eigenvalue      Occupation
1   --    -0.233499       1.000000
Info: Ground-state restart information will be written to 'restart/gs'.


• After the LCAO, the real DFT calculation starts. For each self-consistency step some information is printed. When SCF converges, the calculation is done.



*********************** SCF CYCLE ITER #    1 ************************
etot  = -4.47162815E-01 abs_ev   =  1.12E-03 rel_ev   =  4.78E-03
ediff =        4.47E-01 abs_dens =  5.51E-03 rel_dens =  5.51E-03
Matrix vector products:      4
Converged eigenvectors:      0

#  State  Eigenvalue [H]  Occupation    Error
1       -0.234620    1.000000   ( 1.0E-02)

Elapsed time for SCF step     1:          0.01
**********************************************************************



*********************** SCF CYCLE ITER #   12 ************************
etot  = -4.46629384E-01 abs_ev   =  1.83E-07 rel_ev   =  7.84E-07
ediff =        2.28E-07 abs_dens =  2.71E-07 rel_dens =  2.71E-07
Matrix vector products:      9
Converged eigenvectors:      0

#  State  Eigenvalue [H]  Occupation    Error
1       -0.233108    1.000000   ( 2.0E-07)

Elapsed time for SCF step    12:          0.01
**********************************************************************

Info: Writing states. 2022/09/15 at 09:37:12

Info: Finished writing states. 2022/09/15 at 09:37:12

Info: SCF converged in   12 iterations

Info: Number of matrix-vector products:         86
Info: Finished writing information to 'restart/gs'.

Calculation ended on 2022/09/15 at 09:37:12

Walltime:  00.562s

Octopus emitted 3 warnings.


Just running the command octopus will write the output directly to the terminal. To have a saved copy of the output, it is generally advisable to redirect the output into a file, and to capture the standard error stream as well, which can be done like this: octopus &> log . That would create a file called log containing all output including warnings and errors in their context.

### Analyzing the results

After finishing the calculation you will find a series of files in the directory you ran:


% ls
exec inp restart static


For the moment we will ignore the ‘‘‘exec’’’ and ‘‘‘restart’’’ directories and focus on the static/info file, which contains the detailed results of the ground-state calculation. If you open that file, first you will see some parameters of the calculations (that we already got from the output) and then the calculated energies and eigenvalues in Hartrees:



Eigenvalues [H]
#st  Spin   Eigenvalue      Occupation
1   --    -0.233108       1.000000

Energy [H]:
Total       =        -0.44662938
Free        =        -0.44662938
-----------
Ion-ion     =         0.00000000
Eigenvalues =        -0.23310828
Hartree     =         0.28436697
Int[n*v_xc] =        -0.30453467
Exchange    =        -0.19392286
Correlation =        -0.03976595
vanderWaals =         0.00000000
Delta XC    =         0.00000000
Entropy     =         1.38629436
-TS         =        -0.00000000
Photon ex.  =         0.00000000
Kinetic     =         0.41886422
External    =        -0.91617152
Non-local   =         0.00000000
Int[n*v_E]  =         0.00000000



Since by default Octopus does a spin-unpolarized density-functional-theory calculation with the local-density approximation, our results differ from the exact total energy of 0.5 H. Our exchange-correlation functional can be set by the variable XCFunctional, using the set provided by the libxc library.

### Extra

If you want to improve the LDA results, you can try to repeat the calculation with spin-polarization:


SpinComponents = spin_polarized


And if you want to obtain the exact Schödinger equation result (something possible only for very simple systems like this one) you have to remove the self-interaction error (a problem of the LDA). Since we only have one electron the simplest way to do it for this case is to use independent electrons:


TheoryLevel = independent_particles


A more general way would be to include self-interaction correction.