23 #include "CollectiveVariable.h"
24 #include "Validator/ObjectRequirement.h"
25 #include "Drivers/DriverException.h"
83 std::vector<int> found(n, 0);
84 for(
size_t i = 0; i < n; ++i)
90 MPI_Allreduce(MPI_IN_PLACE, found.data(), n, MPI_INT, MPI_SUM, snapshot.
GetCommunicator());
91 unsigned ntot = std::accumulate(found.begin(), found.end(), 0, std::plus<int>());
94 "ParticlePositionCV: Expected to find " +
96 " atoms, but only found " +
108 std::vector<int> idx;
113 const auto& masses = snapshot.
GetMasses();
142 reader.parse(JsonSchema::ParticlePositionCV, schema);
143 validator.
Parse(schema, path);
151 for(
auto&
id : json[
"atom_ids"])
152 atomids.push_back(
id.asInt());
155 position[0] = json[
"position"][0].asDouble();
156 position[1] = json[
"position"][1].asDouble();
157 position[2] = json[
"position"][2].asDouble();
159 auto fixx = json[
"fix"][0].asBool();
160 auto fixy = json[
"fix"][1].asBool();
161 auto fixz = json[
"fix"][2].asBool();
std::vector< int > Label
List of integers.
bool HasErrors()
Check if errors have occured.
Vector3 point_
Target point in space.
unsigned GetNumAtoms() const
Get number of atoms in this snapshot.
double TotalMass(const Label &indices) const
Compute the total mass of a group of particles based on index.
Collective variable on an particle position.
Class containing a snapshot of the current simulation in time.
void Evaluate(const Snapshot &snapshot) override
Evaluate the CV.
Bool3 fix_
Each dimension determines if a constraint is applied by the CV.
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
int GetLocalIndex(int id) const
Gets the local atom index corresponding to an atom ID.
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
const mxx::comm & GetCommunicator() const
Get communicator for walker.
void GetLocalIndices(const Label &ids, Label *indices) const
Exception to be thrown when building the Driver fails.
std::vector< std::string > GetErrors()
Get list of error messages.
Vector3 CenterOfMass(const Label &indices) const
const std::vector< double > & GetMasses() const
Const access to the particle masses.
Label atomids_
Vector of atom ids of interest.
ParticlePositionCV(const Label &atomids, const Vector3 &position, bool fixx, bool fixy, bool fixz)
Constructor.
Requirements on an object.
void Initialize(const Snapshot &snapshot) override
Initialize necessary variables.
Eigen::Vector3d Vector3
Three-dimensional vector.
void ApplyMinimumImage(Vector3 *v) const
Apply minimum image to a vector.
double val_
Current value of CV.
Abstract class for a collective variable.
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.
Eigen::Matrix< bool, 3, 1 > Bool3
Three-dimensional boolean.