10 #include "../utils/map_to_index.h" 11 #include "../utils/runtime_error.h" 22 new GenDict({{
"Mols", mols}, {
"Atoms", atoms}})));
28 const Vec<std::pair<ElPtr,ElPtr>> &pairs)
32 for (
const auto &pair : pairs)
35 new GenDict({{
"Mols", pair.first}, {
"Atoms", pair.second}})));
46 auto el_mols =
generators[index]->get_element(
"Mols");
49 el_mols->check_required_keys({
"id",
"atom-ids"});
51 auto &mols = el_mols->get_data();
53 auto el_atoms =
generators[index]->get_element(
"Atoms");
55 el_atoms->check_required_keys({
"xu",
"yu",
"zu",
"id"});
57 auto &atoms = el_atoms->get_data();
63 for (
const auto &mol : mols)
67 auto &atom_ids = mol[
"atom-ids"];
69 auto &atom1 = atoms[id2index_atom[atom_ids.at(
index1_in_mol)]];
70 auto &atom2 = atoms[id2index_atom[atom_ids.at(
index2_in_mol)]];
72 auto dx = atom2[
"xu"].get<
double>() - atom1[
"xu"].get<double>();
73 auto dy = atom2[
"yu"].get<
double>() - atom1[
"yu"].get<double>();
74 auto dz = atom2[
"zu"].get<
double>() - atom1[
"zu"].get<double>();
76 distance2_tmp.push_back(dx*dx+dy*dy+dz*dz);
80 distance2_tmp.data(), distance2_tmp.size());
98 if (n_mols != d2.size())
ArrayXXd get_distance_array()
Get computed distances between two atoms in each molecule as a two-dimensional array: each row corres...
Vec< ShPtr< Generator > > generators
const ArrayXXd & get_distance2_array()
Get computed squared distances between two atoms in each molecule as a two-dimensional array: each ro...
ShPtr< Element > ElPtr
An alias for a shared pointer of Element class.
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ArrayXXd
ArrayXXd is an alias for a two-dimensional array of float numbers.
virtual void finish() override
Fill distance2_array with values of distance2_traj.
std::vector< T > Vec
Vec is an alias for vector (same as list in Python).
Vec< RowArrayXd > distance2_traj
void register_generator(const ShPtr< GEN > &gen)
ProDistanceInMolecule(const ElPtr &mols, const ElPtr &atoms)
Constructor of ProDistanceInMolecule class for a snapshot of simulation.
void runtime_error(const Str &msg)
Raise (for Python) and throw (for C++) a runtime error.
This file has a definition of ProDistanceInMolecule class, which is a subclass of Processor class...
GenDict is a dictionary (or map) of Generator objects.
virtual void run_impl(const int index) override
Implementation of analysis using an element of generators.
Namespace for utility functions.
void set_moltype(int target_moltype_)
Specify a molecular type. Only molecules whose type property is the specified type are analyzed...
void set_indices(int index1_in_mol_, int index2_in_mol_)
Specify two atoms in a molecule by zero-based index. Distance between the two atoms is computed for e...
std::shared_ptr< T > ShPtr
ShPtr is an alias for shared pointer.
std::unordered_map< T, U > Map
Map is an alias for unordered map (same as dict in Python).
Map< Json, int > map_to_index(const Json &data, const Str &key)
Create a Map object from values of selected property in an array Json object to corresponding index i...
void register_generators(const Vec< ShPtr< GEN >> &gens)
virtual void prepare() override
Resize distance2_traj.