Handle the fact that mchammer no longer edits the atoms object
In icet 0.2, mchammer changed the atoms object such that one could run mchammer in a loop where the last state from one iteration conveniently provided the initial state to the next. This behavior changed with icet 0.3, so that the atoms object is no longer changed. I don't know if this was on purpose or not, but if it is on purpose, the tutorial should probably be changed so that this is reflected.
The behavior can be observed by running this script in different versions (it is almost identical to the tutorial on running VCSGC):
from ase.build import make_supercell
from icet import ClusterExpansion
from mchammer.calculators import ClusterExpansionCalculator
from mchammer.ensembles import VCSGCEnsemble
import numpy as np
from os import mkdir
# step 1: Set up structure to simulate as well as calculator
ce = ClusterExpansion.read('mixing_energy.ce')
atoms = make_supercell(ce.cluster_space.primitive_structure,
3 * np.array([[-1, 1, 1],
[1, -1, 1],
[1, 1, -1]]))
atoms.set_chemical_symbols(['Ag']*108)
calculator = ClusterExpansionCalculator(atoms, ce)
# step 2: Carry out Monte Carlo simulations
# Make sure output directory exists
output_directory = 'monte_carlo_data'
try:
mkdir(output_directory)
except FileExistsError:
pass
for temperature in [900, 300]:
# Evolve configuration through the entire composition range
for phi in np.arange(-2.1, 0.11, 0.08):
# Initialize MC ensemble
mc = VCSGCEnsemble(
atoms=atoms,
calculator=calculator,
temperature=temperature,
data_container='{}/vcsgc-T{}-phi{:+.3f}.dc'
.format(output_directory, temperature, phi),
phis={'Ag': -2.0 - phi, 'Pd': phi},
kappa=200)
print('1', atoms.get_chemical_formula(), mc.atoms.get_chemical_formula())
mc.run(number_of_trial_steps=2 * len(atoms))
print('2', atoms.get_chemical_formula(), mc.atoms.get_chemical_formula())