Stuff for testing things

class ase.calculators.test.FreeElectrons(restart=None, ignore_bad_restart_file=False, label=None, atoms=None, **kwargs)[source]

Free-electron band calculator.


nvalence: int
Number of electrons
kpts: dict
K-point specification.


>>> calc = FreeElectrons(nvalence=1, kpts={'path': 'GXL'})

Basic calculator implementation.

restart: str
Prefix for restart file. May contain a directory. Default is None: don’t restart.
ignore_bad_restart_file: bool
Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.
label: str
Name used for all files. May contain a directory.
atoms: Atoms object
Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.
calculate(atoms, properties, system_changes)[source]

Do the calculation.

properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.

Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:

self.results = {'energy': 0.0,
                'forces': np.zeros((len(atoms), 3)),
                'stress': np.zeros(6),
                'dipole': np.zeros(3),
                'charges': np.zeros(len(atoms)),
                'magmom': 0.0,
                'magmoms': np.zeros(len(atoms))}

The subclass implementation should first call this implementation to set the atoms attribute.

get_eigenvalues(kpt, spin=0)[source]
implemented_properties = ['energy']