votca 2026-dev
Loading...
Searching...
No Matches
chargeresponsefit.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 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#pragma once
21#ifndef VOTCA_XTP_CHARGERESPONSEFIT_H
22#define VOTCA_XTP_CHARGERESPONSEFIT_H
23
24// Standard includes
25#include <array>
26#include <string>
27#include <vector>
28
29// Local VOTCA includes
30#include "aobasis.h"
31#include "eigen.h"
32#include "hirshfeldpartition.h"
33#include "vxc_grid.h"
34
35namespace votca {
36namespace tools {
37class Property;
38}
39namespace xtp {
40class Logger;
41class Orbitals;
42
63 public:
64 struct Result {
65 Eigen::MatrixXd pi; // symmetrized, charge conserving
66 double pi_asymmetry = 0.0; // ||Pi - Pi^T|| / ||Pi|| before
67 Eigen::VectorXd pi_eigenvalues;
68 Eigen::Matrix3d alpha; // molecular, a.u.
69 Eigen::Matrix3d alpha_ct; // X^T Pi X
70 Eigen::Matrix3d alpha_res; // alpha - alpha_ct
71 Eigen::VectorXd res_weights; // sum 1
72 std::vector<Eigen::Matrix3d> alpha_res_atoms; // weights * alpha_res
73 std::vector<Eigen::Matrix3d> alpha_atoms; // Hirshfeld, a.u.
74 };
75
76 struct FitOptions {
79 bool analytic = true;
81 double tolerance = 1e-7;
83 double step = 1e-3;
86 bool use_inversion = true;
87 };
88
95 static Result Fit(const tools::Property& dftoptions, Orbitals& orb,
96 const FitOptions& fit, Logger& log);
97
103 struct Inversion {
104 std::vector<Index> atom_map;
105 Eigen::MatrixXd T;
106 };
107 static Inversion FindInversion(const QMMolecule& mol, const AOBasis& basis,
108 double tol = 1e-4);
109
113 static std::vector<Eigen::MatrixXd> WeightMatrices(
114 const std::vector<HirshfeldPartition::AtomicReference>& atoms,
115 const AOBasis& basis, const Vxc_Grid& grid);
116
119 static std::vector<Eigen::Matrix3d> AtomicPolarizabilities(
120 const std::vector<HirshfeldPartition::AtomicReference>& atoms,
121 const std::vector<Eigen::Vector3d>& positions, const AOBasis& basis,
122 const Vxc_Grid& grid, const std::array<Eigen::MatrixXd, 3>& dP_field);
123
128 static Result Analyse(const std::vector<Eigen::Vector3d>& positions,
129 const std::vector<Eigen::MatrixXd>& W,
130 const std::vector<Eigen::MatrixXd>& dP_potential,
131 const std::array<Eigen::MatrixXd, 3>& dipole,
132 const std::array<Eigen::MatrixXd, 3>& dP_field,
133 const std::vector<Eigen::Matrix3d>& alpha_atoms);
134};
135
136} // namespace xtp
137} // namespace votca
138
139#endif // VOTCA_XTP_CHARGERESPONSEFIT_H
class to manage program options with xml serialization functionality
Definition property.h:55
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
Parametrization of a charge-response molecule (see ChargeResponse) from the static density response o...
static Inversion FindInversion(const QMMolecule &mol, const AOBasis &basis, double tol=1e-4)
static std::vector< Eigen::Matrix3d > AtomicPolarizabilities(const std::vector< HirshfeldPartition::AtomicReference > &atoms, const std::vector< Eigen::Vector3d > &positions, const AOBasis &basis, const Vxc_Grid &grid, const std::array< Eigen::MatrixXd, 3 > &dP_field)
static Result Analyse(const std::vector< Eigen::Vector3d > &positions, const std::vector< Eigen::MatrixXd > &W, const std::vector< Eigen::MatrixXd > &dP_potential, const std::array< Eigen::MatrixXd, 3 > &dipole, const std::array< Eigen::MatrixXd, 3 > &dP_field, const std::vector< Eigen::Matrix3d > &alpha_atoms)
static std::vector< Eigen::MatrixXd > WeightMatrices(const std::vector< HirshfeldPartition::AtomicReference > &atoms, const AOBasis &basis, const Vxc_Grid &grid)
static Result Fit(const tools::Property &dftoptions, Orbitals &orb, const FitOptions &fit, Logger &log)
Logger is used for thread-safe output of messages.
Definition logger.h:164
Container for molecular orbitals and derived one-particle data.
Definition orbitals.h:47
Provides a means for comparing floating point numbers.
Definition basebead.h:33
double step
finite differences: strength of each perturbation
std::vector< Eigen::Matrix3d > alpha_res_atoms
std::vector< Eigen::Matrix3d > alpha_atoms