ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
vdw.h
Go to the documentation of this file.
1#ifndef VDW_H
2#define VDW_H
3
4#include <memory>
5#include <vector>
7#include "vdw_parameters.h"
8#include "vdwd2_parameters.h"
9#include "vdwd3_parameters.h"
10
11namespace vdw
12{
13
14 template<typename T, typename... Args>
15 std::unique_ptr<T> make_unique(Args &&... args) {
16 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
17
18}
19
20class Vdw
21{
22 public:
23 Vdw(const UnitCell &unit_in) : ucell_(unit_in) {};
24
25 virtual ~Vdw() = default;
26
27 inline double get_energy(bool cal=true) {
28 if (cal) { cal_energy(); }
29 return energy_;
30 }
31 inline const std::vector<ModuleBase::Vector3<double>> &get_force(bool cal=true) {
32 if (cal) { cal_force(); }
33 return force_;
34 }
35 inline const ModuleBase::Matrix3 &get_stress(bool cal=true) {
36 if (cal) { cal_stress(); }
37 return stress_;
38 }
39
40 protected:
42
43 double energy_ = 0;
44 std::vector<ModuleBase::Vector3<double>> force_;
46
47 virtual void cal_energy() = 0;
48 virtual void cal_force() = 0;
49 virtual void cal_stress() = 0;
50};
51
60std::unique_ptr<Vdw> make_vdw(const UnitCell &ucell,
61 const Input_para &input,
62 std::ofstream* plog = nullptr);
63
64} // namespace vdw
65
66#endif // VDW_H
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
Definition unitcell.h:16
Definition vdw.h:21
double get_energy(bool cal=true)
Definition vdw.h:27
virtual void cal_energy()=0
const UnitCell & ucell_
Definition vdw.h:41
const ModuleBase::Matrix3 & get_stress(bool cal=true)
Definition vdw.h:35
const std::vector< ModuleBase::Vector3< double > > & get_force(bool cal=true)
Definition vdw.h:31
virtual ~Vdw()=default
ModuleBase::Matrix3 stress_
Definition vdw.h:45
double energy_
Definition vdw.h:43
virtual void cal_force()=0
Vdw(const UnitCell &unit_in)
Definition vdw.h:23
std::vector< ModuleBase::Vector3< double > > force_
Definition vdw.h:44
virtual void cal_stress()=0
#define T
Definition exp.cpp:237
Definition vdw.cpp:41
std::unique_ptr< Vdw > make_vdw(const UnitCell &ucell, const Input_para &input, std::ofstream *plog)
make vdw correction object
Definition vdw.cpp:43
std::unique_ptr< T > make_unique(Args &&... args)
Definition vdw.h:15
Definition input_parameter.h:12