Skip to content

Commit

Permalink
new documentaion
Browse files Browse the repository at this point in the history
  • Loading branch information
mts87985 committed May 6, 2021
1 parent aba2010 commit 86b0eba
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require other packages.
* Python 3
* `Matplotlib <https://matplotlib.org/>`_ (only required for interactive plotting features).
* `Atomic Simulation Environment <https://wiki.fysik.dtu.dk/ase/>`_ (only required for reading Gaussian cube files and for atom centred averaging).
* `Pandas <https://pandas.pydata.org/>`_ (can speed up I/O of files significantly).
* `Pandas <https://pandas.pydata.org/>`_ (can speed up I/O of files significantly; version 1.2.0 or greater).

Installation
------------
Expand Down
Binary file added docs/source/images/hj-offset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/hj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 65 additions & 1 deletion docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Planar averaging of a potential
-------------------------------

This example is for plotting the planar average of a potential along a vector (here it is z). The only variables which need to be set are in the first three lines.
Note ``LOCPOT`` file is just a regular ``VASP`` grid file.
Note ``LOCPOT`` file is just a regular ``VASP`` grid file. You can find a ``Jupyter`` notebook of this tutorian in the main repository under
``tutorials/Slab/SlabCalculation.ipynb``

Here ``lattice_vector`` is the length of a repeat unit in the direction
of the averaging, it is used to calculate the macroscopic average.
Expand Down Expand Up @@ -48,9 +49,72 @@ Finally we get planar and macroscopic averages and save and plot these.
np.savetxt(planar_file, planar)
np.savetxt(macroscopic_file, macro)
Heterojunction offset
---------------------

This example gets the potential offset at a heterojunction interface. You can find a ``Jupyter`` notebook of this tutorian in the main repository under
``tutorials/HeteroJunction/HeteroJunction.ipynb``. Note that this tutorial uses the ``LOCPOT`` in the ``HeteroJunction`` directory of ``tutorials``.

.. image:: images/hj.png
:width: 700
:alt: Alternative text

Here ``lattice_vector`` is the length of a repeat unit in the direction
of the averaging, it is used to calculate the macroscopic average.

.. code:: python
import os
import macrodensity as md
import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
input_file = 'LOCPOT'
lattice_vector = 3.6
output_file = 'planar.dat'
vasp_pot, NGX, NGY, NGZ, Lattice = md.read_vasp_density(input_file)
vector_a,vector_b,vector_c,av,bv,cv = md.matrix_2_abc(Lattice)
resolution_x = vector_a/NGX
resolution_y = vector_b/NGY
resolution_z = vector_c/NGZ
grid_pot, electrons = md.density_2_grid(vasp_pot,NGX,NGY,NGZ)
## POTENTIAL
planar = md.planar_average(grid_pot, NGX, NGY, NGZ)
## MACROSCOPIC AVERAGE
macro = md.macroscopic_average(planar, lattice_vector/2, resolution_z)
We can now plot the results:

.. code:: python
fig, ax1 = plt.subplots(1, 1, sharex=True)
textsize = 22
mpl.rcParams['xtick.labelsize'] = textsize
mpl.rcParams['ytick.labelsize'] = textsize
mpl.rcParams['figure.figsize'] = (15, 8)
ax1.plot(planar,label="Planar",lw=3)
ax1.plot(macro,label="Macroscopic",lw=3)
ax1.set_ylabel('V/V', fontsize=22)
ax1.set_xlabel('Grid position', fontsize=22)
ax1.set_xlim(0,len(planar))
ax1.set_facecolor((0.95,0.95,0.95))
ax1.grid(True)
ax1.legend(fontsize=22)
plt.show()
.. image:: images/hj-offset.png
:width: 700
:alt: Alternative text



Expand Down

0 comments on commit 86b0eba

Please sign in to comment.