# 1. Pt surface with no solvent or applied bias

Start by contrasting the input file `in` with those of the previous session.
We have a 3-layer Pt(111) slab with a vacuum gap, which has a hexagonal unit cell.
The third direction is arbitrary, but we set it such that there is sufficient room for the 
electronic wavefunctions to decay to zero and not interact with the periodic image in that direction.
The long-range Coulomb interactions are truncated, but this time only in the third direction, as specified by:

    coulomb-interaction Slab 001
    coulomb-truncation-embed 0 0 0.5

The 001 indicates that the third direction is truncated (001 of the hexagonal unit cell, not the bulk fcc cell).
Generating such surface structures can be done using tools like ASE and pymatgen,
or if you want to understand it better at first, by hand as discussed at length
in the [JDFTx website tutorials](http://jdftx.org/MetalSurfaces.html).

We specify the exchange-correlation functional (PBE) explicitly this time (just for clarity).
In addition, we use DFT-D3 dispersion corrections since we are dealing with adsorption.

Our Brillouin zone sampling requires a k-mesh only in the periodic directions,
so is 8 x 8 x 1, instead of the 8 x 8 x 8 we had for the bulk case.
The smearing to sample the Fermi surface remains the same as for the bulk metal.
We optimize electronically and ionically, and ask for outputs at each geometry step:

    dump Ionic Ecomponents EigStats Forces IonicPositions

which include energy components in a separate file, eigenvalue statistics,
forces and ionic positions.
(This is a vacuum calculation still, with no solvation or applied bias.)


## Run the calculation

Start an interactive session (if not already in one):

    beast-interactive

and run the code as:

    srun -n 4 --gpus 4 jdftx_gpu -i in | tee out

This uses 4 MPI processes with one GPU each as before.
If you examine the output, we have `nStates = 10` and we could have run this efficiently till upto 10 MPI processes, which would have needed an allocation of three nodes on Perlmutter.

This should run for about 20 s, and you can keep the interactive session running for the next tutorial,
or quit it (`Ctrl+D`) and start it again then.

Note that the output log is structured exactly as for the ionic minimization runs for the molecules in the previous session.


## Analysis

We can get the total energy and its components from `jdftx.Ecomponents` in addition to the log file.
The single total energy by itself is not particularly useful, but we'll analyze differences in the next activity.

Looking at `jdftx.eigStats`, we can see that the absolute Fermi level mu is at -0.207 $E_h$.
This absolute mu is sensible because we used Coulomb truncation,
and the amount by which this is below the vacuum level far away at 0
is the work function of the Pt(111) slab by definition.
The HOMO and LUMO are really close to mu, with the tiny gap for this metallic system just being an artifact of the finite k-mesh.

Note in the FillingsUpdate lines in `out`, that the number of electrons stays fixed at the neutral value of 48. (See if you can find where this is stated in the output file.)
Here, mu was selected to keep the system neutral, since this is the standard canonical ensemble.


## Visualization

Open Visualize.ipynb using the file browser to examine the structure of the slab.


## Further exercises

Using ASE, pymatgen, or by hand:
+ Construct a 2x2 supercell in the periodic directions and compute the energy and work function.
+ Construct slabs with 5 and 7 atomic layers: converge the work function and energy with the number of layers.

After completing all four tutorials in this session return here to compute the gas phase H adsorption energy on some of the structures you have built. Specifically:
+ The 1x1 Pt slab (this is the adsorption energy at 100% coverage)
+ The 2x2 Pt slab (this is the adsorption energy at 25% coverage)
Note that you will need to compute and reference to 1/2G(H2) instead of G(H+).
How do these adsorption energies compare to literature? How do these compare to your aqueous phase calculations?