# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.
from ase import units
from ase.md.langevin import Langevin
from pyiron_base import GenericParameters
from pyiron.gpaw.pyiron_ase import AseAdapter
from pyiron.atomistics.job.interactivewrapper import InteractiveWrapper
__author__ = "Jan Janssen"
__copyright__ = "Copyright 2020, Max-Planck-Institut für Eisenforschung GmbH - " \
"Computational Materials Design (CM) Department"
__version__ = "1.0"
__maintainer__ = "Jan Janssen"
__email__ = "janssen@mpie.de"
__status__ = "development"
__date__ = "Sep 1, 2018"
[docs]class LangevinAse(InteractiveWrapper):
"""
Reference implementation of a thermostat implemented in ASE. While we have multiple implementations of the
Langevin thermostat already, this one is using the ASE interface and the Langevin thermostat implemented in ASE.
It is therefore a perfect example how other thermostats implemented in ASE can be used inside pyiron.
Args:
project (ProjectHDFio): points to the HDF5 file the job is stored in
job_name (str): name of the job, which has to be unique within the project
Attributes:
input (pyiron.objects.hamilton.md.lammps.Input): handle the input
"""
def __init__(self, project, job_name):
super(LangevinAse, self).__init__(project, job_name)
self.__name__ = "LangevinAse"
self.input = Input()
self._fast_mode = False
def _write_run_wrapper(self, debug=False):
"""
No wrapper is written for the ASE interface
Args:
debug (bool): the debug flag is ignored
"""
pass
[docs] def run_static(self):
"""
Static run function, which uses the ASEAdapter to connect the pyiron interactive reference job with the
Langevin thermostat implemented in ASE, by setting the ASEAdapter as a replacement of the ASE atoms object.
"""
self.status.running = True
self.ref_job_initialize()
aseadapter = AseAdapter(
self.ref_job,
self._fast_mode
)
langevin = Langevin(
atoms=aseadapter,
timestep=self.input['time_step'] * units.fs,
temperature=self.input['temperature'] * units.kB,
friction=self.input['friction'],
fixcm=True
)
langevin.run(self.input['ionic_steps'])
self.status.collect = True
aseadapter.interactive_close()
self._finish_job()