[ase-users] Using internal optimizers of codes with ASE
Ask Hjorth Larsen
asklarsen at gmail.com
Fri Jun 2 16:23:27 CEST 2017
Dear Ivan and others,
We finally finished the GULP interface. In doing so, we also decided
on a way (for now) to use internal optimizers (as discussed below a
long time ago).
Basically:
atoms = Atoms(...)
calc = GULP(...keywords for doing a relaxation in gulp...)
opt = calc.get_optimizer(atoms)
opt.run(fmax=0.05, steps=17)
Thus, the calculator can create a kind of optimizer object, but the
optimizer will simply 'cheat' and call get_potential_energy() which we
know will trigger a relaxation, then update the atomic coordinates
afterwards. The fact that the object has a run() method allows it to
be used (hopefully) transparently in the same way as other ASE
optimizers e.g. through BasinHopping.
The optimizer object is only a few lines of code:
class GULPOptimizer:
def __init__(self, atoms, calc):
self.atoms = atoms
self.calc = calc
def todict(self):
return {'type': 'optimization',
'optimizer': 'GULPOptimizer'}
def run(self, fmax=None, steps=None, **gulp_kwargs):
if fmax is not None:
gulp_kwargs['gmax'] = fmax
if steps is not None:
gulp_kwargs['maxcyc'] = steps
self.calc.set(**gulp_kwargs)
self.atoms.calc = self.calc
self.atoms.get_potential_energy()
self.atoms.positions[:] = self.calc.get_atoms().positions
We could decide whether we like this pattern and want to do something
similar for other calculators.
Of course in general we may need calc.get_xxx() methods for other
kinds of operations (MD, etc.).
Best regards
Ask
2016-10-17 10:31 GMT+02:00 Kondov, Ivan (SCC) via ase-users
<ase-users at listserv.fysik.dtu.dk>:
> Dear Ask,
>
> For structure relaxations I use the Turbomole, NWChem and Vasp calculators
> with their own structure optimizers.
>
> Regarding implementation: The current implementations of Turbomole and NWChem
> calculators lack some functionality to treat this method of operation. The
> get_potential_energy() method works well with the Vasp calculator but it does
> not work with Turbomole and NWChem without additional hacks. The problem with
> Turbomole was that the structure optimization required the invocation of other
> executables (jobex) from the package. With the NWChem the problem was that
> after a relaxation run the structure in the Atoms object was not updated by
> the calculator.
>
> Regarding interface: There should be a 'task' attribute of the Calculator
> class which can be set when constructing the calculator object. Then,
> depending on 'task', lazy evaluation can be triggered by both a getter method
> of Atoms class or by a calculate() method of the calculator class.
>
> Best regards,
> Ivan
>
>> -----Original Message-----
>> From: ase-users-bounces at listserv.fysik.dtu.dk [mailto:ase-users-
>> bounces at listserv.fysik.dtu.dk] On Behalf Of Ask Hjorth Larsen via
> ase-users
>> Sent: Thursday, October 13, 2016 8:46 PM
>> To: ase-users at listserv.fysik.dtu.dk
>> Subject: [ase-users] Using internal optimizers of codes with ASE
>>
>> Hi
>>
>> Please excuse my recent bad ratio of suggestions/discussions to actually
> getting
>> things done. I promise this will change. Anyway:
>>
>> For file IO calculators, it is often convenient to trigger a structure
> optimization
>> using the code's own optimizer on purpose through get_potential_energy().
>>
>> For example if someone uses the genetic algorithm, basin hopping or
> similar,
>> lots of optimizations will be going on, and you don't want too much IO.
>>
>> Using atoms.get_potential_energy()/calc.calculate() for this is obviously
> a hack,
>> but the idea of using the internal optimizer is quite valid, and maybe ASE
> could
>> offer a systematic way of doing this.
>>
>> Has anyone thought of a nice way of doing this?
>>
>> To call basin hopping that way, you just need to supply an object that
> acts like an
>> Optimizer, but secretly just calls calculate() on the calculator. This
> may be the
>> minimally painful way. Should we have a wrapper like that? Are there
> better
>> ways?
>>
>> Best regards
>> Ask
>> _______________________________________________
>> ase-users mailing list
>> ase-users at listserv.fysik.dtu.dk
>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
More information about the ase-users
mailing list