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 "colvarmodule.h"
14#include "colvarproxy.h"
15
16// forward declarations
17
18namespace LAMMPS_NS {
19class LAMMPS;
20class RanPark;
21} // namespace LAMMPS_NS
22
26
27 // LAMMPS specific data objects and flags
28 protected:
29 // pointers to LAMMPS class instances
30 LAMMPS_NS::LAMMPS *_lmp;
31 LAMMPS_NS::RanPark *_random;
32
33 // state of LAMMPS properties
34 double bias_energy;
35 cvm::step_number previous_step;
36
37 bool first_timestep;
38 bool do_exit;
39
40 std::vector<int> atoms_types;
41
42 public:
43 colvarproxy_lammps(LAMMPS_NS::LAMMPS *lmp);
44 ~colvarproxy_lammps() override;
45
46 // disable default and copy constructor
47 colvarproxy_lammps() = delete;
48 colvarproxy_lammps(const colvarproxy_lammps &) = delete;
49
50 void init();
51
53 void set_random_seed(int seed);
54
55 int setup() override;
56
57 // methods for lammps to move data or trigger actions in the proxy
58 public:
59 bool total_forces_enabled() const override { return total_force_requested; };
60 // Total forces are saved at end of step, only processed at the next step
61 bool total_forces_same_step() const override { return false; };
62 bool want_exit() const { return do_exit; };
63
64 // perform colvars computation. returns biasing energy
65 double compute();
66
67 // Request to set the units used internally by Colvars
68 int set_unit_system(std::string const &units_in, bool check_only) override;
69
71 char const *script_obj_to_str(unsigned char *obj);
72
74 std::vector<std::string> script_obj_to_str_vector(unsigned char *obj);
75
76 void add_energy(cvm::real energy) override { bias_energy += energy; };
77 void request_total_force(bool yesno) override { total_force_requested = yesno; };
78
79 void log(std::string const &message) override;
80 void error(std::string const &message) override;
81
83 cvm::atom_pos const &pos2) const override;
84
85 cvm::real rand_gaussian() override;
86
87 int init_atom(int atom_number) override;
88 int check_atom_id(int atom_number) override;
89
90 inline std::vector<int> *modify_atom_types() { return &atoms_types; }
91};
92
93#endif
vector of real numbers with three components
Definition: colvartypes.h:724
double real
Defining an abstract real number allows to switch precision.
Definition: colvarmodule.h:139
long long step_number
Use a 64-bit integer to store the step number.
Definition: colvarmodule.h:136
Communication between colvars and LAMMPS (implementation of colvarproxy)
Definition: colvarproxy_lammps.h:25
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:77
int init_atom(int atom_number) override
Definition: colvarproxy_lammps.cpp:269
int setup() override
(Re)initialize required member data (called after the module)
Definition: colvarproxy_lammps.cpp:93
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:190
void set_random_seed(int seed)
Set the internal seed used by rand_gaussian().
Definition: colvarproxy_lammps.cpp:77
bool total_forces_enabled() const override
Are total forces being used?
Definition: colvarproxy_lammps.h:59
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:226
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:237
void add_energy(cvm::real energy) override
Pass restraint energy value for current timestep to MD engine.
Definition: colvarproxy_lammps.h:76
cvm::real rand_gaussian() override
Pseudo-random number with Gaussian distribution.
Definition: colvarproxy_lammps.cpp:84
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:210
int check_atom_id(int atom_number) override
Definition: colvarproxy_lammps.cpp:250
bool total_forces_same_step() const override
Definition: colvarproxy_lammps.h:61
char const * script_obj_to_str(unsigned char *obj)
Convert a command-line argument to string.
Definition: colvarproxy_lammps.cpp:218
void log(std::string const &message) override
Print a message to the main log.
Definition: colvarproxy_lammps.cpp:203
bool total_force_requested
Whether the total forces have been requested.
Definition: colvarproxy_system.h:180
Definition: colvarproxy.h:559
Collective variables main module.
Colvars proxy classes.