46 double Echange =
E_hist_.getDiff().Etotal();
47 std::string info =
"not converged";
48 bool converged =
false;
49 if (std::abs(Echange) <
deltaE_) {
55 <<
" is " << info <<
" deltaE=" << Echange << std::flush;
63#pragma omp parallel for reduction(+ : e)
80#pragma omp declare reduction(CustomPlus : eeInteractor::E_terms : omp_out += \
87#pragma omp parallel for reduction(CustomPlus : terms)
89 for (
Index j = 0; j < i; ++j) {
94#pragma omp parallel for reduction(CustomPlus : terms)
100#pragma omp parallel for reduction(CustomPlus : terms)
111#pragma omp parallel for reduction(+ : e)
114 e += site.deltaQ_V_ext();
136 Index dof_polarization = 0;
138 dof_polarization += seg.size() * 3;
140 return dof_polarization;
145 Eigen::VectorXd initial_induced_dipoles =
146 Eigen::VectorXd::Zero(dof_polarization);
150 initial_induced_dipoles.segment(index, 3 * seg.size()) =
152 index += 3 * seg.size();
154 return initial_induced_dipoles;
159 Eigen::VectorXd last_induced_dipoles =
160 Eigen::VectorXd::Zero(dof_polarization);
164 last_induced_dipoles.segment<3>(index) = site.Induced_Dipole();
168 return last_induced_dipoles;
175 site.setInduced_Dipole(x.segment<3>(index));
182 const Eigen::VectorXd& initial_guess) {
183 Eigen::VectorXd b = Eigen::VectorXd::Zero(initial_guess.size());
187 auto V = site.V() + site.V_noE();
188 b.segment<3>(index) = -
V;
195 Eigen::DiagonalPreconditioner<double>>
200 Eigen::VectorXd x = cg.solveWithGuess(b, initial_guess);
203 <<
TimeStamp() <<
" CG: #iterations: " << cg.iterations()
204 <<
", estimated error: " << cg.error() << std::flush;
206 if (cg.info() == Eigen::ComputationInfo::NoConvergence) {
208 errormsg_ =
"PCG iterations did not converge";
211 if (cg.info() == Eigen::ComputationInfo::NumericalIssue) {
223 std::accumulate(energies.begin(), energies.end(), 0.0);
225 <<
" Calculated static-static and polar-static "
226 "interaction with other regions"
230 <<
" Calculated static interaction in region "
234 <<
TimeStamp() <<
" Starting Solving for classical polarization with "
235 << dof_polarization <<
" degrees of freedom." << std::flush;
237 Eigen::VectorXd initial_induced_dipoles;
252 x = initial_induced_dipoles;
259 <<
" Calculated polar interaction in region"
263 <<
" Calculated polar interaction with other regions"
267 <<
" Internal static energy [hrt]= "
270 <<
" External static energy [hrt]= "
273 << std::setprecision(10)
274 <<
" Total static energy [hrt]= " << e_contrib.
Estatic() << std::flush;
277 <<
" internal dQ-dQ energy [hrt]= "
281 <<
" internal Q-dQ energy [hrt]= "
285 <<
" Internal energy [hrt]= "
289 <<
" External polar energy [hrt]= "
293 << std::setprecision(10)
294 <<
" Total polar energy [hrt]= " << e_contrib.
Epolar() << std::flush;
297 << std::setprecision(10) <<
" Total energy [hrt]= " << e_contrib.
Etotal()
315#pragma omp parallel for reduction(+ : e)
318 double e_thread = 0.0;
338#pragma omp parallel for reduction(+ : e)
340 double e_thread = 0.0;
void addInternalPolarContrib(const eeInteractor::E_terms &induction_terms)
double & E_static_static()
Index size() const override
std::vector< PolarSegment > segments_
void WriteToCpt(CheckpointWriter &w) const override
void ReadFromCpt(CheckpointReader &r) override
Eigen::VectorXd CalcInducedDipoleInsideSegments() const
void AppendResult(tools::Property &prop) const override
void WriteInducedDipolesToSegments(const Eigen::VectorXd &x)
void ReadFromCpt(CheckpointReader &r) override
double InteractwithQMRegion(const QMRegion ®ion) override
void Initialize(const tools::Property &prop) override
bool Converged() const override
eeInteractor::E_terms PolarEnergy() const
Eigen::VectorXd CalcInducedDipolesViaPCG(const Eigen::VectorXd &initial_guess)
Eigen::VectorXd ReadInducedDipolesFromLastIteration() const
std::string identify() const override
double StaticInteraction()
hist< Energy_terms > E_hist_
void WriteToCpt(CheckpointWriter &w) const override
double InteractwithPolarRegion(const PolarRegion ®ion) override
void Evaluate(std::vector< std::unique_ptr< Region > > ®ions) override
double InteractwithStaticRegion(const StaticRegion ®ion) override
double PolarEnergy_extern() const
Class to represent Atom/Site in electrostatic+polarization.
void ApplyQMFieldToPolarSegments(std::vector< PolarSegment > &segments) const
std::vector< double > ApplyInfluenceOfOtherRegions(std::vector< std::unique_ptr< Region > > ®ions)
Timestamp returns the current time as a string Example: cout << TimeStamp()
Mediates interaction between polar and static sites.
double ApplyStaticField(const T &segment1, PolarSegment &segment2) const
double ApplyInducedField(const PolarSegment &segment1, PolarSegment &segment2) const
E_terms CalcPolarEnergy(const S1 &segment1, const S2 &segment2) const
Eigen::VectorXd Cholesky_IntraSegment(const PolarSegment &seg) const
double CalcPolarEnergy_IntraSegment(const PolarSegment &seg) const
#define XTP_LOG(level, log)
ClassicalSegment< PolarSite > PolarSegment
ClassicalSegment< StaticSite > StaticSegment
base class for all analysis tools