CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
CASM::SiteExchanger Class Reference

#include <SiteExchanger.hh>

Detailed Description

Definition at line 11 of file SiteExchanger.hh.

Public Member Functions

 SiteExchanger (const Supercell &scel)
 Constructor determine possible swaps in the given Supercell. More...
 
const std::vector< Index > & variable_sites () const
 std::vector of indices into occupation array of ConfigDoF that have more than one allowed occupant More...
 
const std::vector< int > & sublat () const
 sublat()[i] is the sublattice index for site variable_sites()[i] More...
 
const std::vector< std::vector
< std::vector< int > > > & 
possible_swap () const
 For a given sublattice with a particular occupant, show what OTHER occupants it could be. More...
 
const std::vector< std::vector
< int > > & 
sublat_to_mol () const
 Map the integer values from the possible swaps or variable sites arrays into actual species. More...
 

Private Attributes

std::vector< Indexm_variable_sites
 std::vector of indices into occupation array of m_confdof that have more than one allowed occupant More...
 
std::vector< int > m_sublat
 m_sublat[i] is the sublattice index for site m_variable_sites[i] More...
 
std::vector< std::vector
< std::vector< int > > > 
m_possible_swap
 For a given sublattice with a particular occupant, show what OTHER occupants it could be m_possible_swap[sublat][curr_occupant index][i] -> other occupant index (i, for each possible other occupant) More...
 
std::vector< std::vector< int > > m_sublat_to_mol
 Map the integer values from the possible swaps or variable sites arrays into actual species m_sublat_to_mol[sublat][occupant_index] -> species_type_index. More...
 

Constructor & Destructor Documentation

CASM::SiteExchanger::SiteExchanger ( const Supercell scel)

Constructor determine possible swaps in the given Supercell.

For Monte Carlo simulations such as Grand Canonical that involve changing the occupants of sites, you need to know: -Which sites are allowed to change -> variable_sites std::vector<long int> -Which sublattices those sites are on -> sublat std::vector<int> -What sites that are allowed to change can change to -> possible_swap std::vector<std::vector<std::vector<int> > > -How to interpret the occupant indices -> sublat_to_mol std::vector<std::vector<int>

The Monte Carlo class works on a Configuration, which has an std::vector<int> that describes what's living at each site (m_occupation). Remember this array is organized in blocks of primitive basis sites. This means that for a PRIM with 3 basis sites in a SUPERCELL of size four, the first four values in the occupancy array would correspond to the first basis site of the PRIM. Put another way, the array is organized in bijk order.

Suppose site 0 can hold type A, D 1 can hold type A 2 can hold type A, B, C

PRIM: /---------—\ SUPERCELL: /----------------------—\ | 2 | | 5 | 11 | | 1 | | 4 | 10 | | 0 | | 3 | 9 | ---------—/ |---------—+---------—| | 2 | 8 | | 1 | 7 | | 0 | 6 | ----------------------—/

Though the order the example of SUPERCELL shows each PRIM is may be off, it is unimportant for this routine. The occupancy array of the Configurations with parent SUPERCELL will represent sites in the order:

OCCUPATION: | 0 3 6 9 | 1 4 7 10 | 2 5 8 11 | (!)

(!) The actual occupancy array holds the values of the current occupant. What's shown above is simply meant to show which sites correspond to each index.

Where '|' represents the beginning/end of a primitive basis block (not found in the actual std::vector<int>). variable_sites is simply a subset of the occupancy array indices, containing only the blocks for sites that can hold more than one occupant. We don't care about the others because the indices in variable_sites are selected at random to change the occupation at a site. For this example, this means we only care about sites that came from primitive sites 0 (A, D) and 2 (A, B, C).

VARIABLE_SITES: [ 0 1 2 3 8 9 10 11 ] (!!)

(!!) Unlike the OCCUPATION example, VARIABLE_SITES shown above would hold these values.

We also store the sublattice that each variable_site corresponds to

SUBLAT: [ 0 0 0 0 2 2 2 2 ] (!!)

(!!) Unlike the OCCUPATION example, SUBLAT shown above would hold these values.

The result is an array from which we pick a random value, which we use as an index to access a site in the occupancy array of a Configuration. Whatever site that corresponds to will have more than one allowed occupant. We want to change the current occupant to something else, but need to know what values that site can go up to. In order to know this we use possible_swap, which for a given site (outer array) for a given current occupant (middle array) holds all values that are NOT the current occupant (inner array).

POSSIBLE_SWAP: [ 1 ][ 1 2 ] [ 0 ][ 0 2 ] [ 0 1 ]

