Skip to content

Commit

Permalink
New documentation structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst committed May 30, 2020
1 parent 0442f55 commit d0b2f25
Show file tree
Hide file tree
Showing 30 changed files with 1,085 additions and 986 deletions.
99 changes: 15 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Density-functional toolkit

| **Documentation** | **Build Status** | |
|:------------------------------------------------------- |:------------------------------------------------------ |:-------------------------------------------------------- |
| [![][docs-img]][docs-url] [![][gitter-img]][gitter-url] | [![][travis-img]][travis-url] [![][cov-img]][cov-url] | [![][license-img]][license-url] [![][doi-img]][doi-url] |
| **Documentation** | **Build Status** | **License** |
|:------------------------------------------------------- |:------------------------------------------------------ |:-------------------------------- |
| [![][docs-img]][docs-url] [![][gitter-img]][gitter-url] | [![][travis-img]][travis-url] [![][cov-img]][cov-url] | [![][license-img]][license-url] |

[docs-img]: https://img.shields.io/badge/docs-dev-blue.svg
[docs-url]: https://juliamolsim.github.io/DFTK.jl/dev
Expand All @@ -18,106 +18,37 @@
[cov-img]: https://coveralls.io/repos/JuliaMolSim/DFTK.jl/badge.svg?branch=master&service=github
[cov-url]: https://coveralls.io/github/JuliaMolSim/DFTK.jl?branch=master

[doi-img]: https://zenodo.org/badge/181734238.svg
[doi-url]: https://zenodo.org/badge/latestdoi/181734238

[license-img]: https://img.shields.io/github/license/JuliaMolSim/DFTK.jl.svg?maxAge=2592000
[license-url]: https://github.com/JuliaMolSim/DFTK.jl/blob/master/LICENSE

