Commit 54ab8f1c authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh
Browse files

Added MC-VQE ground state calculation test.


Signed-off-by: default avatarDmitry I. Lyakh <quant4me@gmail.com>
parent 43748e8d
......@@ -16,7 +16,7 @@
#include "errors.hpp"
//Test activation:
#define EXATN_TEST0
/*#define EXATN_TEST0
#define EXATN_TEST1
#define EXATN_TEST2
#define EXATN_TEST3
......@@ -41,10 +41,10 @@
#define EXATN_TEST22
#define EXATN_TEST23
#define EXATN_TEST24
#define EXATN_TEST25
#define EXATN_TEST25*/
#define EXATN_TEST26 //requires input file from source
#define EXATN_TEST27
#define EXATN_TEST28
//#define EXATN_TEST27
//#define EXATN_TEST28
#ifdef EXATN_TEST0
......@@ -2825,7 +2825,9 @@ TEST(NumServerTester, HubbardHamiltonian) {
const int num_sites = 8, max_bond_dim = std::min(static_cast<int>(std::pow(2,num_sites/2)),16); //2x2 sites x dim(4) = 8 qubits (sites)
//Read 2x2 Hubbard Hamiltonian in spin representation:
auto hubbard_operator = exatn::quantum::readSpinHamiltonian("HubbardHam","hubbard_2x2.txt",TENS_ELEM_TYPE);
//auto hubbard_operator = exatn::quantum::readSpinHamiltonian("MCVQEHam","mcvqe_8q.txt",TENS_ELEM_TYPE);
//success = hubbard_operator->deleteComponent(0); assert(success);
auto hubbard_operator = exatn::quantum::readSpinHamiltonian("HubbardHam","hubbard_2x2_8q.txt",TENS_ELEM_TYPE);
hubbard_operator->printIt();
//Create tensor network ansatz:
......
(-10729.963236109992+0j) [] +
(0.013958292661992958+0j) [X0] +
(0.017780394781136848+0j) [X0 X1] +
(-0.006896704529177866+0j) [X0 Z1] +
(-0.03376113630025557+0j) [Z0] +
(0.011474775121306156+0j) [Z0 X1] +
(-0.004444563032874407+0j) [Z0 Z1] +
(0.009522097764876093+0j) [X1] +
(-0.008640686174448204+0j) [X1 X2] +
(-0.00641012019143096+0j) [X1 Z2] +
(-0.042308599255825224+0j) [Z1] +
(0.0033005482717231548+0j) [Z1 X2] +
(0.0024514303165071353+0j) [Z1 Z2] +
(-0.006583545256676178+0j) [X2] +
(-0.007287160094179741+0j) [X2 X3] +
(0.004086379532445629+0j) [X2 Z3] +
(-0.04957343856301523+0j) [Z2] +
(-0.005120355594249221+0j) [Z2 X3] +
(0.00289351687114843+0j) [Z2 Z3] +
(-0.006327031384126287+0j) [X3] +
(-0.01840086316143409+0j) [X3 X4] +
(-0.012367083572855955+0j) [X3 Z4] +
(-0.03839552410604509+0j) [Z3] +
(0.010913763352627169+0j) [Z3 X4] +
(0.007334390217786867+0j) [Z3 Z4] +
(0.009699304994889446+0j) [X4] +
(-0.004742884975867185+0j) [X4 X5] +
(-0.0011410992924187104+0j) [X4 Z5] +
(-0.03672437524536075+0j) [Z4] +
(-0.0028540627220499703+0j) [Z4 X5] +
(-0.0006758931704842083+0j) [Z4 Z5] +
(-0.008546718038275256+0j) [X5] +
(0.0012774322501627943+0j) [X5 X6] +
(-0.0006862884757300228+0j) [X5 Z6] +
(-0.040029787841621825+0j) [Z5] +
(0.0004181198916071052+0j) [Z5 X6] +
(-0.0002418324220780885+0j) [Z5 Z6] +
(-0.004220761908087866+0j) [X6] +
(-0.007850802949685699+0j) [X6 X7] +
(-0.004536735382497114+0j) [X6 Z7] +
(-0.041302161404488+0j) [Z6] +
(0.005221816809904007+0j) [Z6 X7] +
(0.003023554049679674+0j) [Z6 Z7] +
(0.0023629329298370094+0j) [X7] +
(-0.04139809785433139+0j) [Z7]
/** ExaTN::Numerics: Tensor network expansion
REVISION: 2021/08/09
REVISION: 2021/09/20
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -205,6 +205,14 @@ bool TensorExpansion::appendExpansion(const TensorExpansion & another,
}
bool TensorExpansion::deleteComponent(std::size_t component_num)
{
if(component_num >= components_.size()) return false;
components_.erase(components_.cbegin()+component_num);
return true;
}
void TensorExpansion::conjugate()
{
for(auto & component: components_){
......
/** ExaTN::Numerics: Tensor network expansion
REVISION: 2021/08/09
REVISION: 2021/09/20
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -199,6 +199,9 @@ public:
bool appendExpansion(const TensorExpansion & another, //in: tensor network expansion
const std::complex<double> coefficient); //in: scaling coefficient (applies to the appended tensor network expansion)
/** Deletes the specified component of the tensor expansion. **/
bool deleteComponent(std::size_t component_num);
/** Conjugates the tensor network expansion: All constituting tensors are complex conjugated,
all tensor legs reverse their direction, complex linear expansion coefficients are conjugated:
The ket tensor network expansion becomes a bra, and vice versa. **/
......
/** ExaTN::Numerics: Tensor operator
REVISION: 2021/03/05
REVISION: 2021/09/20
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -160,6 +160,14 @@ bool TensorOperator::appendSymmetrizeComponent(std::shared_ptr<Tensor> tensor,
}
bool TensorOperator::deleteComponent(std::size_t component_num)
{
if(component_num >= components_.size()) return false;
components_.erase(components_.cbegin()+component_num);
return true;
}
void TensorOperator::conjugate()
{
for(auto & component: components_){
......
/** ExaTN::Numerics: Tensor operator
REVISION: 2021/03/05
REVISION: 2021/09/20
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -135,6 +135,9 @@ public:
const std::complex<double> coefficient, //in: expansion coefficient
bool antisymmetrize = false); //in: whether or not to negate the coefficient for odd permutations
/** Deletes the specified component of the tensor operator. **/
bool deleteComponent(std::size_t component_num);
/** Conjugates the tensor operator: All constituting tensors are complex conjugated,
all tensor legs reverse their direction, bra legs and ket legs are swapped,
complex linear expansion coefficients are complex conjugated. **/
......
......@@ -378,10 +378,12 @@ bool parse_pauli_string(const std::string & input,
const auto plus_pos = input.find("+",left_par_pos);
if(plus_pos != std::string::npos){
const auto real_len = plus_pos - left_par_pos - 1;
//std::cout << "#DEBUG(parse_pauli_string): Coef: " << input.substr(left_par_pos+1,real_len); //debug
if(real_len > 0) coef_real = std::stod(input.substr(left_par_pos+1,real_len));
const auto imag_end_pos = input.find("j",plus_pos);
if(imag_end_pos != std::string::npos){
const auto imag_len = imag_end_pos - plus_pos - 1;
//std::cout << " " << input.substr(plus_pos+1,imag_len) << std::endl; //debug
if(imag_len > 0) coef_imag = std::stod(input.substr(plus_pos+1,imag_len));
coefficient = std::complex<double>{coef_real, coef_imag};
}else{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment