|
| 1 | +# Documentation |
| 2 | + |
| 3 | +## Install |
| 4 | + |
| 5 | +To install this package, you need a running Python 3 installation (Python >= 3.10 recommended), and |
| 6 | + |
| 7 | +```bash |
| 8 | +pip3 install git+https://github.com/pierre-24/phonopy-vibspec.git |
| 9 | +``` |
| 10 | + |
| 11 | +Note: as this script install programs, you might need to add their location (such as `$HOME/.local/bin`, if you use `--user`) to your `$PATH`, if any. |
| 12 | + |
| 13 | +## Theory |
| 14 | + |
| 15 | +For an intro to phonon calculations, see [the VASP documentation](https://www.vasp.at/wiki/index.php/Phonons:_Theory). |
| 16 | + |
| 17 | +Long story short, in order to get a spectra, one needs to: |
| 18 | + |
| 19 | +1. Compute the dynamic matrix (also called mass-weighted hessian) and diagonalize it, which will provide the frequencies and modes, and |
| 20 | +2. Compute the Born charge in order to compute the IR intensities and/or their derivatives to get the Raman intensities. |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +### Frequencies and normal modes |
| 25 | + |
| 26 | +To get the force constant, you need to use [`Phonopy`](https://phonopy.github.io/phonopy/index.html) (which is installed since it is a dependency of this package) as usual. |
| 27 | + |
| 28 | +On the one hand, if you can use [DFPT](https://phonopy.github.io/phonopy/vasp-dfpt.html#vasp-dfpt-interface) (which is recommended), the procedure is the following: |
| 29 | + |
| 30 | +```bash |
| 31 | +# 1. Create POSCAR of supercell: |
| 32 | +phonopy -d --dim="1 1 1" -c unitcell.vasp |
| 33 | +# Note: use preferentially a larger cell! |
| 34 | + |
| 35 | +# 2. cleanup |
| 36 | +rm POSCAR-* |
| 37 | +mv SPOSCAR POSCAR |
| 38 | + |
| 39 | +# 3. Run VASP using `IBRION` (see below) |
| 40 | +vasp_std |
| 41 | + |
| 42 | +# 4. Extract force constants (a `force_constants.hdf5` file is created) |
| 43 | +phonopy --hdf5 --fc vasprun.xml |
| 44 | +``` |
| 45 | + |
| 46 | +For step 3, the [`IBRION`](https://www.vasp.at/wiki/index.php/IBRION) keyword should be set to 5, 6, 7, or 8 (more info [there](https://www.vasp.at/wiki/index.php/IBRION#Computing_the_phonon_modes)). |
| 47 | +When using numerical differentiation (`IBRION=5` or `IBRION=6`), convergence criterion should be stricter. |
| 48 | +For example: |
| 49 | + |
| 50 | +```text |
| 51 | +IBRION = 6 ! numerical differentiation, using symmetry |
| 52 | +NFREE = 2 ! central differences for the force, should be 2 or 4 |
| 53 | +POTIM = 0.015 ! displacement, default is 0.015 |
| 54 | +EDIFF = 1.0e-08 ! stricter criterion for energy convergence |
| 55 | +PREC = Accurate ! increase precision |
| 56 | +``` |
| 57 | + |
| 58 | +You might also want to increase [`NELM`](https://www.vasp.at/wiki/index.php/NELM) since `EDIFF` is increased. |
| 59 | + |
| 60 | +On the other hand, (see [there](https://phonopy.github.io/phonopy/vasp.html)): |
| 61 | + |
| 62 | +```bash |
| 63 | +# 1. Create POSCAR of supercell: |
| 64 | +phonopy -d --dim="1 1 1" -c unitcell.vasp |
| 65 | +# Note: use preferentially a larger cell |
| 66 | + |
| 67 | +# 2. Create folders for calculations |
| 68 | +for i in POSCAR-*; do a=${i/POSCAR/disp}; mkdir -p $a; mv $i ${a}/POSCAR; done; |
| 69 | + |
| 70 | +# 3. Run VASP using `IBRION=-1` (see below) |
| 71 | +vasp_std |
| 72 | + |
| 73 | +# 4. Extract force sets |
| 74 | +phonopy -f disp-*/vasprun.xml |
| 75 | + |
| 76 | +# 5. Compute force constants (a `force_constants.hdf5` file is created) |
| 77 | +phonopy --writefc-format HDF5 --writefc |
| 78 | +``` |
| 79 | + |
| 80 | +Again, for step 3, you need to set: |
| 81 | + |
| 82 | +```text |
| 83 | +EDIFF = 1.0e-08 ! stricter criterion for energy convergence |
| 84 | +PREC = Accurate ! increase precision |
| 85 | +``` |
| 86 | + |
| 87 | +### Visualisation and interpretation of the normal modes |
| 88 | + |
| 89 | +If you want, you can then create files to visualize the modes in [VESTA](http://jp-minerals.org/vesta/en/): |
| 90 | + |
| 91 | +```bash |
| 92 | +phonopy-vs-modes --modes="4 5 6" |
| 93 | +``` |
| 94 | + |
| 95 | +A `modexxx.vesta` is created per mode. |
| 96 | + |
| 97 | +Furthermore, a partial analysis of normal modes is available: it estimates the percentage of translation, rotation, and vibration of normal modes. |
| 98 | + |
| 99 | +```bash |
| 100 | +phonopy-vs-analyze-modes |
| 101 | +``` |
| 102 | + |
| 103 | +However, to determine the rotation, the program needs a center of rotation. |
| 104 | +By default, it is taken as the center of mass. You can manually set it with `-C`, *e.g.* `-C ".5 .5 .5"` for the center of the cell (this center is to be given in **fractional coordinates**). |
| 105 | +It is also possible to "unwrap" the cell (i.e., move atoms close together), which gives better results for single molecules. |
| 106 | + |
| 107 | +**Note:** negative vibrational contributions are sometimes reported. Keep in mind that this is an estimate. |
| 108 | + |
| 109 | +### Infrared spectrum |
| 110 | + |
| 111 | +After obtaining the dynamic matrix, the frequencies and corresponding mode, you then need to run another calculation in order to compute the born effective charges and extract them using [a utility](https://phonopy.github.io/phonopy/auxiliary-tools.html#phonopy-vasp-born) provided by Phonopy: |
| 112 | + |
| 113 | +```bash |
| 114 | +# 1. Run a calculation with `LEPSILON = .TRUE.` **on the unit cell** |
| 115 | +vasp_std |
| 116 | + |
| 117 | +# 2. Extract Born effective charges from calculations (a `BORN` file is created) |
| 118 | +phonopy-vasp-born vasprun.xml > BORN |
| 119 | +``` |
| 120 | + |
| 121 | +For step 1, the `INCAR` file should use the following parameters (again, to ensure precision): |
| 122 | + |
| 123 | +```text |
| 124 | +LEPSILON = .TRUE. ! Compute dielectric matrix |
| 125 | +PREC = Accurate |
| 126 | +EDIFF = 1.0e-08 |
| 127 | +``` |
| 128 | + |
| 129 | +Then, you can create an IR spectrum: |
| 130 | + |
| 131 | +```bash |
| 132 | +# 3. Get IR spectrum |
| 133 | +phonopy-vs-ir -b BORN spectrum.csv |
| 134 | +``` |
| 135 | + |
| 136 | +The `-b` option controls the location of the `BORN` file |
| 137 | + |
| 138 | +The output CSV file contains two sections: |
| 139 | + |
| 140 | +1. a list of each normal mode, its irreducible representation, and their IR activity, and |
| 141 | +2. a spectrum. |
| 142 | + |
| 143 | +You can control the latter using different command line options: |
| 144 | + |
| 145 | ++ `--limit 200:2000`, which create a graph between 200 and 2000 cm⁻¹; |
| 146 | ++ `--each=1`, the interval between each point (in cm⁻¹); |
| 147 | ++ `--linewidth=5`, the linewidth of the Lorentzian (in cm⁻¹); |
| 148 | + |
| 149 | +It is also possible to compute spectra at other `q` points in the Brillouin zone: |
| 150 | + |
| 151 | +```bash |
| 152 | +phonopy-vs-ir -q="0.5 0 0" spectrum_0.5.csv |
| 153 | +``` |
| 154 | + |
| 155 | +Note that Phonopy is generally not able to assign symmetry labels in that case. |
| 156 | + |
| 157 | +## Raman spectrum |
| 158 | + |
| 159 | +The procedure is more complex, since one needs the derivatives of the BORN charge with respect to polarizability (*i.e.*, the polarizability): |
| 160 | + |
| 161 | +```bash |
| 162 | +# 1. Get displaced geometries |
| 163 | +phonopy-vs-prepare-raman |
| 164 | + |
| 165 | +# 2. Create folders for calculations |
| 166 | +for i in dielec-*.vasp; do a=$(i%.vasp); mkdir -p $a; cd $a; ln -s ../$i POSCAR; cd ..; done; |
| 167 | + |
| 168 | +# 3. Run calculations with `LEPSILON = .TRUE.` for each displaced geometry |
| 169 | +for i in dielec-*; do cd $i; vasp_std; cd ..; done |
| 170 | + |
| 171 | +# 4. Collect dielectric constants |
| 172 | +phonopy-vs-gather-raman dielec-*/vasprun.xml |
| 173 | + |
| 174 | +# 4. Get Raman spectrum |
| 175 | +phonopy-vs-raman spectrum.csv |
| 176 | +``` |
| 177 | + |
| 178 | +The resulting output contains the same sections as with IR (except it gives raman activities), and can be controlled using the same command line options. |
| 179 | + |
| 180 | +## Contribute |
| 181 | + |
| 182 | +Contributions, either with [issues](https://github.com/pierre-24/phonopy-vibspec/issues) or [pull requests](https://github.com/pierre-24/phonopy-vibspec/pulls) are welcomed. |
| 183 | + |
| 184 | +### Install |
| 185 | + |
| 186 | +If you want to contribute, this is the usual deal: |
| 187 | +start by [forking](https://guides.github.com/activities/forking/), then clone your fork and use the following install procedures instead. |
| 188 | + |
| 189 | +```bash |
| 190 | +cd phonopy-vibspec |
| 191 | + |
| 192 | +# definitely recommended in this case: use a virtualenv! |
| 193 | +python -m venv virtualenv |
| 194 | +source venv/bin/activate |
| 195 | + |
| 196 | +# install also dev dependencies |
| 197 | +make install |
| 198 | +``` |
| 199 | + |
| 200 | +### Tips to contribute |
| 201 | + |
| 202 | ++ A good place to start is the [list of issues](https://github.com/pierre-24/phonopy-vibspec/issues). |
| 203 | + In fact, it is easier if you start by filling an issue, and if you want to work on it, says so there, so that everyone knows that the issue is handled. |
| 204 | + |
| 205 | ++ Don't forget to work on a separate branch. |
| 206 | + Since this project follows the [git flow](http://nvie.com/posts/a-successful-git-branching-model/), you should base your branch on `main`, not work in it directly: |
| 207 | + |
| 208 | + ```bash |
| 209 | + git checkout -b new_branch origin/main |
| 210 | + ``` |
| 211 | + |
| 212 | ++ Don't forget to regularly run the linting and tests: |
| 213 | +
|
| 214 | + ```bash |
| 215 | + make lint |
| 216 | + make test |
| 217 | + ``` |
| 218 | + |
| 219 | + Indeed, the code follows the [PEP-8 style recommendations](http://legacy.python.org/dev/peps/pep-0008/), checked by [`flake8`](https://flake8.pycqa.org/en/latest/). |
| 220 | + Having an extensive test suite is also a good idea to prevent regressions. |
| 221 | +
|
| 222 | ++ Pull requests should be unitary, and include unit test(s) and documentation if needed. |
| 223 | + The test suite and lint must succeed for the merge request to be accepted. |
| 224 | +
|
| 225 | +## Who? |
| 226 | +
|
| 227 | +My name is [Pierre Beaujean](https://pierrebeaujean.net), and I have a Ph.D. in quantum chemistry from the [University of Namur](https://unamur.be) (Belgium). |
| 228 | +I'm the main (and only) developer of this project, used in our lab. |
| 229 | +I use this in the frame of my post-doctoral research in order to study batteries and solid electrolyte interphrase, and I developed this project to ease my life. |
| 230 | + |
| 231 | +Note: due to my (quantum) chemistry background, we may speak of similar things using a different vocabulary. |
0 commit comments