|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
interface between an ABACUS MD run and the PLUMED plugin More...
#include <plumed_interface.h>
Public Member Functions | |
| PlumedInterface ()=default | |
| ~PlumedInterface () | |
| PlumedInterface (const PlumedInterface &)=delete | |
| PlumedInterface & | operator= (const PlumedInterface &)=delete |
| bool | init (const std::string &plumed_file, const int nat, const double dt_au, const double *masses_au) |
| create a PLUMED object and read the PLUMED input file | |
| void | move (const int istep, const ModuleBase::Vector3< double > *pos, ModuleBase::Vector3< double > *force, const double *cell, const double potential, const double *virial) |
| one MD step: hand over the configuration, let PLUMED compute the collective variables and add the biasing forces to force | |
| void | finalize () |
| finalize PLUMED (flushes the COLVAR and other output files) | |
| bool | active () const |
| whether PLUMED is active in this run | |
Private Member Functions | |
| void | compute_forces_ (const int istep, const ModuleBase::Vector3< double > *pos, double *force, const double *cell, const double potential, const double *virial) |
| register the configuration of one step with PLUMED and let it compute the collective variables and the biasing forces | |
| void | prepare_virial_ (const double *cell, const double *virial) |
| build the 3x3 virial (in energy units) handed over to PLUMED | |
Private Attributes | |
| plumed_handle | plumed_ {nullptr} |
| handle returned by plumed_create() | |
| bool | has_plumed_ = false |
| whether a PLUMED object is alive | |
| bool | active_run_ = false |
| whether init() has been called | |
| int | nat_ = 0 |
| number of atoms | |
| std::vector< double > | masses_amu_ |
| atomic masses in amu | |
| double | virial_buf_ [9] = {0.0} |
| virial handed over to PLUMED (energy units) | |
interface between an ABACUS MD run and the PLUMED plugin
This class wraps the C API of the PLUMED wrapper library (libplumed.so, plumed_create / plumed_cmd / plumed_finalize, see <plumed/wrapper/Plumed.h> in a PLUMED installation) so that collective variables, biasing potentials and free-energy methods provided by PLUMED (https://www.plumed.org) can be used in ABACUS MD runs.
Units: ABACUS atomic units differ from the PLUMED defaults, so the conversion factors are declared once in init() through the commands setMDEnergyUnits (Hartree -> kJ/mol), setMDLengthUnits (Bohr -> nm) and setMDTimeUnits (atomic unit of time -> ps). From then on all quantities are passed in ABACUS native units and PLUMED performs the conversion internally:
The interface currently supports a single MPI rank only, because PLUMED must see the whole system while ABACUS distributes the atoms of an MD run over the ranks; run_md.cpp stops the run before the MD loop when more than one rank is used.
This interface is a no-op stub unless ABACUS is configured with -DENABLE_PLUMED=ON; requesting PLUMED in INPUT while ABACUS was built without it stops the run with an error message.
|
default |
| ModulePlumed::PlumedInterface::~PlumedInterface | ( | ) |
|
delete |
|
inline |
whether PLUMED is active in this run
|
private |
register the configuration of one step with PLUMED and let it compute the collective variables and the biasing forces
| void ModulePlumed::PlumedInterface::finalize | ( | ) |
finalize PLUMED (flushes the COLVAR and other output files)
| bool ModulePlumed::PlumedInterface::init | ( | const std::string & | plumed_file, |
| const int | nat, | ||
| const double | dt_au, | ||
| const double * | masses_au ) |
create a PLUMED object and read the PLUMED input file
Must be called once before the MD loop.
| plumed_file | [in] path of the PLUMED input file |
| nat | [in] number of atoms |
| dt_au | [in] MD time step in atomic units of time |
| masses_au | [in] atomic masses in ABACUS atomic units (electron masses), nat entries |
| void ModulePlumed::PlumedInterface::move | ( | const int | istep, |
| const ModuleBase::Vector3< double > * | pos, | ||
| ModuleBase::Vector3< double > * | force, | ||
| const double * | cell, | ||
| const double | potential, | ||
| const double * | virial ) |
one MD step: hand over the configuration, let PLUMED compute the collective variables and add the biasing forces to force
| istep | [in] global MD step index |
| pos | [in] atomic positions in Bohr (nat entries) |
| force | [in,out] atomic forces in Hartree/Bohr; PLUMED adds the biasing forces in place |
| cell | [in] 3x3 cell matrix in Bohr, row-major, the rows being the lattice vectors |
| potential | [in] potential energy in Hartree |
| virial | [in] 3x3 virial in Hartree (=-stress * volume), or nullptr when the stress is not available |
|
delete |
|
private |
build the 3x3 virial (in energy units) handed over to PLUMED
|
private |
whether init() has been called
|
private |
whether a PLUMED object is alive
|
private |
atomic masses in amu
|
private |
number of atoms
|
private |
handle returned by plumed_create()
|
private |
virial handed over to PLUMED (energy units)