GQCP
Loading...
Searching...
No Matches
CCDSolver.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
31
32
33namespace GQCP {
34
35
41template <typename _Scalar>
42class CCDSolver {
43public:
44 using Scalar = _Scalar;
45
46
47public:
48 /*
49 * MARK: Factory methods
50 */
51
60 static IterativeAlgorithm<CCSDEnvironment<Scalar>> Plain(const double threshold = 1.0e-08, const size_t maximum_number_of_iterations = 128) {
61
62 // Create the iteration cycle that effectively 'defines' a plain CCD solver.
64 plain_ccd_cycle
68
69
70 // Create a convergence criterion on the norm of subsequent T2-amplitudes, which is facilitated by the .norm() API of the T2-amplitudes.
72 const auto t2_extractor = [](const CCSDEnvironment<Scalar>& environment) { return environment.t2_amplitudes; };
73 const T2ConvergenceType t2_convergence_criterion {threshold, t2_extractor, "the T2 amplitudes"};
74
75 // Put together the pieces of the algorithm.
76 return IterativeAlgorithm<CCSDEnvironment<Scalar>>(plain_ccd_cycle, t2_convergence_criterion, maximum_number_of_iterations);
77 }
78
79
90 static IterativeAlgorithm<CCSDEnvironment<Scalar>> DIIS(const size_t minimum_subspace_dimension = 6, const size_t maximum_subspace_dimension = 6, const double threshold = 1.0e-08, const size_t maximum_number_of_iterations = 128) {
91
92 // Create the iteration cycle that effectively 'defines' a DIIS CCD solver.
94 diis_ccd_cycle
98 .add(T2DIIS<Scalar>(minimum_subspace_dimension, maximum_subspace_dimension))
100
101 // Create a convergence criterion on the norm of subsequent T2-amplitudes, which is facilitated by the .norm() API of the T2-amplitudes.
103 const auto t2_extractor = [](const CCSDEnvironment<Scalar>& environment) { return environment.t2_amplitudes; };
104 const T2ConvergenceType t2_convergence_criterion {threshold, t2_extractor, "the T2 amplitudes"};
105
106 // Put together the pieces of the algorithm.
107 return IterativeAlgorithm<CCSDEnvironment<Scalar>>(diis_ccd_cycle, t2_convergence_criterion, maximum_number_of_iterations);
108 }
109};
110
111
112} // namespace GQCP
Definition: CCDAmplitudesUpdate.hpp:35
Definition: CCDEnergyCalculation.hpp:35
Definition: CCDIntermediatesUpdate.hpp:35
Definition: CCDSolver.hpp:42
_Scalar Scalar
Definition: CCDSolver.hpp:44
static IterativeAlgorithm< CCSDEnvironment< Scalar > > DIIS(const size_t minimum_subspace_dimension=6, const size_t maximum_subspace_dimension=6, const double threshold=1.0e-08, const size_t maximum_number_of_iterations=128)
Definition: CCDSolver.hpp:90
static IterativeAlgorithm< CCSDEnvironment< Scalar > > Plain(const double threshold=1.0e-08, const size_t maximum_number_of_iterations=128)
Definition: CCDSolver.hpp:60
Definition: CCSDEnvironment.hpp:39
std::deque< T2Amplitudes< Scalar > > t2_amplitudes
Definition: CCSDEnvironment.hpp:49
Definition: ConsecutiveIteratesNormConvergence.hpp:40
Definition: IterativeAlgorithm.hpp:38
Definition: StepCollection.hpp:41
enable_if_t< std::is_same< Environment, typename Z::Environment >::value, StepCollection< Environment > & > add(const Z &step)
Definition: StepCollection.hpp:92
Definition: T2DIIS.hpp:40
Definition: T2ErrorCalculation.hpp:35
Definition: BaseOneElectronIntegralBuffer.hpp:25