The density-functional toolkit, **DFTK** for short, is a library of
Julia routines for experimentation with plane-wave-based
Julia routines for experimentation with plane-wave
density-functional theory (DFT), as implemented in much larger
production codes such as [Abinit](https://www.abinit.org/),
[Quantum Espresso](http://quantum-espresso.org/) and
[VASP](https://www.vasp.at/). The main
aim at the moment is to provide a platform to facilitate numerical
analysis of algorithms and techniques related to DFT. For this we want
to leverage as much of the existing developments in plane-wave DFT and
the related ecosystems of Julia python or C codes as possible.

## Features
The library is at an early stage but we do already support a sizeable
set of features. An overview:

* Methods and models:
- Kohn-Sham-like models, with an emphasis on flexibility: compose your own model,
from Cohen-Bergstresser linear eigenvalue equations to Gross-Pitaevskii equations
and sophisticated LDA/GGA functionals (any functional from the
[libxc](https://tddft.org/programs/libxc/) library)
- Analytic potentials or Godecker norm-conserving pseudopotentials (GTH, HGH)
- Brillouin zone symmetry for k-Point sampling using [spglib](https://atztogo.github.io/spglib/)
- Smearing functions for metals
- Self-consistent field approaches: Damping, Kerker mixing, Anderson/Pulay/DIIS mixing,
interface to [NLsolve.jl](https://github.com/JuliaNLSolvers/NLsolve.jl)
- Direct minimization using [Optim.jl](https://github.com/JuliaNLSolvers/Optim.jl)
- Multi-level threading (kpoints, eigenvectors, FFTs, linear algebra)
- 1D / 2D / 3D systems
- Magnetic fields
* Ground-state properties and post-processing:
- Total energy
- Forces
- Density of states (DOS), local density of states (LDOS)
- Band structures
- Easy access to all intermediate quantities (e.g. density, Bloch waves)
* Support for arbitrary floating point types, including `Float32` (single precision)
or `Double64` (from [DoubleFloats.jl](https://github.com/JuliaMath/DoubleFloats.jl)).
For DFT this is currently restricted to LDA (with Slater exchange and VWN correlation).
[VASP](https://www.vasp.at/).

All this in about 5k lines of pure Julia code. The code emphasizes simplicity and
flexibility, with the goal of facilitating methodological development and
The unique feature of this code is its emphasis on simplicity and flexibility
with the goal of facilitating methodological development and
interdisciplinary collaboration.
In about 5k lines of pure Julia code we already support a
[sizeable set of features](https://juliamolsim.github.io/DFTK.jl/dev/index.html#package-features-1),
after just a good year of development.
Our performance is of the same order of magnitude as established packages.

**Note:** DFTK has only been compared against standard packages
for a small number of test cases and might still contain bugs.
For getting started with DFTK, see our documentation:
- [Installation instructions](https://juliamolsim.github.io/DFTK.jl/dev/manual/installation.html)
- [Tutorial](https://juliamolsim.github.io/DFTK.jl/dev/manual/tutorial.html)
- [Examples](https://juliamolsim.github.io/DFTK.jl/dev/manual/examples.html)

## Getting started
The package is not yet registered in the [General](https://github.com/JuliaRegistries/General)
registry of Julia. Instead you can obtain it from
the [MolSim](https://github.com/JuliaMolSim/MolSim.git) registry,
which contains a bunch of packages related to performing molecular simulations in Julia.
Note that at least **Julia 1.3** is required.

First add `MolSim` to your installed registries. For this use
```
] registry add https://github.com/JuliaMolSim/MolSim.git
```
for a Julia command line.
Afterwards you can install DFTK like any other package in Julia:
```
] add DFTK
```
or if you like the bleeding edge:
```
] add DFTK#master
```

Some parts of the code require a working Python installation with the libraries
[`pymatgen`](https://pymatgen.org/) and [`spglib`](https://atztogo.github.io/spglib/).
Check out which version of python is used by the
[PyCall.jl](https://github.com/JuliaPy/PyCall.jl) package.
You can do this for example with the Julia commands
```julia
using PyCall
PyCall.python
```
Then use the corresponding package manager (usually `apt`, `pip`, `pip3` or `conda`)
to install aforementioned libraries, for example
```
pip install spglib pymatgen
```
or
```
conda install -c conda-forge spglib pymatgen
```
You can then run the code in the `examples/` directory.

## Citation
[![DOI](https://zenodo.org/badge/181734238.svg)](https://zenodo.org/badge/latestdoi/181734238)

## Funding
This project has received funding from
the [institute of computing and data sciences (ISCD, Sorbonne Université)](https://iscd.sorbonne-universite.fr/),
the [Institute of computing and data sciences (ISCD, Sorbonne Université)](https://iscd.sorbonne-universite.fr/),
[École des Ponts ParisTech](https://enpc.fr), [Inria Research Centre Paris](https://www.inria.fr/fr/centre-inria-de-paris)
and from the European Research Council (ERC) under the European Union's Horizon 2020 research and
innovation program ([grant agreement No 810367](https://cordis.europa.eu/project/id/810367)).
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ DFTK = "acf6eb54-70d9-11e9-0013-234b7a5f5337"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"

[compat]
Documenter = "~0.24"
74 changes: 48 additions & 26 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,54 @@ using Documenter
using DFTK
using Literate

# Collect examples to include in the documentation
examples = [String(m[1])
for m in match.(r"\"(examples/[^\"]+.md)\"",
readlines(joinpath(@__DIR__, "src/index.md")))
if !isnothing(m)]

# Collect files to treat with literate (i.e. the examples and the .jl files in the docs)
literate_files = [(src=joinpath(@__DIR__, "..", splitext(file)[1] * ".jl"),
dest=joinpath(@__DIR__, "src/examples"), is_example=true)
for file in examples]
for (dir, directories, files) in walkdir(joinpath(@__DIR__, "src"))
for file in files
if endswith(file, ".jl")
Literate.markdown(joinpath(dir, file), dir;
documenter=true, credit=false)
push!(literate_files, (src=joinpath(dir, file), dest=dir, is_example=false))
end
end
end

# Latex macros:
# https://github.com/JuliaAtoms/AtomicLevels.jl/blob/b989896f6e7f62e9213f14b5ce38dffc50bc14b1/docs/make.jl
# Function to insert badges to examples
function add_badges(str)
badges = [
"[![](https://mybinder.org/badge_logo.svg)](@__BINDER_ROOT_URL__/examples/@__NAME__.ipynb)",
"[![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/examples/@__NAME__.ipynb)"
]

# Find the Header and insert the badges right below
splitted = split(str, "\n")
idx = findfirst(startswith.(splitted, "# # "))
insert!(splitted, idx + 1, "#md # " * badges[1])
insert!(splitted, idx + 2, "#md # " * badges[2])
join(splitted, "\n")
end

# Run literate on them all
for file in literate_files
preprocess = file.is_example ? add_badges : identity
Literate.markdown(file.src, file.dest; documenter=true, credit=false,
preprocess=preprocess)
Literate.notebook(file.src, file.dest; credit=false)
end

makedocs(
modules = [DFTK],
format = Documenter.HTML(
# Use clean URLs, unless built as a "local" build
prettyurls = get(ENV, "CI", nothing) == "true",
canonical = "https://juliamolsim.github.io/DFTK.jl/stable/",
# assets = ["assets/favicon.ico"],
assets = ["assets/favicon.ico"],
),
sitename = "DFTK.jl",
authors = "Michael F. Herbst, Antoine Levitt and contributors.",
Expand All @@ -32,28 +61,21 @@ makedocs(
],
pages = [
"Home" => "index.md",
# "Manual" => Any[
# "Guide" => "man/guide.md",
# "man/examples.md",
# "man/syntax.md",
# "man/doctests.md",
# "man/latex.md",
# hide("man/hosting.md", [
# "man/hosting/walkthrough.md"
# ]),
# "man/other-formats.md",
# ],
# "showcase.md",
# "Library" => Any[
# "Public" => "lib/public.md",
# "Internals" => map(
# s -> "lib/internals/$(s)",
# sort(readdir(joinpath(@__DIR__, "src/lib/internals")))
# ),
# ],
# "contributing.md",
"Getting started" => Any[
"guide/installation.md",
"Tutorial" => "guide/tutorial.md",
],
"Examples" => examples,
"Advanced topics" => Any[
"advanced/conventions.md",
"advanced/useful_formulas.md",
"advanced/symmetries.md",
],
"api.md",
"publications.md",
"contributing.md",
],
strict = false, # TODO
strict = true,
)

deploydocs(
Expand Down
4 changes: 3 additions & 1 deletion docs/src/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/index.md
/examples/
/guide/tutorial.md
/guide/tutorial.ipynb
85 changes: 85 additions & 0 deletions docs/src/advanced/conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Notation and conventions

## Usage of unicode characters
DFTK liberally uses unicode characters to represent Greek characters
(e.g. ψ, ρ, ε...). Make sure you use the proper
[Julia plugins](https://github.com/JuliaEditorSupport/)
to simplify typing them.

## [Symbol conventions](@id symbol-conventions)

- **Reciprocal-space vectors:** ``k`` for vectors in the Brillouin zone,
``G`` for vectors of the reciprocal lattice,
``q`` for general vectors
- **Real-space vectors:** ``R`` for lattice vectors,
``r`` and ``x`` are usually used for unit for vectors in the unit cell
or general real-space vectors, respectively.
This convention is, however, less consistently applied.
- ``\Omega`` is the unit cell, and ``|\Omega|``
(or sometimes just ``\Omega``) is its volume.
- ``A`` are the real-space lattice vectors (`model.lattice`)
and ``B`` the Brillouin zone lattice vectors (`model.recip_lattice`).
- The **Bloch waves** are
```math
\psi_{nk}(x) = e^{ik\cdot x} u_{nk}(x),
```
where ``n`` is the band index and ``k`` the ``k``-point. In the code we
sometimes use ``\psi`` and ``u`` interchangeably.
- ``\varepsilon`` are the **eigenvalues**,
``\varepsilon_F`` is the **Fermi level**.
- ``\rho`` is the **density**.
- In the code we use **normalized plane waves**:
```math
e_G(r) = \frac 1 {\sqrt{\Omega}} e^{i G \cdot r}.
```
- ``Y^l_m`` are the complex **spherical harmonics**, and ``Y_{lm}`` the real ones.
- ``j_l`` are the **Bessel functions**. In particular, ``j_{0}(x) = \frac{\sin x}{x}``.

## Units
In DFTK atomic units are used thoughout, most importantly
lengths are in Bohr and energies in Hartree.
See [wikipedia](https://en.wikipedia.org/wiki/Hartree_atomic_units)
for a list of conversion factors. Useful conversion factors
can also be found in `DFTK.units` and using [`DFTK.unit_to_au`](@ref).

## [Lattices and lattice vectors](@id conventions-lattice)
Both the real-space lattice (i.e. `model.lattice`) and reciprocal-space lattice
(`model.recip_lattice`) contain the lattice vectors in columns. If 1D or 2D
problems are to be treated these arrays are still ``3 \times 3`` matrices,
but contain two or one zero-columns, respectively.
The real-space lattice vectors are sometimes referred to by ``A`` and the
reciprocal-space lattice vectors by ``B = 2\pi A^{-T}``.

We use the convention that the unit cell in real space is
``[0, 1)^3`` in reduced coordinates and the unit cell in reciprocal
space (the reducible Brillouin zone) is ``[-1/2, 1/2)^3``.

## Lattice coordinate systems
Unless denoted otherwise the code uses **reduced coordinates**
for reciprocal-space vectors such as ``k``, ``G``, ``q``
or real-space vectors like ``r`` and ``R``
(see [Symbol conventions](@ref symbol-conventions)).
One switches to Cartesian coordinates by
```math
x_\text{cart} = M x_\text{red}
```
where ``M`` is either ``A`` / `model.lattice` (for real-space vectors) or
``B`` / `model.recip_lattice` (for reciprocal-space vectors).
A useful relationship is
```math
b_\text{cart} \cdot a_\text{cart}=2\pi b_\text{red} \cdot a_\text{red}
```
if ``a`` and ``b`` are real-space and reciprocal-space vectors respectively.
Other names for reduced coordinates are **integer coordinates**
(usually for ``G``-vectors) or **fractional coordinates**
(usually for ``k``-points).

## Normalisation convention
The normalization conventions used in the code is that quantities
stored in reciprocal space are coefficients in the ``e_{G}`` basis,
and quantities stored in real space use real physical values.
This means for instance that wavefunctions in the real space grid are
normalized as ``\frac{|\Omega|}{N} \sum_{r} |\psi(r)|^{2} = 1`` where
``N`` is the number of grid points
and in reciprocal space its coefficients are ``\ell^{2}``-normalized,
see the [Tutorial](@ref) for an example where this is demonstrated.
Loading

0 comments on commit d0b2f25

Please sign in to comment.