# Performing spin calculations

## Contents |

## Spherical Isolated Atom calculation: adding occupation numbers

A rather common functionality which is desirable is to control at hand the occupation numbers of the Kohn-Sham orbitals.
In BigDFT, this can be done with the `input.occ` file, where `input` is the name of the calculation (which is indeed `input` if the name is not provided). Let us try to see how this can be used.

First of all, let us perform a calculation of the isolated Nitrogen atom. To do this, modify posinp such that only one atom is considered. Clearly, its actual position does not matter. Run a BigDFT calculation, with the same input file as the LDA case of before. This will run the N atom system in a spin-averaged case. However, you should notice several messages in the screen output:

[...] iter: 11, EKS: -9.59768161367023964E+00, gnrm: 8.53E-06, D: -6.22E-11, #FINAL Energies: {Ekin: 6.75086972420E+00, Epot: -9.81662848671E+00, Enl: 9.52375427785E-01, EH: 8.16024083646E+00, EXC: -2.18618662537E+00, EvXC: -2.86212918289E+00}, SCF criterion: 0} Non-Hermiticity of Hamiltonian in the Subspace: 2.04E-31 #Eigenvalues and New Occupation Numbers Orbitals: [ {e: -6.784496257144E-01, f: 2.0000}, # 00001 {e: -2.692693944980E-01, f: 2.0000}, # 00002 {e: -2.436073443985E-01, f: 1.0000}] # 00003 [...] WARNING: odd number of electrons, no closed shell system [...]

## Spin-averaged atom: spherical versus non-spherical run

Since the number of electrons of the Nitrogen atom is odd, the last orbital (the third) is only half occupied. In addition, the configuration is not spherical. Run another run by inserting the follwing information in the `input.occ`
file:

4 1 2. 2 1. 3 1. 4 1.

The first line is the number of orbital you put in the system. Then the association orbital-occupation number are written in the other lines. You migh also put only lines which refer to orbitals which have non-default occupation number (2 in this case). See if the energy lowers: it should. Moreover, the warnings of the previous output are now completed by additional information:

Total Number of Electrons : 5 Spin treatment : Averaged #WARNING: Odd number of electrons, no closed shell system Orbitals Repartition: MPI tasks 0- 3 : 1 MPI tasks 4- 5 : 0 Total Number of Orbitals : 4 Occupation numbers coming from : LDA.occ Input Occupation Numbers: #(4 lines read) - Occupation Numbers: {Orbital No. 1: 2.0000, Orbitals No. 2-4: 1.0000} [...] iter: 10, EKS: -9.62050199128620598E+00, gnrm: 6.56E-06, D: -2.52E-11, #FINAL Energies: {Ekin: 6.77667774178E+00, Epot: -9.88013829899E+00, Enl: 9.53019240562E-01, EH: 8.13688421624E+00, EXC: -2.15797500742E+00, EvXC: -2.82479854902E+00}, SCF criterion: 0} Non-Hermiticity of Hamiltonian in the Subspace: 3.95E-32 #Eigenvalues and New Occupation Numbers Orbitals: [ {e: -6.766112597598E-01, f: 2.0000}, # 00001 {e: -2.657398836110E-01, f: 1.0000}, # 00002 {e: -2.657398836110E-01, f: 1.0000}, # 00003 {e: -2.657390305875E-01, f: 1.0000}] # 00004 [...]

## Perform a spin-polarized calculation: adding a spin

Now you can add the (collinear) spin degree of freedom to the system. Since it is a single atom, Hund's rule implies also a given polarization. According to this, this should generate a up-down collinear polarization of 3 electrons. To control that, create an input file in which `nspin` and `mpol` become respectively 2 (collinear spin treatment) and 3 (difference between up and down polarization).

### Decide the Input Guess polarization

The code will not work immediately, since it will ask for a Input Guess polarization of the system:

Total Number of Electrons 5 Spin-polarized calculation ERROR: Total input polarisation (found 0) must be equal to norbu-norbd. With norb=5 and mpol=3 norbu-norbd=3

In BigDFT, this input polarization might be added by putting the corresponding value for any atom in the `posinp.xyz` file:

1 angstroem free N 0. 0. 0. 3

Then the calculation can run. You can see that the energy is remarkably lower than in the best possible spin-averaged run:

iter: 13, EKS: -9.74400144009337055E+00, gnrm: 5.05E-06, D: -2.03E-11, #FINAL Energies: {Ekin: 7.03926166852E+00, Epot: -1.01605631945E+01, Enl: 9.15644315633E-01, EH: 8.26549243288E+00, EXC: -2.31842478215E+00, EvXC: -3.04557298530E+00}, SCF criterion: 0} Non-Hermiticity of Hamiltonian in the Subspace: 3.14E-31 #Eigenvalues and New Occupation Numbers Total magnetization : 3.000000 Orbitals: [ {e: -7.229029257136E-01, f: 1.0000, s: 1}, {e: -5.515531181504E-01, f: 1.0000, s: -1}, # 00001 {e: -3.104006975241E-01, f: 1.0000, s: 1}, # 00002 {e: -3.104006975241E-01, f: 1.0000, s: 1}, # 00003 {e: -3.103997714676E-01, f: 1.0000, s: 1}] # 00004

**Exercise**: Charge the Nitrogen atom (say, remove one electron) and compare the energies of the system in symmetric spin-averaged configuration with respect to the spin-polarized case.

Hint: The `input.occ` file might also accept fractional number written as actual fractions, e.g. 2/3 instead as 0.666666