36#ifndef MADNESS_CHEM_MOLECULAR_OPTIMIZER_H__INCLUDED
37#define MADNESS_CHEM_MOLECULAR_OPTIMIZER_H__INCLUDED
69 (
"remove_dof", {
"tx",
"ty",
"tz",
"rx",
"ry",
"rz"},
"degree of freedom projected out: translation/rotation");
103 std::shared_ptr<MolecularOptimizationTargetInterface>
target;
113 const std::shared_ptr<MolecularOptimizationTargetInterface>&
tar)
157 for (
size_t i=0; i<
target->molecule().natom(); ++i) {
158 h(3*i ,3*i )=1.0/(
target->molecule().get_atom(i).mass);
159 h(3*i+1,3*i+1)=1.0/(
target->molecule().get_atom(i).mass);
160 h(3*i+2,3*i+2)=1.0/(
target->molecule().get_atom(i).mass);
168 madness::print(
"\ngopt: projected vibrational frequencies (cm-1)\n");
169 printf(
"frequency in cm-1 ");
170 for (
int i=0; i<
freq.size(); ++i) {
186 target->value_and_gradient(x,
f, gradient);
217 madness::print(
"\ngopt: projected vibrational frequencies (cm-1)\n");
218 printf(
"frequency in cm-1 ");
219 for (
int i=0; i<
freq.size(); ++i) {
239 printf(
" QuasiNewton iteration %2d energy: %16.8f gradient %.2e displacement %.2e \n", iter,
f,
gnorm,
disp2);
244 print(
"final hessian");
322 for (
int i=0; i<
e.size(); ++i) {
325 " forcing negative eigenvalue to be positive %d %.1e\n", i,
e[i]);
330 else if (
e[i] < tol) {
332 " forcing small eigenvalue to be zero %d %.1e\n", i,
e[i]);
339 gv[i] = -
gv[i] /
e[i];
343 " restricting step in spectral direction %d %.1e --> %.1e\n",
367 const std::vector<std::string>& remove_dof) {
373 for (
size_t i=0; i<mol.
natom(); ++i) {
404 for (
size_t iatom=0; iatom<mol.
natom(); ++iatom) {
420 rotx(3*iatom + 0)=
p(1)*
v(0,2)-
p(2)*
v(0,1);
421 rotx(3*iatom + 1)=
p(1)*
v(1,2)-
p(2)*
v(1,1);
422 rotx(3*iatom + 2)=
p(1)*
v(2,2)-
p(2)*
v(2,1);
424 roty(3*iatom + 0)=
p(2)*
v(0,0)-
p(0l)*
v(0,2);
425 roty(3*iatom + 1)=
p(2)*
v(1,0)-
p(0l)*
v(1,2);
426 roty(3*iatom + 2)=
p(2)*
v(2,0)-
p(0l)*
v(2,2);
428 rotz(3*iatom + 0)=
p(0l)*
v(0,1)-
p(1)*
v(0,0);
429 rotz(3*iatom + 1)=
p(0l)*
v(1,1)-
p(1)*
v(1,0);
430 rotz(3*iatom + 2)=
p(0l)*
v(2,1)-
p(1)*
v(2,0);
454 for (
int i=0; i<6; ++i) {
466 for (
int i=0; i<6; ++i) {
490 const std::vector<std::string>& remove_dof) {
509 const std::vector<std::string>& remove_dof={},
const bool print_hessian=
false) {
514 for (
size_t i=0; i<3*
molecule.natom(); ++i)
Minv(i,i)=1.0/
M(i,i);
523 if (remove_dof.size()>0) {
524 print(
"mass-weighted hessian with translation and rotation projected out");
526 print(
"mass-weighted unprojected hessian");
530 print(
"mass-weighted unprojected hessian; mass-weighing undone");
536 for (
long i=0; i<
freq.size(); ++i) {
554 for (
size_t i=0; i<3*
molecule.natom(); ++i) {
double y
Definition molecule.h:60
double x
Definition molecule.h:60
double z
Definition molecule.h:60
double get_mass_in_au() const
return the mass in atomic units (electron mass = 1 a.u.)
Definition molecule.h:104
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
Definition molecular_optimizer.h:56
std::vector< std::string > remove_dof() const
Definition molecular_optimizer.h:89
MolecularOptimizationParameters(World &world, const commandlineparser &parser)
Definition molecular_optimizer.h:72
MolecularOptimizationParameters()
ctor reading out the input file
Definition molecular_optimizer.h:60
bool printtest() const
Definition molecular_optimizer.h:88
double tol() const
Definition molecular_optimizer.h:85
std::string cg_method() const
Definition molecular_optimizer.h:83
double gradient_precision() const
Definition molecular_optimizer.h:87
double value_precision() const
Definition molecular_optimizer.h:86
std::string update() const
Definition molecular_optimizer.h:82
void set_derived_values()
Definition molecular_optimizer.h:79
int maxiter() const
Definition molecular_optimizer.h:84
Molecular optimizer derived from the QuasiNewton optimizer.
Definition molecular_optimizer.h:100
void set_hessian(const Tensor< double > &hess)
set an (initial) hessian
Definition molecular_optimizer.h:140
bool optimize_quasi_newton(Tensor< double > &x)
Definition molecular_optimizer.h:147
bool optimize(Tensor< double > &x)
optimize the underlying molecule
Definition molecular_optimizer.h:120
Tensor< double > h
Definition molecular_optimizer.h:104
double gradient_norm() const
Definition molecular_optimizer.h:137
MolecularOptimizationParameters parameters
Definition molecular_optimizer.h:109
static Tensor< double > compute_frequencies(const Molecule &molecule, const Tensor< double > &hessian, Tensor< double > &normalmodes, const std::vector< std::string > &remove_dof={}, const bool print_hessian=false)
returns the vibrational frequencies
Definition molecular_optimizer.h:507
bool converged() const
Definition molecular_optimizer.h:127
bool converged(const Tensor< double > &displacement) const
Definition molecular_optimizer.h:131
static Tensor< double > projector_external_dof(const Molecule &mol, const std::vector< std::string > &remove_dof)
compute the projector to remove transl. and rot. degrees of freedom
Definition molecular_optimizer.h:366
static Tensor< double > compute_reduced_mass(const Molecule &molecule, const Tensor< double > &normalmodes)
Definition molecular_optimizer.h:544
double f
Definition molecular_optimizer.h:105
bool optimize_conjugate_gradients(Tensor< double > &x)
Definition molecular_optimizer.h:250
MolecularOptimizer(World &world, const commandlineparser &parser, const std::shared_ptr< MolecularOptimizationTargetInterface > &tar)
same ctor as the QuasiNewton optimizer
Definition molecular_optimizer.h:112
std::shared_ptr< MolecularOptimizationTargetInterface > target
How to update the hessian: BFGS or SR1.
Definition molecular_optimizer.h:103
Tensor< double > new_search_direction2(const Tensor< double > &g, const Tensor< double > &hessian) const
effectively invert the hessian and multiply with the gradient
Definition molecular_optimizer.h:304
static void remove_external_dof(Tensor< double > &hessian, const Molecule &mol, const std::vector< std::string > &remove_dof)
remove translational degrees of freedom from the hessian
Definition molecular_optimizer.h:489
double gnorm
Definition molecular_optimizer.h:106
double value() const
Definition molecular_optimizer.h:135
Definition molecule.h:124
void translate(const Tensor< double > &translation)
translate the molecule
Definition molecule.cc:670
const Atom & get_atom(unsigned int i) const
Definition molecule.cc:447
Tensor< double > center_of_mass() const
compute the center of mass
Definition molecule.cc:839
size_t natom() const
Definition molecule.h:389
class for holding the parameters for calculation
Definition QCCalculationParametersBase.h:290
virtual void read_input_and_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
Definition QCCalculationParametersBase.h:325
static double line_search(double a1, double f0, double dxgrad, const Tensor< double > &x, const Tensor< double > &dx, std::shared_ptr< OptimizationTargetInterface > target, double value_precision)
make this static for other QN classed to have access to it
Definition solvers.cc:113
static void hessian_update_bfgs(const Tensor< double > &dx, const Tensor< double > &dg, Tensor< double > &hessian)
make this static for other QN classed to have access to it
Definition solvers.cc:179
static void hessian_update_sr1(const Tensor< double > &s, const Tensor< double > &y, Tensor< double > &hessian)
make this static for other QN classed to have access to it
Definition solvers.cc:166
A tensor is a multidimensional array.
Definition tensor.h:317
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1726
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type scale(Q x)
Inplace multiplication by scalar of supported type (legacy name)
Definition tensor.h:686
A parallel world class.
Definition world.h:132
double(* energy)()
Definition derivatives.cc:58
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
const double beta
Definition gygi_soltion.cc:62
static const double v
Definition hatom_sf_dirac.cc:20
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
constexpr double au2invcm
conversion from atomic units in reciprocal centimeter
Definition constants.h:273
constexpr double atomic_mass_in_au
Atomic mass in atomic units.
Definition constants.h:270
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
response_space transpose(response_space &f)
Definition basic_operators.cc:10
Key< NDIM > displacement(const Key< NDIM > &source, const Key< NDIM > &target)
given a source and a target, return the displacement in translation
Definition key.h:451
static const Slice _(0,-1, 1)
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
NDIM const Function< R, NDIM > & g
Definition mra.h:2481
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2066
void syev(const Tensor< T > &A, Tensor< T > &V, Tensor< typename Tensor< T >::scalar_type > &e)
Real-symmetric or complex-Hermitian eigenproblem.
Definition lapack.cc:969
static long abs(long a)
Definition tensor.h:218
const double mu
Definition navstokes_cosines.cc:95
static const double L
Definition rk.cc:46
Defines interfaces for optimization and non-linear equation solvers.
Definition test_ar.cc:204
Definition molecular_optimizer.h:46
virtual Molecule & molecule()
return the molecule of the target
Definition molecular_optimizer.h:49
The interface to be provided by functions to be optimized.
Definition solvers.h:176
The interface to be provided by optimizers.
Definition solvers.h:206
very simple command line parser
Definition commandlineparser.h:15
static std::string tolower(std::string s)
make lower case
Definition commandlineparser.h:85
static const double_complex I
Definition tdse1d.cc:164
void converge(World &world, functionT &potn, functionT &psi, double &eps)
Definition tdse.cc:441
double norm(const T i1)
Definition test_cloud.cc:72
void e()
Definition test_sig.cc:75
static Molecule molecule
Definition testperiodicdft.cc:39