votca 2024-dev
Loading...
Searching...
No Matches
csg_reupdate.h
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#ifndef VOTCA_CSG_CSG_REUPDATE_H
19#define VOTCA_CSG_CSG_REUPDATE_H
20
21// Third party includes
22#include <boost/program_options.hpp>
23
24// VOTCA includes
27#include <votca/tools/table.h>
28
29// Local VOTCA includes
36
37using namespace votca::csg;
38using namespace votca::tools;
39
41
42 PotentialInfo(votca::Index index, bool bonded_, votca::Index vec_pos_,
43 std::string &param_in_ext_, Property *options,
44 bool gentable = false);
45
47 bool bonded;
50 std::pair<votca::Index, votca::Index> beadTypes;
51
52 std::string potentialName;
53 std::string potentialFunction;
54 std::string type1, type2;
55
56 double rmin, rcut;
57
59};
60
62 public:
63 std::string ProgramName() override { return "csg_reupdate"; }
64 void HelpText(std::ostream &out) override {
65 out << "computes relative entropy update.";
66 }
67
68 bool DoTrajectory() override { return true; }
69
70 bool DoMapping() override { return false; }
71
72 bool DoThreaded() override { return true; }
73 bool SynchronizeThreads() override { return false; }
74
75 bool NeedsTopology() override { return false; }
76
77 void Initialize() override;
78 bool EvaluateOptions() override;
79 void BeginEvaluate(Topology *top, Topology *top_atom = nullptr) override;
80 void LoadOptions(const std::string &file);
81
82 void Run() override;
83
84 void EndEvaluate() override;
85 std::unique_ptr<CsgApplication::Worker> ForkWorker(void) override;
86 void MergeWorker(Worker *worker) override;
87
88 private:
89 protected:
91 std::vector<Property *> nonbonded_;
92
93 using PotentialContainer = std::vector<PotentialInfo *>;
95
97 Eigen::VectorXd lamda_;
98 // HS_ is a symmetric matrix
99 Eigen::MatrixXd HS_;
100 Eigen::VectorXd DS_;
101 Eigen::VectorXd dUFrame_;
103
104 double UavgAA_;
105 double UavgCG_;
106 double beta_;
107 double relax_;
109
111
112 std::vector<Table *> aardfs_;
113 std::vector<double *> aardfnorms_;
114
115 // file extension for the inputs/outputs
117 std::string pot_out_ext_;
118 std::string rdf_ext_;
119
120 void WriteOutFiles();
121 void EvalBonded(Topology *conf, PotentialInfo *potinfo);
122 void EvalNonbonded(Topology *conf, PotentialInfo *potinfo);
123
124 // Compute Avg U, dU, and d2U values in reference AA ensemble
125 void AAavgBonded(PotentialInfo *potinfo);
126 void AAavgNonbonded(PotentialInfo *potinfo);
127
128 // Formulates HS_ dlamda = - DS_ system of Lin Eq.
129 void REFormulateLinEq();
130
131 // Solve HS_ dlamda = - DS_ and update lamda_
132 void REUpdateLamda();
133};
134
136 public:
137 ~CsgREupdateWorker() override = default;
138
140 std::vector<Property *> nonbonded_;
141
142 using PotentialContainer = std::vector<PotentialInfo *>;
144
146 Eigen::VectorXd lamda_;
147 Eigen::MatrixXd HS_;
148 Eigen::VectorXd DS_;
149 Eigen::VectorXd dUFrame_;
150
151 double UavgCG_;
152 double beta_;
154
155 void EvalConfiguration(Topology *conf, Topology *conf_atom) override;
156 void EvalBonded(Topology *conf, PotentialInfo *potinfo);
157 void EvalNonbonded(Topology *conf, PotentialInfo *potinfo);
158};
159
160#endif // VOTCA_CSG_CSG_REUPDATE_H
PotentialContainer potentials_
votca::Index nlamda_
void EvalConfiguration(Topology *conf, Topology *conf_atom) override
overload with the actual computation
votca::Index nframes_
std::vector< Property * > nonbonded_
Eigen::VectorXd dUFrame_
Eigen::VectorXd lamda_
Eigen::VectorXd DS_
~CsgREupdateWorker() override=default
void EvalBonded(Topology *conf, PotentialInfo *potinfo)
Eigen::MatrixXd HS_
void EvalNonbonded(Topology *conf, PotentialInfo *potinfo)
std::vector< PotentialInfo * > PotentialContainer
void Run() override
Main body of application.
Property options_
std::string pot_out_ext_
void EvalNonbonded(Topology *conf, PotentialInfo *potinfo)
std::string ProgramName() override
program name
void HelpText(std::ostream &out) override
help text of application without version information
bool DoTrajectory() override
overload and return true to enable trajectory command line options
bool SynchronizeThreads() override
std::string rdf_ext_
std::vector< Property * > nonbonded_
PotentialContainer potentials_
void MergeWorker(Worker *worker) override
std::vector< double * > aardfnorms_
void AAavgNonbonded(PotentialInfo *potinfo)
std::unique_ptr< CsgApplication::Worker > ForkWorker(void) override
void LoadOptions(const std::string &file)
void AAavgBonded(PotentialInfo *potinfo)
void REFormulateLinEq()
votca::Index nlamda_
bool hessian_check_
votca::Index nframes_
std::vector< Table * > aardfs_
Eigen::VectorXd lamda_
void EndEvaluate() override
called after the last frame
bool EvaluateOptions() override
Process command line options.
void Initialize() override
Initialize application data.
void BeginEvaluate(Topology *top, Topology *top_atom=nullptr) override
called before the first frame
void WriteOutFiles()
std::string param_in_ext_
bool DoMapping() override
overload and return true to enable mapping command line options
void EvalBonded(Topology *conf, PotentialInfo *potinfo)
void REUpdateLamda()
Eigen::MatrixXd HS_
bool DoThreaded() override
Eigen::VectorXd DS_
bool NeedsTopology() override
if topology is always needed
std::string param_out_ext_
Eigen::VectorXd dUFrame_
std::vector< PotentialInfo * > PotentialContainer
Worker, derived from Thread, does the work.
topology of the whole system
Definition topology.h:81
class to manage program options with xml serialization functionality
Definition property.h:55
Eigen::Index Index
Definition types.h:26
std::pair< votca::Index, votca::Index > beadTypes
votca::Index vec_pos
votca::Index potentialIndex
std::string potentialName
std::string type2
std::string potentialFunction
Property * options_
PotentialFunction * ucg
std::string type1