How to use the ase.calculators.calculator.Calculator function in ase

To help you get started, we’ve selected a few ase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jkitchin / vasp / vasp / View on Github external
        inner.__doc__ = 'Wrapped in vasp.tryit.'
    return inner

from ase.calculators.calculator import Calculator,\

import inspect

# We avoid decorating class methods. It seems to break them.
for attr in Vasp.__dict__:
    f = getattr(Vasp, attr)
    if inspect.ismethod(f) and f.__self__ is not Vasp:
        setattr(Vasp, attr, tryit(getattr(Vasp, attr)))

for attr in Calculator.__dict__:
    f = getattr(Vasp, attr)
    if inspect.ismethod(f) and f.__self__ is not Vasp:
        setattr(Calculator, attr, tryit(getattr(Calculator, attr)))

for attr in FileIOCalculator.__dict__:
    f = getattr(Vasp, attr)
    if inspect.ismethod(f) and f.__self__ is not Vasp:
        setattr(FileIOCalculator, attr,
                tryit(getattr(FileIOCalculator, attr)))
github pyscf / pyscf / pbc / tools / View on Github external

import numpy as np
from ase.calculators.calculator import Calculator
import ase.dft.kpoints
from ase.lattice import bulk

def ase_atoms_to_pyscf(ase_atoms):
    '''Convert ASE atoms to PySCF atom.

    Note: ASE atoms always use A.
    return [[atom.symbol, atom.position] for atom in ase_atoms]
atoms_from_ase = ase_atoms_to_pyscf

class PySCF(Calculator):
    implemented_properties = ['energy']

    def __init__(self, restart=None, ignore_bad_restart_file=False,
                 label='PySCF', atoms=None, scratch=None, **kwargs):
        """Construct PySCF-calculator object.

        label: str
            Prefix to use for filenames (, label.txt, ...).
            Default is 'PySCF'.

        mfclass: PySCF mean-field class
        molcell: PySCF :Mole: or :Cell:
        Calculator.__init__(self, restart=None, ignore_bad_restart_file=False,
github SUNCAT-Center / CatalysisHubBackend / View on Github external
                                constraint=constraints) = {}['unique_id'] = self.unique_id['key_value_pairs'] = self.key_value_pairs

        data =
        if data:
  ['data'] = data

        if not self.calculator == "unknown":
            params = self.calculator_parameters
            atoms.calc = Calculator(self.calculator, **params)
   = self.calculator
            all_properties = ['energy', 'forces', 'stress', 'dipole',
                              'charges', 'magmom', 'magmoms', 'free_energy']
            results = {}
            for prop in all_properties:
                result = getattr(self, prop, None)
                if result is not None:
                    results[prop] = result
            if results:
                atoms.calc = SinglePointCalculator(atoms, **results)
       = getattr(self, 'calculator', 'unknown')
        return atoms
github aiqm / torchani / torchani / View on Github external
"""Tools for interfacing with `ASE`_.

.. _ASE:

import torch
from .nn import Sequential
import ase.neighborlist
from . import utils
import ase.calculators.calculator
import ase.units
import copy

class Calculator(ase.calculators.calculator.Calculator):
    """TorchANI calculator for ASE

        species (:class:`` of :class:`str`):
            sequence of all supported species, in order.
        aev_computer (:class:`torchani.AEVComputer`): AEV computer.
        model (:class:`torchani.ANIModel` or :class:`torchani.Ensemble`):
            neural network potential models.
        energy_shifter (:class:`torchani.EnergyShifter`): Energy shifter.
        dtype (:class:`torchani.EnergyShifter`): data type to use,
            by dafault ``torch.float64``.
        overwrite (bool): After wrapping atoms into central box, whether
            to replace the original positions stored in :class:`ase.Atoms`
            object with the wrapped positions.
github rosswhitfield / ase / ase / View on Github external
for atoms in self.images:
                yield atoms

        for i, atoms in enumerate(self.images):
            if i == 0 or i == self.nimages - 1:
                yield atoms
                atoms = atoms.copy()
                atoms.calc = SinglePointCalculator(energy=self.energies[i],
                yield atoms

class IDPP(Calculator):
    """Image dependent pair potential.

        Improved initial guess for minimum energy path calculations.
        Søren Smidstrup, Andreas Pedersen, Kurt Stokbro and Hannes Jónsson
        Chem. Phys. 140, 214106 (2014)

    implemented_properties = ['energy', 'forces']

    def __init__(self, target, mic):
        Calculator.__init__(self) = target
        self.mic = mic

    def calculate(self, atoms, properties, system_changes):
github libAtoms / matscipy / matscipy / View on Github external
            cellf = open('castep.cell', 'w')
            write_castep_cell(cellf, at, castep_cell=self.castep.cell)
            write_param('castep.param', self.castep.param, force_write=True)


    def extra_args(self, label=None):
        return ['castep']

class SocketCalculator(Calculator):
    ASE-compatible calculator which communicates with remote
    force engines via sockets using a (synchronous) AtomsServer.

    implemented_properties = ['energy', 'forces', 'stress']
    default_parameters = {}
    name = 'SocketCalculator'

    def __init__(self, client, ip=None, atoms=None, port=0, logger=screen, bgq=False):

        self.client = client
        if ip is None:
            ip = '' # default to localhost
        self.logger = logger
github isayev / ASE_ANI / View on Github external
def __init__(self, **kwargs):
        Calculator.__init__(self, **kwargs)
github rosswhitfield / ase / ase / calculators / View on Github external
from ase.parallel import paropen
from ase.calculators.calculator import Calculator
from ase.calculators.calculator import all_changes
from import chemical_symbols
from import atomic_masses
from import write_lammps_data
from import read_lammps_dump
from ase.calculators.lammps import Prism
from ase.calculators.lammps import write_lammps_in
from ase.calculators.lammps import CALCULATION_END_MARK
from ase.calculators.lammps import convert

__all__ = ["LAMMPS"]

class LAMMPS(Calculator):
    """The LAMMPS calculators object

    files: list
        List of files typically containing relevant potentials for the calculation
    parameters: dict
        Dictionary of settings to be passed into the input file for calculation.
    specorder: list
        Within LAAMPS, atoms are identified by an integer value starting from 1.
        This variable allows the user to define the order of the indices assigned to the
        atoms in the calculation, with the default if not given being alphabetical
    keep_tmp_files: bool
        Retain any temporary files created. Mostly useful for debugging.
    tmp_dir: str
        path/dirname (default None -> create automatically).
        Explicitly control where the calculator object should create
        its files. Using this option implies 'keep_tmp_files'
github rosswhitfield / ase / ase / optimize / activelearning / gp / View on Github external
import numpy as np
import warnings
from import SquaredExponential
from import GaussianProcess
from import ConstantPrior
from ase.calculators.calculator import Calculator, all_changes
from scipy.linalg import solve_triangular
from scipy.spatial.distance import euclidean

class GPCalculator(Calculator, GaussianProcess):
    GP model parameters
    train_images: list
        List of Atoms objects containing the observations which will be use
        to train the model.

    prior: Prior object or None
        Prior for the GP regression of the PES surface. See
        ase.optimize.activelearning.prior. If *Prior* is None, then it is set
        as the ConstantPrior with the constant being updated using the
        update_prior_strategy specified as a parameter.

    weight: float
        Pre-exponential factor of the Squared Exponential kernel. If
        *update_hyperparams* is False, changing this parameter has no effect