1 //////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source
3 // License. See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by:
8 // Miguel A. Morales, moralessilva2@llnl.gov
9 // Lawrence Livermore National Laboratory
10 //
11 // File created by:
12 // Miguel A. Morales, moralessilva2@llnl.gov
13 // Lawrence Livermore National Laboratory
14 ////////////////////////////////////////////////////////////////////////////////
15
16 #ifndef QMCPLUSPLUS_AFQMC_HAMOPSIO_HPP
17 #define QMCPLUSPLUS_AFQMC_HAMOPSIO_HPP
18
19 #include <fstream>
20
21 #include "hdf/hdf_multi.h"
22 #include "hdf/hdf_archive.h"
23
24 #include "AFQMC/config.h"
25
26 #include "AFQMC/HamiltonianOperations/HamiltonianOperations.hpp"
27 #include "AFQMC/HamiltonianOperations/SparseTensorIO.hpp"
28 #include "AFQMC/HamiltonianOperations/THCOpsIO.hpp"
29 //#ifdef QMC_COMPLEX
30 //#include "AFQMC/HamiltonianOperations/KP3IndexFactorizationIO.hpp"
31 //#endif
32
33 namespace qmcplusplus
34 {
35 namespace afqmc
36 {
loadHamOps(hdf_archive & dump,WALKER_TYPES type,int NMO,int NAEA,int NAEB,std::vector<PsiT_Matrix> & PsiT,TaskGroup_ & TGprop,TaskGroup_ & TGwfn,RealType cutvn,RealType cutv2)37 HamiltonianOperations loadHamOps(hdf_archive& dump,
38 WALKER_TYPES type,
39 int NMO,
40 int NAEA,
41 int NAEB,
42 std::vector<PsiT_Matrix>& PsiT,
43 TaskGroup_& TGprop,
44 TaskGroup_& TGwfn,
45 RealType cutvn,
46 RealType cutv2)
47 {
48 int hops_type = -1;
49 if (TGwfn.Global().root())
50 {
51 if (!dump.push("HamiltonianOperations", false))
52 {
53 app_error() << " Error in loadHamOps: Group HamiltonianOperations not found. \n";
54 APP_ABORT("");
55 }
56 if (dump.is_group(std::string("THCOps")))
57 hops_type = 1;
58 else if (dump.is_group(std::string("KP3IndexFactorization")))
59 hops_type = 3;
60 else if (dump.is_group(std::string("SparseTensor")))
61 {
62 dump.push("SparseTensor", false);
63 std::vector<int> type;
64 if (!dump.readEntry(type, "type"))
65 {
66 app_error() << " Error in loadHamOps: Problems reading type dataset. \n";
67 APP_ABORT("");
68 }
69 if (type[0] == 11)
70 hops_type = 211;
71 else if (type[0] == 12)
72 hops_type = 212;
73 else if (type[0] == 21)
74 hops_type = 221;
75 else if (type[0] == 22)
76 hops_type = 222;
77 else
78 {
79 app_error() << " Unknown SparseTensor/type: " << type[0] << std::endl;
80 APP_ABORT("");
81 }
82 dump.pop();
83 }
84 else
85 {
86 app_error() << " Error in loadHamOps: Unknown hdf5 format. \n";
87 APP_ABORT("");
88 }
89 dump.pop();
90 }
91 TGwfn.Global().broadcast_value(hops_type);
92
93 if (hops_type == 1)
94 return HamiltonianOperations(loadTHCOps(dump, type, NMO, NAEA, NAEB, PsiT, TGprop, TGwfn, cutvn, cutv2));
95 else if (hops_type == 211)
96 return HamiltonianOperations(
97 loadSparseTensor<ValueType, ValueType>(dump, type, NMO, NAEA, NAEB, PsiT, TGprop, TGwfn, cutvn, cutv2));
98 else if (hops_type == 212)
99 return HamiltonianOperations(
100 loadSparseTensor<ValueType, ComplexType>(dump, type, NMO, NAEA, NAEB, PsiT, TGprop, TGwfn, cutvn, cutv2));
101 else if (hops_type == 221)
102 return HamiltonianOperations(
103 loadSparseTensor<ComplexType, ValueType>(dump, type, NMO, NAEA, NAEB, PsiT, TGprop, TGwfn, cutvn, cutv2));
104 else if (hops_type == 222)
105 return HamiltonianOperations(
106 loadSparseTensor<ComplexType, ComplexType>(dump, type, NMO, NAEA, NAEB, PsiT, TGprop, TGwfn, cutvn, cutv2));
107 // else if(hops_type == 3)
108 // return HamiltonianOperations(loadKP3IndexFactorization(dump,type,NMO,NAEA,NAEB,PsiT,TGprop,TGwfn,cutvn,cutv2));
109
110 app_error() << " Error in loadHamOps: Unknown HOps type: " << hops_type << std::endl;
111 ;
112 APP_ABORT("");
113 return HamiltonianOperations{};
114 }
115
116 } // namespace afqmc
117 } // namespace qmcplusplus
118
119 #endif
120