Loading...
Searching...
No Matches
MeasuredCurvatureMetric.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4#pragma once
5
8
9namespace gpr::optim {
10
17 const gpr::Coord& positions, const gpr::AtomsConfiguration& configuration,
18 const Eigen::MatrixXd& basis, const Eigen::MatrixXd& actions)
19{
20 const Eigen::Index dimension = positions.cols();
21 if (basis.rows() != dimension || basis.cols() == 0 ||
22 actions.rows() != dimension || actions.cols() != basis.cols() ||
23 !basis.allFinite() || !actions.allFinite())
24 return std::numeric_limits<double>::infinity();
25 Eigen::MatrixXd cartesian_directions =
26 massWeightedPhysicalCurvatureBasis(positions, configuration);
27 const Eigen::Index physical_dimension = cartesian_directions.cols();
28 if (physical_dimension == 0) return std::numeric_limits<double>::infinity();
29 const Eigen::VectorXd masses =
30 movingAtomicMasses(configuration, dimension / 3);
31 for (Eigen::Index atom = 0; atom < masses.size(); ++atom)
32 cartesian_directions.middleRows(3 * atom, 3) /= std::sqrt(masses(atom));
33 const Eigen::MatrixXd coefficients =
34 basis.transpose() * cartesian_directions;
35 const Eigen::MatrixXd projected =
36 coefficients.transpose() * (basis.transpose() * actions) * coefficients;
37 return analyzeMeasuredCurvature(Eigen::MatrixXd::Identity(
38 physical_dimension, physical_dimension),
39 projected)
41}
42
43} // namespace gpr::optim
Eigen::MatrixXd massWeightedPhysicalCurvatureBasis(const gpr::Coord &positions, const gpr::AtomsConfiguration &config, bool exclude_rotations=true)
MeasuredCurvatureSpectrum analyzeMeasuredCurvature(const Eigen::MatrixXd &basis, const Eigen::MatrixXd &action)
Eigen::VectorXd movingAtomicMasses(const gpr::AtomsConfiguration &config, Eigen::Index n_moving)
double massWeightedMeasuredCurvatureResolution(const gpr::Coord &positions, const gpr::AtomsConfiguration &configuration, const Eigen::MatrixXd &basis, const Eigen::MatrixXd &actions)
FieldMatrixd Coord
Definition Macros.h:35
Stores configurations of all atoms in the system.
Definition Structures.h:832