Configuration manager

class mchammer.ConfigurationManager(atoms, strict_constraints, sites_by_sublattice, occupation_constraints=None)

The ConfigurationManager owns and handles information pertaining to a configuration being sampled in a Monte Carlo simulation.

  • atoms (ASE Atoms) – configuration to be handled
  • strict_constraints (list of list of int) – strictest form of the allowed occupations
  • sites_by_sublattice (list of list of int) – sites (inner list) that belong to each sublattice (outer list)
  • occupation_constraints (list of list of int) – optional occupation constraint to enfore a more stricter species occupation than what is allowed from the Calculator.


  • occupation constraint not implemented
  • add check that all sites in the different sublattices all have the same occupation constraint.
  • revise docstrings
  • clarify “occupation_constraints” vs “strict_constraints”; the OccupationConstraints class should help here

atomic structure associated with configuration (copy)

Return type:Atoms

Returns a site index and a new species for the site.

Parameters:sublattice (int) – index of sublattice from which to pick a site
Return type:Tuple[int, int]

Returns two random sites (first element of tuple) and their occupation after a swap (second element of tuple). The new configuration will obey the occupation constraints associated with the configuration mananger.

Parameters:sublattice (int) – sublattice from which to pick sites


  • profile this method as it is called frequently
  • look for speed up opportunities
  • The current implementation assumes all sites in this sublattice to have the same allowed occupations.
Return type:Tuple[List[int], List[int]]

occupation constraints associated with configuration manager (copy); the outer list runs over sites with each inner list representing the species allowed on this site.

Return type:List[List[int]]

occupation vector of the configuration (copy)

Return type:List[int]

sites belonging to each sublattice of the configuration (copy)

Return type:List[List[int]]
update_occupations(sites, species)

Updates the occupation vector of the configuration being sampled. This will change the state in both the configuration in the calculator and the configuration manager.

  • sites (List[int]) – indices of sites of the configuration to change
  • species (List[int]) – new occupations (species) by atomic number