| version 1.11 | version 1.12 |
|---|
| |
| #include "colvarvalue.h" | #include "colvarvalue.h" |
| | |
| #ifndef COLVARPROXY_VERSION | #ifndef COLVARPROXY_VERSION |
| #define COLVARPROXY_VERSION "2015-07-24" | #define COLVARPROXY_VERSION "2016-10-06" |
| #endif | #endif |
| | |
| // For replica exchange | // For replica exchange |
| |
| | |
| protected: | protected: |
| | |
| | /// \brief Array of atom indices (relative to the colvarproxy arrays), |
| | /// usedfor faster copy of atomic data |
| | std::vector<int> atoms_map; |
| | |
| /// Pointer to the NAMD simulation input object | /// Pointer to the NAMD simulation input object |
| SimParameters const *simparams; | SimParameters const *simparams; |
| | |
| | /// Self-explained |
| BigReal thermostat_temperature; | BigReal thermostat_temperature; |
| | |
| /// NAMD-style PRNG object | /// NAMD-style PRNG object |
| Random random; | Random random; |
| | |
| | /// How often NAMD is instructed to write state files |
| size_t restart_frequency_s; | size_t restart_frequency_s; |
| size_t previous_NAMD_step; | |
| bool first_timestep; | |
| bool system_force_requested; | |
| | |
| std::vector<int> colvars_atoms; | bool first_timestep; |
| std::vector<size_t> colvars_atoms_ncopies; | size_t previous_NAMD_step; |
| std::vector<cvm::rvector> positions; | |
| std::vector<cvm::rvector> total_forces; | |
| std::vector<cvm::rvector> applied_forces; | |
| | |
| size_t init_namd_atom(AtomID const &aid); | bool total_force_requested; |
| | |
| | /// Used to submit restraint energy as MISC |
| SubmitReduction *reduction; | SubmitReduction *reduction; |
| | |
| #ifdef NAMD_TCL | #ifdef NAMD_TCL |
| |
| colvarproxy_namd(); | colvarproxy_namd(); |
| ~colvarproxy_namd(); | ~colvarproxy_namd(); |
| | |
| /// \brief Reimplements GlobalMaster member function, to be called | int setup(); |
| /// at every step | |
| | // synchronize the local arrays with requested or forced atoms |
| | int update_atoms_map(AtomIDList::const_iterator begin, AtomIDList::const_iterator end); |
| | |
| void calculate(); | void calculate(); |
| | |
| void add_energy(cvm::real energy); | |
| void request_system_force(bool yesno); | |
| void log(std::string const &message); | void log(std::string const &message); |
| void error(std::string const &message); | void error(std::string const &message); |
| void fatal_error(std::string const &message); | void fatal_error(std::string const &message); |
| void exit(std::string const &message); | void exit(std::string const &message); |
| | void add_energy(cvm::real energy); |
| | void request_total_force(bool yesno); |
| | |
| | bool total_forces_enabled() const |
| | { |
| | return total_force_requested; |
| | } |
| | |
| // Callback functions | |
| int run_force_callback(); | int run_force_callback(); |
| int run_colvar_callback(std::string const &name, | int run_colvar_callback(std::string const &name, |
| std::vector<const colvarvalue *> const &cvcs, | std::vector<const colvarvalue *> const &cvcs, |
| |
| std::vector<const colvarvalue *> const &cvcs, | std::vector<const colvarvalue *> const &cvcs, |
| std::vector<cvm::matrix2d<cvm::real> > &gradient); | std::vector<cvm::matrix2d<cvm::real> > &gradient); |
| | |
| inline cvm::real unit_angstrom() | cvm::real unit_angstrom() |
| { | { |
| return 1.0; | return 1.0; |
| } | } |
| |
| return thermostat_temperature; | return thermostat_temperature; |
| } | } |
| | |
| | cvm::real rand_gaussian() |
| | { |
| | return random.gaussian(); |
| | } |
| | |
| cvm::real dt() | cvm::real dt() |
| { | { |
| return simparams->dt; | return simparams->dt; |
| } | } |
| | |
| | int smp_enabled() |
| | { |
| | #if CMK_SMP && USE_CKLOOP |
| | return COLVARS_OK; |
| | #else |
| | return COLVARS_NOT_IMPLEMENTED; |
| | #endif |
| | } |
| | |
| | #if CMK_SMP && USE_CKLOOP |
| | int smp_colvars_loop(); |
| | |
| | int smp_biases_loop(); |
| | |
| | int smp_biases_script_loop(); |
| | |
| | friend void calc_colvars_items_smp(int first, int last, void *result, int paramNum, void *param); |
| | friend void calc_cv_biases_smp(int first, int last, void *result, int paramNum, void *param); |
| | #endif |
| | |
| | friend void calc_cv_scripted_forces(int paramNum, void *param); |
| | |
| | int smp_thread_id() |
| | { |
| | return CkMyRank(); |
| | } |
| | |
| | int smp_num_threads() |
| | { |
| | return CkMyNodeSize(); |
| | } |
| | |
| | protected: |
| | |
| | CmiNodeLock smp_lock_state; |
| | |
| | public: |
| | |
| | int smp_lock() |
| | { |
| | smp_lock_state = CmiCreateLock(); |
| | return COLVARS_OK; |
| | } |
| | |
| | int smp_trylock() |
| | { |
| | return COLVARS_NOT_IMPLEMENTED; |
| | } |
| | |
| | int smp_unlock() |
| | { |
| | CmiDestroyLock(smp_lock_state); |
| | return COLVARS_OK; |
| | } |
| | |
| // Replica communication functions. | // Replica communication functions. |
| bool replica_enabled() { | bool replica_enabled() { |
| #if CMK_HAS_PARTITION | #if CMK_HAS_PARTITION |
| |
| return restart_frequency_s; | return restart_frequency_s; |
| } | } |
| | |
| | int init_atom(int atom_number); |
| | int check_atom_id(int atom_number); |
| | int init_atom(cvm::residue_id const &residue, |
| | std::string const &atom_name, |
| | std::string const &segment_id); |
| | int check_atom_id(cvm::residue_id const &residue, |
| | std::string const &atom_name, |
| | std::string const &segment_id); |
| | void clear_atom(int index); |
| | |
| | inline void update_atom_properties(int index) |
| | { |
| | Molecule *mol = Node::Object()->molecule; |
| | // update mass |
| | atoms_masses[index] = mol->atommass(atoms_ids[index]); |
| | // update charge |
| | atoms_charges[index] = mol->atomcharge(atoms_ids[index]); |
| | } |
| | |
| cvm::rvector position_distance(cvm::atom_pos const &pos1, | cvm::rvector position_distance(cvm::atom_pos const &pos1, |
| cvm::atom_pos const &pos2); | cvm::atom_pos const &pos2); |
| cvm::real position_dist2(cvm::atom_pos const &pos1, | cvm::real position_dist2(cvm::atom_pos const &pos1, |
| |
| | |
| | |
| int load_atoms(char const *filename, | int load_atoms(char const *filename, |
| std::vector<cvm::atom> &atoms, | cvm::atom_group &atoms, |
| std::string const &pdb_field, | std::string const &pdb_field, |
| double const pdb_field_value = 0.0); | double const pdb_field_value = 0.0); |
| | |
| |
| std::string const &pdb_field, | std::string const &pdb_field, |
| double const pdb_field_value = 0.0); | double const pdb_field_value = 0.0); |
| | |
| std::ostream * output_stream(std::string const &output_name); | |
| int close_output_stream(std::string const &output_name); | |
| int backup_file(char const *filename); | |
| | |
| cvm::real rand_gaussian(void) | int scalable_group_coms() |
| { | { |
| return random.gaussian(); | return COLVARS_OK; |
| } | } |
| | int init_atom_group(std::vector<int> const &atoms_ids); |
| | void clear_atom_group(int index); |
| | int update_group_properties(int index); |
| | |
| | std::ostream * output_stream(std::string const &output_name); |
| | int close_output_stream(std::string const &output_name); |
| | int backup_file(char const *filename); |
| }; | }; |
| | |
| | |
| |
| } | } |
| | |
| | |
| | inline cvm::real colvarproxy_namd::position_dist2(cvm::atom_pos const &pos1, |
| | cvm::atom_pos const &pos2) |
| | { |
| | Lattice const *l = this->lattice; |
| | Vector const p1(pos1.x, pos1.y, pos1.z); |
| | Vector const p2(pos2.x, pos2.y, pos2.z); |
| | Vector const d = l->delta(p1, p2); |
| | return cvm::real(d.x*d.x + d.y*d.y + d.z*d.z); |
| | } |
| | |
| | |
| inline void colvarproxy_namd::select_closest_image(cvm::atom_pos &pos, | inline void colvarproxy_namd::select_closest_image(cvm::atom_pos &pos, |
| cvm::atom_pos const &ref_pos) | cvm::atom_pos const &ref_pos) |
| { | { |
| |
| } | } |
| | |
| | |
| inline cvm::real colvarproxy_namd::position_dist2(cvm::atom_pos const &pos1, | |
| cvm::atom_pos const &pos2) | |
| { | |
| Lattice const *l = this->lattice; | |
| Vector const p1(pos1.x, pos1.y, pos1.z); | |
| Vector const p2(pos2.x, pos2.y, pos2.z); | |
| Vector const d = l->delta(p1, p2); | |
| return cvm::real(d.x*d.x + d.y*d.y + d.z*d.z); | |
| } | |
| | |
| | |
| | |
| #endif | #endif |