matscipy.calculators.pair_potential package

Modules

matscipy.calculators.pair_potential.calculator

Simple pair potential.

matscipy.calculators.pair_potential.calculator module

Simple pair potential.

class matscipy.calculators.pair_potential.calculator.CutoffInteraction(cutoff)

Bases: ABC

Pair interaction potential with cutoff.

__init__(cutoff)

Initialize with cutoff.

property cutoff

Physical cutoff distance for pair interaction.

get_cutoff()

Get cutoff. Deprecated.

abstract first_derivative(r, qi, qj)

Compute derivative w/r to distance.

abstract second_derivative(r, qi, qj)

Compute second derivative w/r to distance.

derivative(n=1)

Return specified derivative.

class matscipy.calculators.pair_potential.calculator.LennardJonesCut(epsilon, sigma, cutoff)

Bases: CutoffInteraction

Functional form for a 12-6 Lennard-Jones potential with a hard cutoff. Energy is shifted to zero at cutoff.

__init__(epsilon, sigma, cutoff)

Initialize with cutoff.

first_derivative(r, *args)

Compute derivative w/r to distance.

second_derivative(r, *args)

Compute second derivative w/r to distance.

property cutoff

Physical cutoff distance for pair interaction.

derivative(n=1)

Return specified derivative.

get_cutoff()

Get cutoff. Deprecated.

class matscipy.calculators.pair_potential.calculator.LennardJonesQuadratic(epsilon, sigma, cutoff)

Bases: CutoffInteraction

Functional form for a 12-6 Lennard-Jones potential with a soft cutoff. Energy, its first and second derivative are shifted to zero at cutoff.

__init__(epsilon, sigma, cutoff)

Initialize with cutoff.

first_derivative(r, *args)

Compute derivative w/r to distance.

second_derivative(r, *args)

Compute second derivative w/r to distance.

property cutoff

Physical cutoff distance for pair interaction.

derivative(n=1)

Return specified derivative.

get_cutoff()

Get cutoff. Deprecated.

class matscipy.calculators.pair_potential.calculator.LennardJonesLinear(epsilon, sigma, cutoff)

Bases: CutoffInteraction

Function form of a 12-6 Lennard-Jones potential with a soft cutoff The energy and the force are shifted at the cutoff.

__init__(epsilon, sigma, cutoff)

Initialize with cutoff.

first_derivative(r, *args)

Compute derivative w/r to distance.

second_derivative(r, *args)

Compute second derivative w/r to distance.

property cutoff

Physical cutoff distance for pair interaction.

derivative(n=1)

Return specified derivative.

get_cutoff()

Get cutoff. Deprecated.

class matscipy.calculators.pair_potential.calculator.FeneLJCut(K, R0, epsilon, sigma)

Bases: LennardJonesCut

Finite extensible nonlinear elastic(FENE) potential for a bead-spring polymer model. For the Lennard-Jones interaction a LJ-cut potential is used. Due to choice of the cutoff (rc=2^(1/6) sigma) it ensures a continous potential and force at the cutoff.

__init__(K, R0, epsilon, sigma)

Initialize with cutoff.

first_derivative(r, *args)

Compute derivative w/r to distance.

second_derivative(r, *args)

Compute second derivative w/r to distance.

property cutoff

Physical cutoff distance for pair interaction.

derivative(n=1)

Return specified derivative.

get_cutoff()

Get cutoff. Deprecated.

class matscipy.calculators.pair_potential.calculator.LennardJones84(C1, C2, C3, C4, cutoff)

Bases: CutoffInteraction

Function form of a 8-4 Lennard-Jones potential, used to model the structure of a CuZr. Kobayashi, Shinji et. al. “Computer simulation of atomic structure of Cu57Zr43 amorphous alloy.” Journal of the Physical Society of Japan 48.4 (1980): 1147-1152.

__init__(C1, C2, C3, C4, cutoff)

Initialize with cutoff.

first_derivative(r, *args)

Compute derivative w/r to distance.

second_derivative(r, *args)

Compute second derivative w/r to distance.

property cutoff

Physical cutoff distance for pair interaction.

derivative(n=1)

Return specified derivative.

get_cutoff()

Get cutoff. Deprecated.

class matscipy.calculators.pair_potential.calculator.BeestKramerSanten(A, B, C, cutoff)

Bases: CutoffInteraction

Beest, Kramer, van Santen (BKS) potential.

Buckingham:

Energy is shifted to zero at the cutoff.

References

    1. Van Beest, G. J. Kramer and R. A. Van Santen, Phys. Rev. Lett. 64.16 (1990)

__init__(A, B, C, cutoff)

Initialize with cutoff.

first_derivative(r, *args)

Compute derivative w/r to distance.

second_derivative(r, *args)

Compute second derivative w/r to distance.

property cutoff

Physical cutoff distance for pair interaction.

derivative(n=1)

Return specified derivative.

get_cutoff()

Get cutoff. Deprecated.

class matscipy.calculators.pair_potential.calculator.PairPotential(f, cutoff=None)

Bases: MatscipyCalculator

implemented_properties: List[str] = ['energy', 'free_energy', 'stress', 'forces', 'hessian', 'dynamical_matrix', 'nonaffine_forces', 'birch_coefficients', 'nonaffine_elastic_contribution', 'stress_elastic_contribution', 'born_constants', 'elastic_constants']

Properties calculator can handle (energy, forces, …)

default_parameters: Dict[str, Any] = {}

Default parameters

name = 'PairPotential'
__init__(f, cutoff=None)

Construct calculator.

reset()

Clear all information from old calculation.

calculate(atoms, properties, system_changes)

Calculate system properties.

band_structure()

Create band-structure object for plotting.

calculate_numerical_forces(atoms, d=0.001)

Calculate numerical forces using finite difference.

All atoms will be displaced by +d and -d in all directions.

calculate_numerical_stress(atoms, d=1e-06, voigt=True)

Calculate numerical stress using finite difference.

calculate_properties(atoms, properties)

This method is experimental; currently for internal use.

calculation_required(atoms, properties)
check_state(atoms, tol=1e-15)

Check for any system changes since last calculation.

property directory: str
discard_results_on_any_change = False

Whether we purge the results following any change in the set() method.

export_properties()
get_atoms()
get_birch_coefficients(atoms)

Compute the Birch coefficients (Effective elastic constants at non-zero stress).

Parameters:

atoms (ase.Atoms) – Atomic configuration in a local or global minima.

get_born_elastic_constants(atoms)

Compute the Born elastic constants.

Parameters:

atoms (ase.Atoms) – Atomic configuration in a local or global minima.

get_charges(atoms=None)
get_default_parameters()
get_dipole_moment(atoms=None)
get_dynamical_matrix(atoms)

Compute dynamical matrix (=mass weighted Hessian).

get_elastic_constants(atoms, cg_parameters={'M': None, 'atol': 1e-05, 'callback': None, 'maxiter': None, 'tol': 1e-05, 'x0': None})

Compute the elastic constants at zero temperature. These are sum of the born, the non-affine and the stress contribution.

Parameters:
  • atoms (ase.Atoms) – Atomic configuration in a local or global minima.

  • cg_parameters (dict) –

    Dictonary for the conjugate-gradient solver.

    x0: {array, matrix}

    Starting guess for the solution.

    tol/atol: float, optional

    Tolerances for convergence, norm(residual) <= max(tol*norm(b), atol).

    maxiter: int

    Maximum number of iterations. Iteration will stop after maxiter steps even if the specified tolerance has not been achieved.

    M: {sparse matrix, dense matrix, LinearOperator}

    Preconditioner for A.

    callback: function

    User-supplied function to call after each iteration.

get_forces(atoms=None)
get_hessian(atoms, format='sparse', divide_by_masses=False)

Calculate the Hessian matrix for a pair potential. For an atomic configuration with N atoms in d dimensions the hessian matrix is a symmetric, hermitian matrix with a shape of (d*N,d*N). The matrix is in general a sparse matrix, which consists of dense blocks of shape (d,d), which are the mixed second derivatives. The result of the derivation for a pair potential can be found e.g. in: L. Pastewka et. al. “Seamless elastic boundaries for atomistic calculations”, Phys. Rev. B 86, 075459 (2012).

Parameters:
  • atoms (ase.Atoms) – Atomic configuration in a local or global minima.

  • format ("sparse" or "neighbour-list") – Output format of the hessian matrix.

  • divide_by_masses (bool) – if true return the dynamic matrix else hessian matrix

  • Restrictions

  • ----------

  • systems (This method is currently only implemented for three dimensional) –

get_magnetic_moment(atoms=None)
get_magnetic_moments(atoms=None)

Calculate magnetic moments projected onto atoms.

get_non_affine_contribution_to_elastic_constants(atoms, eigenvalues=None, eigenvectors=None, pc_parameters=None, cg_parameters={'M': None, 'atol': 1e-05, 'callback': None, 'maxiter': None, 'tol': 1e-05, 'x0': None})

