00001 #ifndef COLVARATOMS_H 00002 #define COLVARATOMS_H 00003 00004 #include "colvarmodule.h" 00005 #include "colvarparse.h" 00006 00018 class colvarmodule::atom { 00019 00020 protected: 00021 00024 size_t index; 00025 00026 public: 00027 00029 int id; 00030 00032 cvm::real mass; 00033 00036 cvm::atom_pos pos; 00037 00040 cvm::rvector vel; 00041 00044 cvm::rvector system_force; 00045 00056 cvm::rvector grad; 00057 00059 inline atom() {} 00060 00064 atom (int const &atom_number); 00065 00071 atom (cvm::residue_id const &residue, 00072 std::string const &atom_name, 00073 std::string const &segment_id = std::string ("")); 00074 00076 atom (atom const &a); 00077 00079 ~atom(); 00080 00082 inline void reset_data() { 00083 pos = atom_pos (0.0); 00084 vel = grad = system_force = rvector (0.0); 00085 } 00086 00088 void read_position(); 00089 00091 void read_velocity(); 00092 00094 void read_system_force(); 00095 00103 void apply_force (cvm::rvector const &new_force); 00104 }; 00105 00106 00107 00108 00117 class colvarmodule::atom_group 00118 : public std::vector<cvm::atom>, 00119 public colvarparse 00120 { 00121 public: 00122 // Note: all members here are kept public, to make possible to any 00123 // object accessing and manipulating them 00124 00125 00129 bool b_dummy; 00131 cvm::atom_pos dummy_atom_pos; 00132 00135 std::vector<int> sorted_ids; 00136 00138 void create_sorted_ids (void); 00139 00140 00143 bool b_center; 00144 00153 bool b_rotate; 00155 cvm::rotation rot; 00156 00159 std::vector<cvm::atom_pos> ref_pos; 00163 cvm::atom_pos ref_pos_cog; 00166 atom_group *ref_pos_group; 00167 00168 00170 cvm::real total_mass; 00171 00174 bool noforce; 00175 00176 00181 atom_group (std::string const &conf, 00182 char const *key, 00183 atom_group *ref_pos_group = NULL); 00184 00187 void parse (std::string const &conf, 00188 char const *key, 00189 atom_group *ref_pos_group = NULL); 00190 00192 atom_group (std::vector<cvm::atom> const &atoms); 00193 00195 void add_atom (cvm::atom const &a); 00196 00198 atom_group(); 00199 00201 ~atom_group(); 00202 00206 void read_positions(); 00207 00209 void apply_translation (cvm::rvector const &t); 00210 00212 void apply_rotation (cvm::rotation const &q); 00213 00214 00218 void read_velocities(); 00219 00223 void read_system_forces(); 00224 00226 inline void reset_atoms_data() 00227 { 00228 for (cvm::atom_iter ai = this->begin(); ai != this->end(); ai++) 00229 ai->reset_data(); 00230 } 00231 00233 std::vector<cvm::atom_pos> positions() const; 00234 00236 std::vector<cvm::atom_pos> positions_shifted (cvm::rvector const &shift) const; 00237 00240 cvm::atom_pos center_of_geometry (cvm::atom_pos const &ref_pos); 00243 cvm::atom_pos center_of_geometry() const; 00244 00247 cvm::atom_pos center_of_mass (cvm::atom_pos const &ref_pos); 00250 cvm::atom_pos center_of_mass() const; 00251 00253 std::vector<cvm::atom_pos> old_pos; 00254 00255 00257 std::vector<cvm::rvector> velocities() const; 00258 00259 00261 std::vector<cvm::rvector> system_forces() const; 00263 cvm::rvector system_force() const; 00264 00265 00269 void set_weighted_gradient (cvm::rvector const &grad); 00270 00283 void apply_colvar_force (cvm::real const &force); 00284 00294 void apply_force (cvm::rvector const &force); 00295 00306 void apply_forces (std::vector<cvm::rvector> const &forces); 00307 }; 00308 00309 00310 00311 00312 #endif 00313 00314 00315 // Emacs 00316 // Local Variables: 00317 // mode: C++ 00318 // End:
1.3.9.1