$$\newcommand{\braketmatrix}[3]{\left \langle #1 \middle \rvert #2 \middle \rvert #3 \right \rangle}$$
# Day 2: "Beyond-DFT" calculations in practice with JDFTx + BGW

## Introduction

This tutorial provides an example of how JDFTx and BerkeleyGW can be combined to calculate GW@DFT electronic structures in vacuum and with solvent screening. BerkeleyGW is needed for this method because JDFTx cannot calculate the necessary dielectric and self-energy matrices. For this tutorial, we will be calculating the HOMO-LUMO values for a H$_2$O molecule in vacuum and in SaLSA implicit solvation (with water as the solvent). We will compare the effect of solvation on the HOMO and LUMO states. 

If you are interested in learning more about the formalism/results from using this feature please see our paper entitled [Impact of solvation on the GW quasiparticle spectra of molecules](https://pubs.aip.org/aip/jap/article/134/8/085001/2907640), which is published in the Journal of Applied Physics. 

We note that this tutorial is only a very brief overview of the capability of BerkeleyGW and the theory behind these calculations. If you are interested in running calculations like this, it is highly recommended to read more about the BerkeleyGW code:

1. [BerkeleyGW website](https://berkeleygw.org/)
2. Jack Deslippe, Georgy Samsonidze, David A. Strubbe, Manish Jain, Marvin L. Cohen, and Steven G. Louie, [BerkeleyGW: A Massively Parallel Computer Package for the Calculation of the Quasiparticle and Optical Properties of Materials and Nanostructures](https://www.sciencedirect.com/science/article/pii/S0010465511003912?via%3Dihub), Comput. Phys. Commun. 183, 1269 (2012) 

and the GW approximation formalism:

<span id="gwreview1">1.</span> Dorothea Golze, Marc Dvorak, Patrick Rinke, [The GW Compendium: A Practical Guide to Theoretical Photoemission Spectroscopy](https://www.frontiersin.org/journals/chemistry/articles/10.3389/fchem.2019.00377/full), Front. Chem. 7:377 (2019)

<span id="gwreview2">2.</span> Lucia Reining, [The GW approximation: content, successes and limitations](https://wires.onlinelibrary.wiley.com/doi/10.1002/wcms.1344), WIREs Comput Mol Sci, 8:e1344 (2017)

for semiconductors and metallic systems, with a particular focus on the correct method for converging GW approximation calculations, as GW calculations require converging a number of inter-related parameters.

## Workflow overview

GW@DFT calculations (GW calculations based off of a DFT starting point) require multiple steps, which are listed below:

1. Calculate DFT charge densities using DFT-relaxed structures. This step is typically run with a limited number of unoccupied bands to save computational expense. This step occurs in the 1-dft/ directories.
2. Calculate the eigenvalues of many additional unoccupied bands starting from the DFT charge density and structure. This step occurs in the 2-wfn/ directories. 
3. (Ignored for vacuum calculation) If running a solvated GW calculation, calculate the fluid polarizability that will be added to the electronic polarizability in 4-epsilon later. This step occurs in the 3-chi/ directory. 
4. Calculate the dielectric matrix using the wavefunction generated in Step 2. If you are running a calculation using the liquid polarizability from Step 3, it is added to the electronic polarizability prior to the calculation of $\epsilon$. This step occurs in the 4-epsilon/ and 4-epsilon+chi/ directories. 
5. Calculate the self-energy and the GW quasiparticle eigenvalues. This occurs in the 5-sigma/ and 5-sigma+chi/ directories. Multiple of these calculations may need to be run if one wishes to reach self-consistency in either G or W.

Here, steps 1, 2, and 3 will be run using JDFTx and steps 4 and 5 will be run using BerkeleyGW.  

In this tutorial, these steps can be performed by running the various executables in the 01-h2o_vacuum/ and 02-h2o_salsa/ directories in numerical order by their prefix (run the script starting with 01_ first, 02_ second, etc.). 

To start, please descend into the 01-h2o_vacuum/ directory. We will first calculate the GW quasiparticle eigenvalues for H$_2$O in vacuum. Once you have completed all 5 of the below Steps, please return to Step 1, navigate to the 02-h2o_salsa/ directory and repeat all steps again, but this time also including the subsections for Steps 4 and 5 for the +chi/ directories. After completing these steps, return to this directory and run the final_compare_eigenvalues.ipynb code. The update_submitfiles.sh utility has been included only for convenience if you need to update all of the module submit.sh files for some reason. You likely won't need to use it. 

## Very brief introduction to the formalism
This is an extremely condensed introduction towards the use of solvent screening in GW calculations. A longer version is located at the end of this document. 

Broadly, GW can be thought of as a dynamically screened version of Hartree-Fock (HF).[$^1$](#gwreview1) We solve Hedin's equations by making several approximations. $\Sigma \approx iGW$ is the namesake approximation for the self-energy, which describes the feedback occurring due to the interactions of a particle with surrounding electrons. This is again in contrast to Hartree-Fock theory, which would use the bare Coulomb interaction instead of W to calculate the HF bare exchange. In the GW formalism, G refers to the one-body Green's function and W the dynamically screened Coulomb interaction. We use the single-particle wavefunctions from DFT as our quasiparticle wavefunctions and iterate to self-consistency in the quasiparticle energies that enter into the G. GW calculations carried out using the DFT vacuum or SaLSA wavefunctions are labeled as GW@GGA or GW@GGA+SaLSA, respectively. 

Many more equations are important, but here are two of the most important related to the incorporation of solvent screening. The self-energy operator $\Sigma$ depends on the screened Coulomb interaction,

\begin{equation}
W_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)
= \epsilon^{-1}_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)
v(\textbf{q}+\textbf{G}'),
\end{equation}

where $v$ is the bare Coulomb interaction, $\epsilon$ is the full-frequency dielectric matrix. Within the random phase approximation $\epsilon$ is given by

\begin{equation}
\epsilon_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)=\delta_{\textbf{G}\textbf{G}'}-v(\textbf{q}+\textbf{G})\chi^0_{\textbf{G}\textbf{G}'}(\textbf{q};\omega).
\end{equation}

Note that this is why RPA and GW are frequently referred to together in "beyond-DFT" discussions. The RPA is typically used in the GW formalism, but also enables one to also use this polarizability to calculate total energies. 

Above, $\chi^0$ is the independent-electron polarizability. To account for solvent screening, we replace $\chi^0$ with $\chi^{solv} = \chi^0 + \chi^{lq}$, where $\chi^{lq}$ is the independent-particle susceptibility of the liquid using an implicit solvation model. This approach is labeled GW@GGA+SaLSA+$\chi^{lq}$ below and we use the nonlocal susceptibility from the SaLSA solvation model. The nonlocality of the SaLSA model leads to $\chi^{lq}_{\textbf{GG}'} \to 0$ as $\textbf{G} \to \infty$, where $\textbf{G}$ are reciprocal-lattice vectors. This allows the liquid susceptibility to be converged with a small plane wave cutoff, in comparison to the $\chi^{lq}_{\textbf{GG}'} \propto \textbf{G}\cdot\textbf{G}'$ of local models, that require additional numerical care in constructing and inverting $\epsilon_{\textbf{GG}'}$. Additionally, the lack of empiricism in the SaLSA model is appealing for an ab-initio approach to solvated beyond-DFT calculations. 

## Step 0 - Open the README.md file and a terminal window

This tutorial will be run using the terminal and a Jupyter notebook. Please keep this README.md preview open and open a new terminal tab that you can use to run code on the terminal command line. These commands can be copied and pasted into the command line and will be formatted like this:

```bash
./XX_example_script.sh
```

Please open the needed .ipynb files by double-clicking on them in the the file navigator to the left. If Jupyter ever needs you to select a kernel due to a restart, please select 'BEAST Python' from the list. All .ipynb should already have this set (which you can see in the top right corner). 

Note that any scripts with the name format XX_run_???.sh submit jobs to the queue. Please do not run these scripts multiple times in a row. If, for some reason, you do need to resubmit a job, please check that the previously submitted job has finished with ```sq``` (the alias of ```squeue -u YOUR_USERNAME``` you should have set earlier from the SETUP document). You can cancel jobs with ```scancel THE_JOB_ID_NUMBER```.

## Step 1 - DFT job

Descend into 1-dft/ in both your terminal (cd 1-dft) and the file navigator to the left. First, let's visualize the structure we are running. Open the 01a_visualize_structure.ipynb jupyter notebook in a new tab. Then, click on the code block and hit "Shift+Enter" to run it. You should see a molecule render (you may need to zoom in or out some). 

Once you are done looking at the molecule, run the following terminal command:
    
```bash
./01b_run_dft.sh
```

Verify that this job has run sucessfully by examining the output file (name: "out"). You should see the usual timing lines printed at the end of the file. Additionally, the total energy close to the end should be: Etot = -17.0233 Ha for vacuum and -17.0300 Ha for SaLSA when you get to it. The input tags used here closely mirror those used in previous JDFTx DFT tutorials. This calculation uses a 20 Ha planewave cutoff. Note that this value is underconverged to allow these calculations run quickly. The correct value will depend on your pseudopotentials. Why is this? Note that the SaLSA run took significantly longer to complete (about 2 minutes) than the vacuum run (or your previous CANDLE runs). 

If the job has run successfully, navigate back up a directory (cd ../) on both your terminal and file navigator to the left. 
    
Navigate back up a directory. 

## Step 2 - JDFTx empty state generation

Now we are ready to set up the JDFTx empty state generation calculation for later use in Steps 4 and 5. Descend into 2-wfn/ and run:

```bash
./02a_setup_wfn.sh
```

This script copies input and output files from Step 1 for reuse. The wavefunction generation calculation is run at fixed DFT charge density. 

Next, run:
    
```bash
./02b_run_wfn.sh
```

to start the job. It will take about 2 minutes to run. While the job is running, note that the input file for this job (name: "in") is very similar to the one in 3-chi/. The only change is for the ```bgw-params``` tag, which now specifies ```nBandsDense 1000```. This input tells JDFTx to generate a wavefunction with 1000 empty bands, rather than the few used in the DFT calculation. 

Verify that this job has run sucessfully by examining the output file (name: "out"). To check that the wavefunction was generated correctly, run:
    
```bash
./02c_analyze_wfn.sh
```
    
This script runs a BerkeleyGW utility that compiles important information in the wavefunction into a human-readable condensed format file called "wfn_info.txt". Open this file and examine some of the information there if you wish. In the K-POINTS section, you should see that 1000 bands are present and you should see the same list of points listed in kgrid.jdft. The ifmax field lists the highest occupied band for each k/q-point, are these results what you would expect for this system? 

Note that another jdft.bgw.vxc.dat file was created during this job. This file is needed for the BerkeleyGW sigma calculation later for GW calculations.

Navigate back up a directory. 

## Step 3 (only for 02-h2o_salsa) - JDFTx liquid chi calculation

Now we are ready to set up the JDFTx calculation of the liquid polarizability file. Descend into 3-chi/ and run:
    
```bash
./03a_setup_chi.sh
```
   
This script copies input and output files from Step 1 for reuse. This is run at fixed DFT charge density to save computational expense. 

Next, run:
 
```bash
./03b_run_chi.sh
```

to start the job. It will take about 90 seconds to run. While the job is running, look at the input file for this job (name: "in") and see what has changed as compared to the "in" file in 1-dft/. The important things to note are:

1. Fewer ```dump``` tags are used because we only need some files printed for BerkeleyGW to read later. 
2. The k-grid tags have changed to not expand the k-grid automatically because we read in kgrid.jdft (the ```include kgrid.jdft``` tag). 
3. We have added a new tag called ```bgw-params```. This tag controls what we print for GW@DFT calculations. Here, we specify that we want the liquid polarizability file using ```EcutChiFluid 2.5``` (note that this cutoff is the same screened cutoff in epsilon.inp and sigma.inp later but in Ha). The subtags starting with ```freq``` here are to ensure that the frequency grid printed in the polarizability file matches the grid used in the epsilon calculation later.

Verify that this job has run sucessfully by examining the output file (name: "out"). You should now see a file named jdft.bgw.chi0Fluid.h5, which contains the solvent polarizability matrix that will be read in during Step 4. 

Navigate back up a directory. 
    
## Step 4 - BerkeleyGW epsilon calculation

Descend into 4-epsilon/ and run:

```bash
./04a_setup_eps.sh
./04b_run_eps.sh
```

to run the job. It will take under 1 minute to finish. You should see that the "Head of Epsilon Inverse" is 1 and "Epsilon Inverse(2,2)" is 9.568E-01 at the end of the "out" file. Coulomb truncation ensures the Head of epsilon is 1. 
    
### BerkeleyGW epsilon input file and job setup

This is a highly abridged introduction to GW using BerkeleyGW. It is highly recommended to read their latest documentation in detail as well.

Open the epsilon.inp file to see the information specified there. Here are some highlights: 
1. ```cell_box_truncation``` truncates the Coulomb interaction in all 3 directions. 
2. The q-point grid is the same as the k-point grid JDFTx uses for all of the previous jobs. BerkeleyGW requires the user to provide an explicit list of k/q-points rather than specifying a grid folding like commonly done in DFT calculations. GW calculations do not necessarily need to be run on the same grid folding as DFT calculations but will for this tutorial. The q-point list here can be found in the 1-scf/jdft.kPts file, with the points shifted to be between 0 and 1. It can also be found in 2-wfn/wfn_info.txt. 
3. cell_box_truncation truncates the Coulomb interaction perpendicular in all three directions, removing the singularity in the Coulomb kernel. Read the main BerkeleyGW for further discussion of this point.
4. The ```epsilon_cutoff tag``` specifies the screened cutoff to use for the polarizability in the job. 
5. The ```epsilon_cutoff``` and ```number_bands``` tags are the two most important convergence criteria tags in these calculations. Like RPA, GW calculations require the inclusion of many unoccupied states. 
6. The frequency tags specify the frequency grid used to calculate the polarizability and other internal tags specific to BerkeleyGW. 

The epsilon job reads in the wavefunction generated in the previous step. However, because this wavefunction is generally dozens or hundreds of gigabytes, we typically create a symbolic link to it to save space. The symbolic links were created by running the ./04a_setup_eps.sh script. If you run ```ls -l``` in the terminal, you will see that the file named "WFN.h5" points to the original wavefunction. 

This job will create the eps0mat.h5 (and epsmat.h5 for more k/q-points beyond the q0 point) file. This file contains the dielectric matrix and will be read in in the following sigma calculation step. 

Navigate back up a directory. 

### (Only for 02-h2o_salsa)

Descend into 4-epsilon+chi/ and run:
    
```bash
./04c_setup_epschi.sh
./04d_run_epschi.sh
```
    
to run the job. It will take under 1 minute to finish. You should see that the "Head of Epsilon Inverse" is 1 and "Epsilon Inverse(2,2)" is 4.625E-01 at the end of the "out" file. Note the presence of a new linked file named chi0mat_add.h5. Run ```ls -l``` to see the file it is linked to. It should be the file discussed in Step 3. 

Navigate back up a directory. 

Run:
    
```bash
./04e_compare_eps_inputfiles.sh
```

to see how the epsilon.inp tags change for each run. These two new tags are the only changes needed in BerkeleyGW to enable reading of the JDFTx liquid polarizability file. 

## Step 5 - BerkeleyGW sigma calculation

Descend into 5-sigma/ and run:
    
```bash
./05a_setup_sigma.sh
./05b_run_sigma.sh
```
    
to run the job. It will take under 1 minute to finish. You should see the eqp1.dat file created with several rows of data. 
    
### BerkeleyGW sigma input file and job setup

This is a highly abridged introduction to GW using BerkeleyGW. It is highly recommended to read their latest documentation in detail as well.

Open the sigma.inp file to see the information specified there. Here are some highlights: 
1. ```cell_box_truncation``` truncates the Coulomb interaction in all 3 directions
2. The ```screened_coulomb_cutoff``` tag specifies the screened cutoff to use in the job and should match the epsilon.inp cutoff. 
3. The ```screened_coulomb_cutoff``` and ```number_bands tags``` are the two most important convergence criteria tags in these calculations. Like RPA, GW calculations require the inclusion of many unoccupied states. 
4. The frequency tags specify the method used to calculate the self-energy and other internal tags specific to BerkeleyGW.
5. ```band_index_min/max``` specify the range (starting index of 1) of bands over which you want to actually calculate the quasiparticle eigenvalues. Increasing this range can greatly increase the cost of the sigma job. We only care about bands near the Fermi level here (and usually), and thus specify a much smaller range than the 500 total requested in the epsilon calculation previously. 

The sigma job reads in the wavefunction generated in the previous step (note the new name!). However, because this wavefunction is generally dozens or hundreds of gigabytes, we typically create a symbolic link to it to save space. The symbolic links were created by running the ./05a_setup_eps.sh script. If you run ```ls -l``` in the terminal, you will see that the file named "WFN_inner.h5" points to the original wavefunction. This job also reads in the eps0mat.h5 (and epsmat.h5 file if present) file. This file is how the solvent polarizability change is passed to the self-energy calculation. The vxc.dat file is linked back to the jdft.bgw.vxc.dat file you already generated in Step 4. 

This job will create the eqp1.dat file (along with several other files we will ignore for now). This file contains the quasiparticle eigenvalues for each k/q-point. Going left-to-right the first 4 columns specify each spin index, band index (matches ```band_index_min/max```), DFT eigenvalue, and GW eigenvalue. 

Navigate back up a directory. 
    
### (Only for 02-h2o_salsa)

Descend into 5-sigma+chi/ and run:
    
```bash
./05c_setup_sigmachi.sh
./05d_run_sigmachi.sh
```
   
to run the job. It will take under 1 minute to finish. You should see the eqp1.dat file created with several rows of data.  

Navigate back up a directory. 

# Final comparisons of the HOMO and LUMO states

Now that you have completed calculating the GW quasiparticle eigenvalues for both a vacuum and solvated H$_2$O molecule, we are finally ready to compare the  methods. Open the final_compare_eigenvalues.ipynb jupyter notebook and run the first code block. This code looks for the 3 "eqp1.dat" files in 01-h2o_vacuum/5-sigma/, 02-h2o_salsa/5-sigma/, and 02-h2o_salsa/5-sigma+chi/ and calculates the HOMO-LUMO gaps. Note that the terms "HOMO" and "LUMO" are a bit ambiguous here due to the planewave approach approach yet use of only a single k/q-point. Despite this, we still use these terms here to make it clearer which specific eigenvalues we are referring to. You should get 8.795 eV as the G0W0@GGA+SaLSA+chi gap. Run the second code block to plot the eigenvalues for each "band" index across all of the methods (here we use the general BerkeleyGW tag nomenclature; these are not truly bands in the traditional sense of molecular orbital theory for solids). Do the occupied and unoccupied states change differently with solvation? GW can also reorder DFT eigenvalues. Bands described poorly by DFT may be most accurately described by coming to self-consistency in both G and W (updating both eigenvalues and underlying wavefunctions). Bands described decently by DFT may be described well-enough by reaching self-consistency only in G by iterating on the quasiparticle eigenvalues. 

The large increase in gap for G0W0@GGA as compared to GGA is very common. GGA DFT functionals infamously underestimate energy gaps. The inclusion of SaLSA implicit solvation also does not typically change gaps drastically at the DFT level. This is expected because the contribution to the electrostatic potential from the solvation model is mostly constant / varies slowly in the spatial region of the solute, and therefore contributes an almost rigid shift in the DFT orbital energies of molecules. G0W0 calculations run using SaLSA DFT wavefunctions only (G0W0@GGA+SaLSA) produces similar results to the G0W0@GGA case. In contrast, incorporating the liquid polarizability into the epsilon calculation (G0W0@GGA+SaLSA+chi) dramatically lowers the predicted gap. This gap lowering is the expected behavior of a molecule moving from vacuum to a solvated state. 

As a final important note, these calculations are fairly underconverged. Doing testing of convergence parameters as per the BerkeleyGW convergence tutorial would be beneficial for the interested user. The experimental range for the first ionization potential (which is the negative of the HOMO energy here) of H$_2$O is 11.1 - 11.5 eV. How does this compare to the value you calculated? The HOMO energy you calculated will decrease quite a bit to approximately -11.2 eV when a more strict planewave cutoff, screened cutoff, and number of bands in the epsilon/sigma calculations are used (see bonus exercises). 

Another example of improvements one could make would be running to self-consistency in both G and W, which can frequently change the final quasiparticle eigenvalues by a non-trivial amount. Self-consistency in W is commonly ignored due to the computational difficulty of updating the wavefunctions. Self-consistency in G however is more common because it only involves repeating the sigma calculations after reading in quasiparticle eigenvalues calculated on the prior iteration. See the BerkeleyGW documentation to see how to do this. 
 
Here are some extra questions to consider or read further about if you are interested:

1. Why might the HOMO and LUMO be affected differently by solvation? See our paper for further discussion on this point. 
2. The number of bands used in these calculations increase as more DFT planewaves are used in the calculation. How do the number of planewaves scale with system size and what does this suggest about GW computational expense? 
3. How might other molecules be affected by solvation screening?

# BONUS EXERCISES

These exercises are intended for more advanced users who have already finished the above material and are comfortable with modifying things in JDFTx/BerkeleyGW and GW convergence in BerkeleyGW. 

Try creating another structure for another molecule such as H$_2$ or CO and rerun the workflow. How do your results compare to H$_2$O? Although it will become more unphysical, for the tutorial you can try lowering the planewave cutoff, screened cutoff, and number of bands if you are trying to run a larger molecule and are seeing (particularly epsilon and sigma) jobs error out due to lack of memory. Alternatively, you can try running on more nodes, say 2, although please be mindful that you are sharing a reservation so do not run more than a couple of these jobs at a time. If you get to this point you might benefit more from learning about GW convergence if you haven't already. 

If you would like additional systems to run to understand convergence better, try actually running some calculations. Copy the 01-h2o_vacuum/1-scf/ directory a few times into newly named directories and increase/decrease the planewave cutoff in the "in" file in increments of 2-5 (warning: don't increase the planewave cutoff above approximately 40 Ha for this tutorial or your jobs will start to slow down dramatically). After running these jobs, run ```grep 'average nbasis' out``` to see the average planewaves across all k-points in the JDFTx "out". Plot these values vs the planewave cutoffs. What is the trend on how this value grows? Note that if you want to see how the planewave cutoff influences the GW results, you will need to rerun all subsequent JDFTx jobs. ***NOTE: Please do not do run 3-chi jobs for solvated GW using elec-cutoff > 20 Ha and EcutChiFluid > 7.5 Ha for any extra H$_2$O solvated GW calculations you run at this workshop on the training accounts. The generated jdft.bgw.chi0Fluid.h5 file grows very quickly with these cutoffs due to all of the needed vacuum space for a molecule in a box. It will be over 100 GB for these settings already and can easily hit 1 TB. This is why we strongly recommend learning GW convergence on the vacuum calculation first!***

Similarly, try copying the 01-h2o_vacuum/4-epsilon/ directory into a new directory and increase the screened cutoff and/or number_bands to larger values. The screened cutoff can be anything value between 0 and the planewave cutoff (in Ryd!), with 20-25 Ryd usually reasonable. The wavefunction in 2-wfn/ was generated using 1000 bands so number_bands can be set to 999 or less). Then, copy 01-h2o_vacuum/5-sigma/ into corresponding new directories and link the new eps0mat.h5 files appropriately so the screened cutoffs match with the epsilon jobs. Run the sigma jobs to get new GW eigenvalues. Plot a particular eigenvalues as a function of the different screened cutoffs to see how it converges. 

You can also increase the number of bands used in the sigma calculations. The number of bands used in epsilon and sigma do not necessarily have to be the same, sigma may or may not be smaller. Try varying some of these to see how the costs change and construct convergence curves that results from changing different parameters (again, see the BerkeleyGW tutorials for extra details). 

Other molecules will be affected by solvent screening differently. Try applying this towards other molecules. Although it will become more unphysical, for the tutorial you can try lowering the planewave cutoff, screened cutoff, and number of bands if you are trying to run a larger molecule and are seeing (particularly epsilon and sigma) jobs error out due to lack of memory. Alternatively, you can try running on more nodes, say 2 to 4. 

## Longer introduction to the formalism
The GW approach solves the Dyson equation for the quasiparticle (QP) energies and wavefunctions (using Hartree atomic units),

\begin{equation}
\left[
-\frac{\nabla^2}{2} + V_{ion}+V_{H}+\Sigma(E_{nk}^{\text{QP}})
\right]
\psi_{nk}^{\text{QP}} = E_{nk}^{\text{QP}}\psi_{nk}^{\text{QP}},
\end{equation}

where $\nabla$ is the kinetic energy operator, $V_{ion}$ is the ionic potential, $V_H$ is the Hartree potential, $\Sigma$ is the nonlocal, energy-dependent self energy within the GW approximation, and E$_{nk}^{\text{QP}}$ and $\psi_{nk}^{\text{QP}}$ are the quasiparticle energies and wavefunctions, respectively. In the GW formalism, G refers to the one-body Green's function and W the dynamically screened Coulomb interaction. We use the single-particle wavefunctions from DFT as our quasiparticle wavefunctions (the diagonal approximation) and iterate to self-consistency in the quasiparticle energies that enter into the Green's function G in the GW approximation. GW calculations carried out using the DFT vacuum or SaLSA wavefunctions are labeled as GW@GGA or GW@GGA+SaLSA, respectively. 

The self-energy operator $\Sigma$ depends on the screened Coulomb interaction,

\begin{equation}
W_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)
= \epsilon^{-1}_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)
v(\textbf{q}+\textbf{G}'),
\end{equation}

where $v$ is the bare Coulomb interaction, $\epsilon$ is the full-frequency dielectric matrix. Within the random phase approximation $\epsilon$ is given by

\begin{equation}
\epsilon_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)=\delta_{\textbf{G}\textbf{G}'}-v(\textbf{q}+\textbf{G})\chi^0_{\textbf{G}\textbf{G}'}(\textbf{q};\omega).
\end{equation}

Above, $\chi^0$ is the independent-electron polarizability, written in the plane-wave basis as

\begin{equation}
\chi^0_{\textbf{G}\textbf{G}'}(\textbf{q};\omega) = 
\sum_{\scriptsize\begin{array}{c}
n~\text{occ.}\\
n'~\text{emp.}
\end{array}} \sum_{\textbf{k}}
\frac{2
M^{*}_{nn'}(\textbf{k},\textbf{q},\textbf{G}) 
M_{nn'}(\textbf{k},\textbf{q},\textbf{G}')
}{
\varepsilon_{n\textbf{k}+\textbf{q}} - \varepsilon_{n'\textbf{k}}
\pm\omega + i\delta
}
\end{equation}

with the matrix elements M defined by

\begin{equation}
M_{nn'}(\textbf{k},\textbf{q},\textbf{G})
\equiv
\braketmatrix{\psi_{n\textbf{k}+\textbf{q}}}{e^{i(\textbf{q}+\textbf{G})\cdot \textbf{r}}}{\psi_{n'\textbf{k}}}.
\end{equation}

Here, $\textbf{q}$ is a vector in the first Brillouin zone, $\textbf{G}$ and $\textbf{G}'$ are reciprocal-lattice vectors, $\omega$ is frequency, $\delta$ is an infinitesimal that locates the poles of $\chi_0$ relative to the real frequency axis, $\psi_{n\textbf{k}}$ and $\varepsilon_{n\textbf{k}}$ are the Kohn-Sham orbitals and energies from the DFT starting point, and $n$ and $n'$ count occupied and empty bands, respectively. 

To account for solvent screening, we replace $\chi^0$ in the equation for $\epsilon_{\textbf{G}\textbf{G}'}(\textbf{q};\omega)$ with $\chi^{solv} = \chi^0 + \chi^{lq}$, where $\chi^{lq}$ is the independent-particle susceptibility of the liquid using an implicit solvation model. This approach is labeled GW@GGA+SaLSA+$\chi^{lq}$ below. Note that $\chi^{lq}$ is also a response to the total Coulomb potential, analogous to $\chi^0$ for the electrons, which is necessary for this additivity.

Here, we use the nonlocal susceptibility from the SaLSA solvation model,

\begin{multline}
\chi_{\textbf{GG}'}^{lq}(\textbf{q};\omega)
= - \frac{\tilde{N}_0(\textbf{G} - \textbf{G}')}{4\pi T}
\sum_{lm}
C^l_{rot}(\omega)
P_l(\textbf{g}\cdot\textbf{g}')
\tilde{\rho}^{lm}_{mol}(\textbf{g})
\tilde{\rho}^{lm\ast}_{mol}(\textbf{g}')
-\sum_\alpha
\tilde{N}^0_\alpha(\textbf{G} - \textbf{G}')
C_{pol}(\omega)
\chi_\alpha
\textbf{g}\cdot\textbf{g}'
\tilde{w}_\alpha(\textbf{g}) \tilde{w}^{\ast}_\alpha(\textbf{g}'),
\end{multline}

where $\textbf{g} = \textbf{q}+\textbf{G}$ and $\textbf{g}' = \textbf{q}+\textbf{G}'$. The first term captures the rotational response of solvent molecules with density $N_0(\textbf{r})$ ($\tilde{N}_0$ is its Fourier transform) at temperature $T$, with $\rho_{mol}^{lm}$ being the charge density distribution of a solvent molecule projected to each spherical harmonic component indexed by $l, m$. The second term captures the electronic polarization response of solvent molecules from atomic sites with densities $N^0_\alpha(\vec{r})$, each with susceptibilities of strength $\chi_\alpha$ and non-local weight function $w_\alpha(\textbf{r})$. All the above parameters are extracted from DFT calculations of solvent molecules, while the correlation strength functions $C_{rot}(\omega)$ and $C_{pol}(\omega)$ are constrained by the experimental rotational and electronic dielectric response of the solvent. See [the paper describing SaLSA](http://dx.doi.org/10.1063/1.4906828) for its derivation and complete parameterization.

We will just emphasize here that the nonlocality of the SaLSA model leads to $\chi^{lq}_{\textbf{GG}'} \to 0$ as $\textbf{G} \to \infty$ because the nonlocal weight functions $\tilde{\rho}^{lm}_{mol}(\textbf{G})$ and $\tilde{w}_\alpha(\textbf{G}) \to 0$ as $\textbf{G} \to \infty$. This allows the liquid susceptibility to be converged with a small plane wave cutoff, in comparison to the $\chi^{lq}_{\textbf{GG}'} \propto \textbf{G}\cdot\textbf{G}'$ of local models, that require additional numerical care in constructing and inverting $\epsilon_{\textbf{GG}'}$. Additionally, the lack of empiricism in the SaLSA model is appealing for an ab-initio approach to solvated beyond-DFT calculations. 

