22#include <boost/lexical_cast.hpp>
50 vector<string> &args) {
51 if (args[0] ==
"set") {
54 }
else if (cmd ==
"tab") {
56 if (args.size() > 2) {
57 if (args[1] ==
"smooth_pdf") {
59 }
else if (args[1] ==
"smooth_pot") {
61 }
else if (args[1] ==
"T") {
64 cout <<
"unknown option " << args[2] << endl;
69 if (args.size() <= 2) {
75 }
else if (args.size() >= 2) {
78 }
else if (cmd ==
"tab") {
82 cout <<
"wrong number of arguments" << endl;
87 if (args.size() == 0) {
89 cout <<
"tab <file> <selection>\n"
90 <<
"Calculate tabulated potential by inverting the distribution "
91 "function. Statistics is calculated using all interactions in "
92 "selection.\nsee also: help tab set\n\nexample:\ntab set scale "
93 "bond\ntab U_bond.txt *:bond:*\n";
96 cout <<
"hist <file> <selection>\n"
97 <<
"Calculate distribution function for selection. Statistics is "
98 "calculated using all interactions in selection.\n see also: help"
99 " hist set\n\nexample:hist U_bond.txt *:bond:*\n";
103 if (args[0] ==
"set") {
104 if (args.size() == 1) {
105 cout << cmd <<
" set <option> <value>\n"
106 <<
"set option for this command. Use \"" << cmd
107 <<
" set\" for a list of available options. To get help on a "
108 "specific option use e.g.\n"
109 << cmd <<
" set periodic\n";
112 if (args[1] ==
"n") {
113 cout << cmd <<
"set n <integer>\n"
114 <<
"set number of bins for table\n";
117 if (args[1] ==
"min") {
118 cout << cmd <<
"set min <value>\n"
119 <<
"minimum value of interval for histogram (see also periodic, "
123 if (args[1] ==
"max") {
124 cout << cmd <<
"set max <value>\n"
125 <<
"maximum value of interval for histogram (see also periodic, "
129 if (args[1] ==
"periodic") {
130 cout << cmd <<
"set periodic <value>\n"
131 <<
"can be 1 for periodic interval (e.g. dihedral) or 0 for "
132 "non-periodic (e.g. bond)\n";
135 if (args[1] ==
"auto") {
137 <<
"set auto <value>\n"
138 "can be 1 for automatically determine the interval for the table "
139 "(min, max, extend will be ignored) or 0 to use min/max as "
143 if (args[1] ==
"extend") {
145 <<
"set extend <value>\n"
146 "should only be used with auto=0. Can be 1 for extend the "
147 "interval if values are out of bounds (min/max) or 0 to "
148 "ignore values which are out of the interal\n";
151 if (args[1] ==
"scale") {
153 <<
"set scale <value>\n"
154 "volume normalization of pdf. Can be no (no scaling), bond "
155 "(1/r^2) or angle ( 1/sin(phi) ). See VOTCA manual, section "
156 "theoretical background for details\n";
159 if (args[1] ==
"normalize") {
162 <<
"set normalize <value>\n"
163 "can be 1 for a normalized histogram or 0 to skip normalization\n";
168 if (args[1] ==
"smooth_pdf") {
169 cout <<
"tab set smooth_pdf <value>\n"
170 "Perform so many smoothing iterations on the distribution "
171 "function before inverting the potential\n";
174 if (args[1] ==
"smooth_pot") {
175 cout <<
"tab set smooth_pot <value>\n"
176 "Perform so many smoothing iterations on tabulated potential "
177 "after inverting the potential\n";
180 if (args[1] ==
"T") {
181 cout <<
"tab set T <value>\n"
182 "Temperature in Kelvin the simulation was performed\n";
188 cout <<
"no help text available" << endl;
198 vector<string> &args) {
202 for (
size_t i = 1; i < args.size(); i++) {
210 cout <<
"histogram created using " << sel->
size() <<
" data-rows, written to "
216 vector<string> &args) {
223 for (
size_t i = 1; i < args.size(); i++) {
240 assert(h.
getInterval() > 0 &&
"Interval for pdf histogram is 0");
244 <<
" " << F[i] << endl;
247 cout <<
"histogram created using " << sel->
size() <<
" data-rows, written to "
256 const vector<string> &args) {
257 if (args.size() > 2) {
258 if (args[1] ==
"n") {
259 op.
n_ = boost::lexical_cast<Index>(args[2]);
260 }
else if (args[1] ==
"min") {
261 op.
min_ = boost::lexical_cast<double>(args[2]);
262 }
else if (args[1] ==
"max") {
263 op.
max_ = boost::lexical_cast<double>(args[2]);
264 }
else if (args[1] ==
"periodic") {
265 op.
periodic_ = boost::lexical_cast<bool>(args[2]);
266 }
else if (args[1] ==
"auto") {
268 }
else if (args[1] ==
"extend") {
270 }
else if (args[1] ==
"normalize") {
271 op.
normalize_ = boost::lexical_cast<bool>(args[2]);
272 }
else if (args[1] ==
"scale") {
273 if (args[2] ==
"no" || args[2] ==
"bond" || args[2] ==
"angle") {
276 cout <<
"scale can be: no, bond or angle\n";
282 cout <<
"n: " << op.
n_ << endl;
283 cout <<
"min: " << op.
min_ << endl;
284 cout <<
"max: " << op.
max_ << endl;
285 cout <<
"periodic: " << op.
periodic_ << endl;
288 cout <<
"scale: " << op.
scale_ << endl;
289 cout <<
"normalize: " << op.
normalize_ << endl;
295 double dx,
bool bPeriodic) {
300 F[n - 1] = F[0] = -(U[1] - U[n - 2]) * f;
302 F[0] = -(U[1] - U[0]) * 2 * f;
303 F[n - 1] = -(U[n - 1] - U[n - 2]) * 2 * f;
305 for (
size_t i = 1; i < n - 1; i++) {
306 F[i] = -(U[i + 1] - U[i - 1]) * f;
314 old[0] = data[n - 3];
315 old[1] = data[n - 2];
321 for (i = 0; i <
Index(data.size()) - 2; i++) {
324 (old[0] + 2. * old[1] + 3. * data[i] + 2. * data[i + 1] + data[i + 2]) /
331 (old[0] + 2. * old[1] + 3. * data[i] + 2. * data[i + 1] + data[0]) / 9.;
332 data[n - 1] = data[0];
334 data[i] = (old[0] + 2. * old[1] + 3. * data[i] + 3. * data[i + 1]) / 9.;
338 data[i] = (old[0] + 2. * old[1] + 6. * data[i]) / 9.;
344 double min = std::numeric_limits<double>::max();
345 double max = std::numeric_limits<double>::min();
347 for (
double i : data) {
348 max = std::max(i, max);
350 min = std::min(i, min);
356 for (
double &i : data) {
Class calculates data associated with bond interactions.
tools::DataCollection< double > & BondedValues()
std::pair< Index, Index > getSmoothIterations() const
Method returns the number of smoothing iterations used on the data.
double getTemperature() const
Returns the temperature used during the bolzmann inversion.
void Command(BondedStatistics &bs, const std::string &cmd, std::vector< std::string > &args) override
double Temperature_
Temperature in units of Kelvin.
void Help(const std::string &cmd, std::vector< std::string > &args) override
void WritePotential(BondedStatistics &bs, std::vector< std::string > &args)
votca::tools::Histogram::options_t hist_options_
void BoltzmannInvert_(std::vector< double > &data)
void CalcForce_(std::vector< double > &U, std::vector< double > &F, double dx, bool bPeriodic)
votca::tools::Histogram::options_t tab_options_
bool SetOption_(votca::tools::Histogram::options_t &op, const std::vector< std::string > &args)
void WriteHistogram(BondedStatistics &bs, std::vector< std::string > &args)
void Register(std::map< std::string, AnalysisTool * > &lib) override
void Smooth_(std::vector< double > &data, bool bPeriodic)
Smooths a vector of doubles.
base class for all analysis tools