substitutionalAlloy¶
- substitutionalAlloy(configuration, indices, algorithm, percentage, new_element, rng=None)¶
Create alloy by substituting a percentage of the specified indices with a new element.
- Parameters:
configuration (BulkConfiguration) – The configuration to create the alloy from.
indices (List of integers) – The indices of the atoms to change.
algorithm (FixedFraction | NormalDistribution) – The algorithm to randomly change a percentage of the atoms. NormalDistribution means you assign a number [0,1] from a normal distribution across all atoms and only pick those that have a value below the given percentage. FixedFraction means if you set 25%, you get 25% of the total number of atoms changed. The size of the random sample are the percentage of atoms provided, rounded to nearest integer.
percentage (float) – The percentage of the atoms that should be changed.
new_element (PeriodicTable.Element or None (vacancy)) – The element to change to.
rng (numpy.random.RandomState) – The random number generator used to generate the random number stream. If None, a new random number generator stream will be made with a seed obtained from the operating system’s entropy pool. Default: numpy.random.RandomState().
- Returns:
The created alloy.
- Return type:
Usage Examples¶
Generate a AuAg alloy with 50/50 composition, by first creating a Ag crystal of the desired size. To affect the entire crystal, define a selection that contains all Ag atoms for passing to the substitutionalAlloy function.
# --- Create the initial configuration ---
# Set up lattice
vector_a = [8.1714, 0.0, 0.0]*Angstrom
vector_b = [0.0, 8.1714, 0.0]*Angstrom
vector_c = [0.0, 0.0, 8.1714]*Angstrom
lattice = UnitCell(vector_a, vector_b, vector_c)
# Define elements
elements = [Silver, Silver, Silver, Silver, Silver, Silver, Silver, Silver,
Silver, Silver, Silver, Silver, Silver, Silver, Silver, Silver,
Silver, Silver, Silver, Silver, Silver, Silver, Silver, Silver,
Silver, Silver, Silver, Silver, Silver, Silver, Silver, Silver]
# Define coordinates
fractional_coordinates = [[ 0. , 0. , 0. ],
[ 0. , 0. , 0.5 ],
[ 0. , 0.5 , 0. ],
[ 0. , 0.5 , 0.5 ],
[ 0.5 , 0. , 0. ],
[ 0.5 , 0. , 0.5 ],
[ 0.5 , 0.5 , 0. ],
[ 0.5 , 0.5 , 0.5 ],
[ 0.25, 0.25, 0. ],
[ 0.25, 0.25, 0.5 ],
[ 0.25, 0.75, 0. ],
[ 0.25, 0.75, 0.5 ],
[ 0.75, 0.25, 0. ],
[ 0.75, 0.25, 0.5 ],
[ 0.75, 0.75, 0. ],
[ 0.75, 0.75, 0.5 ],
[ 0.25, 0. , 0.25],
[ 0.25, 0. , 0.75],
[ 0.25, 0.5 , 0.25],
[ 0.25, 0.5 , 0.75],
[ 0.75, 0. , 0.25],
[ 0.75, 0. , 0.75],
[ 0.75, 0.5 , 0.25],
[ 0.75, 0.5 , 0.75],
[ 0. , 0.25, 0.25],
[ 0. , 0.25, 0.75],
[ 0. , 0.75, 0.25],
[ 0. , 0.75, 0.75],
[ 0.5 , 0.25, 0.25],
[ 0.5 , 0.25, 0.75],
[ 0.5 , 0.75, 0.25],
[ 0.5 , 0.75, 0.75]]
# Set up configuration
bulk_configuration = BulkConfiguration(
bravais_lattice=lattice,
elements=elements,
fractional_coordinates=fractional_coordinates
)
# --- Generate a substitutional alloy ---
# Create a list of selected atoms. A percentage of these will be
# randomly substituted by the new element.
selection = [0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16,
17, 18, 19, 20, 21,
22, 23, 24, 25, 26,
27, 28, 29, 30, 31]
configuration = substitutionalAlloy(
configuration=bulk_configuration,
indices=numpy.array(selection),
algorithm=NormalDistribution,
percentage=50.0,
new_element=Gold
)
Notes¶
The percentage must be a number between 0.0 and 100.0