matscipy.precon

Hessian preconditioner.

Classes

HessianPrecon([c_stab, move_tol, P, ...])

Preconditioner for dense Hessian.

class matscipy.precon.HessianPrecon(c_stab=0.01, move_tol=0.1, P=None, old_positions=None)

Bases: Precon

Preconditioner for dense Hessian.

Methods

Pdot(x)

Return the result of applying P to a vector x

apply(forces, atoms)

Convenience wrapper that combines make_precon() and solve()

asarray()

Array representation of preconditioner, as a dense matrix

dot(x, y)

Return the preconditioned dot product <P x, y>

make_precon(atoms)

Create a preconditioner matrix based on the passed set of atoms.

norm(x)

Return the P-norm of x, where |x|_P = sqrt(<Px, x>)

solve(x)

Solve the (sparse) linear system P x = y and return y

copy

vdot

__init__(c_stab=0.01, move_tol=0.1, P=None, old_positions=None)
make_precon(atoms)

Create a preconditioner matrix based on the passed set of atoms.

Creates a general-purpose preconditioner for use with optimization algorithms, based on examining distances between pairs of atoms in the lattice. The matrix will be stored in the attribute self.P and returned.

Parameters:
  • atoms – the Atoms object used to create the preconditioner.

  • reinitialize – if True, parameters of the preconditioner will be recalculated before the preconditioner matrix is created. If False, they will be calculated only when they do not currently have a value (ie, the first time this function is called).

Returns:

A sparse scipy csr_matrix. BE AWARE that using

numpy.dot() with sparse matrices will result in errors/incorrect results - use the .dot method directly on the matrix instead.

Return type:

P

Pdot(x)

Return the result of applying P to a vector x

solve(x)

Solve the (sparse) linear system P x = y and return y

copy()
asarray()

Array representation of preconditioner, as a dense matrix

apply(forces, atoms)

Convenience wrapper that combines make_precon() and solve()

Parameters:
  • forces (array) – (len(atoms)*3) array of input forces

  • atoms (ase.atoms.Atoms) –

Returns:

  • precon_forces (array) – (len(atoms), 3) array of preconditioned forces

  • residual (float) – inf-norm of original forces, i.e. maximum absolute force

dot(x, y)

Return the preconditioned dot product <P x, y>

Uses 128-bit floating point math for vector dot products

norm(x)

Return the P-norm of x, where |x|_P = sqrt(<Px, x>)

vdot(x, y)