get_non_affine_contribution_to_elastic_constants is deprecated, use elasticity.nonaffine_elastic_contribution instead!

Compute the correction of non-affine displacements to the elasticity tensor. The computation of the occuring inverse of the Hessian matrix is bypassed by using a cg solver.

If eigenvalues and and eigenvectors are given the inverse of the Hessian can be easily computed.

Parameters:
  • atoms (ase.Atoms) – Atomic configuration in a local or global minima.

  • eigenvalues (array) – Eigenvalues in ascending order obtained by diagonalization of Hessian matrix. If given, use eigenvalues and eigenvectors to compute non-affine contribution.

  • eigenvectors (array) – Eigenvectors corresponding to eigenvalues.

  • cg_parameters (dict) –

    Dictonary for the conjugate-gradient solver.

    x0: {array, matrix}

    Starting guess for the solution.

    tol/atol: float, optional

    Tolerances for convergence, norm(residual) <= max(tol*norm(b), atol).

    maxiter: int

    Maximum number of iterations. Iteration will stop after maxiter steps even if the specified tolerance has not been achieved.

    M: {sparse matrix, dense matrix, LinearOperator}

    Preconditioner for A.

    callback: function

    User-supplied function to call after each iteration.

  • pc_parameters (dict) –

    Dictonary for the incomplete LU decomposition of the Hessian.

    A: array_like

    Sparse matrix to factorize.

    drop_tol: float

    Drop tolerance for an incomplete LU decomposition.

    fill_factor: float

    Specifies the fill ratio upper bound.

    drop_rule: str

    Comma-separated string of drop rules to use.

    permc_spec: str

    How to permute the columns of the matrix for sparsity.

    diag_pivot_thresh: float

    Threshold used for a diagonal entry to be an acceptable pivot.

    relax: int

    Expert option for customizing the degree of relaxing supernodes.

    panel_size: int

    Expert option for customizing the panel size.

    options: dict

    Dictionary containing additional expert options to SuperLU.

get_nonaffine_forces(atoms)

Compute the non-affine forces which result from an affine deformation of atoms.

Parameters:

atoms (ase.Atoms) – Atomic configuration in a local or global minima.

get_numerical_non_affine_forces(atoms, d=1e-06)

get_numerical_non_affine_forces is deprecated, use numerical.numerical_nonaffine_forces instead!

Calculate numerical non-affine forces using central finite differences. This is done by deforming the box, rescaling atoms and measure the force.

Parameters:

atoms (ase.Atoms) – Atomic configuration in a local or global minima.

get_potential_energies(atoms=None)
get_potential_energy(atoms=None, force_consistent=False)
get_property(name, atoms=None, allow_calculation=True)

Get the named property.

get_stress(atoms=None)
get_stress_contribution_to_elastic_constants(atoms)

Compute the correction to the elastic constants due to non-zero stress in the configuration. Stress term results from working with the Cauchy stress.

Parameters:

atoms (ase.Atoms) – Atomic configuration in a local or global minima.

get_stresses(atoms=None)

the calculator should return intensive stresses, i.e., such that stresses.sum(axis=0) == stress

ignored_changes: Set[str] = {}

Properties of Atoms which we ignore for the purposes of cache

property label
read(label)

Read atoms, parameters and calculated properties from output file.

Read result from self.label file. Raise ReadError if the file is not there. If the file is corrupted or contains an error message from the calculation, a ReadError should also be raised. In case of succes, these attributes must set:

atoms: Atoms object

The state of the atoms from last calculation.

parameters: Parameters object

The parameter dictionary.

results: dict

Calculated properties like energy and forces.

The FileIOCalculator.read() method will typically read atoms and parameters and get the results dict by calling the read_results() method.

classmethod read_atoms(restart, **kwargs)
set(**kwargs)

Set parameters like set(key1=value1, key2=value2, …).

A dictionary containing the parameters that have been changed is returned.

Subclasses must implement a set() method that will look at the chaneged parameters and decide if a call to reset() is needed. If the changed parameters are harmless, like a change in verbosity, then there is no need to call reset().

The special keyword ‘parameters’ can be used to read parameters from a file.

set_label(label)

Set label and convert label to directory and prefix.

Examples:

  • label=’abc’: (directory=’.’, prefix=’abc’)

  • label=’dir1/abc’: (directory=’dir1’, prefix=’abc’)

  • label=None: (directory=’.’, prefix=None)

todict(skip_default=True)