# Tutorial:Total energy convergence

In this example, for the methane molecule CH_{4}, we will play a little bit with the spacing and the dimensions of the mesh.

## Input

In the input file we define a variable CH that represents the bond length between the carbon and the hydrogen atoms. From our basic chemistry class we know that methane has a tetrahedral structure. If we put the carbon atom at the origin, the hydrogen atoms have the coordinates given in the following input file.

`CalculationMode`

= gs`Units`

= eV_Angstrom`Radius`

= 3.5`Spacing`

= 0.22 CH = 1.2 %`Coordinates`

"C" | 0 | 0 | 0 "H" | CH/sqrt(3) | CH/sqrt(3) | CH/sqrt(3) "H" | -CH/sqrt(3) |-CH/sqrt(3) | CH/sqrt(3) "H" | CH/sqrt(3) |-CH/sqrt(3) | -CH/sqrt(3) "H" | -CH/sqrt(3) | CH/sqrt(3) | -CH/sqrt(3) %

We start with a bond length of 1.2 Å but that's not so important at the moment, since we can optimize it later (for more information see the tutorial on geometry optimization). (You should not use 5 Å or so, but something slightly bigger than 1 Å is fine.)

Some notes concerning the input file:

- We do not tell Octopus explicitly which
`BoxShape`

to use. The default is a union of spheres centered around each atom. This turns out to be the most economical choice in almost all cases. - We also do not specify the %
`Species`

block. In this way, Octopus will use default pseudopotentials for both Carbon and Hydrogen. This should be OK in many cases, but, as a rule of thumb, you should do careful testing before using any pseudopotential for serious calculations.

## Convergence

If you use the given input file you should find the following values in the resulting `static/info` file.

Eigenvalues [eV] #st Spin Eigenvalue Occupation 1 -- -16.158998 2.000000 2 -- -9.055957 2.000000 3 -- -9.055957 2.000000 4 -- -9.055957 2.000000 Energy [eV]: Total = -218.22140083 Free = -218.22140083 ----------- Ion-ion = 236.08498119 Eigenvalues = -86.65374012 Hartree = 392.31922122 Int[n*v_xc] = -105.19503349 Exchange = -69.53566418 Correlation = -10.99278997 vanderWaals = 0.00000000 Delta XC = 0.00000000 Entropy = 0.00000000 -TS = -0.00000000 Kinetic = 161.00368677 External = -927.09881764 Non-local = -45.09601629

Now the question is whether these values are converged or not. This will depend on the `Spacing`

and the `Radius`

. The only way to answer this question is to try other values for these variables. We will start with the spacing. Since we are interested in the total energy of the system, we will look at the changes of its value. We will keep all entries in the input file fixed except for the spacing that we will make smaller by 0.025 Å all the way down to 0.1 Å. So you have to run Octopus several times (you can use the script from the Nitrogen tutorial) to get the following results.

# Spacing Total Energy 0.25 -218.91210792 0.225 -218.58099678 0.2 -218.30722313 0.175 -218.21194720 0.15 -218.13042356 0.125 -218.14849946 0.1 -218.14533429

If you give these numbers to gnuplot (or other software to plot) you will get a curve like the one shown on the right.

As you can see from this picture, the total energy is converged to within 0.1 eV for a spacing of 0.175 Å. So we will use this spacing for the next calculations, and play with the `Radius`

of the box. We will change the radius in steps of 0.5 Å. Doing this we get

# Radius Total Energy 2.5 -218.00107292 3.0 -218.17888864 3.5 -218.21314725 4.0 -218.21996456 4.5 -218.22132794 5.0 -218.22061906

If we again ask for a convergence up to 0.1 eV we should use a radius of 3.5 Å. How does this compare to the size of the molecule? Can you explain why the energy increases (becomes less negative) when one decreases the size of the box?