[][src]Crate bader

An incredibly fast, multi-threaded, Bader charge partitioning binary and library. Based on methods presented in Yu Min and Trinkle Dallas R. 2011 J. Che.m Phys. 134 064111 and W Tang et al 2009 J. Phys.: Condens. Matter 21 084204 with adaptions for multi-threading.

Supported Platforms

  • Linux
  • Os X
  • Windows

Installing the binary


$ cargo install bader

From Source

To check out the lastest features not in the binaries yet you can compile from source. To do this run the following, which will create the ./target/release/bader executable.

$ git clone https://github.com/kerrigoon/bader-rs
$ cd bader-rs
$ cargo build --verbose --release

From here you can either move or link the binary to folder in your path.

$ mv ./target/release/bader ~/bin

Using the library

Add the following to your Cargo.toml: bader = "0.2.2"

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.40.0 and up. It might compile with older versions but that may change in any new patch release. To test this crate requires Rust 1.42.0 and above.


The program takes a charge density file as input and performs Bader analysis of the data. Currently it supports density in VASP or cube formats. It is recommended to run VASP calculations with LAECHG = .TRUE. to print the core density and self-consistent valence density. These can then be passed as reference files to the program using the -r, --reference flag where they will be summed.

$ bader CHGCAR -r AECCAR0 -r AECCAR2

VASP charge density files containing spin densities will output the the partitioned spin also. To achieve this for cube files requires using the --spin flag to pass a second file to treat as the spin density.

$ bader charge-density.cube -s spin-density.cube

For a detailed list of usage options run

$ bader --help


The program outputs two files, ACF.dat & BCF.dat. The Atomic Charge File (ACF.dat) contians the charge (and spin) information for each atom and the Bader Charge File (BCF.dat) contains the information about each Bader volume. The BCF file also includes the atom number in the number column formatted as 'atom number: bader volume'.





Builds the clap::App and parses command-line arguments.


Contains Atoms for storing the relevant data on the atoms in the calculation. Also contains Lattice and ReducedLattice for storing information about the cell in which the density is stored.


Contains Density for managing the reference density for partioning. Also stores structures for moving around the grid on which the density is stored.


Handles the File I/O for both the density file and result files. Provides a FileFormat trait to be implemented by modules designed to cover a specific file format of a density file.


Contains the three methods for partioning the density, (Ongrid, Neargrid, and Weight), and functions for performing a step for in each.


Provides Bar: A quicker thread-safe version of the indicatif::ProgressBar.


Misc functions mainly for vector and matrix manipulation.


Calculates the Voronoi vectors, and their alpha values for the weight method, for lattices. Also useful for periodic minimum distances.


Provides the VoxelMap for storing the maxima and weights of partioned voxels.