The example above shows m_possible_swap, with each column of [] representing a sublattice. For a particular sublattice, we can find all the values the site can change to by looking at the innermost array with the index of the current occupant. For example, we randomly pick index 6 of VARIABLE_SITES. This corresponds to site 8 in SUPERCELL. This site can be occupied by A, B, or C, which is represented simply as 0, 1, 2 in the occupancy array of the Configuration. By accessing said array at index 8, we might find the value to be 2. POSSIBLE_SWAP[6][2] shows the array [ 0 1 ], which are values that SUPERCELL site 8 is allowed to be changed to (currently C, but can change to A, B). When doing Monte Carlo we can again randomly pick from this innermost array to change the current occupant. The last thing needed is a way to know what the integers in the occupancy array mean in terms of actual species. For example, a value of 1 on SUPERCELL site 3 represents species D, but a value of 1 on SUPERCELL site 8 represents species B. To know what means what we use site_to_mol. For a particular site (outer array) with a particular current occupant (inner array) we get the index into the array of species (type std::string) returned by ParamComposition::get_components().

Suppose the array of allowed components is returned as [ A B C D ]

SUBLAT_TO_MOL: [ 0 3 ] [ 0 1 2 ]

Using the same example as before, we can read that a value of 1 on sublattice 0 corresponds to D, while a value of 1 on sublattice 1 represents species B: -VARIABLE_SITES[1] gives the index into the occupancy array of Configuration to SUPERCELL site 3 -SUBLAT[1] gives the sublattice index for SUPERCELL site 3, which is 0 -POSSIBLE_SWAP[SUBLAT[1]][1] (assuming the current occupant is 1) shows only 0 as an alternative allowed occupant -SUBLAT_TO_MOL[SUBLAT[1]][1] gives value 3, which corresponds to D in the array of allowed components

-VARIABLE_SITES[6] gives the index into the occupancy array of Configuration to SUPERCELL site 8 -SUBLAT[6] gives the sublattice index for SUPERCELL site 8, which is 2 -POSSIBLE_SWAP[SUBLAT[6]][1] (assuming the current occupant is 1) shows 0 and 2 as an alternative allowed occupants -SUBLAT_TO_MOL[SUBLAT[6]][1] gives value 1, which corresponds to B in the array of allowed components

Definition at line 103 of file SiteExchanger.cc.

Member Function Documentation

const std::vector< std::vector< std::vector<int> > >& CASM::SiteExchanger::possible_swap ( ) const
inline

For a given sublattice with a particular occupant, show what OTHER occupants it could be.

possible_swap()[sublat][curr_occupant index][i] -> other occupant index (i, for each possible other occupant)

Definition at line 31 of file SiteExchanger.hh.

const std::vector<int>& CASM::SiteExchanger::sublat ( ) const
inline

sublat()[i] is the sublattice index for site variable_sites()[i]

Definition at line 24 of file SiteExchanger.hh.

const std::vector< std::vector<int> >& CASM::SiteExchanger::sublat_to_mol ( ) const
inline

Map the integer values from the possible swaps or variable sites arrays into actual species.

sublat_to_mol()[sublat][occupant_index] -> species_type_index

Definition at line 38 of file SiteExchanger.hh.

const std::vector<Index>& CASM::SiteExchanger::variable_sites ( ) const
inline

std::vector of indices into occupation array of ConfigDoF that have more than one allowed occupant

Definition at line 19 of file SiteExchanger.hh.

Member Data Documentation

std::vector< std::vector< std::vector<int> > > CASM::SiteExchanger::m_possible_swap
private

For a given sublattice with a particular occupant, show what OTHER occupants it could be m_possible_swap[sublat][curr_occupant index][i] -> other occupant index (i, for each possible other occupant)

Definition at line 52 of file SiteExchanger.hh.

std::vector<int> CASM::SiteExchanger::m_sublat
private

m_sublat[i] is the sublattice index for site m_variable_sites[i]

Definition at line 48 of file SiteExchanger.hh.

std::vector< std::vector<int> > CASM::SiteExchanger::m_sublat_to_mol
private

Map the integer values from the possible swaps or variable sites arrays into actual species m_sublat_to_mol[sublat][occupant_index] -> species_type_index.

Definition at line 56 of file SiteExchanger.hh.

std::vector<Index> CASM::SiteExchanger::m_variable_sites
private

std::vector of indices into occupation array of m_confdof that have more than one allowed occupant

Definition at line 45 of file SiteExchanger.hh.


The documentation for this class was generated from the following files: