GeometryOptimization
A geometry optimization package for AtomsBase structures and AtomsCalculator calculators. The source code can be found on github.
Motivating example
We consider the optimisation of the bondlength of a hydrogen molecule using a simple Lennard Jones potential:
using AtomsBase
using EmpiricalPotentials
using GeometryOptimization
using LinearAlgebra
using Unitful
using UnitfulAtomic
# Setup system and calculator
cell_vectors = ([10.0, 0.0, 0.0]u"Å", [0.0, 10.0, 0.0]u"Å", [0.0, 0.0, 10.0]u"Å")
system = periodic_system([:H => [0, 0, 0.0]u"bohr",
:H => [0, 0, 1.9]u"bohr"],
cell_vectors)
zH = 1
emins = Dict((zH, zH) => -1.17u"hartree", )
rmins = Dict((zH, zH) => 0.743u"Å", )
calc = LennardJones(emins, rmins, 5.0u"Å")
# Run the geometry optimisation (using verbosity=1 to print the progress)
results = minimize_energy!(system, calc; verbosity=1)
# Inspect the results
optsystem = results.system
optimised_bondlength = norm(position(optsystem[1]) - position(optsystem[2]))
Geometry optimisation convergence (in atomic units)
┌─────┬─────────────────┬───────────┬────────────┬────────┐
│ n │ Energy │ log10(ΔE) │ max(Force) │ Δtime │
├─────┼─────────────────┼───────────┼────────────┼────────┤
│ 0 │ -0.349426933806 │ │ 1.00704 │ 2.13s │
│ 1 │ -0.556149988612 │ -0.68 │ 1.61218 │ 236ms │
│ 2 │ -0.750644133823 │ -0.71 │ 2.0642 │ 679μs │
│ 3 │ -1.127520714846 │ -0.42 │ 2.30592 │ 444μs │
│ 4 │ -1.169108399949 │ -1.38 │ 0.00477405 │ 385μs │
│ 5 │ -1.169108666400 │ -6.57 │ 3.58935e-6 │ 355μs │
│ 6 │ -1.169108666400 │ -12.82 │ 1.20259e-7 │ 367μs │
The idea is that any AtomsBase-compatible structure can be employed as a system
any AtomsCalculators-compatible calculator as a calc
. See the list of examples to get an overview of possible calculators to employ.
Note that minimize_energy!
supports further arguments to fine-tune the convergence tolerance or customise the solver selection. See the API documentation or the examples to explore this.