  Computational modeling of the properties of crystalline materials has become
an increasingly important aspect of materials research, consuming hundreds of
millions of CPU-hours at scientific computing centres around the world each
year, if not more. A routine operation in such calculations is the evaluation
of integrals over the Brillouin zone. We have previously demonstrated that
performing such integrals using generalized Monkhorst-Pack k-point grids can
roughly double the speed of these calculations relative to the widely-used
traditional Monkhorst-Pack grids, and such grids can be rapidly generated by
querying a free, internet-accessible database of pre-generated grids. To
facilitate the widespread use of generalized k-point grids, we present new
algorithms that allow rapid generation of optimized generalized Monkhorst-Pack
grids on the fly, an open-source library to facilitate their integration into
external software packages, and an open-source implementation of the database
tool that can be used offline. We also present benchmarks of the speed of our
algorithms on structures randomly selected from the Inorganic Crystal Structure
Database. For grids that correspond to a real-space supercell with at least 50
angstroms between lattice points, which is sufficient to converge density
functional theory calculations within 1 meV/atom for nearly all materials, our
algorithm finds optimized grids in an average of 0.19 seconds on a single
processing core. For 100 angstroms between real-space lattice points, our
algorithm finds optimal grids in less than 5 seconds on average.
