votca 2024-dev
Loading...
Searching...
No Matches
csg_stat.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2021 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// Standard includes
19#include <cstdlib>
20#include <fstream>
21#include <memory>
22
23// Third party includes
24#include <boost/program_options.hpp>
25
26// Local VOTCA includes
28#include "votca/csg/version.h"
29
30// Local private VOTCA includes
31#include "csg_stat_imc.h"
32
33using namespace std;
34using namespace votca::csg;
35
36class CsgStatApp : public CsgApplication {
37 public:
38 string ProgramName() override { return "csg_stat"; }
39 void HelpText(ostream &out) override;
40
41 bool DoTrajectory() override { return true; }
42 bool DoMapping() override { return true; }
43 bool DoMappingDefault(void) override { return false; }
44 bool DoThreaded() override { return true; }
45 bool SynchronizeThreads() override { return true; }
46 void Initialize() override;
47 bool EvaluateOptions() override;
48
49 void BeginEvaluate(Topology *top, Topology *top_ref) override;
50 void EndEvaluate() override;
51
52 std::unique_ptr<CsgApplication::Worker> ForkWorker() override {
53 return imc_.ForkWorker();
54 }
55
56 void MergeWorker(CsgApplication::Worker *worker) override {
57 imc_.MergeWorker(worker);
58 }
59
60 public:
63 string extension_;
64};
65
66void CsgStatApp::HelpText(ostream &out) {
67 out << "Calculate all distributions (bonded and non-bonded) specified in "
68 "options file.\n"
69 "Optionally calculates update Eigen::Matrix3d for invere Monte Carlo. "
70 "This "
71 "program\n"
72 "is called inside the inverse scripts. Unlike csg_boltzmann, big "
73 "systems\n"
74 "can be treated as well as non-bonded interactions can be evaluated.";
75}
76
79 AddProgramOptions("Specific options")("options",
80 boost::program_options::value<string>(),
81 " options file for coarse graining")(
82 "do-imc", " write out additional Inverse Monte Carlo data")(
83 "include-intra", " do not exclude intramolecular neighbors")(
84 "block-length", boost::program_options::value<votca::Index>(),
85 " write blocks of this length, the averages are cleared after every "
86 "write")("ext",
87 boost::program_options::value<string>(&extension_)
88 ->default_value("dist.new"),
89 "Extension of the output");
90}
91
94 CheckRequired("options");
95 CheckRequired("trj", "no trajectory file specified");
96
97 imc_.LoadOptions(OptionsMap()["options"].as<string>());
98
99 if (OptionsMap().count("block-length")) {
100 imc_.BlockLength(OptionsMap()["block-length"].as<votca::Index>());
101 } else {
102 imc_.BlockLength(0);
103 }
104
105 if (OptionsMap().count("do-imc")) {
106 imc_.DoImc(true);
107 }
108
109 if (OptionsMap().count("include-intra")) {
110 imc_.IncludeIntra(true);
111 }
112
114
116 return true;
117}
118
120 imc_.BeginEvaluate(top, top_ref);
121}
122
124
125int main(int argc, char **argv) {
126 CsgStatApp app;
127 return app.Exec(argc, argv);
128}
void EndEvaluate() override
called after the last frame
Definition csg_stat.cc:123
votca::Index block_length_
Definition csg_stat.cc:62
std::unique_ptr< CsgApplication::Worker > ForkWorker() override
Definition csg_stat.cc:52
void HelpText(ostream &out) override
help text of application without version information
Definition csg_stat.cc:66
string extension_
Definition csg_stat.cc:63
void MergeWorker(CsgApplication::Worker *worker) override
Definition csg_stat.cc:56
bool DoMapping() override
overload and return true to enable mapping command line options
Definition csg_stat.cc:42
bool DoThreaded() override
Definition csg_stat.cc:44
void BeginEvaluate(Topology *top, Topology *top_ref) override
called before the first frame
Definition csg_stat.cc:119
bool EvaluateOptions() override
Process command line options.
Definition csg_stat.cc:92
bool DoMappingDefault(void) override
if DoMapping is true, will by default require mapping or not
Definition csg_stat.cc:43
void Initialize() override
Initialize application data.
Definition csg_stat.cc:77
bool DoTrajectory() override
overload and return true to enable trajectory command line options
Definition csg_stat.cc:41
bool SynchronizeThreads() override
Definition csg_stat.cc:45
string ProgramName() override
program name
Definition csg_stat.cc:38
Worker, derived from Thread, does the work.
bool EvaluateOptions() override
Process command line options.
void Initialize() override
Initialize application data.
class to calculate distribution functions and cross correlations for inverse monte carlo
void BlockLength(votca::Index length)
std::unique_ptr< CsgApplication::Worker > ForkWorker()
void EndEvaluate()
end coarse graining a trajectory
void Extension(std::string ext)
void DoImc(bool do_imc)
void IncludeIntra(bool include_intra)
void MergeWorker(CsgApplication::Worker *worker_)
void Initialize(void)
void BeginEvaluate(Topology *top, Topology *top_atom)
begin coarse graining a trajectory
void LoadOptions(const std::string &file)
load cg definitions file
topology of the whole system
Definition topology.h:81
int Exec(int argc, char **argv)
executes the program
boost::program_options::variables_map & OptionsMap()
get available program options & descriptions
boost::program_options::options_description_easy_init AddProgramOptions(const std::string &group="")
add option for command line
void CheckRequired(const std::string &option_name, const std::string &error_msg="")
Check weather required option is set.
int main(int argc, char **argv)
Definition csg_stat.cc:125
STL namespace.
Eigen::Index Index
Definition types.h:26