# 3. Solvated hydronium ion

Now let's switch to a charged system: a hydronium ion in solvent.
We'll put the complete input file again here in `in`.

Compared to the previous examples, we of course have a new ionic geometry for the ion.
Note that `elec-initial-charge` specifies a charge of -1 electrons (note sign convention) for removing an electron.
Through the calculation, this charge will stay fixed (we will discuss automatically adjusting charge in the next session).

To illustrate alternate algorithms available, this example uses [electronic-SCF](http://jdftx.org/CommandElectronicScf.html):

    electronic-SCF \
        mixedVariable Potential \
        energyDiffThreshold 1E-7

which replaces the default variational minimize algorithm we used till now,
specified by the [electronic-minimize](http://jdftx.org/CommandElectronicMinimize.html).
Of the many flags to control this algorithm (see the documentation linked above),
we are asking that the electron potential be mixed (instead of the default of electron density mixing)
and to stop at 1E-7 Hartree change between steps (instead of the default of 1E-8).

All the fluid commands are the same as before.
Note that the electrolyte is much more important for charged systems,
as it produces a counter-charge that neutralizes each unit cell.
This is critical for meaningful energies from periodic calculations.
(Strictly speaking, this is not as important when using coulomb truncation,
but still highly recommended.)

## Run the calculation

As before, start an interactive session:

    beast-interactive

run:

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

and end the interactive session (`Ctrl+D`).

This time, you will see lines starting with `SCF:` instead of `ElecMinimize:`,
due to the different algorithm chosen.
The fluid steps between electronic steps and the outer structure of ionic minimization are the same.

The [website version of this tutorial](http://jdftx.org/SolvationIon.html)
compares the solvation energies of H<sub>3</sub>O<super>+</super> and OH<super>-</super>
in various solvation models.
Here, let's instead compare the solvated H<sub>3</sub>O<super>+</super> and H<sub>2</sub>O energies:

    listEnergy ../*_sol/out

yields:

    -17.280982853391535 ../2_H2O_sol/out
    -17.705499617837262 ../3_H3O_sol/out

The difference between H<sub>3</sub>O<super>+</super> and H<sub>2</sub>O energies
is -0.4245 $E_h$ = -266.4 kcal/mol.
Note that these two calculations are isoelectronic, and this difference
corresponds to bringing in a proton from isolation into the solution.
Therefore, this difference is the <i>proton solvation energy</i>,
which agrees very well with the agreed-upon experimental reference
of -265.9 kcal/mol.
[[J. Phys. Chem. B 2006, 110, 16066-16081](https://doi.org/10.1021/jp063552y)].
Note that this performance for ion solvation energies is unique to the CANDLE solvation model.



## Visualization

Open the `Visualize.ipynb` in this directory to visualize the bound charges of the hydronium ion.

## Further exercises

1. Examine the accuracy of other solvation models. As an exercise repeat the hydronium calculations with linear and nonlinear GLSSA13 (=VASPsol), SCCS and SaLSA as outlined in the further exercises sections of the previous tutorial. How much do the solvation energies vary between models for the ion? Which is the most accurate?

2. Set up and run the solvated calculation for an OH- ion. Make sure to set the charge in the input appropriately. Visualize the bound charge and compare to H3O+. You may use the following coordinates:

    #Save the following to OH-.ionpos
    ion O   0.00 0.00 0.00  0
    ion H   0.00 0.00 1.84  1

3. Use the energies of water, H3O+ and OH- to compute the water dissociation constant pKw
(see the [website version of this tutorial](http://jdftx.org/SolvationIon.html) for more details).

4. Calculate the pKw obtained using other solvation models and compare their accuracy.