matador.swaps package

This module implements the AtomicSwapper class which takes a Query object and a desired “swap”, e.g. swap all group [I] elements to Li, ready to be re-relaxed.

class matador.swaps.AtomicSwapper(cursor, swap=None, uniq=False, top=None, maintain_num_species=True, debug=False, **kwargs)[source]

Bases: object

This class handles the creation of input files from database queries that have swapped atoms.

Initialise class with query cursor and arguments.

Parameters:

cursor (list) – cursor of documents to swap.

Keyword Arguments:
  • swap (str) – specification of swaps to perform, e.g. “LiP:KSn” will swap all Li->P and all K->Sn in the cursor.

  • uniq (bool/float) – filter documents by similarity with the default sim_tol (True) or the value provided here.

  • top (int) – only swap from the first top structures in the cursor.

  • maintain_num_species (bool) – only perform swaps that maintain the number of species in the structure

  • debug (bool) – enable debug output

  • kwargs (dict) – dictionary of extra arguments that should be ignored.

parse_swaps(swap_args=None)[source]

Parse command line options into valid atomic species swaps.

e.g. –swap LiP:NaAs

==> [[[‘Li’], [‘P’]], [[‘Na’], [‘P’]].

Handles multiple many-to-many swaps, macros for groups of the periodic table, and wildcards.

Keyword Arguments:

swap_args (str) – overrides command-line swap args.

construct_swap_options()[source]

Iterate over possible combinations of multiple many-to-many swaps and create a dict for each swap.

atomic_swaps(source_doc)[source]

Swap atomic species according to parsed options.

Parameters:

source_doc (dict) – matador doc to swap from.

Submodules

matador.swaps.swaps module

This file implements atomic swaps through the AtomicSwapper class.

class matador.swaps.swaps.AtomicSwapper(cursor, swap=None, uniq=False, top=None, maintain_num_species=True, debug=False, **kwargs)[source]

Bases: object

This class handles the creation of input files from database queries that have swapped atoms.

Initialise class with query cursor and arguments.

Parameters:

cursor (list) – cursor of documents to swap.

Keyword Arguments:
  • swap (str) – specification of swaps to perform, e.g. “LiP:KSn” will swap all Li->P and all K->Sn in the cursor.

  • uniq (bool/float) – filter documents by similarity with the default sim_tol (True) or the value provided here.

  • top (int) – only swap from the first top structures in the cursor.

  • maintain_num_species (bool) – only perform swaps that maintain the number of species in the structure

  • debug (bool) – enable debug output

  • kwargs (dict) – dictionary of extra arguments that should be ignored.

parse_swaps(swap_args=None)[source]

Parse command line options into valid atomic species swaps.

e.g. –swap LiP:NaAs

==> [[[‘Li’], [‘P’]], [[‘Na’], [‘P’]].

Handles multiple many-to-many swaps, macros for groups of the periodic table, and wildcards.

Keyword Arguments:

swap_args (str) – overrides command-line swap args.

construct_swap_options()[source]

Iterate over possible combinations of multiple many-to-many swaps and create a dict for each swap.

atomic_swaps(source_doc)[source]

Swap atomic species according to parsed options.

Parameters:

source_doc (dict) – matador doc to swap from.