From 0300bed1ee512747da2b8c92b7c6c1ca7783bc41 Mon Sep 17 00:00:00 2001
From: Valentin Bruch <valentin.bruch@rwth-aachen.de>
Date: Thu, 2 Feb 2023 19:35:20 +0100
Subject: [PATCH] more small corrections/improvements in plots

---
 final_plots.py              | 21 ++++++++++++---------
 gen_data.py                 |  6 +++++-
 plot_pyqtgraph.py           |  5 +++++
 tikz/convergence-j.tex      |  6 +++---
 tikz/g_overview_vdc_vac.tex |  2 +-
 tikz/omega5-3d.tex          | 12 ++++++++----
 tikz/overview.tex           |  2 ++
 7 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/final_plots.py b/final_plots.py
index accc8ab..171e5dc 100644
--- a/final_plots.py
+++ b/final_plots.py
@@ -397,6 +397,9 @@ def export_interp(
     def gen_data(order, method, padding=False, s=spline_s, extend_vdc=10, extend_vac=10, **kwargs):
         suffix = "_p" if padding else ""
         reduced_data = selection(order, method, padding, **kwargs)
+        results = {}
+        if reduced_data.shape[0] < 100:
+            return results
         settings.logger.info(f"Starting with {order}{suffix} {method}, found {reduced_data.shape[0]} data points")
         if extend_vdc or extend_vac:
             extended_data = [reduced_data]
@@ -419,9 +422,6 @@ def export_interp(
                     del acdc_mirrored
                 del ac_mirrored
             reduced_data = pd.concat(extended_data)
-        results = {}
-        if reduced_data.shape[0] < 100:
-            return results
         xy_data = (x_func(reduced_data), y_func(reduced_data))
         if order == "o2":
             xy_data = (xy_data[0]/o2_scale_x, xy_data[1]/o2_scale_y)
@@ -587,8 +587,8 @@ def export_interp_relative_o3a(
             | DataManager.SOLVER_FLAGS["deleted"]
     data = data.loc[data.solver_flags & global_bad_flags == 0]
     data = data.sort_values([x_sort_parameter or x_parameter, y_sort_parameter or y_parameter])
-    data.vdc = np.round(data.vdc, 9)
-    data.vac = np.round(data.vac, 9)
+    data.vdc = np.round(data.vdc, 8)
+    data.vac = np.round(data.vac, 8)
     required_flags = dict(
             o3 = 0,
             o3a = DataManager.SOLVER_FLAGS["include_Ga"],
@@ -741,8 +741,8 @@ def export_omega5_interp(
         vac_max = 165.372,
         dc_res = 301,
         ac_res = 201,
-        vdc_max_J = 82.686,
-        vac_max_J = 82.686,
+        vdc_max_J = 5,
+        vac_max_J = 5,
         voltage_branches = 4,
         ):
     """
@@ -750,7 +750,7 @@ def export_omega5_interp(
     """
     def special_selection(data, order, method, padding, **kwargs):
         if method == "J":
-            return (data["vdc"] < vdc_max_J + 1e-3) & (data["vac"] < vac_max_J + 1e-3)
+            return (data["vdc"]/data["omega"] < vdc_max_J + 1e-3) & (data["vac"]/data["omega"] < vac_max_J + 1e-3)
         return True
     yarr = np.linspace(vac_min, vac_max, ac_res)
     yarr[-1] -= 1e-10
@@ -789,7 +789,10 @@ def export_omega5_interp_deviation(
     """
     def special_selection(data, order, method, padding, **kwargs):
         if method == "J":
-            return (data["vdc"] < vdc_max_J + 1e-3) & (data["vac"] < vac_max_J + 1e-3)
+            if padding:
+                return (data["vdc"] < vdc_max_J + 1e-3) & (data["vac"] < vac_max_J + 1e-3) & ((data["version_minor"] >= 15) | (data["nmax"] == 0))
+            else:
+                return (data["vdc"] < vdc_max_J + 1e-3) & (data["vac"] < vac_max_J + 1e-3)
         return True
     yarr = np.linspace(vac_min, vac_max, ac_res)
     yarr[-1] -= 1e-10
diff --git a/gen_data.py b/gen_data.py
index 3be70e3..b9abb0c 100644
--- a/gen_data.py
+++ b/gen_data.py
@@ -23,9 +23,13 @@ def get_ref_nmax(dm, omega, vdc, vac, preset="precise", dc_shift=0, ac_shift=0,
             old = dict(omega=omega, solver_tol_rel=1e-8, solver_tol_abs=1e-10, d=1e9, method="mu", padding=0, good_flags=0x0000, bad_flags=0x1ffc, xL=0.5, voltage_branches=4),
             precise = dict(omega=omega, solver_tol_rel=1e-8, solver_tol_abs=1e-10, d=1e9, method="mu", padding=0, good_flags=0x1000, bad_flags=0x0ffc, xL=0.5, voltage_branches=4),
             normal = dict(omega=omega, solver_tol_rel=1e-9, solver_tol_abs=1e-11, d=1e5, method="mu", padding=0, good_flags=0x1000, bad_flags=0x0ffc, xL=0.5, voltage_branches=4),
+            omega5 = dict(omega=16.5372, solver_tol_rel=1e-8, solver_tol_abs=1e-10, d=1e9, method="mu", padding=0, good_flags=0x1000, bad_flags=0x0ffc, xL=0.5, voltage_branches=4),
             )
     data = dm.list(**parameters[preset])
     assert data.size > 0
+    if preset == "omega5":
+        vdc *= 16.5372/omega
+        vac *= 16.5372/omega
     vdc_arr, vac_arr = np.broadcast_arrays(vdc, vac)
     nmax = -np.ones(vdc_arr.shape, dtype=np.int64).reshape((-1,))
     for i, (vdc, vac) in enumerate(zip((vdc_arr+dc_shift).flat, (vac_arr+ac_shift).flat)):
@@ -256,7 +260,7 @@ python -m frtrg_kondo.gen_data \\
             choices=(2,3), default=3,
             help = "Truncation order of RG equations.")
     method_group.add_argument("--preset", metavar="str", type=str,
-            choices=("normal", "precise", "old"), default="precise",
+            choices=("normal", "precise", "old", "omega5"), default="precise",
             help = "Preset for choosing nmax if set explicitly")
     method_group.add_argument("--preset_dc_shift", metavar="float", type=float, default=0,
             help = "Shift in Vdc for getting nmax from existing data")
diff --git a/plot_pyqtgraph.py b/plot_pyqtgraph.py
index ad79277..258c62f 100644
--- a/plot_pyqtgraph.py
+++ b/plot_pyqtgraph.py
@@ -799,9 +799,14 @@ def parse():
             help="include Ga in RG equations")
     parser.add_argument("--show_gpat", metavar="int", type=int,
             help="Show G from photon assisted tunneling (0 or 1)")
+    parser.add_argument("--min_version_major", metavar="int", type=int, default=14,
+            help="Minimal major version")
+    parser.add_argument("--min_version_minor", metavar="int", type=int, default=-1,
+            help="Minimal minor version")
     args = parser.parse_args()
 
     options = args.__dict__
+    options["min_version"] = (options.pop("min_version_major"), options.pop("min_version_minor"), -1, -1)
     db_filename = options.pop("db_filename", None)
     if db_filename is not None:
         settings.defaults.DB_CONNECTION_STRING = "sqlite:///" + os.path.abspath(db_filename)
diff --git a/tikz/convergence-j.tex b/tikz/convergence-j.tex
index 1dcb2ea..8456c84 100644
--- a/tikz/convergence-j.tex
+++ b/tikz/convergence-j.tex
@@ -38,8 +38,8 @@
       name = colorbar,
       at = (Jp.east),
       anchor = west,
-      ymin = -0.00043767481879499436,
-      ymax = 0.00043767481879499436,
+      ymin = -0.0004348761377387133,
+      ymax = 0.0004348761377387133,
       xshift = 8mm,
       enlargelimits = false,
       axis on top,
@@ -57,6 +57,6 @@
       ylabel = {relative deviation},
       %ylabel shift = -5mm,
     ]
-    \addplot graphics[xmin=0, xmax=1, ymin=-0.00043767481879499436, ymax=0.00043767481879499436] {../figdata/colorbar_seismic_vertical.png};
+    \addplot graphics[xmin=0, xmax=1, ymin=-0.0004348761377387133, ymax=0.0004348761377387133] {../figdata/colorbar_seismic_vertical.png};
   \end{axis}
 \end{tikzpicture}
diff --git a/tikz/g_overview_vdc_vac.tex b/tikz/g_overview_vdc_vac.tex
index f419e80..ac31e82 100644
--- a/tikz/g_overview_vdc_vac.tex
+++ b/tikz/g_overview_vdc_vac.tex
@@ -10,7 +10,7 @@
       xmin = 0, xmax = 10,
       xlabel = {$\vac~(\Omega)$},
       ylabel = {$\vdc~(\Omega)$},
-      zlabel = {$\gdc~(2e^2/h)$},
+      zlabel = {$G~(2e^2/h)$},
       x label style = {sloped},
       y label style = {sloped},
       label style = {font=\small},
diff --git a/tikz/omega5-3d.tex b/tikz/omega5-3d.tex
index f53c84c..099c435 100644
--- a/tikz/omega5-3d.tex
+++ b/tikz/omega5-3d.tex
@@ -11,7 +11,7 @@
       zmode = log,
       xlabel = {$\vac~(\Omega)$},
       ylabel = {$\vdc~(\Omega)$},
-      zlabel = {$\quad\gac~(2e^2/h)\qquad\quad\gdc~(2e^2/h)$},
+      zlabel = {$\quad\gac~(2e^2/h)\qquad\quad G~(2e^2/h)$},
       x label style = {sloped},
       y label style = {sloped},
       label style = {font=\small},
@@ -36,7 +36,8 @@
       surf,
       point meta min = 0,
       point meta max = 1,
-      point meta = {(1-0.18/(\thisrow{gac}+0.1))/0.72},
+      point meta = {(1 - (1.1/(\thisrow{gac}+0.1)-1)/5.12)},
+      %point meta = {(1-0.18/(\thisrow{gac}+0.1))/0.72},
     ] table [x=vac, y=vdc, z expr={\thisrow{gac}}]{../figdata/omega5_interp.dat};
     \addplot3[gray, no marks, line width=0.2pt] coordinates {(10,0,0.1) (10,10,0.1) (0,10,0.1)};
     \addplot3[gray, no marks, line width=0.2pt] coordinates {(10,0,3) (0,0,3) (0,10,3)};
@@ -45,10 +46,12 @@
       surf,
       point meta min = 0,
       point meta max = 1,
-      point meta = {(1-0.18/(\thisrow{gdc}+0.1))/0.72},
+      point meta = {(1 - (1.1/(\thisrow{gdc}+0.1)-1)/5.12)},
+      %point meta = {(1-0.18/(\thisrow{gdc}+0.1))/0.72},
     ] table [x=vac, y=vdc, z expr={30*\thisrow{gdc}}]{../figdata/omega5_interp.dat};
     \addplot3[gray, no marks, line width=0.2pt] coordinates {(10,0,3) (10,10,3) (0,10,3)};
     \node[black] at (axis description cs:0.75,0.82) {$\Omega=4.8\tkv$};
+    \node[anchor=north east] at (axis description cs:-0.02,1) {(b)};
   \end{axis}
   \begin{axis}[
       at = (G3d.north east),
@@ -75,7 +78,8 @@
       samples y = 100,
       shader = interp,
       mesh/color input = colormap,
-      point meta = {(1-0.18/(y+0.1))/0.72}
+      point meta = {(1 - (1.1/(y+0.1)-1)/5.12)},
+      %point meta = {(1-0.18/(y+0.1))/0.72}
     ] {(1-0.18/(y+0.1))/0.72};
   \end{axis}
 \end{tikzpicture}
diff --git a/tikz/overview.tex b/tikz/overview.tex
index bf44b66..d526711 100644
--- a/tikz/overview.tex
+++ b/tikz/overview.tex
@@ -13,6 +13,7 @@
       zlabel = {$\Omega~(\tkv)$},
       axis lines* = left,
       axis on top,
+      clip = false,
     ]
     \addplot3[surf] graphics[
       points={
@@ -34,5 +35,6 @@
     \addplot3[gray,thin] coordinates {(0,0,0) (0,0,4.804)};
     \addplot3[gray,thin] coordinates {(10,0,4.804) (0,0,4.804) (0,10,4.804)};
     %\addplot3[surf] graphics[points={(0,0,0)=>(0,0)}] {../figdata/overview_x.png};
+    \node[anchor=north east] at (axis description cs:0,1) {(a)};
   \end{axis}
 \end{tikzpicture}
-- 
GitLab