Author Topic: Random Swap of Elements  (Read 71 times)

0 Members and 1 Guest are viewing this topic.

Offline physics

  • Heavy QuantumATK user
  • ***
  • Posts: 37
  • Country: se
  • Reputation: 0
    • View Profile
Random Swap of Elements
« on: May 7, 2024, 14:38 »
Hi everyone,

How to randomly swap 2 elements in a alloy using Quantum ATK?

Thank you

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: Random Swap of Elements
« Reply #1 on: May 10, 2024, 00:17 »
Python coding...
You can easily access the elements in a structure with configuration.elements(), that gives a list of the elements, you can then use the random.random() function to pick indices in a relevant way, replace an element and then put it back into the configuration with the secret method configuration._changeAtoms(elements=new_elements).

Or you can just remake the configuration from it's old parts:
new_configuration = BulkConfiguration(old_configuration.bravaisLattice(), new_elements, old_configuration.cartesianCoordinates())