1#ifndef COLVARATOMS_SOA_H
2#define COLVARATOMS_SOA_H
6#include "colvar_rotation_derivative.h"
7#include <unordered_map>
58 static std::vector<cvm::real>
pos_aos_to_soa(
const std::vector<cvm::atom_pos>& aos_in);
94 std::vector<feature *> &modify_features()
override {
return ag_features; }
95 static void delete_features()
97 for (
size_t i = 0; i < ag_features.size(); i++) {
98 delete ag_features[i];
128 std::string
const &atom_name,
129 std::string
const &segment_id);
190 using atom_iter =
decltype(m_atoms)::iterator;
191 using const_atom_iter =
decltype(m_atoms)::const_iterator;
208 inline simple_atom & operator [] (
size_t const i){
return m_atoms[i];}
209 inline simple_atom const & operator [] (
size_t const i)
const {
return m_atoms[i];}
210 inline atom_iter begin(){
return m_atoms.begin();}
211 inline const_atom_iter begin()
const {
return m_atoms.begin();}
212 inline atom_iter end() {
return m_atoms.end();}
213 inline const_atom_iter end()
const {
return m_atoms.end();}
214 inline size_t size()
const {
return m_atoms.size();}
220 int add_atom(simple_atom
const &a);
221 int add_atom_numbers(std::string
const &numbers_conf);
222 int add_atoms_of_group(
const atom_group *ag);
223 int add_index_group(std::string
const &index_group_name,
bool silent =
false);
224 int add_atom_numbers_range(std::string
const &range_conf);
225 int add_atom_name_residue_range(std::string
const &psf_segid,
226 std::string
const &range_conf);
227 int add_atom_id(
int aid);
256 int parse(std::string
const &conf);
260 int parse_fitting_options(std::string
const &group_conf);
272 void update_total_mass();
276 void update_total_charge();
283 void print_properties(std::string
const &colvar_name,
int i,
int j);
287 inline std::vector<int>
const &
ids()
const
291 std::string
const print_atom_ids()
const;
295 int create_sorted_ids();
319 void read_positions();
323 void calc_apply_roto_translation();
328 void setup_rotation_derivative();
338 void center_ref_pos();
354 void read_velocities();
362 void read_total_forces();
366 int calc_required_properties();
371 int calc_center_of_geometry();
375 std::vector<cvm::real> positions()
const;
387 int calc_center_of_mass();
406 std::vector<cvm::real> positions_shifted(
cvm::rvector const &shift)
const;
410 std::vector<cvm::real> velocities()
const;
425 std::vector<cvm::real> total_forces()
const;
439 void calc_fit_gradients();
469 template <
bool B_ag_center,
bool B_ag_rotate,
470 typename main_force_accessor_T,
471 typename fitting_force_accessor_T>
472 void calc_fit_forces_impl(
473 main_force_accessor_T accessor_main,
474 fitting_force_accessor_T accessor_fitting)
const;
491 template <
typename main_force_accessor_T,
typename fitting_force_accessor_T>
492 void calc_fit_forces(
493 main_force_accessor_T accessor_main,
494 fitting_force_accessor_T accessor_fitting)
const;
509 void apply_colvar_force(
cvm::real const &force);
529 void do_feature_side_effects(
int id)
override;
537 void reset_atoms_data();
541 void set_ref_pos_from_aos(
const std::vector<cvm::atom_pos>& pos_aos);
546 inline int& id(
size_t i) {
return atoms_ids[i];}
547 inline const int& id(
size_t i)
const {
return atoms_ids[i];}
599 inline cvm::real& ref_pos_z(
size_t i) {
return ref_pos[i + 2 * num_ref_pos];}
601 inline const cvm::real& ref_pos_y(
size_t i)
const {
return ref_pos[i + num_ref_pos];}
602 inline const cvm::real& ref_pos_z(
size_t i)
const {
return ref_pos[i + 2 * num_ref_pos];}
640 inline cvm::real& fit_gradients_x(
size_t i) {
643 inline cvm::real& fit_gradients_y(
size_t i) {
645 return group_for_fit->
fit_gradients[i + group_for_fit->size()];}
646 inline cvm::real& fit_gradients_z(
size_t i) {
648 return group_for_fit->
fit_gradients[i + 2 * group_for_fit->size()];}
649 inline const cvm::real& fit_gradients_x(
size_t i)
const {
652 inline const cvm::real& fit_gradients_y(
size_t i)
const {
654 return group_for_fit->
fit_gradients[i + group_for_fit->size()];}
655 inline const cvm::real& fit_gradients_z(
size_t i)
const {
657 return group_for_fit->
fit_gradients[i + 2 * group_for_fit->size()];}
679 {pos_x(i), pos_y(i), pos_z(i)},
680 {vel_x(i), vel_y(i), vel_z(i)},
681 {total_force_x(i), total_force_y(i), total_force_z(i)},
682 {grad_x(i), grad_y(i), grad_z(i)}
730 bool m_has_fitting_force;
731 void apply_force_with_fitting_group();
Parent class for a member object of a bias, cv or cvc etc. containing features and their dependencies...
Definition: colvardeps.h:34
2-dimensional array of real numbers with three components along each dimension (works with colvarmodu...
Definition: colvartypes.h:891
A rotation between two sets of coordinates (for the moment a wrapper for colvarmodule::quaternion)
Definition: colvartypes.h:1359
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:150
int residue_id
Residue identifier.
Definition: colvarmodule.h:275
Base class containing parsing functions; all objects which need to parse input inherit from this.
Definition: colvarparse.h:27
Definition: colvarproxy.h:559
The temporary AoS interface to modify cvm::atom_group.
Definition: colvaratoms.h:155
cvm::real m_total_mass
Total mass of the atom group.
Definition: colvaratoms.h:176
std::vector< int > m_atoms_ids
Internal atom IDs (populated during initialization)
Definition: colvaratoms.h:164
std::vector< simple_atom > m_atoms
AoS layout of the atoms.
Definition: colvaratoms.h:168
cvm::atom_group * m_ag
Pointer to the SoA atom group to be modified.
Definition: colvaratoms.h:160
std::unordered_map< int, int > m_atoms_ids_count
A map to avoid doubly counting atoms.
Definition: colvaratoms.h:172
void sync_to_soa() const
Synchronize the atoms from this temporary AoS object to m_ag.
Definition: colvaratoms.cpp:256
int remove_atom(atom_iter ai)
Remove an atom object from this group.
Definition: colvaratoms.cpp:332
cvm::real m_total_charge
Total charge of the atom group.
Definition: colvaratoms.h:180
void update_from_soa()
Populate this temporary AoS object with the atoms from m_ag.
Definition: colvaratoms.cpp:243
A helper class for applying forces on an atom group in a way that is aware of the fitting group....
Definition: colvaratoms.h:692
void add_atom_force(size_t i, const cvm::rvector &force)
Apply force to atom i.
Definition: colvaratoms.cpp:1754
Store the information of a group of atoms in a structure-of-arrays (SoA) style.
Definition: colvaratoms.h:51
cvm::atom_pos center_of_geometry() const
Return the center of geometry of the atomic positions.
Definition: colvaratoms.h:379
cvm::real total_mass
Total mass of the atom group.
Definition: colvaratoms.h:759
cvm::atom_pos ref_pos_cog
Center of geometry of the reference coordinates; regardless of whether f_ag_center is true,...
Definition: colvaratoms.h:806
std::vector< cvm::real > group_forces
The temporary forces acting on the main group atoms. Currently this is only used for calculating the ...
Definition: colvaratoms.h:799
std::vector< int > atoms_index
SOA atom indices (size: num_atoms)
Definition: colvaratoms.h:770
std::vector< cvm::real > atoms_mass
SOA atom mass (size: num_atoms)
Definition: colvaratoms.h:778
std::vector< cvm::real > atoms_grad
SOA atom gradients (size: 3 * num_atoms)
Definition: colvaratoms.h:780
std::mutex modify_lock
Lock for modifier.
Definition: colvaratoms.h:822
cvm::rvector dipole() const
Return the (previously calculated) dipole of the atom group.
Definition: colvaratoms.h:418
std::string key
Keyword used to define the group.
Definition: colvaratoms.h:743
int init()
Set default values for common flags.
Definition: colvaratoms.cpp:136
simple_atom operator[](size_t i) const
Read-only operator[].
Definition: colvaratoms.h:673
bool b_user_defined_fit
Indicates that the user has explicitly set centerToReference or rotateReference, and the correspondin...
Definition: colvaratoms.h:755
cvm::rvector dip
Dipole moment of the atom group.
Definition: colvaratoms.h:820
std::vector< int > const & ids() const
Internal atom IDs (populated during initialization)
Definition: colvaratoms.h:287
int init_dependencies() override
Initialize dependency tree.
Definition: colvaratoms.cpp:163
cvm::rvector center_of_mass_scalar_gradient() const
Return previously gradient of scalar variable with respect to the COM.
Definition: colvaratoms.h:399
std::vector< cvm::real > atoms_total_force
SOA atom total forces (size: 3 * num_atoms)
Definition: colvaratoms.h:782
static std::vector< feature * > ag_features
Implementation of the feature list for atom group.
Definition: colvaratoms.h:765
cvm::rotation rot
The rotation calculated automatically if f_ag_rotate is defined.
Definition: colvaratoms.h:748
atom_group()
Default constructor.
Definition: colvaratoms.cpp:84
std::vector< cvm::real > atoms_weight
Atom masses divided by total mass (size: num_atoms)
Definition: colvaratoms.h:784
std::vector< int > atoms_ids
Internal atom IDs for host code.
Definition: colvaratoms.h:786
std::vector< int > sorted_atoms_ids
Sorted list of internal atom IDs (populated on-demand by create_sorted_ids); used to read coordinate ...
Definition: colvaratoms.h:789
cvm::atom_pos dummy_atom_pos
Dummy atom position.
Definition: colvaratoms.h:793
cvm::atom_pos com
Center of mass.
Definition: colvaratoms.h:814
std::vector< cvm::real > atoms_pos
SOA atom positions (size: 3 * num_atoms)
Definition: colvaratoms.h:772
cvm::atom_pos center_of_mass() const
Return the center of mass (COM) of the atomic positions.
Definition: colvaratoms.h:391
bool b_dummy
If this option is on, this group merely acts as a wrapper for a fixed position; any calls to atoms wi...
Definition: colvaratoms.h:740
size_t size() const
Return the number of atoms of this group.
Definition: colvaratoms.h:533
const std::vector< feature * > & features() const override
Implementation of the feature list accessor for atom group.
Definition: colvaratoms.h:93
static simple_atom init_atom_from_proxy(colvarproxy *const p, cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id)
Initialize an instance of cvm::atom_group::simple_atom from colvarproxy.
Definition: colvaratoms.cpp:27
bool noforce
Don't apply any force on this group (use its coordinates only to calculate a colvar)
Definition: colvaratoms.h:751
std::string name
Optional name to reuse properties of this in other groups.
Definition: colvaratoms.h:736
std::vector< int > const & sorted_ids() const
Sorted internal atom IDs (populated on-demand by create_sorted_ids);.
Definition: colvaratoms.h:301
std::vector< cvm::real > fit_gradients
Derivatives of the fitting transformation.
Definition: colvaratoms.h:757
size_t num_atoms
Number of atoms.
Definition: colvaratoms.h:768
int index
Index in the colvarproxy arrays (if the group is scalable)
Definition: colvaratoms.h:795
cvm::atom_group * fitting_group
If f_ag_center or f_ag_rotate is true, use this group to define the transformation (default: this gro...
Definition: colvaratoms.h:746
cvm::atom_pos cog_orig
Center of geometry before any fitting.
Definition: colvaratoms.h:810
cvm::atom_pos cog
Center of geometry.
Definition: colvaratoms.h:808
cvm::rvector scalar_com_gradient
The derivative of a scalar variable with respect to the COM.
Definition: colvaratoms.h:818
std::vector< int > sorted_atoms_ids_map
Map entries of sorted_atoms_ids onto the original positions in the group.
Definition: colvaratoms.h:791
std::vector< cvm::real > atoms_charge
SOA atom charges (size: num_atoms)
Definition: colvaratoms.h:774
std::vector< cvm::real > atoms_pos_unrotated
Unrotated atom positions for fit gradients.
Definition: colvaratoms.h:812
std::vector< cvm::real > atoms_vel
SOA atom velocities (size: 3 * num_atoms)
Definition: colvaratoms.h:776
cvm::real total_charge
Total charge of the atom group.
Definition: colvaratoms.h:761
atom_modifier get_atom_modifier()
Get the atom modifier object associated with this SoA atom group.
Definition: colvaratoms.h:242
rotation_derivative * rot_deriv
Rotation derivative;.
Definition: colvaratoms.h:763
int setup()
Update data required to calculate cvc's.
Definition: colvaratoms.cpp:223
std::vector< cvm::real > ref_pos
use reference coordinates for f_ag_center or f_ag_rotate
Definition: colvaratoms.h:801
std::vector< int > const & sorted_ids_map() const
Map entries of sorted_atoms_ids onto the original positions in the group.
Definition: colvaratoms.h:306
static std::vector< cvm::real > pos_aos_to_soa(const std::vector< cvm::atom_pos > &aos_in)
A helper function to re-arrange the a vector of cvm::atom_pos (in AoS style xyz......
Definition: colvaratoms.cpp:13
Collective variables main module.
A simplified class of cvm::atom that can be used with cvm::atom_group::atom_modifier.
Definition: colvaratoms.h:106
Helper class for calculating the derivative of rotation.
Definition: colvar_rotation_derivative.h:40