Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2018,2019 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #include "core/ActionShortcut.h" 23 : #include "core/ActionRegister.h" 24 : 25 : namespace PLMD { 26 : namespace analysis { 27 : 28 : //+PLUMEDOC REWEIGHTING WHAM_HISTOGRAM 29 : /* 30 : This can be used to output the a histogram using the weighted histogram technique 31 : 32 : \par Examples 33 : 34 : */ 35 : //+ENDPLUMEDOC 36 : 37 18 : class WhamHistogram : public ActionShortcut { 38 : public: 39 : static void registerKeywords( Keywords& keys ); 40 : explicit WhamHistogram( const ActionOptions& ); 41 : }; 42 : 43 7844 : PLUMED_REGISTER_ACTION(WhamHistogram,"WHAM_HISTOGRAM") 44 : 45 7 : void WhamHistogram::registerKeywords( Keywords& keys ) { 46 7 : ActionShortcut::registerKeywords( keys ); 47 28 : keys.add("compulsory","ARG","the arguments that you would like to make the histogram for"); 48 35 : keys.add("compulsory","BIAS","*.bias","the value of the biases to use when performing WHAM"); 49 28 : keys.add("compulsory","TEMP","the temperature at which the simulation was run"); 50 35 : keys.add("compulsory","STRIDE","1","the frequency with which the data should be stored to perform WHAM"); 51 28 : keys.add("compulsory","GRID_MIN","the minimum to use for the grid"); 52 28 : keys.add("compulsory","GRID_MAX","the maximum to use for the grid"); 53 28 : keys.add("compulsory","GRID_BIN","the number of bins to use for the grid"); 54 28 : keys.add("optional","BANDWIDTH","the bandwidth for kernel density estimation"); 55 7 : } 56 : 57 : 58 6 : WhamHistogram::WhamHistogram( const ActionOptions& ao ) : 59 : Action(ao), 60 6 : ActionShortcut(ao) 61 : { 62 : // Input for REWEIGHT_WHAM 63 6 : std::string rew_line = getShortcutLabel() + "_weights: REWEIGHT_WHAM"; 64 18 : std::string bias; parse("BIAS",bias); rew_line += " ARG=" + bias; 65 18 : std::string temp; parse("TEMP",temp); rew_line += " TEMP=" + temp; 66 6 : readInputLine( rew_line ); 67 : // Input for COLLECT_FRAMES 68 18 : std::string col_line = getShortcutLabel() + "_collect: COLLECT_FRAMES LOGWEIGHTS=" + getShortcutLabel() + "_weights"; 69 18 : std::string stride; parse("STRIDE",stride); col_line += " STRIDE=" + stride; 70 18 : std::string arg; parse("ARG",arg); col_line += " ARG=" + arg; 71 6 : readInputLine( col_line ); 72 : // Input for HISTOGRAM 73 18 : std::string histo_line = getShortcutLabel() + ": HISTOGRAM ARG=" + getShortcutLabel() + "_collect.*"; 74 18 : std::string min; parse("GRID_MIN",min); histo_line += " GRID_MIN=" + min; 75 18 : std::string max; parse("GRID_MAX",max); histo_line += " GRID_MAX=" + max; 76 18 : std::string bin; parse("GRID_BIN",bin); histo_line += " GRID_BIN=" + bin; 77 12 : std::string bw=""; parse("BANDWIDTH",bw); 78 6 : if( bw!="" ) histo_line += " BANDWIDTH=" + bw; 79 : else histo_line += " KERNEL=DISCRETE"; 80 6 : readInputLine( histo_line ); 81 6 : } 82 : 83 : } 84 5874 : }