1 #include "catch.hpp"
2 #include "fixture.h"
3
4 TEST_CASE("Shell ctor", "[shell]") {
5 REQUIRE_NOTHROW(Shell{});
6 auto s0 = Shell{};
7 REQUIRE(s0.alpha.empty());
8 REQUIRE(s0.contr.empty());
9 REQUIRE(s0.max_ln_coeff.empty());
10
11 REQUIRE_NOTHROW(Shell{{1}, {{2, false, {1}}}, {{0, 0, 0}}});
12 auto s1 = Shell{{1}, {{2, false, {1}}}, {{0, 0, 0}}};
13 REQUIRE(s1.alpha == libint2::svector<double>{1});
14 REQUIRE(s1.contr.size() == 1);
15 REQUIRE(s1.contr[0].l == 2);
16 REQUIRE(!s1.contr[0].pure);
17 REQUIRE(s1.contr[0].coeff.size() == 1);
18 REQUIRE(s1.contr[0].coeff[0] == Approx(1.64592278064949)); // (2./\[Pi])^(3/4) 2^l \[Alpha]^((2l+3)/4) / Sqrt[(2l-1)!!]
19 REQUIRE(s1.O == std::array<double,3>{0, 0, 0});
20 }
21
22 TEST_CASE("Engine ctor", "[engine]") {
23 REQUIRE_NOTHROW(Engine{});
24 auto a = Engine{};
25 }
26
27 TEST_CASE("Engine::set", "[engine]") {
28 REQUIRE_THROWS_AS(Engine{}.set(Operator::overlap), Engine::using_default_initialized);
29 REQUIRE_THROWS_AS(Engine{}.set(BraKet::x_x), Engine::using_default_initialized);
30 REQUIRE_NOTHROW(Engine{}.set(CartesianShellNormalization::uniform));
31 REQUIRE_NOTHROW(Engine{}.prescale_by(1.5));
32 REQUIRE_NOTHROW(Engine(Operator::overlap, 1, 0).set(CartesianShellNormalization::uniform).set_precision(1e-20).set(Operator::overlap).prescale_by(1.3).set(BraKet::x_x));
33 }
34
check_uniform(int l,RealBuf && S)35 template <typename RealBuf> void check_uniform(int l, RealBuf && S) {
36 const auto n = (l+1)*(l+2)/2;
37 for(int i=0; i!=n; ++i) {
38 REQUIRE(S[i*n+i] == Approx(1.));
39 }
40 };
41
check_std_2(RealBuf && S)42 template <typename RealBuf> void check_std_2(RealBuf && S) {
43 REQUIRE(S[0] == Approx(1.));
44 REQUIRE(S[7] == Approx(1./3));
45 REQUIRE(S[14] == Approx(1./3));
46 REQUIRE(S[21] == Approx(1.));
47 REQUIRE(S[28] == Approx(1./3));
48 REQUIRE(S[35] == Approx(1.));
49 };
50
check_std_3(RealBuf && S)51 template <typename RealBuf> void check_std_3(RealBuf && S) {
52 REQUIRE(S[0] == Approx(1.));
53 REQUIRE(S[11] == Approx(1./5));
54 REQUIRE(S[22] == Approx(1./5));
55 REQUIRE(S[33] == Approx(1./5));
56 REQUIRE(S[44] == Approx(1./15));
57 REQUIRE(S[55] == Approx(1./5));
58 REQUIRE(S[66] == Approx(1.));
59 REQUIRE(S[77] == Approx(1./5));
60 REQUIRE(S[88] == Approx(1./5));
61 REQUIRE(S[99] == Approx(1.));
62 };
63
64 TEST_CASE("cartesian uniform normalization", "[engine][conventions]") {
65 #if defined(LIBINT2_SUPPORT_ONEBODY) && defined(LIBINT2_SUPPORT_ERI)
66 if (LIBINT_CGSHELL_ORDERING != LIBINT_CGSHELL_ORDERING_STANDARD)
67 return;
68
69 std::vector<Shell> obs{Shell{{1.0}, {{2, false, {1.0}}}, {{0.0, 0.0, 0.0}}},
70 Shell{{1.0}, {{3, false, {1.0}}}, {{0.0, 0.0, 0.0}}}};
71 {
72 const auto lmax = std::min(3,LIBINT2_MAX_AM_overlap);
73 if (lmax >= 2) {
74 auto engine = Engine(Operator::overlap, 1, lmax);
75 engine.compute(obs[0], obs[0]);
76 check_std_2(engine.results()[0]);
77 engine.set(CartesianShellNormalization::uniform).compute(obs[0], obs[0]);
78 check_uniform(2, engine.results()[0]);
79
80 if (lmax >= 3) {
81 engine.set(CartesianShellNormalization::standard)
82 .compute(obs[1], obs[1]);
83 check_std_3(engine.results()[0]);
84 engine.set(CartesianShellNormalization::uniform)
85 .compute(obs[1], obs[1]);
86 check_uniform(3, engine.results()[0]);
87 }
88 }
89 }
90 {
91 const auto lmax = std::min(3,LIBINT2_MAX_AM_eri);
92 if (lmax >= 2) {
93 auto engine = Engine(Operator::delta, 1, lmax);
94 engine.compute(Shell::unit(), obs[0], obs[0], Shell::unit());
95 check_std_2(engine.results()[0]);
96 engine.set(CartesianShellNormalization::uniform)
97 .compute(obs[0], Shell::unit(), Shell::unit(), obs[0]);
98 check_uniform(2, engine.results()[0]);
99
100 if (lmax >= 3) {
101 engine.set(CartesianShellNormalization::standard)
102 .compute(Shell::unit(), obs[1], Shell::unit(), obs[1]);
103 check_std_3(engine.results()[0]);
104 engine.set(CartesianShellNormalization::uniform)
105 .compute(obs[1], Shell::unit(), obs[1], Shell::unit());
106 check_uniform(3, engine.results()[0]);
107 }
108 }
109 }
110
111 #endif // LIBINT2_SUPPORT_ONEBODY
112 }
113