---
# System prepended metadata

title: How to do the macroaverging of ELPT?
tags: [CP2K, Tutorial, TeC]

---

How to do the macroaverging of ELPT?
===

###### tags: `Tutorial` `CP2K`  `TeC`

:::info
- Compute the electrostatic potential (ELPT)
- Average over multiple CUBE files
- Use MACROAVE for the macroaverging

:::

## 1. Compute the electrostatic potential (ELPT)

- You can add the following keyword block in to the CP2K input file:

```bash=
&V_HARTREE_CUBE
    &EACH
        MD 100
    &END
    APPEND
    FILENAME =yoursystem_cube_100
&END

````

:Warning: Note that by convention the potential has opposite sign than the expected physical one. 

## 2. Average over the appended CUBE file

- To do a frame-wise average of the appended CUBE file obtained from the previous section, use the **cube_ave.c** file https://www.dropbox.com/s/8o7l1acfj64mwjz/cube_ave.c?dl=0
- The **cube_ave.c** file must first be compiled by running **gcc cube_ave.c -o cube_ave**.
- By specifying the number of frames and the name of the CUBE file, **cube_ave** will produce an averaged CUBE file called **input.cube**.
- Note that **input.cube** file has already made the sign correction. 


## 3. Use MACROAVE for the macroaverging
* The MACROAVE code can be found here: https://www.dropbox.com/s/tw83ok49dbrzj87/mavroave.zip?dl=0
* You need to compile the source and read the Manual (macroave.pdf).
* An example of TiO<sub>2</sub>-NaCl system at PZC can be found here:
https://www.dropbox.com/s/a8edrvxp3f9agqa/neutral_new.zip?dl=0. It contains **input.cube** generated from the previous section and the input file **macroave.i<span>n** for MACROAVE . 
* After performing the macroaverging analysis, you can compare the planary averaged and macro averaged electrostatic potential profiles. It should look the same as the top panel in the figure **neutral_planar_vs_macro.png**. 

:Warning: Note that the output units from MACROAVE are Volt and Bohr. 
