votca 2024.1-dev
Loading...
Searching...
No Matches
region.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20// Standard includes
21#include <vector>
22
23// Local VOTCA includes
25#include "votca/xtp/qmregion.h"
26#include "votca/xtp/region.h"
28
29namespace votca {
30namespace xtp {
31
33 std::vector<std::unique_ptr<Region> >& regions) {
34 std::vector<double> energies = std::vector<double>(regions.size(), 0.0);
35 for (std::unique_ptr<Region>& reg : regions) {
36 Index id = reg->getId();
37 if (id == this->getId()) {
38 continue;
39 }
40
41 QMRegion QMdummy(0, log_, "");
42 StaticRegion Staticdummy(0, log_);
43 PolarRegion Polardummy(0, log_);
45 << TimeStamp() << " Evaluating interaction between " << this->identify()
46 << " " << this->getId() << " and " << reg->identify() << " "
47 << reg->getId() << std::flush;
48 if (reg->identify() == QMdummy.identify()) {
49 QMRegion* qmregion = dynamic_cast<QMRegion*>(reg.get());
50 energies[id] = InteractwithQMRegion(*qmregion);
51 } else if (reg->identify() == Staticdummy.identify()) {
52 StaticRegion* staticregion = dynamic_cast<StaticRegion*>(reg.get());
53 energies[id] = InteractwithStaticRegion(*staticregion);
54 } else if (reg->identify() == Polardummy.identify()) {
55 PolarRegion* polarregion = dynamic_cast<PolarRegion*>(reg.get());
56 energies[id] = InteractwithPolarRegion(*polarregion);
57 } else {
58 throw std::runtime_error(
59 "Interaction of regions with types:" + this->identify() + " and " +
60 reg->identify() + " not implemented");
61 }
62 }
63
64 return energies;
65}
66
68 tools::Property& region = prop.add("region", "");
69 region.setAttribute("type", identify());
70 region.setAttribute("id", getId());
71 region.setAttribute("size", size());
72 region.setAttribute("Tot_charge", (boost::format("%1$1.6e") % charge()));
73 AppendResult(region);
74}
75
76} // namespace xtp
77} // namespace votca
class to manage program options with xml serialization functionality
Definition property.h:55
Property & add(const std::string &key, const std::string &value)
add a new property to structure
Definition property.cc:108
void setAttribute(const std::string &attribute, const T &value)
set an attribute
Definition property.h:314
std::string identify() const override
Definition polarregion.h:48
std::string identify() const override
Definition qmregion.h:66
std::vector< double > ApplyInfluenceOfOtherRegions(std::vector< std::unique_ptr< Region > > &regions)
Definition region.cc:32
virtual double charge() const =0
void AddResults(tools::Property &prop) const
Definition region.cc:67
virtual double InteractwithQMRegion(const QMRegion &region)=0
virtual Index size() const =0
Index getId() const
Definition region.h:79
virtual void AppendResult(tools::Property &prop) const =0
virtual double InteractwithStaticRegion(const StaticRegion &region)=0
virtual double InteractwithPolarRegion(const PolarRegion &region)=0
Logger & log_
Definition region.h:100
virtual std::string identify() const =0
std::string identify() const override
Timestamp returns the current time as a string Example: cout << TimeStamp()
Definition logger.h:224
#define XTP_LOG(level, log)
Definition logger.h:40
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26