42 std::string mode = options.
get(
"mode").
as<std::string>();
45 Eigen::VectorXd target_vec =
46 options.
get(
".target_polarisability").
as<Eigen::VectorXd>();
47 if (target_vec.size() != 6) {
48 throw std::runtime_error(
49 "ERROR <options.molpol.target> "
50 " should have this format: pxx pxy pxz pyy pyz pzz");
63 std::string qm_package = options.
get(
".qmpackage").
as<std::string>();
64 std::string log_file = options.
get(
".logfile").
as<std::string>();
71 log.setMultithreading(
true);
75 <<
"Using package <" << qm_package <<
">" << std::flush;
77 std::unique_ptr<QMPackage> qmpack =
80 qmpack->setRunDir(
".");
81 qmpack->setLogFileName(log_file);
85 Eigen::VectorXd default_weights = Eigen::VectorXd::Ones(
input_.
size());
87 ".weights", default_weights);
94 const PolarSegment& input,
const Eigen::Vector3d& ext_field)
const {
107 site.V() = ext_field;
109 std::vector<std::unique_ptr<Region>> empty;
111 Eigen::Vector3d induced_dipole = Eigen::Vector3d::Zero();
113 induced_dipole += site.Induced_Dipole();
118 return induced_dipole;
124 double fieldstrength = (0.1 * eVnm_2_hrtbohr);
125 Eigen::Matrix3d polarization = Eigen::Matrix3d::Zero();
126 Eigen::Vector3d ext_field = fieldstrength * Eigen::Vector3d::UnitX();
130 polarization.col(0) = dxplus - dxminus;
131 ext_field = fieldstrength * Eigen::Vector3d::UnitY();
134 polarization.col(1) = dyplus - dyminus;
135 ext_field = fieldstrength * Eigen::Vector3d::UnitZ();
138 polarization.col(2) = dzplus - dzminus;
140 return -polarization / (2 * fieldstrength);
144 std::cout << std::endl <<
"First principle polarization [A^3]" << std::flush;
147 std::cout << std::endl <<
"Scaled classical polarization [A^3]" << std::flush;
148 std::cout << std::endl << result * conversion << std::flush;
149 std::cout << std::endl
150 <<
"EigenValues classical polarization [A^3]" << std::flush;
151 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es2;
152 es2.computeDirect(result, Eigen::EigenvaluesOnly);
153 Eigen::Matrix3d diag = es2.eigenvalues().asDiagonal();
154 std::cout << std::endl << diag * conversion << std::flush;
160 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es;
162 const double pol_volume_target = std::pow(es.eigenvalues().prod(), 1.0 / 3.0);
165 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> es2;
167 es2.computeDirect(pol, Eigen::EigenvaluesOnly);
168 const double pol_volume_iter =
169 std::pow(es2.eigenvalues().prod(), 1.0 / 3.0);
170 double scale = pol_volume_target / pol_volume_iter - 1;
171 std::cout <<
"\nIteration " << iter + 1 <<
" of " <<
max_iter_
172 <<
" target:" << pol_volume_target
173 <<
" current:" << pol_volume_iter << std::endl;
175 for (
Index i = 0; i < polar.
size(); i++) {
176 Eigen::Matrix3d local_pol = polar[i].getpolarization();
177 polar[i].setpolarization(local_pol * (1 + scale *
weights_[i]));
181 std::cout << std::endl
182 <<
"... ... Iterative refinement : *CONVERGED*" << std::flush;
183 std::cout << std::endl
184 <<
"... ... Scaling coefficient : " << scale << std::flush;
189 std::cout << std::endl
190 <<
"... ... Iterative refinement : *FAILED*" << std::flush;
191 std::cout << std::endl
192 <<
"... ... ERROR Convergence not achieved. "
193 <<
"Check your input mps-file, target polarizability <target> "
void LoadFromFile(std::string filename)
void WriteMPS(std::string filename, std::string header) const
Logger is used for thread-safe output of messages.
void setPreface(Log::Level level, const std::string &preface)
void setReportLevel(Log::Level ReportLevel)
void setMultithreading(bool maverick)
void setCommonPreface(const std::string &preface)
void push_back(const T &seg)
void Printpolarization(const Eigen::Matrix3d &result) const
tools::Property polar_options_
void ParseOptions(const tools::Property &user_options)
Eigen::Matrix3d CalcClassicalPol(const PolarSegment &input) const
Eigen::Vector3d CalcInducedDipole(const PolarSegment &input, const Eigen::Vector3d &ext_field) const
Eigen::Matrix3d polarization_target_
void Initialize(const tools::Property &prop) override
void Evaluate(std::vector< std::unique_ptr< Region > > ®ions) override
Class to represent Atom/Site in electrostatic+polarization.
#define XTP_LOG(level, log)
base class for all analysis tools
static Level current_level