QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: xiaolight on July 20, 2017, 21:45

Title: how to write a loop in ATK?
Post by: xiaolight 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?
Title: Re: how to write a loop in ATK?
Post by: Jess Wellendorff 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.