Skip to content

Resolve "Input atoms object is changed unexpectedly when running MC"

Changes here should solve the following user case where input atoms were unexpectedly changed when running mc:

atoms = bulk('Al').repeat(3)
atoms.numbers[0] = 31
print(atoms)

cs  = ClusterSpace(atoms, [5.0], ['Al', 'Ga'])
ce = ClusterExpansion(cs, np.array([0.33]*len(cs)))

calc = ClusterExpansionCalculator(atoms, ce)

mc = CanonicalEnsemble(atoms, calc, temperature=300)
mc.run(50)
print(atoms)

Running above script in the master will return this output:

Atoms(symbols='GaAl26', pbc=True, cell=[[0.0, 6.074999999999999, 6.074999999999999], [6.074999999999999, 0.0, 6.074999999999999], [6.074999999999999, 6.074999999999999, 0.0]])
Atoms(symbols='Al2GaAl24', pbc=True, cell=[[0.0, 6.074999999999999, 6.074999999999999], [6.074999999999999, 0.0, 6.074999999999999], [6.074999999999999, 6.074999999999999, 0.0]])

By doing the same in the current branch the input atoms must remain unchanged:

Atoms(symbols='GaAl26', pbc=True, cell=[[0.0, 6.074999999999999, 6.074999999999999], [6.074999999999999, 0.0, 6.074999999999999], [6.074999999999999, 6.074999999999999, 0.0]])
Atoms(symbols='GaAl26', pbc=True, cell=[[0.0, 6.074999999999999, 6.074999999999999], [6.074999999999999, 0.0, 6.074999999999999], [6.074999999999999, 6.074999999999999, 0.0]])

Merge request reports