Author Topic: how to write a loop in ATK?  (Read 1741 times)

0 Members and 1 Guest are viewing this topic.

Offline xiaolight

  • Regular QuantumATK user
  • **
  • Posts: 14
  • Country: us
  • Reputation: 0
    • View Profile
how to write a loop in ATK?
« on: July 20, 2017, 21:45 »
I am not familiar with the Python language in ATK, so I want to know how to write a loop in ATK, like if I want to change the vacuum level to change the work function of a material, every time what I do is just stretch the lattice little by little and get the result, it is really time-consuming,  so is there some tutorials to show how to write a code to solve this?

Offline Jess Wellendorff

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 933
  • Country: dk
  • Reputation: 29
    • View Profile
Re: how to write a loop in ATK?
« Reply #1 on: July 21, 2017, 08:26 »
Attached script shows how to run calculations for a range of strained silicon lattices. The looping is done like this:
Code
# 10 different relative strains from 0.95 to 1.05
x = numpy.linspace(0.95, 1.05, 11)

# loop over strains and do calculation
for strain in x:
    # output file for calculation with this strain
    out = 'name_%f.hdf5' % strain

    # -------------------------------------------------------------
    # Bulk Configuration
    # -------------------------------------------------------------
    # Set up lattice
    lattice = FaceCenteredCubic(5.4306*Angstrom * strain)
Note that the script saves data in HDF5 format, as introduced with ATK 2017. Change to NC if you use ATK 2016 or older.