SPRKKR

class ase2sprkkr.sprkkr.calculator.SPRKKR(restart=None, label=None, atoms=None, directory='.', input_file=True, output_file=True, potential_file=True, input_parameters=None, options={}, potential=None, print_output=None, mpi=None, empty_spheres=None, executable_suffix=None, executable_dir=None, **kwargs)[source]

ASE calculator for SPR-KKR.

Variables:
Parameters:
  • mpi (Optional[bool])

  • empty_spheres (Optional[Union[str, bool, Dict]])

  • executable_dir (Optional[Union[str, bool]])

The parameters of performed calculations are determined mostly by input_parameters, given either in constructor or in the calculate method. The following attributes of the calculator are mostly the default values of the arguments of the calculate or calculate methods.

Class hierarchy

Inheritance diagram of ase2sprkkr.sprkkr.calculator.SPRKKR

Constructor

__init__(restart=None, label=None, atoms=None, directory='.', input_file=True, output_file=True, potential_file=True, input_parameters=None, options={}, potential=None, print_output=None, mpi=None, empty_spheres=None, executable_suffix=None, executable_dir=None, **kwargs)[source]
Parameters:
  • label (str or None) – Path and begin of the file names used for default templates for input, output and potential files.

  • directory (str or None or False) – Directory, where the files will be created and where the calculation will be runned. False means use temporary directory, so nothing will left after the run.

  • input_file (str or file or bool) – Template according to which the input file name will be created. True means the default template. False means to use a temporary file. The placeholders for the task name, date, etc… can be used.

  • output_file (str or file or bool (default).) – The template for the output file name. True means use the input file name, with replaced .in[p] by .out or appended .out suffix False means not to write the output file at all. See the input_file parameter for the meaning of other values.

  • potential_file (str or file or bool) – The template for the potential file name (see the input_file parameter).

  • print_output (Optional[Union[bool,str]]) – Write the output of runned executables to stdout (in addition to the output file)? (Default value for the calculator) If print_output = ‘info’, only a few info lines per iteration will be printed. None means use the value from config.config.calculator_parameters.print_output.

  • mpi (Union[list,string,int,bool]) – Runner for mpi to run a mpi calculation. True and int means autodetect: use True for a cluster where mpi is able to autodetect the number of the processes, otherwise use integer to specify the number of processes. None means use the value from config.config.calculator_parameters.mpi. E.g. mpi = [ ‘mpirun’, ‘-np’, ‘4’ ], mpi = 4

  • input_parameters (sprkkr.input_parameters.input_parameters.InputParameters or str or None) – The default input parameters, according to which the input file for the calculation will be created. None means that the parameters will be specified in the calculate (or save_input) method. If str is given, it is interpreted as a name of the task (if no dot and no slash are contained in it), for which (see ase2sprkkr.input_parameters.definitions) the default input parameters will be used, or as a filename contained the input file (which will be readed)

  • options (dict) – Further parameters for input parameters

  • potential (sprkkr.potential.Potential or str or bool or None) – The (default) potential to be used in calculations. If a string is given, the potential will be read from the given filename. True means to generate the potential from atoms. False means that the potential will be given by the input_parameters. None (the default value) means that the potential is required to be supplied, when calculate or save_input methods are called (either directly, or via atoms, input_parameters etc.)

  • executable_suffix (str or bool or None) –

    String to be added to the runned executable. In some environments, the version and the hostname is added to the name of sprkkr executables. True: use config.config.executable.suffix, by default initialized

    by SPRKKR_EXECUTABLE_SUFFIX environment variable

    False: do not append anything (the same as ‘’)

  • executable_dir (str | bool | None) – If the SPRKKR exacutables are not in path, or you want to control which executables will be runned, please supply this parameter. None means use the default from config.config.executable.dir (if exists). False means use only the executable in PATH.

  • empty_spheres (str | bool | Dict | None) – Whether to add empty spheres to the structure or not. ‘auto’ means add if no empty sphere is present. None means use the configuration value from config.config.calculator_parameters.empty_spheres. Dict means True, and the dict is passed as kwargs to the ase.bindings.empty_spheres.add_empty_spheres method.

implemented_properties: List[str] = ['energy']

Properties calculator can handle (energy, forces, …)

input_file

A pathname or an open named file for the input file (if not specified otherwise in the called method)

output_file

A pathname or an open file for the output of the runned SPR-KKR task (if not specified otherwise in the called method)

