Author: MITRADIP DAS, NISER, Bhubaneswar, India.
Table of Contents:
The codes were compiled and tested using clang++-5.0 using c++14 standard in Linux 4.8 (Linux Mint 18.2). The files analysis.cpp and cpp_include/libraries.h should not be compiled as stand alone files and are meant to be used as libraries. For running the code, kindly compile the files with main() functions only (like rdf_1.cpp) as per the requirements. You are also invited to design your own libraries, the instructions for which are given later in this file.
This file contains different libraries and generic functions used in the code. It references to different standard c++ libraries like iostream, fstream etc. The generic functions contained are:
- std::string trim_left(const std::string& str): This function left trims a string str.
- std::string trim_right(const std::string& str): This function right trims a string str.
- std::string trim(const std::string& str): This function trims a string str using trim_left and trim_right.
- long int line_skip(string file_name,long int start_pos,long int lines): This functions returns the position of the get pointer in file file_name after skipping lines lines starting from position of get pointer start_pos.
This file contains the codes for analysis of the system. It has different classes for different sections of the work. This file implements cpp_include/libraries.h.
-
class atom: Each object of this class represents an atom and it contains properties of atom like ID, name, Residue (molecule) ID and coordinates.
- void show(): This is used to display the atom and the above properties.
-
class frame: This frame represents one frame from a run of MD simulation. It contains information of multiple atoms (implemented as a vector) and the corresponding box length of the frame.
- long int read_file(string file_name,long int start_line): This function reads the atoms from a PDB file file_name generated using VMD (implementing PBC) with get pointer from start_line till "END" is encountered. It returns the current position of the get pointer in the file (useful while implementing multiple frames).
- void clear_all(): Clear all the information present in a frame.
- void set_box(double len): Sets the box length to len.
- void show_frame(): Display all the data of the whole frame.
- double calc_dist_pbc(long int id1,long int id2): This function returns the distance between two atoms with id1 and id2 implementing PBC.
- void get_idx_of(string src,std::vector<int> &v): This functions stores all the index of atoms with name src in referenced vector v.
- void pair_rdf_fn(double start, double stop, double interval, const string pairs[], std::vector <array <double,2>> &rdf): This function calculates the RDF of the current frame between atom types given in pairs[]. The variables start, stop and interval defines the start, end and mesh size of the RDF, in referenced vector rdf. The RDF implements PBC conditions and hence non-zero results exists only up to half of box length.
- bool interact_2(long id1,long id2,double d12l,double d12h): This function checks if two atoms, given by indices id1 and id2 interact via a distance between d12l and d12h.
- bool interact_3(long id1,long id2,long id3,double d12l,double d12h,double d23l,double d23h,double a123l,double a123h): This function checks if three atoms, with id's id1, id2 and id3 are interacting such that the distance between 1 & 2 lies between d12l and d12h, distance between 2 & 3 lies between d23l and d23h and angle 123 (in degrees) is between a123l and a123h.
- long cnt_intr_2(const string atm1,const string atm2,double d12l,double d12h): This function counts the number of atoms of types atm1 and atm2 interacting via a distance between d12l and d12h.
- long cnt_intr_3(const string atm1,const string atm2,const string atm3,double d12l,double d12h,double d23l,double d23h,double a123l,double a123h): This function counts the number interacting atoms with atom types atm1, atm2 and atm3 such that the distance between 1 & 2 lies between d12l and d12h, distance between 2 & 3 lies between d23l and d23h and angle 123 (in degrees) is between a123l and a123h.
- void list_intr_2(std::vector<int> id1,std::vector<int> id2,double d12l,double d12h,std::vector<int> &idx1,std::vector<int> &idx2): Checks the lists id1 and id2 with atomic ID's for interactions (such that the distance is between d12l and d12h) and stores the same in idx1 and idx2.
-
class trajectory: This class represents the trajectory of the atoms and implements a vector of frames in order to achieve this target.
- long int read_frames(string file_name, long int st_pos, long int nframes, double boxl): This function is used to read nframes frames from a PDB file file_name generated by VMD starting from file get pointer st_pos. This function also fixes the box length of each frame to boxl and it return the current position of get pointer after reading the frames.
- void pair_rdf_fn(double start, double stop, double interval, const string pairs[], std::vector <array<double,2>> &rdf): This function gives the time average of RDF implementing pair_rdf_fn from class frame.
- double idx_msd_fn(int dt,const int idx): This function calculates and returns the MSD of atom present in index idx for a frame (or time) interval dt.
- double type_msd_fn(int dt,const string src): This function calculates and returns the MSD of an atom type src over the whole ensemble for a frame (or time) interval dt. This implements the idx_msd_fn.
- void type_msd_fn_all_dt(const string src,std::vector<array<double,2>> &v): This function calculates the overall MSD for all possible frame intervals, 1 to (no of frames-1), for a given atom type src and stores it in the reference vector v.
- void intr_cnt_3(const string atm1,const string atm2,const string atm3,double d12l,double d12h,double d23l,double d23h,double a123l,double a123h,std::vector<array<long,2>> &v): This function counts the number interacting atoms with atom types atm1, atm2 and atm3 in each time step such that the distance between 1 & 2 lies between d12l and d12h, distance between 2 & 3 lies between d23l and d23h and angle 123 (in degrees) is between a123l and a123h, and stores the data in vector v.
- void intr_cnt_2(const string atm1,const string atm2,double d12l,double d12h,std::vector<array<long,2>> &v): This function counts the number of atoms of types atm1 and atm2 in each time step interacting via a distance between d12l and d12h.
- void tcf_2_all_dt_im(const string atm1,const string atm2,double d12l,double d12h,std::vector<array<double,2>> &v): Gives the time correlation function (survival proablity) between atom types atm1 and atm2 interacting via distance between d12l and d12h, with intermediate approximation, and stores it in vector v for all time steps.
- void tcf_2_all_dt(const string atm1,const string atm2,double d12l,double d12h,std::vector<array<double,2>> &v) : Gives the time correlation function (survival proablity) between atom types atm1 and atm2 interacting via distance between d12l and d12h, without intermediate approximation, and stores it in vector v for all time steps.
This file contains the main() function demonstrating a sample RDF run.
This file contains the main() function demonstrating a sample MSD run.
This file contains the main() function demonstrating a sample interactional statistics study.
This file contains the main() function demonstrating a sample interactional dynamics (time correlation function) study without intermediate approximation.
You are always invited to design your own libraries on this code and contact the author about the same, if you want it to be implemented. Please download analysis.cpp and cpp_include/libraries.h and generate your own C++ code for the analysis required. You may consider looking at the sample codes for reference. Please note that libraries.h has to be inside cpp_include directory.