Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
colvarproxy_lammps.h
1// -*- c++ -*-
2
3// This file is part of the Collective Variables module (Colvars).
4// The original version of Colvars and its updates are located at:
5// https://github.com/Colvars/colvars
6// Please update all Colvars source files before making any changes.
7// If you wish to distribute your changes, please submit them to the
8// Colvars repository at GitHub.
9
10#ifndef COLVARPROXY_LAMMPS_H
11#define COLVARPROXY_LAMMPS_H
12
13#include "colvarproxy_lammps_version.h" // IWYU pragma: export
14
15#include "colvarmodule.h"
16#include "colvarproxy.h"
17#include "colvartypes.h"
18
19#include <mpi.h>
20
21#include "random_park.h"
22
23// forward declarations
24
25namespace LAMMPS_NS {
26class LAMMPS;
27} // namespace LAMMPS_NS
28
32
33 // LAMMPS specific data objects and flags
34 protected:
35 // pointers to LAMMPS class instances
36 LAMMPS_NS::LAMMPS *_lmp;
37 LAMMPS_NS::RanPark *_random;
38
39 // state of LAMMPS properties
40 double bias_energy;
41 cvm::step_number previous_step;
42
43 bool first_timestep;
44 bool do_exit;
45
46 std::vector<int> atoms_types;
47
48 public:
49 friend class cvm::atom;
50
51 colvarproxy_lammps(LAMMPS_NS::LAMMPS *lmp);
52 ~colvarproxy_lammps() override;
53
54 void init();
55
57 void set_random_seed(int seed);
58
59 int setup() override;
60
61 // disable default and copy constructor
62 private:
65
66 // methods for lammps to move data or trigger actions in the proxy
67 public:
68 bool total_forces_enabled() const override { return total_force_requested; };
69 // Total forces are saved at end of step, only processed at the next step
70 bool total_forces_same_step() const override { return false; };
71 bool want_exit() const { return do_exit; };
72
73 // perform colvars computation. returns biasing energy
74 double compute();
75
76 // Request to set the units used internally by Colvars
77 int set_unit_system(std::string const &units_in, bool check_only) override;
78
80 char const *script_obj_to_str(unsigned char *obj);
81
83 std::vector<std::string> script_obj_to_str_vector(unsigned char *obj);
84
85 void add_energy(cvm::real energy) override { bias_energy += energy; };
86 void request_total_force(bool yesno) override { total_force_requested = yesno; };
87
88 void log(std::string const &message) override;
89 void error(std::string const &message) override;
90
92 cvm::atom_pos const &pos2) const override;
93
94 cvm::real rand_gaussian(void) override { return _random->gaussian(); };
95
96 int init_atom(int atom_number) override;
97 int check_atom_id(int atom_number) override;
98
99 inline std::vector<int> *modify_atom_types() { return &atoms_types; }
100};
101
102#endif
Stores numeric id, mass and all mutable data for an atom, mostly used by a colvar::cvc.
Definition: colvaratoms.h:31
vector of real numbers with three components
Definition: colvartypes.h:723
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:100
long long step_number
Use a 64-bit integer to store the step number.
Definition: colvarmodule.h:97
Communication between colvars and LAMMPS (implementation of colvarproxy)
Definition: colvarproxy_lammps.h:31
void request_total_force(bool yesno) override
Tell the proxy whether total forces are needed (they may not always be available)
Definition: colvarproxy_lammps.h:86
cvm::real rand_gaussian(void) override
Pseudo-random number with Gaussian distribution.
Definition: colvarproxy_lammps.h:94
int init_atom(int atom_number) override
Definition: colvarproxy_lammps.cpp:263
int setup() override
(Re)initialize required member data (called after the module)
Definition: colvarproxy_lammps.cpp:87
cvm::rvector position_distance(cvm::atom_pos const &pos1, cvm::atom_pos const &pos2) const override
Get the PBC-aware distance vector between two positions.
Definition: colvarproxy_lammps.cpp:184
void set_random_seed(int seed)
Set the internal seed used by rand_gaussian().
Definition: colvarproxy_lammps.cpp:76
bool total_forces_enabled() const override
Are total forces being used?
Definition: colvarproxy_lammps.h:68
std::vector< std::string > script_obj_to_str_vector(unsigned char *obj)
Convert a command-line argument to a vector of strings.
Definition: colvarproxy_lammps.cpp:220
int set_unit_system(std::string const &units_in, bool check_only) override
Request to set the units used internally by Colvars.
Definition: colvarproxy_lammps.cpp:231
void add_energy(cvm::real energy) override
Pass restraint energy value for current timestep to MD engine.
Definition: colvarproxy_lammps.h:85
void error(std::string const &message) override
Print a message to the main log and/or let the host code know about it.
Definition: colvarproxy_lammps.cpp:204
int check_atom_id(int atom_number) override
Definition: colvarproxy_lammps.cpp:244
bool total_forces_same_step() const override
Definition: colvarproxy_lammps.h:70
char const * script_obj_to_str(unsigned char *obj)
Convert a command-line argument to string.
Definition: colvarproxy_lammps.cpp:212
void log(std::string const &message) override
Print a message to the main log.
Definition: colvarproxy_lammps.cpp:197
bool total_force_requested
Whether the total forces have been requested.
Definition: colvarproxy_system.h:168
Definition: colvarproxy.h:549
Collective variables main module.
Colvars proxy classes.