# Studying a surface

This lesson was created for an earlier version of BigDFT,
from before the change to the yaml input format.
A new version of the tutorial has not yet been created.
In the meantime, `bigdft-tool` can be used to convert
from the old input file format to the yaml format.

## Contents |

## Surface calculations with an ideal monolayer of water molecules

The purpose of this lesson is to introduce the surface calculation, the output of different scalar field like the local potential and to add an electric field.

### Defining a surface configuration

The boundary conditions are specified in the position
file. No other parameters are necessary to be changed. To do it,
modify the second line of the XYZ `posinp.xyz` file to write the keyword
`surface` like in this example:

3 angstroem surface 3.5 1.0 3.0 O 1.5 0.0 1.5 H 0.7285 0.620919 1.5 H 2.2715 0.620919 1.5

Three floats are required after the `surface`
keyword to define the bounding box in x, y and z direction. In BigDFT, the
direction perpendicular to the surface must be the y direction. The
box size in that one is then irrelevant (ignored by the code).

The example above describes a mono layer of water molecules. This un-realistic example is used to easily illustrate the capability of BigDFT to exactly compute the local potential, even in the case of an internal dipolar moment.

**Exercise**: run BigDFT for the given atomic configuration.

You can get here the other usal files for BigDFT: the input file
`input.dft` and the pseudo-potentials `psppar.O` and `psppar.H`.

The convergence is still good and calculation terminates within 13 iterations. One can notice also the y free direction in the screen output when looking at the Poisson solver output, giving a box dimensions of 40x163x36 in grid spacings.

### Plot the potential values

It is possible to output scalar fields like the different
potentials (Hartree, external (ionic) and local) after the last electronic
convergence. To do this, set the third number of the eleventh line of
`input.dft` to 2:

0 0 2 InputPsiId, output_wf, output_grid

**Exercise**: rerun the previous calculation to give a look
to the local potential. A file `local_potential_avg_y`
will be generated in the `data` directory and contains the projection along the y axis of the
local potential (*i.e.*Hartree plus ionic).

One can see the existence of a dipolar moment due to the displacement between the center of mass of negative charges and positive charges. The plot shows the quality of the Poisson solver calculation introducing no artifact or necessary accordance at boundaries.

### Add an electric field

Thanks to the Green function treatment in the Poisson solver,
we've seen that's it's possible to exactly treat the dipolar moment in
a box, add a charge (*cf.* <a href="H1B_grid_cv.html" target="_blank" >previous
tutorial</a>) but it is also possible to add an electric field. To do
this, set the second value of the fourth line of `input.dft`:

0 0.0 0.010 0.0 charge of the system, Electric field

The unit for the electric field is hartree per bohr and the direction of the field is always the y direction (even for non surface calculations).

**Exercise**: rerun the previous calculation with an
electric field of 0.01Ht/bohr.

The local potential is bent by the field as expected.