Author Topic: Updating the DynamicalMatrix object in the loop causes unexpected behavior  (Read 367 times)

0 Members and 1 Guest are viewing this topic.

Offline krzpyrch

  • New ATK user
  • *
  • Posts: 2
  • Country: pl
  • Reputation: 0
    • View Profile
I want to calculate the series of dynamical matrixes in QuantumATK (Version Q-2019.12). I thought that this could be achieved by using standard python for loop and looping after parameter, structure, etc.
Unfortunately, this procedure only results in the proper calculation of the first matrix; others are only initialized but not calculated. I attach the sample script in which this problem occurs.
Is it the right way to calculate the dependence of dynamical matrixes on some parameters?
The desired result should be a series of matrixes in one .hdf5 file.

Thank you for any explanation and help.

Offline Anders Blom

  • QuantumWise Staff
  • Supreme ATK Wizard
  • *****
  • Posts: 5035
  • Country: dk
  • Reputation: 78
    • View Profile
    • QuantumWise
DynamicalMatrix is not designed for your intention, but you can work around it. It is however designed to be interruptable, which is why it doesn't do what you want. Let me explain.

The dynamical matrix can take very long to calculate. If something happens along the way (network outage, computer crashes, whatever) you don't want to rerun the whole thing, but start from where it broke. This is possible with the DynamicalMatrix study object - to restart, you just run the script again. This is also why there is no need for a nlsave() statement, as the results are stored in "filename" along the way.

But this also means that when you come around the second time in the loop, since the filename is the same, the code will just check if the file exists already, and try to start from where it finished. Since it actually completed, it will just exit.

So I think (without having checked) that the solution is as simple as using unique "filename" for each step in the loop. This of course means all objects are saved to different files, but you can just add an explicit nlsave statement after DynamicalMatrix (within the loop), to store all objects in the same file.

I would suggest testing a script like this with a forcefield before trying with DFT, which could takes days. Even if the results are not good, at least it will test the workflow.