potential_file

A pathname or an open named file for the potential file to be used (if not specified otherwise in the called method)

property print_output
property mpi
property empty_spheres
property executable_dir
property executable_suffix
property input_parameters

The parameters for the runned task, given either by the ase2sprkkr.input_parameters.input_parameters.InputParameters object, or by string resulting in the default parameters for a taks with the given name.

If a string is set to the property, the InputPamaters object is created with the default values for the task with a given name.

The parameters can be either overriden by input_parameters argument of the calculate method, or (one-time) modified by its options argument.

set(options={}, value=None, *, unknown='find', **kwargs)[source]

ASE method to set the parameters.

Beware, currently, the method sets only input file parameters, not the potential parameters (see the SPRKKR documentation), and do not call the reset() function at all.

Parameters:
  • options (Dict[str, Any] | str | None) – Dictionary of values to be set, or the name of the value, if the value is given.

  • value – Value to be set. Setting this argument require to pass string name to the options argument.

  • unknown ('add', 'find' or None) – How to handle unknown (not known by the definition) parameters. If ‘find’, try to find the values in descendant containers, throw and exception if none is found. If ‘add’, add unknown values as custom values (use SECTION.OPTION_NAME notation) If None, throw an exception. Keyword only argument.

  • **kwargs (dict) – The values to be set (an alternative syntax as syntactical sugar)

get(name)[source]

Get the value of an input parameter. The parameter of the given name will be sought in sections and the value of the first such one will be returned. If there is an ambiguity, the name of the parameter can be given in SECTION.NAME notation.

property potential: Potential

Default value for mpi parameter of calculate - it determine the way whether and how the mpi is employed.

property atoms: SPRKKRAtoms

Atoms object, associate with the calculator.

Returns:

atoms

Return type:

ase2sprkkr.sprkkr.sprkkr_atoms.SPRKKRAtoms

_advance_counter()[source]

Advance counter for generating filenames with %c counter placeholder

_open_file(filename, directory, templator=None, named=False, mode='w+', allow_temporary=True, create_subdirs=False)[source]

Open a file given a ‘template’ filename file name

Parameters:
  • filename (str or file or None) – if False, temporary object is used if str is given, use it as a template if file is given, return it unchanged

  • directory (str) – Where to open the file

  • templator (callable) – If it is given, the filemae is processed using this function, see FilenameTemplator

  • named (bool) – Whether to use named temporary file.

  • mode (str) – Mode to open the file

  • allow_temporary (bool) – If False, throw an exception if the resulting filename should be temporary, i.e. if None as filename is given

  • create_subdirs (bool) – If true, create all non-existent directories in the given path

save_input(atoms=None, input_parameters=None, potential=None, input_file=None, potential_file=None, output_file=False, directory=None, create_subdirs=False, options={}, task=None, empty_spheres=None, mpi=None, return_files=False)[source]

Save input and potential files for a calculation.

Parameters:
  • properties (list of str) – List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.

  • input_parameters (sprkkr.input_parameters.input_parameters.InputParameters or str or None) –

    If None, the task specified in __init__ is used, or the default parameters for ‘SCF’ task

    will be created.

    If a string is given then if it is a task name, an InputParameters object will be created

    (with the default options for a given task) and saved to the input_file. Otherwise the task is interpreted as a task file name from which the input parameters will be readed.

    The input parameters is written into the input file,

    whose name is given by input_file argument.

  • potential (sprkkr.potential.potentials.Potential or str or None or False) – If it is None, the self.potential value is used instead (see the later options) If False, the potential filename is specified in the input_parameters. If True, create the potential according to the atoms and write to the resulting <potential_file> file. If str, then it is the filename of the potential, that is left unchanged on input If it is None, use the potential value of the calcualtor. If this is None too, the potential is set to True if atoms are set, to False otherwise.

  • input_file (str or bool or None) – Filename or template (see FilenameTemplator class) where to save the input file, None means to use the default value from the Calculator. See the __init__ method for the meaning of other options.

  • potential_file (str or bool or None) – Filename or template (see FilenameTemplator class) where to save the potential_file None means to use the default value from the Calculator. See the __init__ method for the meaning of other options.

  • output_file (str or bool or None) – A filename or a filename template (see FilenameTemplator class) where to save the output None means to use the default value from the Calculator. See the __init__ method for the meaning of other options.

  • directory (str | bool | Directory | None) – Path, to which the relative names of the files above will be resolved. False means temporary directory (usefull just for testing). None means use the (default) value specified by creating the calculator.

  • create_subdirs (boolean) – If true, create directories if they don’t exists.

  • mpi (bool or None) – Save input for a mpi calculation. None means to use the mpi value specified in the constructor. Actually, the only difference is that the temporary input file has to have filename.

  • empty_spheres (str | bool | None) – Whether to add empty spheres to the structure or not. ‘auto’ means add if no empty sphere is present. Default None means use the default value from the calculator for this parameter (which is ‘auto’ by default).

  • options (dict) – Options to set to the input_parameters. If input_parameters are given by a filename, they are readed from the file, altered by the options and then the modified input file (in a temporary file) will be used.

  • task (None) – Change the task (ARPES, DOS, etc…) before the calculation. Instead of setting input_parameters, this way retain the compatible settings in the input parameters.

  • return_files (boolean) – Return open files object instead of just string filenames.

