From 5a59b33d5e62f0fce3c567b1ad065ebb81096428 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Sun, 28 Jan 2024 13:34:19 +0900 Subject: [PATCH] coeff of observable --- .../file_specification/observable_section.rst | 14 +++ .../file_specification/observable_section.rst | 24 ++++- src/iTPS/load_toml.cpp | 27 ++++-- src/iTPS/main.cpp | 7 +- src/iTPS/multisite_obs.cpp | 2 +- src/iTPS/onesite_obs.cpp | 8 +- src/iTPS/twosite_obs.cpp | 4 +- src/operator.hpp | 33 +++++-- test/data/AntiferroHeisenberg_real.toml | 37 +++++++ .../AntiferroHeisenberg_real.toml | 54 ++++++++++- .../correlation.dat | 97 ++++++++++--------- .../correlation_length.dat | 8 +- .../density.dat | 19 ++-- .../multisite_obs_4.dat | 13 ++- .../onesite_obs.dat | 33 ++++--- .../parameters.dat | 4 +- .../twosite_obs.dat | 97 ++++++++++--------- tool/tenes_std.py | 52 ++++++++-- 18 files changed, 370 insertions(+), 163 deletions(-) diff --git a/docs/sphinx/en/file_specification/observable_section.rst b/docs/sphinx/en/file_specification/observable_section.rst index f64b8129..6e27ad76 100644 --- a/docs/sphinx/en/file_specification/observable_section.rst +++ b/docs/sphinx/en/file_specification/observable_section.rst @@ -18,6 +18,8 @@ Define one-body operators that indicate physical quantities defined at each site ``sites``, "Site number", Integer or a list of integer ``dim``, "Dimension of an operator", Integer ``elements``, "Non-zero elements of an operator", String + ``coeff``, "Coefficient of operator (real part)", Float + ``coeff_im``, "Coefficient of operator (imaginary part)", Float ``name`` specifies an operator name. @@ -35,6 +37,9 @@ One element is specified by one line consisting of two integers and two floating - The first two integers are the state numbers before and after the act of the operator, respectively. - The latter two floats indicate the real and imaginary parts of the elements of the operator, respectively. +``coeff`` and ``coeff_im`` are real and imaginary parts of the coefficient of the operator, respectively. +If omitted, they are set to 1.0 and 0.0, respectively. + Example ....... @@ -93,6 +98,8 @@ Define two-body operators that indicate physical quantities defined on two sites ``dim``, "Dimension of an operator", Integer ``elements``, "Non-zero elements of an operator", String ``ops``, "Index of onesite operators", A list of integer + ``coeff``, "Coefficient of operator (real part)", Float + ``coeff_im``, "Coefficient of operator (imaginary part)", Float ``name`` specifies an operator name. @@ -123,6 +130,9 @@ For example, if :math:`S^z` is defined as ``group = 0`` in ``observable.onesite` If both ``elements`` and ``ops`` are defined, the process will end in error. +``coeff`` and ``coeff_im`` are real and imaginary parts of the coefficient of the operator, respectively. +If omitted, they are set to 1.0 and 0.0, respectively. + Example ....... @@ -193,6 +203,8 @@ It is defined as a direct product of one-body operators defined in ``observable. ``group``, "Identification number of operators", Integer ``multisites``, "Sites", String ``ops``, "Index of onesite operators", List of integers + ``coeff``, "Coefficient of operator (real part)", Float + ``coeff_im``, "Coefficient of operator (imaginary part)", Float ``name`` specifies an operator name. @@ -210,3 +222,5 @@ One line consisting of integers means a set sites. Using ``ops``, a multi-body operator can be defined as a direct product of the one-body operators defined in ``observable.onesite``. For example, if :math:`S^z` is defined as ``group = 0`` in ``observable.onesite``, :math:`S^z_i S^z_j S^z_k` can be expressed as ``ops = [0,0,0]``. +``coeff`` and ``coeff_im`` are real and imaginary parts of the coefficient of the operator, respectively. +If omitted, they are set to 1.0 and 0.0, respectively. diff --git a/docs/sphinx/ja/file_specification/observable_section.rst b/docs/sphinx/ja/file_specification/observable_section.rst index ca1ffc61..5ea71226 100644 --- a/docs/sphinx/ja/file_specification/observable_section.rst +++ b/docs/sphinx/ja/file_specification/observable_section.rst @@ -14,11 +14,13 @@ :header: "名前", "説明", "型" :widths: 15, 30, 20 - ``name``, "演算子の名前", 文字列 - ``group``, "演算子の識別番号", 整数 - ``sites``, "サイト番号", 整数 or 整数のリスト - ``dim``, "演算子の次元", 整数 - ``elements``, "演算子の非ゼロ要素", 文字列 + ``name``, "演算子の名前", 文字列 + ``group``, "演算子の識別番号", 整数 + ``sites``, "サイト番号", 整数 or 整数のリスト + ``dim``, "演算子の次元", 整数 + ``elements``, "演算子の非ゼロ要素", 文字列 + ``coeff``, "演算子にかかる係数(実部)", 実数 + ``coeff_im``, "演算子にかかる係数(虚部)", 実数 ``name`` は演算子の名前です。 @@ -36,6 +38,9 @@ - 最初の2つはそれぞれ演算子が作用する前と後の状態番号を示します。 - あとの2つはそれぞれ演算子の要素の実部と虚部を示します。 +``coeff``, ``coeff_im`` は演算子にかかる係数の実部と虚部です。 +省略した場合はそれぞれ 1.0, 0.0 になります。 + 例 .... @@ -95,6 +100,8 @@ S=1/2 のSz 演算子 ``dim``, "演算子の次元", 整数のリスト ``elements``, "演算子の非ゼロ要素", 文字列 ``ops``, "onesite 演算子の識別番号", 整数のリスト + ``coeff``, "演算子にかかる係数(実部)", 実数 + ``coeff_im``, "演算子にかかる係数(虚部)", 実数 ``name`` は演算子の名前です。 @@ -124,6 +131,9 @@ S=1/2 のSz 演算子 ``elements`` と ``ops`` を同時に定義した場合にはエラー終了します。 +``coeff``, ``coeff_im`` は演算子にかかる係数の実部と虚部です。 +省略した場合はそれぞれ 1.0, 0.0 になります。 + 例 .... ここでは具体例として、``Lsub=[2,2]`` の正方格子 S=1/2 ハイゼンベルグ模型のボンドハミルトニアンのエネルギーを求めるため、 @@ -197,6 +207,8 @@ S=1/2 のSz 演算子 ``group``, "演算子の識別番号", 整数 ``multisites``, "サイトの組み合わせ", 文字列 ``ops``, "onesite 演算子の識別番号", 整数のリスト + ``coeff``, "演算子にかかる係数(実部)", 実数 + ``coeff_im``, "演算子にかかる係数(虚部)", 実数 ``name`` は演算子の名前です。 @@ -215,3 +227,5 @@ S=1/2 のSz 演算子 例えば ``observable.onesite`` の ``group=0`` として :math:`S^z` を定義していた場合には、 ``ops = [0,0,0]`` として :math:`S^z_iS^z_jS^z_k` を表現できます。 +``coeff``, ``coeff_im`` は演算子にかかる係数の実部と虚部です。 +省略した場合はそれぞれ 1.0, 0.0 になります。 diff --git a/src/iTPS/load_toml.cpp b/src/iTPS/load_toml.cpp index 91f4ae97..c9cef62c 100644 --- a/src/iTPS/load_toml.cpp +++ b/src/iTPS/load_toml.cpp @@ -78,6 +78,13 @@ struct bittype { typedef int64_t type; }; +template +T reduce(double re, double im); +template <> +std::complex reduce>(double re, double im) { return std::complex(re, im); } +template <> +double reduce(double re, double im) { return re; } + } // end of namespace detail template @@ -516,9 +523,17 @@ Operators load_operator(decltype(cpptoml::parse_file("")) param, auto group = find(param, "group"); auto name = find_or(param, "name", std::string("")); + auto coeff_re = find_or(param, "coeff", 1.0); + auto coeff_im = find_or(param, "coeff_im", 0.0); + typename tensor::value_type coeff = detail::reduce(coeff_re, coeff_im); + auto is_real = std::is_same::value; + if(is_real && coeff_im != 0.0){ + std::stringstream ss; + ss << "parameter.general.is_real is true but coeff_im is not zero in a section " << tablename; + throw tenes::input_error(ss.str()); + } std::vector> ret; - if (nbody == 1) { auto site_int = param->get_as("sites"); auto site_arr = param->get_array_of("sites"); @@ -536,7 +551,7 @@ Operators load_operator(decltype(cpptoml::parse_file("")) param, throw input_error(detail::msg_cannot_find("sites", tablename)); } for (int s : sites) { - ret.emplace_back(name, group, s, A); + ret.emplace_back(name, group, s, A, coeff); } } else if (nbody == 2) { auto bonds_str = find(param, "bonds"); @@ -544,10 +559,10 @@ Operators load_operator(decltype(cpptoml::parse_file("")) param, for (auto bond : bonds) { if (elements) { ret.emplace_back(name, group, std::get<0>(bond), std::get<1>(bond), - std::get<2>(bond), A); + std::get<2>(bond), A, coeff); } else { ret.emplace_back(name, group, std::get<0>(bond), std::get<1>(bond), - std::get<2>(bond), op_ind); + std::get<2>(bond), op_ind, coeff); } } } else { @@ -556,10 +571,10 @@ Operators load_operator(decltype(cpptoml::parse_file("")) param, for (auto ms : mss) { if (elements) { ret.emplace_back(name, group, std::get<0>(ms), std::get<1>(ms), - std::get<2>(ms), A); + std::get<2>(ms), A, coeff); } else { ret.emplace_back(name, group, std::get<0>(ms), std::get<1>(ms), - std::get<2>(ms), op_ind); + std::get<2>(ms), op_ind, coeff); } } } diff --git a/src/iTPS/main.cpp b/src/iTPS/main.cpp index 20f6c82e..4e7c409c 100644 --- a/src/iTPS/main.cpp +++ b/src/iTPS/main.cpp @@ -48,23 +48,24 @@ tenes::Operators> to_real( } MPI_Comm comm = ops[0].op.get_comm(); for (auto const& op : ops) { + double coeff = std::real(op.coeff); if (op.is_onesite()) { mptensor::Tensor A(comm, op.op.shape()); for (size_t lindex = 0; lindex < op.op.local_size(); ++lindex) { A[lindex] = op.op[lindex].real(); } - ret.emplace_back(op.name, op.group, op.source_site, A); + ret.emplace_back(op.name, op.group, op.source_site, A, coeff); } else if (op.ops_indices.empty()) { mptensor::Tensor A(comm, op.op.shape()); for (size_t lindex = 0; lindex < op.op.local_size(); ++lindex) { A[lindex] = op.op[lindex].real(); } - ret.emplace_back(op.name, op.group, op.source_site, op.dx, op.dy, A); + ret.emplace_back(op.name, op.group, op.source_site, op.dx, op.dy, A, coeff); } else { ret.emplace_back(op.name, op.group, op.source_site, op.dx, op.dy, - op.ops_indices); + op.ops_indices, coeff); } } return ret; diff --git a/src/iTPS/multisite_obs.cpp b/src/iTPS/multisite_obs.cpp index cacb8f02..54819856 100644 --- a/src/iTPS/multisite_obs.cpp +++ b/src/iTPS/multisite_obs.cpp @@ -202,7 +202,7 @@ auto iTPS::measure_multisite() core::Contract(C_, eTt_, eTr_, eTb_, eTl_, Tn_, op_, is_density, is_meanfield); value += localvalue; } - ret[op.group][{op.source_site, op.dx, op.dy}] = value / norm; + ret[op.group][{op.source_site, op.dx, op.dy}] = op.coeff * value / norm; } // ret.push_back(norms); diff --git a/src/iTPS/onesite_obs.cpp b/src/iTPS/onesite_obs.cpp index be395e9c..a5b442db 100644 --- a/src/iTPS/onesite_obs.cpp +++ b/src/iTPS/onesite_obs.cpp @@ -66,7 +66,7 @@ auto iTPS::measure_onesite() for (auto const &op : onesite_operators) { const int i = op.source_site; const auto val = core::Contract_one_site_iTPS_MF(Tn_[i], op.op); - local_obs[op.group][i] = val / norm[i]; + local_obs[op.group][i] = op.coeff * val / norm[i]; } } else { // CTM if (is_density) { @@ -80,7 +80,7 @@ auto iTPS::measure_onesite() const auto val = core::Contract_one_site_density_CTM( C1[i], C2[i], C3[i], C4[i], eTt[i], eTr[i], eTb[i], eTl[i], Tn[i], op.op); - local_obs[op.group][i] = val / norm[i]; + local_obs[op.group][i] = op.coeff * val / norm[i]; } } else { for (int i = 0; i < N_UNIT; ++i) { @@ -93,7 +93,7 @@ auto iTPS::measure_onesite() const auto val = core::Contract_one_site_iTPS_CTM( C1[i], C2[i], C3[i], C4[i], eTt[i], eTr[i], eTb[i], eTl[i], Tn[i], op.op); - local_obs[op.group][i] = val / norm[i]; + local_obs[op.group][i] = op.coeff * val / norm[i]; } } } @@ -240,7 +240,7 @@ auto iTPS::measure_onesite_density() const auto val = core::Contract_one_site_density_CTM( C1[i], C2[i], C3[i], C4[i], eTt[i], eTr[i], eTb[i], eTl[i], Tn[i], op.op); - local_obs[op.group][i] = val / norm[i]; + local_obs[op.group][i] = op.coeff * val / norm[i]; } // } double norm_real_min = 1e100; diff --git a/src/iTPS/twosite_obs.cpp b/src/iTPS/twosite_obs.cpp index 6fd5279f..4c7625d1 100644 --- a/src/iTPS/twosite_obs.cpp +++ b/src/iTPS/twosite_obs.cpp @@ -258,7 +258,7 @@ auto iTPS::measure_twosite() // : core::Contract_CTM(C_, eTt_, eTr_, eTb_, eTl_, Tn_, op_); value += localvalue; } - ret[op.group][{op.source_site, op.dx[0], op.dy[0]}] = value / norm; + ret[op.group][{op.source_site, op.dx[0], op.dy[0]}] = op.coeff * value / norm; } ret.push_back(norms); @@ -583,7 +583,7 @@ auto iTPS::measure_twosite_density() } } } - ret[op.group][{op.source_site, op.dx[0], op.dy[0]}] = value / norm; + ret[op.group][{op.source_site, op.dx[0], op.dy[0]}] = op.coeff * value / norm; } ret.push_back(norms); diff --git a/src/operator.hpp b/src/operator.hpp index 5ba78909..f67df65a 100644 --- a/src/operator.hpp +++ b/src/operator.hpp @@ -19,11 +19,14 @@ #include #include +#include namespace tenes { template struct Operator { + using value_type = typename tensor::value_type; + std::string name; int group; int source_site; @@ -31,6 +34,7 @@ struct Operator { std::vector dy; tensor op; std::vector ops_indices; + typename tensor::value_type coeff; /*! * @brief Constructor for a one-site operator. @@ -39,9 +43,10 @@ struct Operator { * @param[in] group Group of the operator. * @param[in] site Site of the operator. * @param[in] op Operator tensor. + * @param[in] coeff coefficient of operator (default: 1.0). */ - Operator(std::string const &name, int group, int site, tensor const &op) - : name(name), group(group), source_site(site), dx(0), dy(0), op(op) { + Operator(std::string const &name, int group, int site, tensor const &op, value_type coeff=static_cast(1.0)) + : name(name), group(group), source_site(site), dx(0), dy(0), op(op), coeff(coeff) { if (op.rank() != 2) { throw std::runtime_error("Operator tensor must be rank 2."); } @@ -56,15 +61,17 @@ struct Operator { * @param[in] dx X displacement of the other site. * @param[in] dy Y displacement of the other site. * @param[in] op Operator tensor. + * @param[in] coeff coefficient of operator (default: 1.0). */ Operator(std::string const &name, int group, int source_site, int dx, int dy, - tensor const &op) + tensor const &op, value_type coeff=static_cast(1.0)) : name(name), group(group), source_site(source_site), dx(1, dx), dy(1, dy), - op(op) { + op(op), + coeff(coeff) { if (op.rank() != 4) { throw std::runtime_error("Operator tensor must be rank 4."); } @@ -80,15 +87,17 @@ struct Operator { * @param[in] dx X displacement of the other site. * @param[in] dy Y displacement of the other site. * @param[in] ops_indices Onesite operator indices. + * @param[in] coeff coefficient of operator (default: 1.0). */ Operator(std::string const &name, int group, int source_site, int dx, int dy, - std::vector const &ops_indices) + std::vector const &ops_indices, value_type coeff=static_cast(1.0)) : name(name), group(group), source_site(source_site), dx(1, dx), dy(1, dy), - ops_indices(ops_indices) { + ops_indices(ops_indices), + coeff(coeff){ if (ops_indices.size() != 2) { throw std::runtime_error( "Operator must be a product of two one-site operators."); @@ -104,16 +113,18 @@ struct Operator { * @param[in] dx X displacement of the other sites. * @param[in] dy Y displacement of the other sites. * @param[in] op Operator tensor. + * @param[in] coeff coefficient of operator (default: 1.0). */ Operator(std::string const &name, int group, int source_site, std::vector const &dx, std::vector const &dy, - tensor const &op) + tensor const &op, value_type coeff=static_cast(1.0)) : name(name), group(group), source_site(source_site), dx(dx), dy(dy), - op(op) { + op(op), + coeff(coeff) { if (dx.size() != dy.size()) { throw std::runtime_error("dx and dy must have the same size."); } @@ -132,16 +143,18 @@ struct Operator { * @param[in] dx X displacement of the other sites. * @param[in] dy Y displacement of the other sites. * @param[in] ops_indices Onesite operator indices. + * @param[in] coeff coefficient of operator (default: 1.0). */ Operator(std::string const &name, int group, int source_site, std::vector const &dx, std::vector const &dy, - std::vector const &ops_indices) + std::vector const &ops_indices, value_type coeff=static_cast(1.0)) : name(name), group(group), source_site(source_site), dx(dx), dy(dy), - ops_indices(ops_indices) { + ops_indices(ops_indices), + coeff(coeff) { if (dx.size() != dy.size()) { throw std::runtime_error("dx and dy must have the same size."); } diff --git a/test/data/AntiferroHeisenberg_real.toml b/test/data/AntiferroHeisenberg_real.toml index 614a54a6..2bf19c6f 100644 --- a/test/data/AntiferroHeisenberg_real.toml +++ b/test/data/AntiferroHeisenberg_real.toml @@ -44,6 +44,16 @@ elements = """ 1 0 0.5 0.0 0 1 0.5 0.0 """ +[[observable.onesite]] +name = "2Sz" +group = 2 +sites = [] +dim = 2 +elements = """ +0 0 0.5 0.0 +1 1 -0.5 0.0 +""" +coeff = 2.0 [[observable.twosite]] name = "bond_hamiltonian" @@ -115,6 +125,21 @@ elements = """ 1 0 0 1 0.25 0.0 0 0 1 1 -0.25 0.0 """ +[[observable.twosite]] +name = "2SzSz" +group = 4 +bonds = """ +0 1 0 +1 1 0 +2 1 0 +3 1 0 +0 0 1 +1 0 1 +2 0 1 +3 0 1 +""" +ops = [0, 0] +coeff = 2.0 [[observable.multisite]] name = "SzSzSzSz" @@ -127,6 +152,18 @@ multisites = """ """ ops = [0,0,0,0] +[[observable.multisite]] +name = "2SzSzSzSz" +group = 1 +multisites = """ +0 1 0 1 1 0 1 +1 1 0 1 1 0 1 +2 1 0 1 1 0 1 +3 1 0 1 1 0 1 +""" +ops = [0,0,0,0] +coeff = 2.0 + [evolution] [[evolution.simple]] source_site = 0 diff --git a/test/data/output_AntiferroHeisenberg_real/AntiferroHeisenberg_real.toml b/test/data/output_AntiferroHeisenberg_real/AntiferroHeisenberg_real.toml index 658a50db..2bf19c6f 100644 --- a/test/data/output_AntiferroHeisenberg_real/AntiferroHeisenberg_real.toml +++ b/test/data/output_AntiferroHeisenberg_real/AntiferroHeisenberg_real.toml @@ -21,6 +21,10 @@ virtual_dim = [2, 2, 2, 2] initial_state = [0.0] noise = 0.01 +[correlation] +r_max = 3 +operators = [[0,0], [0,1]] + [observable] [[observable.onesite]] name = "Sz" @@ -40,9 +44,19 @@ elements = """ 1 0 0.5 0.0 0 1 0.5 0.0 """ +[[observable.onesite]] +name = "2Sz" +group = 2 +sites = [] +dim = 2 +elements = """ +0 0 0.5 0.0 +1 1 -0.5 0.0 +""" +coeff = 2.0 [[observable.twosite]] -name = "hamiltonian" +name = "bond_hamiltonian" group = 0 bonds = """ 0 1 0 @@ -111,6 +125,44 @@ elements = """ 1 0 0 1 0.25 0.0 0 0 1 1 -0.25 0.0 """ +[[observable.twosite]] +name = "2SzSz" +group = 4 +bonds = """ +0 1 0 +1 1 0 +2 1 0 +3 1 0 +0 0 1 +1 0 1 +2 0 1 +3 0 1 +""" +ops = [0, 0] +coeff = 2.0 + +[[observable.multisite]] +name = "SzSzSzSz" +group = 0 +multisites = """ +0 1 0 1 1 0 1 +1 1 0 1 1 0 1 +2 1 0 1 1 0 1 +3 1 0 1 1 0 1 +""" +ops = [0,0,0,0] + +[[observable.multisite]] +name = "2SzSzSzSz" +group = 1 +multisites = """ +0 1 0 1 1 0 1 +1 1 0 1 1 0 1 +2 1 0 1 1 0 1 +3 1 0 1 1 0 1 +""" +ops = [0,0,0,0] +coeff = 2.0 [evolution] [[evolution.simple]] diff --git a/test/data/output_AntiferroHeisenberg_real/correlation.dat b/test/data/output_AntiferroHeisenberg_real/correlation.dat index 558b18e2..cac72c45 100644 --- a/test/data/output_AntiferroHeisenberg_real/correlation.dat +++ b/test/data/output_AntiferroHeisenberg_real/correlation.dat @@ -9,52 +9,53 @@ # The names of operators are the following: # 0: Sz # 1: Sx +# 2: 2Sz -0 0 0 1 0 -1.61814083059261232e-01 0.00000000000000000e+00 -0 0 1 1 0 -7.69262211008062136e-02 0.00000000000000000e+00 -0 0 0 2 0 1.51101865176695660e-01 0.00000000000000000e+00 -0 0 1 2 0 -7.68731988366160718e-02 0.00000000000000000e+00 -0 0 0 3 0 -1.49061437639722988e-01 0.00000000000000000e+00 -0 0 1 3 0 -4.86911672846061377e-02 0.00000000000000000e+00 -0 0 0 0 1 -1.33324968627196561e-01 0.00000000000000000e+00 -0 0 1 0 1 -1.09228626247116448e-01 0.00000000000000000e+00 -0 0 0 0 2 1.47921448594502625e-01 0.00000000000000000e+00 -0 0 1 0 2 -7.70665086768835550e-02 0.00000000000000000e+00 -0 0 0 0 3 -1.32305314089022769e-01 0.00000000000000000e+00 -0 0 1 0 3 -9.14168175696279950e-02 0.00000000000000000e+00 -0 1 0 1 0 -1.62023966039102713e-01 0.00000000000000000e+00 -0 1 1 1 0 9.83353666819980904e-02 0.00000000000000000e+00 -0 1 0 2 0 1.52489835935105650e-01 0.00000000000000000e+00 -0 1 1 2 0 4.65300818653293785e-02 0.00000000000000000e+00 -0 1 0 3 0 -1.49056944997098123e-01 0.00000000000000000e+00 -0 1 1 3 0 7.95224809542846023e-02 0.00000000000000000e+00 -0 1 0 0 1 -1.71118008938635602e-01 0.00000000000000000e+00 -0 1 1 0 1 -2.45303989785474498e-02 0.00000000000000000e+00 -0 1 0 0 2 1.52001220434321266e-01 0.00000000000000000e+00 -0 1 1 0 2 4.68802665173839034e-02 0.00000000000000000e+00 -0 1 0 0 3 -1.46855044813913649e-01 0.00000000000000000e+00 -0 1 1 0 3 -3.79097815452288656e-02 0.00000000000000000e+00 -0 2 0 1 0 -1.65776212997030048e-01 0.00000000000000000e+00 -0 2 1 1 0 -2.85894408258394270e-03 0.00000000000000000e+00 -0 2 0 2 0 1.26142514742576900e-01 0.00000000000000000e+00 -0 2 1 2 0 7.72324683987457572e-02 0.00000000000000000e+00 -0 2 0 3 0 -1.30780421583722717e-01 0.00000000000000000e+00 -0 2 1 3 0 -3.26773769543835246e-02 0.00000000000000000e+00 -0 2 0 0 1 -1.33365169593476440e-01 0.00000000000000000e+00 -0 2 1 0 1 8.92440518635981700e-02 0.00000000000000000e+00 -0 2 0 0 2 1.20436413956494903e-01 0.00000000000000000e+00 -0 2 1 0 2 8.10044814931354384e-02 0.00000000000000000e+00 -0 2 0 0 3 -1.32303915371563996e-01 0.00000000000000000e+00 -0 2 1 0 3 7.07780020062377252e-02 0.00000000000000000e+00 -0 3 0 1 0 -1.66391777687540071e-01 0.00000000000000000e+00 -0 3 1 1 0 -8.14152807029617093e-02 0.00000000000000000e+00 -0 3 0 2 0 1.44059463516688607e-01 0.00000000000000000e+00 -0 3 1 2 0 3.18357113679693451e-02 0.00000000000000000e+00 -0 3 0 3 0 -1.30790812987773120e-01 0.00000000000000000e+00 -0 3 1 3 0 -8.95361260748531312e-02 0.00000000000000000e+00 -0 3 0 0 1 -1.71537906054281014e-01 0.00000000000000000e+00 -0 3 1 0 1 -3.54238944218439461e-02 0.00000000000000000e+00 -0 3 0 0 2 1.43331346702437440e-01 0.00000000000000000e+00 -0 3 1 0 2 3.32403019967970059e-02 0.00000000000000000e+00 -0 3 0 0 3 -1.46856745636973290e-01 0.00000000000000000e+00 -0 3 1 0 3 -4.73152954282259133e-02 0.00000000000000000e+00 +0 0 0 1 0 -1.61814083059259678e-01 0.00000000000000000e+00 +0 0 1 1 0 -7.69262211008061580e-02 0.00000000000000000e+00 +0 0 0 2 0 1.51101865176693384e-01 0.00000000000000000e+00 +0 0 1 2 0 -7.68731988366181673e-02 0.00000000000000000e+00 +0 0 0 3 0 -1.49061437639721545e-01 0.00000000000000000e+00 +0 0 1 3 0 -4.86911672846055896e-02 0.00000000000000000e+00 +0 0 0 0 1 -1.33324968627193369e-01 0.00000000000000000e+00 +0 0 1 0 1 -1.09228626247116767e-01 0.00000000000000000e+00 +0 0 0 0 2 1.47921448594500127e-01 0.00000000000000000e+00 +0 0 1 0 2 -7.70665086768852758e-02 0.00000000000000000e+00 +0 0 0 0 3 -1.32305314089019938e-01 0.00000000000000000e+00 +0 0 1 0 3 -9.14168175696282170e-02 0.00000000000000000e+00 +0 1 0 1 0 -1.62023966039100908e-01 0.00000000000000000e+00 +0 1 1 1 0 9.83353666819996586e-02 0.00000000000000000e+00 +0 1 0 2 0 1.52489835935104817e-01 0.00000000000000000e+00 +0 1 1 2 0 4.65300818653292397e-02 0.00000000000000000e+00 +0 1 0 3 0 -1.49056944997096569e-01 0.00000000000000000e+00 +0 1 1 3 0 7.95224809542867533e-02 0.00000000000000000e+00 +0 1 0 0 1 -1.71118008938634658e-01 0.00000000000000000e+00 +0 1 1 0 1 -2.45303989785445077e-02 0.00000000000000000e+00 +0 1 0 0 2 1.52001220434320433e-01 0.00000000000000000e+00 +0 1 1 0 2 4.68802665173836675e-02 0.00000000000000000e+00 +0 1 0 0 3 -1.46855044813912455e-01 0.00000000000000000e+00 +0 1 1 0 3 -3.79097815452261108e-02 0.00000000000000000e+00 +0 2 0 1 0 -1.65776212997028355e-01 0.00000000000000000e+00 +0 2 1 1 0 -2.85894408258031843e-03 0.00000000000000000e+00 +0 2 0 2 0 1.26142514742574346e-01 0.00000000000000000e+00 +0 2 1 2 0 7.72324683987454935e-02 0.00000000000000000e+00 +0 2 0 3 0 -1.30780421583720247e-01 0.00000000000000000e+00 +0 2 1 3 0 -3.26773769543806450e-02 0.00000000000000000e+00 +0 2 0 0 1 -1.33365169593473304e-01 0.00000000000000000e+00 +0 2 1 0 1 8.92440518635987251e-02 0.00000000000000000e+00 +0 2 0 0 2 1.20436413956491697e-01 0.00000000000000000e+00 +0 2 1 0 2 8.10044814931352858e-02 0.00000000000000000e+00 +0 2 0 0 3 -1.32303915371561137e-01 0.00000000000000000e+00 +0 2 1 0 3 7.07780020062389048e-02 0.00000000000000000e+00 +0 3 0 1 0 -1.66391777687538850e-01 0.00000000000000000e+00 +0 3 1 1 0 -8.14152807029630693e-02 0.00000000000000000e+00 +0 3 0 2 0 1.44059463516686886e-01 0.00000000000000000e+00 +0 3 1 2 0 3.18357113679664239e-02 0.00000000000000000e+00 +0 3 0 3 0 -1.30790812987770622e-01 0.00000000000000000e+00 +0 3 1 3 0 -8.95361260748535476e-02 0.00000000000000000e+00 +0 3 0 0 1 -1.71537906054279793e-01 0.00000000000000000e+00 +0 3 1 0 1 -3.54238944218441265e-02 0.00000000000000000e+00 +0 3 0 0 2 1.43331346702435913e-01 0.00000000000000000e+00 +0 3 1 0 2 3.32403019967941263e-02 0.00000000000000000e+00 +0 3 0 0 3 -1.46856745636971792e-01 0.00000000000000000e+00 +0 3 1 0 3 -4.73152954282254692e-02 0.00000000000000000e+00 diff --git a/test/data/output_AntiferroHeisenberg_real/correlation_length.dat b/test/data/output_AntiferroHeisenberg_real/correlation_length.dat index dad3699e..5206f280 100644 --- a/test/data/output_AntiferroHeisenberg_real/correlation_length.dat +++ b/test/data/output_AntiferroHeisenberg_real/correlation_length.dat @@ -5,7 +5,7 @@ # $4-: eigenvalues e_i = -log|t_i/t_0| # where i > 0 and t_i is i-th largest eigenvalue of T -0 0 8.44994724744467240e-01 1.18343934076323087e+00 1.31217387840878708e+00 1.50088448589389079e+00 -0 1 8.45007547885713084e-01 1.18342138185876844e+00 1.31207991892442499e+00 1.49884260767436839e+00 -1 0 7.09058133674783431e-01 1.41032159777559229e+00 1.57230304927109032e+00 1.80264278143236978e+00 -1 1 7.09013376311946608e-01 1.41041062610365642e+00 1.57276526937484551e+00 1.80524017948036231e+00 +0 0 8.44994724744483339e-01 1.18343934076320823e+00 1.31217387840875177e+00 1.50088448589384638e+00 +0 1 8.45007547885718746e-01 1.18342138185876045e+00 1.31207991892443365e+00 1.49884260767438549e+00 +1 0 7.09058133674792535e-01 1.41032159777557409e+00 1.57230304927106412e+00 1.80264278143232781e+00 +1 1 7.09013376311950050e-01 1.41041062610364953e+00 1.57276526937485217e+00 1.80524017948038074e+00 diff --git a/test/data/output_AntiferroHeisenberg_real/density.dat b/test/data/output_AntiferroHeisenberg_real/density.dat index bb99b257..aa2cde5d 100644 --- a/test/data/output_AntiferroHeisenberg_real/density.dat +++ b/test/data/output_AntiferroHeisenberg_real/density.dat @@ -1,8 +1,11 @@ -Energy = -5.43694699199371301e-01 0.00000000000000000e+00 -Sz = 6.11534505262875672e-03 0.00000000000000000e+00 -Sx = -1.18113776629292302e-01 0.00000000000000000e+00 -bond_hamiltonian = -5.43694699199371301e-01 0.00000000000000000e+00 -SzSz = -3.16338023249131073e-01 0.00000000000000000e+00 -SxSx = -8.55764725464009945e-02 0.00000000000000000e+00 -SySy = -1.41780203403839261e-01 0.00000000000000000e+00 -SzSzSzSz = 3.00538294519135732e-02 0.00000000000000000e+00 +Energy = -5.43694699199365972e-01 0.00000000000000000e+00 +Sz = 6.11534505262877059e-03 0.00000000000000000e+00 +Sx = -1.18113776629296119e-01 0.00000000000000000e+00 +2Sz = 1.22306901052575412e-02 0.00000000000000000e+00 +bond_hamiltonian = -5.43694699199365972e-01 0.00000000000000000e+00 +SzSz = -3.16338023249127298e-01 0.00000000000000000e+00 +SxSx = -8.55764725463981218e-02 0.00000000000000000e+00 +SySy = -1.41780203403840510e-01 0.00000000000000000e+00 +2SzSz = -6.32676046498254596e-01 0.00000000000000000e+00 +SzSzSzSz = 3.00538294519129001e-02 0.00000000000000000e+00 +2SzSzSzSz = 6.01076589038258002e-02 0.00000000000000000e+00 diff --git a/test/data/output_AntiferroHeisenberg_real/multisite_obs_4.dat b/test/data/output_AntiferroHeisenberg_real/multisite_obs_4.dat index 73747088..23e78d33 100644 --- a/test/data/output_AntiferroHeisenberg_real/multisite_obs_4.dat +++ b/test/data/output_AntiferroHeisenberg_real/multisite_obs_4.dat @@ -11,8 +11,13 @@ # $10: imag # The names of op_group are the following: # 0: SzSzSzSz +# 1: 2SzSzSzSz -0 0 1 0 1 1 0 1 2.99570527341487293e-02 0.00000000000000000e+00 -0 1 1 0 1 1 0 1 3.00861555469653479e-02 0.00000000000000000e+00 -0 2 1 0 1 1 0 1 3.00214333584342373e-02 0.00000000000000000e+00 -0 3 1 0 1 1 0 1 3.01506761681059714e-02 0.00000000000000000e+00 +0 0 1 0 1 1 0 1 2.99570527341480666e-02 0.00000000000000000e+00 +0 1 1 0 1 1 0 1 3.00861555469647268e-02 0.00000000000000000e+00 +0 2 1 0 1 1 0 1 3.00214333584335157e-02 0.00000000000000000e+00 +0 3 1 0 1 1 0 1 3.01506761681052948e-02 0.00000000000000000e+00 +1 0 1 0 1 1 0 1 5.99141054682961333e-02 0.00000000000000000e+00 +1 1 1 0 1 1 0 1 6.01723110939294537e-02 0.00000000000000000e+00 +1 2 1 0 1 1 0 1 6.00428667168670313e-02 0.00000000000000000e+00 +1 3 1 0 1 1 0 1 6.03013523362105897e-02 0.00000000000000000e+00 diff --git a/test/data/output_AntiferroHeisenberg_real/onesite_obs.dat b/test/data/output_AntiferroHeisenberg_real/onesite_obs.dat index 26109d50..7e62ce11 100644 --- a/test/data/output_AntiferroHeisenberg_real/onesite_obs.dat +++ b/test/data/output_AntiferroHeisenberg_real/onesite_obs.dat @@ -4,19 +4,24 @@ # $3: real # $4: imag # The names of op_group are the following: -# 0: Sz -# 1: Sx +# 0: Sz +# 1: Sx +# 2: 2Sz # -1: norm -0 0 3.82993056788538233e-01 0.00000000000000000e+00 -0 1 -3.89547536347500889e-01 0.00000000000000000e+00 -0 2 -3.45608673013142298e-01 0.00000000000000000e+00 -0 3 3.76624532782616039e-01 0.00000000000000000e+00 -1 0 -2.04721312181347537e-01 0.00000000000000000e+00 -1 1 -1.27047473942019484e-01 0.00000000000000000e+00 -1 2 -2.38535026007565459e-01 0.00000000000000000e+00 -1 3 9.78487056137541805e-02 0.00000000000000000e+00 --1 0 7.06065905040426989e-01 0.00000000000000000e+00 --1 1 7.43593497668431858e-01 0.00000000000000000e+00 --1 2 7.51167269076829069e-01 0.00000000000000000e+00 --1 3 6.72513272653018523e-01 0.00000000000000000e+00 +0 0 3.82993056788538955e-01 0.00000000000000000e+00 +0 1 -3.89547536347500223e-01 0.00000000000000000e+00 +0 2 -3.45608673013137857e-01 0.00000000000000000e+00 +0 3 3.76624532782614208e-01 0.00000000000000000e+00 +1 0 -2.04721312181346732e-01 0.00000000000000000e+00 +1 1 -1.27047473942022121e-01 0.00000000000000000e+00 +1 2 -2.38535026007569151e-01 0.00000000000000000e+00 +1 3 9.78487056137536115e-02 0.00000000000000000e+00 +2 0 7.65986113577077909e-01 0.00000000000000000e+00 +2 1 -7.79095072695000446e-01 0.00000000000000000e+00 +2 2 -6.91217346026275714e-01 0.00000000000000000e+00 +2 3 7.53249065565228415e-01 0.00000000000000000e+00 +-1 0 7.06065905040425768e-01 0.00000000000000000e+00 +-1 1 7.43593497668432746e-01 0.00000000000000000e+00 +-1 2 7.51167269076826738e-01 0.00000000000000000e+00 +-1 3 6.72513272653016414e-01 0.00000000000000000e+00 diff --git a/test/data/output_AntiferroHeisenberg_real/parameters.dat b/test/data/output_AntiferroHeisenberg_real/parameters.dat index 151a9543..61dc847c 100644 --- a/test/data/output_AntiferroHeisenberg_real/parameters.dat +++ b/test/data/output_AntiferroHeisenberg_real/parameters.dat @@ -22,6 +22,8 @@ use_rsvd = false rsvd_oversampling_factor = 2 meanfield_env = false +mode = ground state +simple Lcor = 0 seed = 11 is_real = 1 @@ -34,4 +36,4 @@ outdir = output_AntiferroHeisenberg_real Lsub = [ 2 , 2 ] skew = 0 -start_datetime = 2023-06-07T16:31:03+09:00 +start_datetime = 2024-01-15T23:23:01+09:00 diff --git a/test/data/output_AntiferroHeisenberg_real/twosite_obs.dat b/test/data/output_AntiferroHeisenberg_real/twosite_obs.dat index 93a66d7a..ecf9697c 100644 --- a/test/data/output_AntiferroHeisenberg_real/twosite_obs.dat +++ b/test/data/output_AntiferroHeisenberg_real/twosite_obs.dat @@ -6,49 +6,58 @@ # $5: real # $6: imag # The names of op_group are the following: -# 0: hamiltonian -# 1: SzSz -# 2: SxSx -# 3: SySy +# 0: bond_hamiltonian +# 1: SzSz +# 2: SxSx +# 3: SySy +# 4: 2SzSz # -1: norm -0 0 0 1 -1.66584129761267519e-01 0.00000000000000000e+00 -0 0 1 0 -2.61373275291908735e-01 0.00000000000000000e+00 -0 1 0 1 -3.21160656464442973e-01 0.00000000000000000e+00 -0 1 1 0 -2.62784471088295724e-01 0.00000000000000000e+00 -0 2 0 1 -1.67312423722473624e-01 0.00000000000000000e+00 -0 2 1 0 -3.35067831613584444e-01 0.00000000000000000e+00 -0 3 0 1 -3.22957384828300387e-01 0.00000000000000000e+00 -0 3 1 0 -3.37538624027198475e-01 0.00000000000000000e+00 -1 0 0 1 -1.33324968627194868e-01 0.00000000000000000e+00 -1 0 1 0 -1.61814083059259678e-01 0.00000000000000000e+00 -1 1 0 1 -1.71118008938635324e-01 0.00000000000000000e+00 -1 1 1 0 -1.62023966039101103e-01 0.00000000000000000e+00 -1 2 0 1 -1.33365169593474941e-01 0.00000000000000000e+00 -1 2 1 0 -1.65776212997030326e-01 0.00000000000000000e+00 -1 3 0 1 -1.71537906054280792e-01 0.00000000000000000e+00 -1 3 1 0 -1.66391777687539821e-01 0.00000000000000000e+00 -2 0 0 1 1.69979452151880171e-02 0.00000000000000000e+00 -2 0 1 0 -2.68075650106709765e-02 0.00000000000000000e+00 -2 1 0 1 -7.43982975314806949e-02 0.00000000000000000e+00 -2 1 1 0 -2.73263995592405579e-02 0.00000000000000000e+00 -2 2 0 1 1.67249333950529773e-02 0.00000000000000000e+00 -2 2 1 0 -8.57656256668481581e-02 0.00000000000000000e+00 -2 3 0 1 -7.50642098592703699e-02 0.00000000000000000e+00 -2 3 1 0 -8.66666711683256874e-02 0.00000000000000000e+00 -3 0 0 1 -5.02571063492606718e-02 0.00000000000000000e+00 -3 0 1 0 -7.27516272219781851e-02 0.00000000000000000e+00 -3 1 0 1 -7.56443499943268149e-02 0.00000000000000000e+00 -3 1 1 0 -7.34341054899541185e-02 0.00000000000000000e+00 -3 2 0 1 -5.06721875240518163e-02 0.00000000000000000e+00 -3 2 1 0 -8.35259929497060571e-02 0.00000000000000000e+00 -3 3 0 1 -7.63552689147493080e-02 0.00000000000000000e+00 -3 3 1 0 -8.44801751713327859e-02 0.00000000000000000e+00 --1 0 0 1 5.15823310085911979e-01 0.00000000000000000e+00 --1 0 1 0 5.27867949487865862e-01 0.00000000000000000e+00 --1 1 0 1 5.15206590510061679e-01 0.00000000000000000e+00 --1 1 1 0 4.86751317029447073e-01 0.00000000000000000e+00 --1 2 0 1 4.88534553522139314e-01 0.00000000000000000e+00 --1 2 1 0 5.27355982720729588e-01 0.00000000000000000e+00 --1 3 0 1 4.88243759924334775e-01 0.00000000000000000e+00 --1 3 1 0 4.86525799277800153e-01 0.00000000000000000e+00 +0 0 0 1 -1.66584129761265548e-01 0.00000000000000000e+00 +0 0 1 0 -2.61373275291908513e-01 0.00000000000000000e+00 +0 1 0 1 -3.21160656464443139e-01 0.00000000000000000e+00 +0 1 1 0 -2.62784471088293947e-01 0.00000000000000000e+00 +0 2 0 1 -1.67312423722470932e-01 0.00000000000000000e+00 +0 2 1 0 -3.35067831613582723e-01 0.00000000000000000e+00 +0 3 0 1 -3.22957384828299499e-01 0.00000000000000000e+00 +0 3 1 0 -3.37538624027199752e-01 0.00000000000000000e+00 +1 0 0 1 -1.33324968627193452e-01 0.00000000000000000e+00 +1 0 1 0 -1.61814083059259706e-01 0.00000000000000000e+00 +1 1 0 1 -1.71118008938634658e-01 0.00000000000000000e+00 +1 1 1 0 -1.62023966039100881e-01 0.00000000000000000e+00 +1 2 0 1 -1.33365169593473304e-01 0.00000000000000000e+00 +1 2 1 0 -1.65776212997028355e-01 0.00000000000000000e+00 +1 3 0 1 -1.71537906054279987e-01 0.00000000000000000e+00 +1 3 1 0 -1.66391777687538794e-01 0.00000000000000000e+00 +2 0 0 1 1.69979452151889088e-02 0.00000000000000000e+00 +2 0 1 0 -2.68075650106703658e-02 0.00000000000000000e+00 +2 1 0 1 -7.43982975314810419e-02 0.00000000000000000e+00 +2 1 1 0 -2.73263995592394823e-02 0.00000000000000000e+00 +2 2 0 1 1.67249333950540459e-02 0.00000000000000000e+00 +2 2 1 0 -8.57656256668478112e-02 0.00000000000000000e+00 +2 3 0 1 -7.50642098592703005e-02 0.00000000000000000e+00 +2 3 1 0 -8.66666711683264507e-02 0.00000000000000000e+00 +3 0 0 1 -5.02571063492610673e-02 0.00000000000000000e+00 +3 0 1 0 -7.27516272219783794e-02 0.00000000000000000e+00 +3 1 0 1 -7.56443499943273423e-02 0.00000000000000000e+00 +3 1 1 0 -7.34341054899534801e-02 0.00000000000000000e+00 +3 2 0 1 -5.06721875240516845e-02 0.00000000000000000e+00 +3 2 1 0 -8.35259929497065290e-02 0.00000000000000000e+00 +3 3 0 1 -7.63552689147491831e-02 0.00000000000000000e+00 +3 3 1 0 -8.44801751713343679e-02 0.00000000000000000e+00 +4 0 0 1 -2.66649937254386904e-01 0.00000000000000000e+00 +4 0 1 0 -3.23628166118519411e-01 0.00000000000000000e+00 +4 1 0 1 -3.42236017877269316e-01 0.00000000000000000e+00 +4 1 1 0 -3.24047932078201761e-01 0.00000000000000000e+00 +4 2 0 1 -2.66730339186946608e-01 0.00000000000000000e+00 +4 2 1 0 -3.31552425994056710e-01 0.00000000000000000e+00 +4 3 0 1 -3.43075812108559974e-01 0.00000000000000000e+00 +4 3 1 0 -3.32783555375077589e-01 0.00000000000000000e+00 +-1 0 0 1 5.15823310085911646e-01 0.00000000000000000e+00 +-1 0 1 0 5.27867949487862531e-01 0.00000000000000000e+00 +-1 1 0 1 5.15206590510061568e-01 0.00000000000000000e+00 +-1 1 1 0 4.86751317029445851e-01 0.00000000000000000e+00 +-1 2 0 1 4.88534553522136039e-01 0.00000000000000000e+00 +-1 2 1 0 5.27355982720726590e-01 0.00000000000000000e+00 +-1 3 0 1 4.88243759924331056e-01 0.00000000000000000e+00 +-1 3 1 0 4.86525799277798876e-01 0.00000000000000000e+00 diff --git a/tool/tenes_std.py b/tool/tenes_std.py index b6560a00..240a072d 100644 --- a/tool/tenes_std.py +++ b/tool/tenes_std.py @@ -381,7 +381,9 @@ def check(self) -> None: Raises RuntimeError if any information is invalid. """ if not (isinstance(self.L, list) and len(self.L) == 2 and all_positive(self.L)): - msg = "L_sub should be a positive integer or a list with 2 positive integers" + msg = ( + "L_sub should be a positive integer or a list with 2 positive integers" + ) raise RuntimeError(msg) failed = False @@ -581,7 +583,7 @@ def __init__( *, elements: Optional[np.ndarray] = None, ops: Optional[List[int]] = None, - group: Optional[int] = None + group: Optional[int] = None, ): self.bond = bond self.group = group @@ -630,14 +632,26 @@ class OnesiteObservable: elements: np.ndarray sites: List[int] name: str + coeff: float + coeff_im: float - def __init__(self, group: int, elements: np.ndarray, sites: List[int], name: str): + def __init__( + self, + group: int, + elements: np.ndarray, + sites: List[int], + name: str = "", + coeff: float = 1.0, + coeff_im: float = 0.0, + ): self.group = group assert elements.ndim == 2 assert elements.shape[0] == elements.shape[1] self.elements = elements self.sites = sites self.name = name + self.coeff = coeff + self.coeff_im = coeff_im def to_toml_strs(self) -> List[str]: ret = [] @@ -663,6 +677,8 @@ def to_toml_strs(self) -> List[str]: ret.append(line) it.iternext() ret.append('"""') + ret.append("coeff = {}".format(self.coeff)) + ret.append("coeff_im = {}".format(self.coeff_im)) return ret @@ -672,6 +688,8 @@ class TwositeObservable: elements: Optional[np.ndarray] ops: Optional[List[int]] name: str + coeff: float + coeff_re: float def __init__( self, @@ -680,7 +698,9 @@ def __init__( *, elements: np.ndarray = None, ops: List[int] = None, - name: str = "" + name: str = "", + coeff: float = 1.0, + coeff_im: float = 0.0, ): self.group = group if elements is not None: @@ -697,6 +717,8 @@ def __init__( self.ops = ops self.bonds = bonds self.name = name + self.coeff = coeff + self.coeff_im = coeff_im def to_toml_strs(self) -> List[str]: ret = [] @@ -728,6 +750,8 @@ def to_toml_strs(self) -> List[str]: ret.append('"""') else: ret.append("ops = {}".format(self.ops)) + ret.append("coeff = {}".format(self.coeff)) + ret.append("coeff_im = {}".format(self.coeff_im)) return ret def to_twosite_operators(self) -> List[NNOperator]: @@ -742,9 +766,17 @@ class MultisiteObservable: multisites: List[Multisite] ops: List[int] name: str + coeff: float + coeff_im: float def __init__( - self, group: int, multisites: List[Multisite], ops: List[int], name: str = "" + self, + group: int, + multisites: List[Multisite], + ops: List[int], + name: str = "", + coeff: float = 1.0, + coeff_im: float = 0.0, ): self.group = group self.multisites = multisites @@ -753,6 +785,8 @@ def __init__( raise ValueError("Multisites have different number of sites") self.ops = ops self.name = name + self.coeff = coeff + self.coeff_im = coeff_im def nsites(self) -> int: return self.multisites[0].nsites() @@ -764,11 +798,13 @@ def to_toml_strs(self) -> List[str]: ret.append('multisites = """') for ms in self.multisites: line = str(ms.source_site) - for i in range(ms.nsites()-1): + for i in range(ms.nsites() - 1): line += f" {ms.dx[i]} {ms.dy[i]}" ret.append(line) ret.append('"""') ret.append("ops = {}".format(self.ops)) + ret.append("coeff = {}".format(self.coeff)) + ret.append("coeff_im = {}".format(self.coeff_im)) return ret @@ -809,8 +845,8 @@ def make_evolution_twosite( source = hamiltonian.bond.source_site dx = hamiltonian.bond.dx dy = hamiltonian.bond.dy - msg = f"A bond term of Hamiltonian connects a source site {source} and a target site (dx, dy) = ({dx}, {dy}) " - msg += "but they are disconnected. please check the dimensions of virtual bonds (D=1 bonds are disconnected)." + msg = f"A bond term of Hamiltonian connects a source site {source} and a target site (dx, dy) = ({dx}, {dy}) " + msg += "but they are disconnected. please check the dimensions of virtual bonds (D=1 bonds are disconnected)." raise RuntimeError(msg) if nhops == 1: