Preconditioned Geometry Optimisers for the CASTEP and ONETEP codes


Key Personnel

PI/Co-I: PI: Dr James Kermode Co-Is: Prof. Christoph Ortner, Dr Nicholas Hine, Prof. Matt Probert

Technical: Dr Letif Mones and Dr Jolyon Aarons

Relevant Documents

eCSE Technical Report: Preconditioned Geometry Optimisers for the CASTEP and ONETEP codes

Project summary

Density functional theory (DFT) is one of the most widely used computational methods to investigate molecules and materials by performing calculations that explicitly the electronic degrees of freedom. The CASTEP and ONETEP DFT packages are UK flagship codes and are heavily used on ARCHER (making up 8 and 1% respectively of recent usage).

For a given configuration DFT can provide the ground-state energy of the system and the forces on atoms. This gives the possibility to perform geometry optimisation to obtain optimal configuration(s), where the ground-state energy is minimal (and therefore the force and stress components are zero). Optimal configurations are essential for several advanced analysis such as examination of vibrational modes for molecules in gas phase and phonon or electronic bandstructure calculations for material systems.

The most widely used geometry optimisers in the field of computational chemistry is the limited memory Broyden–Fletcher–Goldfarb–Shanno algorithm (LBFGS). Due to the high dimensionality of the space, most chemical and material systems have illconditioned potential energy surfaces around their minima that in general results in slow convergence of the LBFGS method. It is widely known that preconditioners that redefine the metric through a coordinate transformation (and therefore make the local shape of the surface more isotropic) can speed up convergence. We implemented two recently developed preconditioners into the ONETEP and CASTEP codes, whose efficiency has been previously demonstrated (with a speedup factor of 2-10x compared to standard LBFGS).

The Exp preconditioner is based on the continuous generalisation of the Laplacian matrix. It is a very simple but effective preconditioner that uses only local environmental information around the atoms and therefore its computation is very straightforward. The Force Field (FF) preconditioner includes rather specific information about the local bonding based on a universal force field.

The application of preconditioners requires solving a linear system, which is the most expensive part of their application. However, our aim was to keep the computational cost of the construction of the preconditioners and the solution of linear system below 5% of the cost of the electronic structure problem. Keeping the overhead small ensures that the computational gain using preconditioners is comparable to the speed up factor in the convergence that they provide. The current implementation supports variable cell optimisations as well, and as a methodological development we also introduced an automatic scaling to adjust strain components that resulted in an additional ~30% improvement in the convergence rate for selected systems.

We carried out the implementations in an extendable way that gives the possibility to easily add other preconditioners later as well as combining these preconditioners with other optimisation algorithms besides LBFGS. Using a wide variety of systems (including single molecule, molecular crystal, carbon nanotube and materials system) we demonstrated that the application of preconditioners reduces the number of optimisation steps and corresponding CPU times at least by a factor of two.

There are two types of problems where the application of preconditioners is extremely useful. One of them is when a very precise optimisation threshold is required. A good example for this is the investigation of crystalline polymorphs that can have structures with subtle energy difference and a very precise convergence criterion is required to optimise their structure to distinguishable local minima. The other important applicability of preconditioners is when one needs to perform geometry optimisation of large systems. ONETEP is widely used for calculations of large biomolecules such as proteins and DNA.

Achievement of objectives

  1. Produce a robust serial implementation of the preconditioner of Packwood et al. [J. Chem. Phys. 144, 164109 (2016)] in both CASTEP and ONETEP.

    Success metric: reduction of 2-10x in the number of force evaluations required to optimise the geometry of ~1k atom inorganic crystals in both CASTEP and ONETEP compared to current implementation of LBFGS (Limited-memory Broyden Fletcher Goldfarb Shanno) scheme, with precise factor depending on system size and bonding complexity.

    Achievement: several systems were tested including single organic molecule, molecular crystals, carbon nanotube with defects and materials system. The reduction of force evaluations was at least two-fold even for smaller systems and depending on the bonding complexity the gain increased with system size as expected.

  2. Optimise and parallelise the construction and application of the preconditioner sufficiently that it does not become a bottleneck in large systems for typical parallel partition sizes used on ARCHER.

    Success metric: reduce overhead of preconditioned geometry compared to current LBFGS implementation to less than 5% of electronic minimisation time for systems containing ~1k atoms running on ~1k cores on ARCHER. Combined with 2-10x reduction in number of steps required from Objective 1, this will deliver a significant speedup in the overall runtime.

    Achievement: based on careful tests the overhead of preconditioned geometry optimisation was less than 5% of electronic minimisation time and given the significant reduction in the number of force evaluations it has a negligible computational cost.

  3. Evaluate the necessity for the use of sparse matrices and/or an algebraic multigrid solver to speed up preconditioner assembly and application, considering both existing sparse matrix infrastructure within the codes and additional external libraries. Only required if Objective 2 cannot be met with dense linear algebra.

    Success metric: use sparse linear algebra to reduce overhead of preconditioned geometry compared to current implementation to less than 5% of electronic minimisation time for systems containing ~1k atoms running on ~1k cores on ARCHER.

    Achievement: as the current implementation of the construction of the preconditioners and solution of the linear equations have an overhead less than 5% this objective was not required.

  4. Provide experimental support for new preconditioners (prototypes in unpublished work) to allow further speedup e.g. by taking into account multiple bond types, which need to be preconditioned differently.

    Success metric: implementation of novel preconditioners completed and speed up of at least 2x relative to current unpreconditioned LBFGS demonstrated for geometry optimisation of molecular crystals.

    Achievement: a simple but highly efficient recently introduced force-field-based preconditioner was also implemented. For some systems this preconditioner outperformed even the Exp preconditioner. Also, we implemented an automatic scaling method to adjust strain components of the preconditioner for variable cell optimisations that resulted in an additional ~30% improvement.

  5. Leave behind the infrastructure and expertise to expand preconditioned geometry optimisation in both codes for specific application areas that may require bespoke preconditioners.

    Success metric: code implementing objectives 1-4 made available in main CASTEP and ONETEP codebases, documented and supported through user tutorials, and in use by at least two of the early user research groups identified in Section 7.

    Achievement: the implementation was carried out in a modular way that supports any additional extension of the code using general or specific preconditioners.

Summary of the software

The enhanced geometry optimisation code has been committed to the CASTEP mercurial repository and to the ONETEP subversion repository, allowing it to be evaluated by all developers of both codes and their collaborators (e.g. students/postdocs).

The next releases of CASTEP (v19, expected October 2018) and ONETEP (v5, summer 2018) will both incorporate the new functionality, after which it will be available to all users.