Returns:

  • input_parameters (InputParameters) – Created task object to be run.

  • input_filename (str or file) – Input/task file. See return_files

  • potential_filename (str or file) – Potential file. See return_files

  • output_filename (str or file) – Output file. See return_files

run(atoms=None, input_parameters=None, potential=None, input_file=None, potential_file=None, output_file=None, directory=None, create_subdirs=False, options={}, task=None, empty_spheres=None, mpi=None, print_output=None, executable_suffix=None, executable_dir=None, gdb=False)[source]

Do the calculation, return various results.

Parameters:
  • print_output (bool or str or None) – Print output to stdout, too. If print_output==’info’ only a few lines per iteration will be printed. None means to use a default value (specified in constructor)

  • executable_suffix (str or bool or None) – If not None, it overrides the executable_postifx, that have been specified when the calculator have been created.

  • executable_dir (str or bool or None) – If not None, it overrides the executable_dir, that have been specified when the calculator have been created.

  • mpi (bool or None) – Runner for mpi to run a mpi calculation. True and int means autodetect: use True for a cluster where mpi is able to autodetect the number of the processes, otherwise use integer to specify the number of processes. None means use the default value (specified in the calculator’s contructor). E.g. mpi = [ ‘mpirun’, ‘-np’, ‘4’ ], mpi = 4

  • ---------

  • parameters (For the other)

  • method (see the save_input())

  • directory (str | bool | Directory | None)

  • create_subdirs (bool)

  • empty_spheres (str | bool | None)

value_or_default(name, value)[source]

Return the default value of the parameter, if the given value is None

calculate(atoms=None, properties=['energy'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'], input_parameters=None, potential=None, input_file=None, potential_file=None, output_file=None, directory=None, create_subdirs=False, empty_spheres=None, mpi=None, options={}, task=None, print_output=None, executable_suffix=None, executable_dir=None, gdb=False)[source]

ASE-interface method for the calculation. This method runs the appropriate task(s) for the requested properties (currently always the SCF one) and updates the calculator object with the results.

See https://wiki.fysik.dtu.dk/ase/development/calculators.html#ase.calculators.calculator.Calculator.calculate for the documentation of ASE interface.

Parameters:
  • properties (list or 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’.

    This calculator ignore properties and system_changes.

  • ---------

  • parameters (For the other)

  • methods (see the run() and save_input())

  • ---------

  • documentation (From ASE)

  • example:: (inserted into results dictionary like shown in this dummy) –

    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))}

  • directory (str | bool | Directory | None)

  • create_subdirs (bool)

  • empty_spheres (str | bool | None)

  • mpi (bool)

scf(*args, **kwargs)[source]

A shortcut for calculating a SCF task

phagen(*args, **kwargs)[source]

A shortcut for calculating a PHAGEN task

_abc_impl = <_abc._abc_data object>
kkrgen(*args, **kwargs)[source]

A shortcut for calculating a KKRGEN task

kkrspec(*args, **kwargs)[source]

A shortcut for calculating a KKRSPEC task

kkrch(*args, **kwargs)[source]

A shortcut for calculating a KKRCH task

run_xband(executable='xband')[source]
copy_with_potential(potential)[source]

Return copy of self, with the potential variable set. Use the method to create a new calculator with the given “result potential”

property potential_object

Convert self.potential to a Potential object

change_task(task)[source]

Just a shortcut to input_parameters.change_task