From d9966bad2abfa647803f6f51ea5f18ab6121bfe2 Mon Sep 17 00:00:00 2001
From: Yuichi Motoyama <y-motoyama@issp.u-tokyo.ac.jp>
Date: Fri, 10 Nov 2023 16:17:21 +0900
Subject: [PATCH] mod

---
 src/iTPS/finite_temperature.cpp | 17 +----------------
 src/iTPS/measure.cpp            | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/iTPS/finite_temperature.cpp b/src/iTPS/finite_temperature.cpp
index d6d879c8..dc6fcaa5 100644
--- a/src/iTPS/finite_temperature.cpp
+++ b/src/iTPS/finite_temperature.cpp
@@ -49,21 +49,6 @@ void iTPS<tensor>::finite_temperature() {
     Timer<> timer;
 
     for (int int_tau = 0; int_tau < nsteps; ++int_tau) {
-      // DEBUG
-      std::cerr << int_tau << std::endl;
-      int debug_site_i = 0;
-      typename tensor::value_type v;
-      for (int debug_n = 0; debug_n < Tn[debug_site_i].local_size(); ++debug_n) {
-        mptensor::Index idx = Tn[debug_site_i].global_index(debug_n);
-        Tn[debug_site_i].get_value(idx, v);
-        std::cerr << "DEBUG Tn " << debug_n << " ";
-        for (int d = 0; d < idx.size(); ++d) {
-          std::cerr << idx[d] << " ";
-        }
-        std::cerr << std::scientific << std::setprecision(std::numeric_limits<double>::max_digits10) << std::real(v) << " " << std::imag(v) << std::endl;
-      }
-      std::flush(std::cerr);
-
       auto const& evols = simple_updates;
       for (auto up : evols) {
         if (up.group != group) {
@@ -94,7 +79,7 @@ void iTPS<tensor>::finite_temperature() {
     }  // end of for (int_tau)
     if (measure_interval == 0 || nsteps % measure_interval != 0) {
       Timer<> timer_m;
-      measure_density(beta, "TE_");
+      measure_density(beta, "FT_");
       time_measure += timer_m.elapsed();
     }
     time_simple_update += timer.elapsed() - time_measure;
diff --git a/src/iTPS/measure.cpp b/src/iTPS/measure.cpp
index cc002c0c..c04d28bb 100644
--- a/src/iTPS/measure.cpp
+++ b/src/iTPS/measure.cpp
@@ -113,6 +113,33 @@ void iTPS<ptensor>::measure_density(double beta, std::string filename_prefix) {
   update_CTM_density();
   //  }
 
+  // DEBUG
+#define DUMP_TENSOR(NAME) \
+  { \
+    int site = 0; \
+    for (int n=0; n < NAME[site].local_size(); ++n){ \
+      typename ptensor::value_type v; \
+      mptensor::Index idx = NAME[site].global_index(n); \
+      NAME[site].get_value(idx, v); \
+      std::cerr << "DEBUG " #NAME " " << beta << " "; \
+      for(int d=0; d<idx.size(); ++d){ \
+        std::cerr << idx[d] << " "; \
+      } \
+      std::cerr << std::scientific << std::setprecision(std::numeric_limits<double>::max_digits10) << std::real(v) << " " << std::imag(v) << std::endl; \
+    } \
+  }
+
+  DUMP_TENSOR(C1);
+  DUMP_TENSOR(C2);
+  DUMP_TENSOR(C3);
+  DUMP_TENSOR(C4);
+  DUMP_TENSOR(eTl);
+  DUMP_TENSOR(eTt);
+  DUMP_TENSOR(eTl);
+  DUMP_TENSOR(eTb);
+
+#undef DUMP_TENSOR
+
   // auto onesite_obs = measure_onesite_density();
   auto onesite_obs = measure_onesite();
   save_onesite(onesite_obs, beta, filename_prefix);