SemiGrandCanonicalMonteCarloHook

class SemiGrandCanonicalMonteCarloHook(elements, chemical_potential=None, temperature=None, swap_ratio=None, random_seed=None, call_interval=None)

A hook function that implements semi-grand canonical Monte Carlo simulation

Parameters:
  • elements (Sequence of PeriodicTableElement) – The elements being swapped between.

  • chemical_potential (PhysicalQuantity of type energy) – The chemical potential of swapping from the first to the second atom.
    Default: 0 eV

  • temperature (PhysicalQuantity of type temperature) – The Monte Carlo selection temperature.
    Default: 300 Kelvin

  • swap_ratio (float) – The fraction of available atoms that are attempted to be swapped at each call.
    Default: 0.01

  • random_seed (int) – The seed for the random number generator used to select the Monte Carlo moves.

  • call_interval (int) – The number of dynamics steps between each Monte Carlo step.

callInterval()
Returns:

The call interval of this hook function.

Return type:

int

chemicalPotential()
Returns:

The chemical potential difference used in calculating swap probabilities.

Return type:

PhysicalQuantity of type energy

elements()
Returns:

List of the elements being swapped in the Monte Carlo step.

Return type:

list of PeriodicTableElement

monteCarloQuantity()

The value being averaged in the Monte Carlo simulation. In this simulation this is the fraction of the second atom in the configuration.

Returns:

The ratio of second atoms to the first in the configuration.

Return type:

float

randomSeed()
Returns:

The random seed used to create the Monte Carlo random number generator.

Return type:

int

swapElementCount(configuration)

Count the number of atoms that have been swapped to the second element.

Parameters:

configuration (BulkConfiguration) – The current configuration.

Returns:

The number of elements

Return type:

int

swapRatio()
Returns:

The fraction of atoms to attempt to swap in each Monte Carlo cycle.

Return type:

float

temperature()
Returns:

The temperature of the simulation.

Return type:

PhysicalQuantity of type temperature

uniqueString()

Return a unique string representing the state of the object.

Usage Examples

In this example the semi-grand canonical Monte Carlo method is used to study the composition of a gold-silver alloy. The chemical potential is chosen to be close to the change in free energy of the two materials. The result of the calculation is a ConfigurationDataContainer that contains the composition at each step as a measurement. Averaging this value over the second half of the simulation should give a composition of approximately 23% silver and 77% gold.

A workflow for the calculation can be downloaded here with a corresponding python script Au_Ag_MonteCarlo.py. The simulation may take around an hour to run, given the number of samples required.

Notes

The SemiGrandCanonicalMonteCarloHook class implements Monte Carlo simulation in the semi-grand canonical ensemble. In this ensemble the number of particles, the difference in chemical potential, temperature and pressure are held constant. This allows for swapping identities of particles in the simulation with the given change in chemical potential. Volume changes are also allowed when controlling the pressure.

In a semi-grand canonical Monte Carlo simulation the acceptance probability of swapping one element for another is given as:

\[p_{acc}(o \rightarrow n) = \min\left[1, \exp\left(\frac{-\Delta E -\Delta \mu N \Delta x}{k_bT}\right)\right]\]

Here \(\Delta E\) is the change in energy between the old and new states, \(\Delta \mu\) is the change in the chemical potential between the two elements, \(N\) is the number of atoms able to be exchanged and \(\Delta x\) is the change in the fractional composition of the elements.

The semi-grand canonical ensemble is useful for studying the thermodynamics of alloys[1]. Using this method the average composition between two elements can be calculated at a specific chemical potential. Calculating the composition at a range of chemical potentials can then give the relationship between the composition and the chemical potential. In a binary this is related to the free energy such that:

\[\Delta \mu(x, T) = \frac{\partial G(x, T)}{\partial x}\]

Here \(T\) is the temperature and \(G\) is the free energy. Integrating the chemical potential with respect to the composition then gives the free energy. This can be then used to determine the thermodynamics of mixing of the two materials, and if the elements are miscible under the given conditions.

Semi-grand canonical Monte Carlo simulations are normally carried out as part of a hybrid Monte Carlo simulation using the HybridMonteCarlo() method. The dynamics steps handle sampling the relative positions of the atoms, while the Monte Carlo steps sample possible elemental configurations. In creating the class the first argument, elements, takes a tuple of the two elements being exchanged during the simulation. Other elements are assumed not to be able to be exchanged. This can be used to simulate the thermodynamics of exchanging one element for another in a ternary material or an oxide. Note also that the order of the atoms matters in this argument. The results of the simulation are generally expressed with reference to the second element. So the difference in chemical potential is given as the change in chemical potential in going from the first to the second element. The composition is also expressed as the fraction of the second element in the configuration.

The swap_ratio argument is used to specify the number of swap moves performed in each Monte Carlo cycle. This is expressed as a fraction of the number of atoms available to be swapped. Similarly the call_interval argument specifies the number of dynamics steps between a Monte Carlo cycle.