eabf2D.h

Go to the documentation of this file.
00001 //
00002 // The extended adaptive biasing force method has been contributed to NAMD by the following authors:
00003 //
00004 //    Haohao Fu and Christophe Chipot
00005 //    Laboratoire International Associ\'e
00006 //    Centre National de la Recherche Scientifique et University of Illinois at Urbana--Champaign
00007 //    Unit\'e Mixte de Recherche No. 7565, Universit\'e de Lorraine
00008 //    B.P. 70239, 54506 Vand\oe uvre-lès-Nancy cedex, France
00009 //
00010 // Copyright 2016, Centre National de la Recherche Scientifique
00011 //
00012 
00013 #ifndef EABF2D_H
00014 #define EABF2D_H
00015 
00016 #include <iostream>
00017 #include <string>
00018 #include <sstream>
00019 #include <vector>
00020 
00021 #include "eabf.h"
00022 
00023 class eABF2D : public eABF
00024 {
00025 public:
00026     // called when (re)start a namd run
00027         eABF2D(const double _lowerboundary,
00028                 const double _upperboundary,
00029                 const double _width,
00030                 const double _krestr,
00031                 const double _lowerboundary2,
00032                 const double _upperboundary2,
00033                 const double _width2,
00034                 const double _krestr2,
00035                 const std::string& _outputfile,
00036                 const int _outputfreq,
00037                 const bool _restart,
00038                 const std::string& _inputfile,
00039                 const bool _outputgrad,
00040                 const int _gradfreq,
00041                 const double _temperature);
00042 
00043     virtual ~eABF2D()
00044     {
00045                 for (int i = 0; i < bins[0] * bins[0]; i++)
00046                         delete[] countall[i];
00047                 delete[] countall;
00048     }
00049 
00050     // called by colvar each step, update the sampling point
00051     bool update(const std::string&);
00052 
00053 
00054 private:
00055     // for 2D eABF, much memories are need, I have to use C-style pointer and array
00056     // BE VERY CAREFUL ABOUT IT!
00057     int** countall; // the distribution of samples, needed for eABF
00058     std::vector<std::vector<double> > sumx1; // the sum of x in each bin, needed for eABF
00059     std::vector<std::vector<double> > sumx21; // the sum of x^2, needed for eABF
00060     std::vector<std::vector<double> > sumx2;
00061         std::vector<std::vector<double> > sumx22;
00062     std::vector<std::vector <int> > county; // the distribution in each bin, needed for eABF
00064 
00065     // initialize the variables
00066     bool initialize();
00067 
00068     // read variables from a restart file
00069     bool readfile();
00070 
00071     // write restart file
00072     bool writefile() const;
00073 
00074     // write the head of grad file
00075     bool writehead(ofstream_namd&) const;
00076 
00077     // calculate grad and pmf
00078         bool calpmf() const;
00079 
00080         // convert the scale in file to the scale in this eabf
00081         virtual int convertscale(double lowerboundary, int window, int dimension) const
00082         {
00083                 if (dimension == 1)
00084                         return int((lowerboundary - this->lowerboundary[0]) / width[0] + window);
00085                 if (dimension == 2)
00086                         return int((lowerboundary - this->lowerboundary[1]) / width[1] + window);
00087                 return 0;
00088         }
00089 };
00090 #endif // EABF2D_H

Generated on Sat Sep 23 01:17:13 2017 for NAMD by  doxygen 1.4.7