# 2. Molecule free energy references

## Background

To calculate the free energy change of a reaction step, we need to calculate molecule reference free energies.
We can use the Computational Hydrogen Electrode (CHE) to get our references for H2 and H+. Following the definition
of the Standard Hydrogen Electrode (SHE), the free energy of a proton electron pair must be equal to that of an H2 molecule at
0 V vs. SHE. 

2(H+ + e-) <=> H2

G(H+ + e-) = (1/2)G(H2) @ 0V vs. SHE

The CHE model then gets the energy of a proton electron pair as:

G(H+ + e-) = (1/2)G(H2) - U(vs SHE)

Where U is the potential referenced to 0V SHE. Because our calculations are grand canonical, we need to subtract
the U*Ne term, which is calculated self-consistently by JDFTx. We then can get the free energy of a proton with:

G(H+) = (1/2)G(H2) - (1/2)mu*2

Where the 2 comes from the 2 electrons in hydrogen. Thus, we can obtain both the H2 and proton reference energies from
one molecule free energy calculation.

## Calculation Setup

We will do two sequential JDFTx runs to optimize the H2 geometry and then perform a vibrations calculation. There are two in files: `in.relax` and `in.vibration`. `in.relax` should look like the molecule calculations you ran in the first unit. `in.vibration` has a new tag,

    vibrations useConstraints no rotationSym yes

which will calculate the hessian, giving us vibrational frequencies in the harmonic approximation. We can use these frequencies to calculate free energies. First run the relax calculation followed by the vibration calculation.

    srun -n 1 --gpus 1 jdftx_gpu -i in.relax | tee out.relax
    srun -n 1 --gpus 1 jdftx_gpu -i in.vibration | tee out.vibration

Look through the `out.vibration` to see the results of the vibrations calculation. Notice that there are several zero modes
before the firt real mode appears. Often, these zero modes are translations and rotations that are not projected out of the hessian, and they can be ignored.
You'll see one real mode at about 4450 cm^-1, which is a slight overestimate of the known H2 bond stretch frequency.

After these calculations finish, open the `FreeEnergy` notebook to go through calculating a free energy reference.


## Further exercises

In our model, we are calculating free energies using gas phase rotational, and translational contributions but using implicit solvent to calculate the DFT energy. Is this appropriate?


