vossjo / ase-espresso

ase interface for Quantum Espresso
GNU General Public License v3.0
65 stars 55 forks source link

Traj files not updated while using vc-relax #23

Closed arv14ind closed 7 years ago

arv14ind commented 7 years ago

Hi users,

I am currently trying to run calculations that would simultaneously optimize the positions of atoms while also optimizing the cell shape and volume. I am using the vc-relax mode in ase espresso to do this.

The problem I encountered is that my calculations are converging to the correct potenital energy, but the traj file is not updated from the initialization. This is bizarre considering that the potenital energy is read from the same atoms object I used to update the traj files. I tried to read off lattice constants from the same atoms object and they are not updated either. So the only thing that was correct was the potenital energy.

So there is something off about vc-relax that's causing this to happen. Any suggestions on how to resolve this issue?

Here is part of the job script I used for this calculation

This is a part of the script I used for job submission

from ase.io import read from ase.optimize import QuasiNewton from espresso import espresso from ase.dft.bee import BEEF_Ensemble import cPickle as pickle import os atoms = read('qn.traj') calc = espresso(pw=600, dw=6000, xc='PBE', kpts=(12,12,12), nbands=-60, mode = 'vc-relax', cell_dynamics = 'bfgs', opt_algorithm = 'bfgs', cell_factor = 5, smearing='gaussian', sigma=0.1, convergence= {'energy':1e-5, 'mixing':0.1, 'nmix':10, 'mix':4, 'maxsteps':500, 'diag':'david', 'mixing_mode':'local-TF' }, dipole={'status':False}, spinpol=False, outdir='calcdir', output = {'removesave':True}, psppath = psppath)

atoms.set_calculator(calc) qn = QuasiNewton(atoms,trajectory='qn.traj',logfile='qn.log') qn.run(fmax=0.05) energy = atoms.get_potential_energy() f = open('out.energy','w') f.write(str(energy)) f.close()

Thank you all for your help and time in advance!

vossjo commented 7 years ago

'vc-relax' is an optimization algorithm running in espresso itself - it is not run base ase's BFGS, hence it won't write to trajectory files. You can convert the output of espresso (the log file) to a trajectory file with the included pwlog2trajectory tool. In the above example, you run ASE's QN on top of espresso's own BFGS / vc-relax, that doesn't make sense. With the above vc-relax, etc. definitions, you should simply run atoms.get_potential_energy() to trigger an espresso calculation (which will internally use vc-relax then). The simplest solution is to save the atoms from calc.get_final_structure() to a file and take the energy from atoms.get_potential_energy(). If having trajectories on the fly is important, espresso's own optimizers cannot be used, use ASE's optimizers instead.