forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathtest_xc6.cpp
More file actions
84 lines (73 loc) · 2.78 KB
/
Copy pathtest_xc6.cpp
File metadata and controls
84 lines (73 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "../xc_functional.h"
#include "../libxc_abacus.h"
#include "gtest/gtest.h"
#include "xctest.h"
#include "../exx_info.h"
#include <cmath>
#include <iostream>
#include <iomanip>
namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
void TITLE(const std::string &class_function_name,bool disable){};
void TITLE(const std::string &class_name,const std::string &function_name,bool disable){};
}
namespace GlobalV
{
std::string BASIS_TYPE = "";
bool CAL_STRESS = false;
int CAL_FORCE = 0;
int NSPIN = 1;
}
namespace GlobalC
{
Exx_Info exx_info;
}
class XCTest_SCANL_Laplacian : public XCTest
{
protected:
double e_base, v1_base, v2_base, v3_base;
double e_modified, v1_modified, v2_modified, v3_modified;
double e_scaled, v1_scaled, v2_scaled, v3_scaled;
void SetUp()
{
XC_Functional::set_xc_type("MGGA_X_SCANL+MGGA_C_SCANL");
const double rho = 0.17E+01;
const double grho = 0.81E-11;
const double tau = 0.02403590412;
const double lapl_base = 0.15E+01;
double hybrid_alpha = 0.0;
XC_Functional_Libxc::tau_xc(
XC_Functional::get_func_id(),
rho, grho, lapl_base, tau,
e_base, v1_base, v2_base, v3_base, hybrid_alpha
);
XC_Functional_Libxc::tau_xc(
XC_Functional::get_func_id(),
rho, grho, lapl_base + 1.0, tau,
e_modified, v1_modified, v2_modified, v3_modified, hybrid_alpha
);
XC_Functional_Libxc::tau_xc(
XC_Functional::get_func_id(),
rho, grho, 2.0 * lapl_base, tau,
e_scaled, v1_scaled, v2_scaled, v3_scaled, hybrid_alpha
);
}
};
TEST_F(XCTest_SCANL_Laplacian, laplacian_affects_energy)
{
EXPECT_NE(e_base, e_modified);
EXPECT_NE(e_base, e_scaled);
std::cout << std::scientific << std::setprecision(15);
std::cout << "\n=== SCAN Laplacian Sensitivity Test ===" << std::endl;
std::cout << "Base Laplacian: " << 0.15E+01 << std::endl;
std::cout << " E_xc = " << e_base << std::endl;
std::cout << " dE/dlapl ≈ " << (e_modified - e_base) / 1.0 << std::endl;
std::cout << "Modified Laplacian:" << 0.15E+01 + 1.0 << std::endl;
std::cout << " E_xc = " << e_modified << std::endl;
std::cout << " Delta E = " << e_modified - e_base << std::endl;
std::cout << "Scaled Laplacian: " << 2.0 * 0.15E+01 << std::endl;
std::cout << " E_xc = " << e_scaled << std::endl;
std::cout << " Delta E = " << e_scaled - e_base << std::endl;
std::cout << "========================================" << std::endl;
}