votca 2026-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
26#include "votca/xtp/qmregion.h"
27#include "votca/xtp/region.h"
29
30namespace votca {
31namespace xtp {
32
34 std::vector<std::unique_ptr<Region> >& regions) {
35 std::vector<double> energies = std::vector<double>(regions.size(), 0.0);
36 for (std::unique_ptr<Region>& reg : regions) {
37 Index id = reg->getId();
38 if (id == this->getId()) {
39 continue;
40 }
41
42 QMRegion QMdummy(0, log_, "");
43 StaticRegion Staticdummy(0, log_);
44 PolarRegion Polardummy(0, log_);
45 EwaldRegion Ewalddummy(0, log_);
47 << TimeStamp() << " Evaluating interaction between " << this->identify()
48 << " " << this->getId() << " and " << reg->identify() << " "
49 << reg->getId() << std::flush;
50 if (reg->identify() == QMdummy.identify()) {
51 QMRegion* qmregion = dynamic_cast<QMRegion*>(reg.get());
52 energies[id] = InteractwithQMRegion(*qmregion);
53 } else if (reg->identify() == Staticdummy.identify()) {
54 StaticRegion* staticregion = dynamic_cast<StaticRegion*>(reg.get());
55 energies[id] = InteractwithStaticRegion(*staticregion);
56 } else if (reg->identify() == Polardummy.identify()) {
57 PolarRegion* polarregion = dynamic_cast<PolarRegion*>(reg.get());
58 energies[id] = InteractwithPolarRegion(*polarregion);
59 } else if (reg->identify() == Ewalddummy.identify()) {
60 EwaldRegion* ewaldregion = dynamic_cast<EwaldRegion*>(reg.get());
61 energies[id] = InteractwithEwaldRegion(*ewaldregion);
62 } else {
63 throw std::runtime_error(
64 "Interaction of regions with types:" + this->identify() + " and " +
65 reg->identify() + " not implemented");
66 }
67 }
68
69 return energies;
70}
71
73 tools::Property& region = prop.add("region", "");
74 region.setAttribute("type", identify());
75 region.setAttribute("id", getId());
76 region.setAttribute("size", size());
77 region.setAttribute("Tot_charge", (boost::format("%1$1.6e") % charge()));
78 AppendResult(region);
79}
80
81} // namespace xtp
82} // 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:325
The periodic Ewald background, as a Region.
Definition ewaldregion.h:76
std::string identify() const override
Definition ewaldregion.h:81
std::string identify() const override
Definition polarregion.h:49
std::string identify() const override
Definition qmregion.h:82
std::vector< double > ApplyInfluenceOfOtherRegions(std::vector< std::unique_ptr< Region > > &regions)
Definition region.cc:33
virtual double charge() const =0
void AddResults(tools::Property &prop) const
Definition region.cc:72
virtual double InteractwithQMRegion(const QMRegion &region)=0
virtual Index size() const =0
Index getId() const
Definition region.h:80
virtual void AppendResult(tools::Property &prop) const =0
virtual double InteractwithStaticRegion(const StaticRegion &region)=0
virtual double InteractwithPolarRegion(const PolarRegion &region)=0
virtual double InteractwithEwaldRegion(const EwaldRegion &region)=0
Logger & log_
Definition region.h:106
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
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26