ASRCalculator
- class ase2sprkkr.asr.test.mocks.gpaw.calculator.ASRCalculator(restart=None, ignore_bad_restart_file=<object object>, label=None, atoms=None, directory='.', **kwargs)[source]
Mock of a generic ASE calculator.
This test calculator is specifically designed to look like the GPAW calculator, and to make additional monkey patching easy. Each of the public methods have an identical private method prefaced with underscore that can be easily patch using the pytest mocker.patch functionality. For example, ASRCalculator.get_fermi_level has an identical ASRCalculator._get_fermi_level method that can be easily mocked up.
By default, the eigenvalues set up the calculator has some valence bands with negative curvature and some conduction bands with positive curvature. Furthermore, if the return value of _get_band_gap is non-zero the valence and conduction bands will be separated by a band gap. This provides an easy way to manipulate the properties of a test material.
Class hierarchy
Constructor
- __init__(restart=None, ignore_bad_restart_file=<object object>, label=None, atoms=None, directory='.', **kwargs)
Basic calculator implementation.
- restart: str
Prefix for restart file. May contain a directory. Default is None: don’t restart.
- ignore_bad_restart_file: bool
Deprecated, please do not use. Passing more than one positional argument to Calculator() is deprecated and will stop working in the future. Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.
- directory: str or PurePath
Working directory in which to read and write files and perform calculations.
- label: str
Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.
- 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.
- implemented_properties: List[str] = ['energy', 'forces', 'stress', 'dipole', 'magmom', 'magmoms', 'stresses', 'charges', 'fermi_level', 'gap', 'berry_phases']
Properties calculator can handle (energy, forces, …)
- default_parameters: Dict[str, Any] = {'gridsize': 3, 'kpts': (4, 4, 4), 'nbands': 12, 'txt': None}
Default parameters
- occupations = <ase2sprkkr.asr.test.mocks.gpaw.calculator.Occupations object>
- wfs = <ase2sprkkr.asr.test.mocks.gpaw.calculator.WaveFunctions object>
- world = namespace(size=1, rank=0, broadcast=<function broadcast>, barrier=<function barrier>, new_communicator=<function new_communicator>, sum=<function world_sum>)
- calculate(atoms, *args, **kwargs)[source]
Calculate properties of atoms and set some necessary instance variables.
This is the main method that calculates the energy, forces and other properties of the given structure. This method should not be mocked. In stead mock the implementation of the specific property you need to amend.
- set(**kwargs)[source]
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.
- property spos_ac
- _get_setup_fingerprint(element_number)[source]
Get specific setup fingerprint.
- Parameters:
element_number (int) – Atomic number of element.
- Return type:
str
- _get_setup_nvalence(element_number)[source]
Get number of valence electrons.
This also dynamically controls the number of valence bands.
- _get_setup(element_number)[source]
Get specific setup.
- Parameters:
element_number (int) – Atomic number of element.
- Returns:
A SimpleNamespace that resembles a GPAW Setups class.
- Return type:
SimpleNamespace
- _get_berry_phases(dir, spin)[source]
Return berry phases.
- Parameters:
dir (int) – Which direction to return berry phases along.
spin (int) – Spin channel.
- Returns:
Berry phases along a specific axis
- Return type:
np.ndarray
- get_all_eigenvalues()[source]
Get all eigenvalues.
Constructs all eigenvalues for the test calculator. The valence bands will have a negative curvature and the number of valence bands are determined by
ASRCalculator.get_number_of_valence_electrons()
. Conduction bands have positive curvature and are separated from the valence bands by a bandgap. The band gap is obtained fromASRCalculator._get_band_gap()
.
- get_eigenvalues(kpt, spin=0)[source]
Return the eigenvalues of a specific k-point.
- Parameters:
kpt (int) – K-point index.
spin (int) – Spin channel.
- get_number_of_valence_electrons()[source]
Get number of valence electrons.
The number of valence electrons exclude any extra doping there might exist due to any additional doping.
- _abc_impl = <_abc._abc_data object>