mcpele  1.0.0
The Monte Carlo Python Energy Landscape Explorer
lowest_eigenvalue.cpp
00001 #include <cmath>
00002 
00003 #include "mcpele/lowest_eigenvalue.h"
00004 
00005 namespace mcpele{
00006 
00007 FindLowestEigenvalue::FindLowestEigenvalue(std::shared_ptr<pele::BasePotential> landscape_potential, const size_t boxdimension,
00008         const pele::Array<double> ranvec, const size_t lbfgsniter)
00009     : m_lowesteigpot(std::make_shared<pele::LowestEigPotential>(landscape_potential, ranvec.copy(), boxdimension)),
00010       m_ranvec((ranvec.copy() /= norm(ranvec))),
00011       m_lbfgs(m_lowesteigpot, m_ranvec.copy())
00012 {
00013     if (isinf(double(1) / norm(ranvec))) {
00014         throw std::runtime_error("FindLowestEigenvalue: 1/norm(ranvec) is isinf");
00015     }
00016     m_lbfgs.set_max_iter(lbfgsniter);
00017 }
00018 
00019 double FindLowestEigenvalue::compute_lowest_eigenvalue(pele::Array<double> coords)
00020 {
00021     m_lowesteigpot->reset_coords(coords);
00022     m_lbfgs.reset(m_ranvec);
00023     m_lbfgs.set_use_relative_f(1);
00024     m_lbfgs.run();
00025     const double lowesteig = m_lbfgs.get_f();
00026     return lowesteig;
00027 }
00028 
00029 }//namespace mcpele
 All Classes Namespaces Functions Variables Typedefs