Author Topic: How to restart a geometry optimization calculation with previous trajectory file  (Read 4172 times)

0 Members and 1 Guest are viewing this topic.

Offline lknife

  • QuantumATK Guru
  • ****
  • Posts: 214
  • Country: us
  • Reputation: 1
    • View Profile
Dear all,

I want to restart the geometry optimization calculation which was stopped without finishing. I saved the trajectory file as doing the optimization. Then, how to use the trajectory file to restart the calculation? I have read the tutorial "Restarting a stopped calculation". However, in that tutorial, it was just said "you can take out some of the later images and set up a new optimization using this geometry as a starting point".

The question is: how can I do it? how to use the trajectory file as a starting point?

Thanks very much for your time and kind help!
 

Offline lknife

  • QuantumATK Guru
  • ****
  • Posts: 214
  • Country: us
  • Reputation: 1
    • View Profile
If my previously saved trajectory filename is "trajectory.nc", when I want to restart the calculation, do I just need to add a code line "trajectory = nlread('trajectory.nc', Trajectory)[0]" to my original script as shown below?

---------------------------------------------------------------------
bulk_configuration = OptimizeGeometry(
    bulk_configuration,
    max_forces=0.01*eV/Ang,
    max_stress=0.001*eV/Ang**3,
    max_steps=1000,
    max_step_length=0.2*Ang,
    constraints=constraints,
    trajectory_filename='trajectory.nc',
    optimizer_method=LBFGS(),
    constrain_bravais_lattice=True,
)
trajectory = nlread('trajectory.nc', Trajectory)[0]
------------------------------------------------------------------

Thanks a lot for anyone willing to help me!


Offline Ulrik G. Vej-Hansen

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 426
  • Country: dk
  • Reputation: 9
    • View Profile
No this will not work - in this case you read in the trajectory after performing the optimization, and do not extract the configuration.

You need to read in the trajectory before doing the optimization, and then also read in the actual configuration and set the calculator anew:

trajectory = nlread('trajectory.nc', Trajectory)[0]
bulk_configuration=trajectory.lastImage()

bulk_configuration.setCalculator(...)

bulk_configuration = OptimizeGeometry(
    bulk_configuration,
    max_forces=0.01*eV/Ang,
    max_stress=0.001*eV/Ang**3,
    max_steps=1000,
    max_step_length=0.2*Ang,
    constraints=constraints,
    trajectory_filename='trajectory.nc',
    optimizer_method=LBFGS(),
    constrain_bravais_lattice=True,
)


The calculator is not saved in a trajectory, only the geometry is.
« Last Edit: June 12, 2017, 16:44 by Ulrik G. Vej-Hansen »

Offline lknife

  • QuantumATK Guru
  • ****
  • Posts: 214
  • Country: us
  • Reputation: 1
    • View Profile
Thank you for your reply!

Attached is the .py file for restarting the calculation. Could you please have a look if it is correct now?

Thanks very much again for your kind help!

Offline Ulrik G. Vej-Hansen

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 426
  • Country: dk
  • Reputation: 9
    • View Profile
Looks ok to me. Remember that you can test the new code-lines used to read from the Trajectory by simply running the script on your laptop.

Offline lknife

  • QuantumATK Guru
  • ****
  • Posts: 214
  • Country: us
  • Reputation: 1
    • View Profile
Thanks very much for your kind help!