ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ions_move_methods.h
Go to the documentation of this file.
1#ifndef IONS_MOVE_METHODS_H
2#define IONS_MOVE_METHODS_H
3
4#include "ions_move_basic.h"
5#include "ions_move_bfgs.h"
6#include "ions_move_bfgs2.h"
7#include "ions_move_cg.h"
8#include "ions_move_lbfgs.h"
9#include "ions_move_sd.h"
10#include "relax_criteria.h"
11
12#include <fstream>
13#include <iostream>
14#include <vector>
15
17{
18 public:
21
22 void allocate(const int &natom, const std::string &relax_method);
23 void cal_movement(
24 const int &istep,
25 const int &force_step,
26 const ModuleBase::matrix &f,
27 const double &etot,
28 UnitCell &ucell,
29 std::ofstream &ofs,
30 std::string &relax_method,
31 const Relax_Criteria &criteria);
32 void reset_after_cell_change(const std::string &relax_method, std::ofstream &ofs);
33
34 bool get_converged() const { return converged_; }
35
36 double get_ediff() const { return etot_info_[0] - etot_info_[1]; }
37 double get_largest_grad() const { return Ions_Move_Basic::largest_grad; }
39 int get_update_iter() const { return update_iter_; }
40
41 //====================================================================
42 // Test seam.
43 //
44 // reset_after_cell_change() is expected to clear the per-run state of
45 // whichever method is active, so the test seeds that state through the
46 // sub-optimiser it belongs to and checks it was cleared. get_converged()
47 // and get_update_iter() above already cover the reads.
48 //
49 // Production code must keep using the private names directly.
50 //====================================================================
51
52 void set_converged(const bool value) { converged_ = value; }
53 void set_update_iter(const int value) { update_iter_ = value; }
55 std::vector<double> &get_etot_info() { return etot_info_; }
60
61 private:
67 bool converged_ = false;
68 int update_iter_ = 0;
69 std::vector<double> etot_info_{0.0, 0.0}; // [etot, etot_p]
70};
71#endif
Definition ions_move_bfgs2.h:17
Definition ions_move_bfgs.h:13
Definition ions_move_cg.h:14
Implements L-BFGS optimization algorithm for structural relaxation.
Definition ions_move_lbfgs.h:22
std::vector< double > etot_info_
Definition ions_move_methods.h:69
bool get_converged() const
Definition ions_move_methods.h:34
bool converged_
Definition ions_move_methods.h:67
Ions_Move_BFGS bfgs
Definition ions_move_methods.h:62
Ions_Move_BFGS & get_bfgs()
the BFGS optimiser used by relax_method "bfgs"
Definition ions_move_methods.h:57
int get_update_iter() const
Definition ions_move_methods.h:39
std::vector< double > & get_etot_info()
{etot, etot_p} of the current and previous step
Definition ions_move_methods.h:55
double get_largest_grad() const
Definition ions_move_methods.h:37
int update_iter_
Definition ions_move_methods.h:68
void cal_movement(const int &istep, const int &force_step, const ModuleBase::matrix &f, const double &etot, UnitCell &ucell, std::ofstream &ofs, std::string &relax_method, const Relax_Criteria &criteria)
Definition ions_move_methods.cpp:54
Ions_Move_LBFGS lbfgs
Definition ions_move_methods.h:66
double get_trust_radius() const
Definition ions_move_methods.h:38
Ions_Move_SD sd
Definition ions_move_methods.h:64
void set_converged(const bool value)
Definition ions_move_methods.h:52
Ions_Move_BFGS2 bfgs_trad
Definition ions_move_methods.h:65
~Ions_Move_Methods()
Definition ions_move_methods.cpp:11
Ions_Move_CG cg
Definition ions_move_methods.h:63
void set_update_iter(const int value)
Definition ions_move_methods.h:53
Ions_Move_Methods()
Definition ions_move_methods.cpp:10
double get_ediff() const
Definition ions_move_methods.h:36
Ions_Move_BFGS2 & get_bfgs_trad()
the traditional BFGS optimiser used by relax_method "bfgs_trad"
Definition ions_move_methods.h:59
void reset_after_cell_change(const std::string &relax_method, std::ofstream &ofs)
Definition ions_move_methods.cpp:97
void allocate(const int &natom, const std::string &relax_method)
Definition ions_move_methods.cpp:13
Definition ions_move_sd.h:29
Definition matrix.h:15
Provide the basic information about unitcell.
Definition unitcell.h:16
double trust_radius
Current trust radius.
Definition ions_move_basic.cpp:11
INPUT-derived settings that the relaxation algorithms need.
Definition relax_criteria.h:19