27 void CheMPS2::DMRG::saveMPS(
const std::string name, TensorT ** MPSlocation, SyBookkeeper * BKlocation,
bool isConverged)
const{
30 hid_t file_id = H5Fcreate(name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
33 hid_t group_id = H5Gcreate(file_id,
"/Convergence", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
36 hid_t dataspace_id = H5Screate_simple(1, &dimarray, NULL);
37 hid_t dataset_id = H5Dcreate(group_id,
"Converged_yn", H5T_STD_I32LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
38 int toWrite = (isConverged)?1:0;
39 H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &toWrite);
42 H5Sclose(dataspace_id);
47 for (
int bound=0; bound<=BKlocation->gL(); bound++){
48 for (
int N=BKlocation->gNmin(bound); N<=BKlocation->gNmax(bound); N++){
49 for (
int TwoS=BKlocation->gTwoSmin(bound,N); TwoS<=BKlocation->gTwoSmax(bound,N); TwoS+=2){
50 for (
int Irrep=0; Irrep<BKlocation->getNumberOfIrreps(); Irrep++){
52 std::stringstream sstream;
53 sstream <<
"/VirtDim_" << bound <<
"_" << N <<
"_" << TwoS <<
"_" << Irrep;
54 hid_t group_id2 = H5Gcreate(file_id, sstream.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
56 hsize_t dimarray2 = 1;
57 hid_t dataspace_id2 = H5Screate_simple(1, &dimarray2, NULL);
58 hid_t dataset_id2 = H5Dcreate(group_id2,
"Value", H5T_STD_I32LE, dataspace_id2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
59 int toWrite2 = BKlocation->gCurrentDim(bound,N,TwoS,Irrep);
60 H5Dwrite(dataset_id2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &toWrite2);
62 H5Dclose(dataset_id2);
63 H5Sclose(dataspace_id2);
73 for (
int site=0; site<BKlocation->gL(); site++){
75 std::stringstream sstream;
76 sstream <<
"/MPS_" << site;
77 hid_t group_id3 = H5Gcreate(file_id, sstream.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
79 hsize_t dimarray3 = MPSlocation[site]->gKappa2index(MPSlocation[site]->gNKappa());
80 hid_t dataspace_id3 = H5Screate_simple(1, &dimarray3, NULL);
81 hid_t dataset_id3 = H5Dcreate(group_id3,
"Values", H5T_IEEE_F64LE, dataspace_id3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
82 H5Dwrite(dataset_id3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, MPSlocation[site]->gStorage());
84 H5Dclose(dataset_id3);
85 H5Sclose(dataspace_id3);
96 void CheMPS2::DMRG::loadDIM(
const std::string name, SyBookkeeper * BKlocation){
99 hid_t file_id = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
102 for (
int bound=0; bound<=BKlocation->gL(); bound++){
103 for (
int N=BKlocation->gNmin(bound); N<=BKlocation->gNmax(bound); N++){
104 for (
int TwoS=BKlocation->gTwoSmin(bound,N); TwoS<=BKlocation->gTwoSmax(bound,N); TwoS+=2){
105 for (
int Irrep=0; Irrep<BKlocation->getNumberOfIrreps(); Irrep++){
107 std::stringstream sstream;
108 sstream <<
"/VirtDim_" << bound <<
"_" << N <<
"_" << TwoS <<
"_" << Irrep;
109 hid_t group_id2 = H5Gopen(file_id, sstream.str().c_str(), H5P_DEFAULT);
111 hid_t dataset_id2 = H5Dopen(group_id2,
"Value", H5P_DEFAULT);
113 H5Dread(dataset_id2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &toRead);
114 BKlocation->SetDim(bound, N, TwoS, Irrep, toRead);
115 H5Dclose(dataset_id2);
128 void CheMPS2::DMRG::loadMPS(
const std::string name, TensorT ** MPSlocation,
bool * isConverged){
131 hid_t file_id = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
134 hid_t group_id = H5Gopen(file_id,
"/Convergence", H5P_DEFAULT);
136 hid_t dataset_id = H5Dopen(group_id,
"Converged_yn", H5P_DEFAULT);
138 H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &toRead);
139 isConverged[0] = (toRead==0)?
false:
true;
140 H5Dclose(dataset_id);
145 for (
int site=0; site<L; site++){
147 std::stringstream sstream;
148 sstream <<
"/MPS_" << site;
149 hid_t group_id3 = H5Gopen(file_id, sstream.str().c_str(), H5P_DEFAULT);
151 hid_t dataset_id3 = H5Dopen(group_id3,
"Values", H5P_DEFAULT);
152 H5Dread(dataset_id3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, MPSlocation[site]->gStorage());
153 H5Dclose(dataset_id3);
166 std::stringstream thestream;
167 thestream <<
"rm " << CheMPS2::DMRG_MPS_storage_prefix <<
"*.h5";
168 int info = system(thestream.str().c_str());
169 std::cout <<
"Info on DMRG::MPS rm call to system: " << info << std::endl;
void deleteStoredMPS()
Call "rm " + CheMPS2::DMRG_MPS_storage_prefix + "*.h5".