Skip to content
Open
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ external/gqten/
*swo
.DS_Store
.ycm_extra_conf.py
.vscode/c_cpp_properties.json
.vscode/settings.json
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ endif()

option(GQMPS2_BUILD_UNITTEST "Build unittests for GraceQ/mps2." OFF)

option(GQMPS2_BUILD_GQTEN_USE_EXTERNAL_HPTT_LIB "Use external hptt library when building dependency external/gqten." OFF)
option(TEST_BUILD_USE_EXTERNAL_GQTEN "Use external gqten library when building unittests for GraceQ/mps2." OFF)

option(TEST_BUILD_USE_EXTERNAL_HPTT_LIB "Use external hptt library when building unittests for GraceQ/mps2." OFF)

# Compilation and linking control.
set(CMAKE_CXX_STANDARD 14)
Expand All @@ -59,13 +61,20 @@ add_subdirectory(script)

# Build unittests.
if(GQMPS2_BUILD_UNITTEST)
# Build dependencies (GraceQ/tensor).
if(GQMPS2_BUILD_GQTEN_USE_EXTERNAL_HPTT_LIB)
option(GQTEN_USE_EXTERNAL_HPTT_LIB "Set related option in external/gqten" ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/external/gqten/cmake/Modules/")
if(NOT TEST_BUILD_USE_EXTERNAL_GQTEN)
add_subdirectory(external)
set(GQMPS2_TENSOR_LIB_HEADER_PATH "${PROJECT_SOURCE_DIR}/external/gqten/include")
else()
find_path(GQMPS2_TENSOR_LIB_HEADER_PATH "gqten")
endif()

if(NOT TEST_BUILD_USE_EXTERNAL_HPTT_LIB)
set(hptt_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/external/gqten/external/hptt/include")
set(hptt_LIBRARY "${CMAKE_BINARY_DIR}/external/gqten/external/hptt/libhptt.a")
else()
find_path(hptt_INCLUDE_DIR "hptt.h")
find_library(hptt_LIBRARY "libhptt.a")
endif()
add_subdirectory(external)
set(GQMPS2_TENSOR_LIB_HEADER_PATH "${PROJECT_SOURCE_DIR}/external/gqten/include")

enable_testing()
find_package(GTest REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion include/gqmps2/algorithm/lanczos_solver_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ LanczosRes<TenT> LanczosSolver(
bases[m] = gamma;

#ifdef GQMPS2_TIMING_MODE
mat_vec_timer.Restart();
mat_vec_timer.ClearAndRestart();
#endif

last_mat_mul_vec_res = (*eff_ham_mul_state)(rpeff_ham, bases[m]);
Expand Down
86 changes: 86 additions & 0 deletions include/gqmps2/algorithm/vmps/single_site_update_finite_vmps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: LGPL-3.0-only

/*
* Author: Hao-Xin Wang <wanghx18@mails.tsinghua.edu.cn>
* Rongyang Sun <sun-rongyang@outlook.com>
* Creation Date: 2021-7-9
*
* Description: GraceQ/MPS2 project. Single-site vMPS algorithm header.
*/

/**
@file single_site_update_finite_vmps.h
@brief Single-site update finite size vMPS.
*/
#ifndef GQMPS2_ALGORITHM_VMPS_SINGLE_SITE_UPDATE_FINITE_VMPS_H
#define GQMPS2_ALGORITHM_VMPS_SINGLE_SITE_UPDATE_FINITE_VMPS_H


#include "gqmps2/consts.h" // kMpsPath, kRuntimeTempPath
#include "gqmps2/algorithm/lanczos_solver.h" // LanczParams

#include <string> // string


namespace gqmps2 {
const double kSingleVMPSMaxNoise = 1.0; //maximal noise
const double kSingleVMPSNoiseIncrease = 1.02;
const double kSingleVMPSNoiseDecrease = 0.95;
const double kSingleVMPSAlpha = 0.3;

struct SingleVMPSSweepParams {
SingleVMPSSweepParams(
const size_t sweeps,
const size_t dmin, const size_t dmax, const double trunc_err,
const LanczosParams &lancz_params,
const std::vector<double> noises = std::vector<double>(1, 0.0),
const double max_noise = kSingleVMPSMaxNoise,
const double noise_increase = kSingleVMPSNoiseIncrease,
const double noise_decrease = kSingleVMPSNoiseDecrease,
const double alpha = kSingleVMPSAlpha,
const std::string mps_path = kMpsPath,
const std::string temp_path = kRuntimeTempPath
) :
sweeps(sweeps),
Dmin(dmin), Dmax(dmax), trunc_err(trunc_err),
lancz_params(lancz_params),
noises(noises),
max_noise(max_noise),
noise_increase(noise_increase),
noise_decrease(noise_decrease),
alpha(alpha),
mps_path(mps_path),
temp_path(temp_path) {}

size_t sweeps;

size_t Dmin;
size_t Dmax;
double trunc_err;

LanczosParams lancz_params;


/// Noise magnitude each sweep
std::vector<double> noises;
double max_noise;
double noise_increase;
double noise_decrease;
double alpha;

// Advanced parameters
/// MPS directory path
std::string mps_path;

/// Runtime temporary files directory path
std::string temp_path;

};
} /* gqmps2 */


// Implementation details
#include "gqmps2/algorithm/vmps/single_site_update_finite_vmps_impl.h"


#endif /* ifndef GQMPS2_ALGORITHM_VMPS_SINGLE_SITE_UPDATE_FINITE_VMPS_H */
Loading