ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ModulePlumed::PlumedInterface Class Reference

interface between an ABACUS MD run and the PLUMED plugin More...

#include <plumed_interface.h>

Collaboration diagram for ModulePlumed::PlumedInterface:

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)

Detailed Description

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:

  • positions / cell : Bohr
  • forces : Hartree/Bohr (biasing forces are added in place by PLUMED)
  • potential energy : Hartree
  • virial : Hartree (=-stress * volume, following the Quantum ESPRESSO interface convention)
  • masses : electron masses (converted to amu 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.

Constructor & Destructor Documentation

◆ PlumedInterface() [1/2]

ModulePlumed::PlumedInterface::PlumedInterface ( )
default
Here is the caller graph for this function:

◆ ~PlumedInterface()

ModulePlumed::PlumedInterface::~PlumedInterface ( )
Here is the call graph for this function:

◆ PlumedInterface() [2/2]

ModulePlumed::PlumedInterface::PlumedInterface ( const PlumedInterface & )
delete
Here is the call graph for this function:

Member Function Documentation

◆ active()

bool ModulePlumed::PlumedInterface::active ( ) const
inline

whether PLUMED is active in this run

Here is the caller graph for this function:

◆ compute_forces_()

void ModulePlumed::PlumedInterface::compute_forces_ ( const int istep,
const ModuleBase::Vector3< double > * pos,
double * force,
const double * cell,
const double potential,
const double * virial )
private

register the configuration of one step with PLUMED and let it compute the collective variables and the biasing forces

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize()

void ModulePlumed::PlumedInterface::finalize ( )

finalize PLUMED (flushes the COLVAR and other output files)

Here is the caller graph for this function:

◆ init()

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.

Parameters
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
Returns
true when the interface is ready to be used in the MD loop
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move()

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

Parameters
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

PlumedInterface & ModulePlumed::PlumedInterface::operator= ( const PlumedInterface & )
delete
Here is the call graph for this function:

◆ prepare_virial_()

void ModulePlumed::PlumedInterface::prepare_virial_ ( const double * cell,
const double * virial )
private

build the 3x3 virial (in energy units) handed over to PLUMED

Here is the caller graph for this function:

Member Data Documentation

◆ active_run_

bool ModulePlumed::PlumedInterface::active_run_ = false
private

whether init() has been called

◆ has_plumed_

bool ModulePlumed::PlumedInterface::has_plumed_ = false
private

whether a PLUMED object is alive

◆ masses_amu_

std::vector<double> ModulePlumed::PlumedInterface::masses_amu_
private

atomic masses in amu

◆ nat_

int ModulePlumed::PlumedInterface::nat_ = 0
private

number of atoms

◆ plumed_

plumed_handle ModulePlumed::PlumedInterface::plumed_ {nullptr}
private

handle returned by plumed_create()

◆ virial_buf_

double ModulePlumed::PlumedInterface::virial_buf_[9] = {0.0}
private

virial handed over to PLUMED (energy units)


The documentation for this class was generated from the following files: