Add images for website

This commit is contained in:
matthias@quintern.xyz 2025-03-09 22:00:34 +01:00
parent 8fcb948ecc
commit ac6feedba4
11 changed files with 927 additions and 0 deletions

61
images/Makefile Normal file
View File

@ -0,0 +1,61 @@
# Matthias Quintern 2025
# Compile image (tex) to pdf,
# convert to svg in tmp dir
# and then replace all color occurances with css class names
SRC_DIR = src
PDF_DIR = out
TMP_DIR = /tmp/latex-img
SVG_DIR = svg
WDIR = $(shell pwd)
DIRS = $(SRC_DIR) $(PDF_DIR) $(TMP_DIR) $(SVG_DIR)
LATEX = lualatex
BIBER = biber
REPL_COLORS = python3 repl-colors.py
DEPS = $(SRC_DIR)/colorscheme.sty $(SRC_DIR)/tensorstyle.sty
SRC_FLS = $(wildcard $(SRC_DIR)/*.tex)
SRC_FLS_= $(notdir $(SRC_FLS))
PDF_FLS = $(SRC_FLS_:%.tex=$(PDF_DIR)/%.pdf)
TMP_FLS = $(SRC_FLS_:%.tex=$(TMP_DIR)/%.svg)
SVG_FLS = $(SRC_FLS_:%.tex=$(SVG_DIR)/%.svg)
# PDF_FLS = $(foreach file,$(notdir $(SRC_FLS)), $(PDF_DIR)/$(file))
# TMP_FLS = $(foreach file,$(notdir $(SRC_FLS)), $(TMP_DIR)/$(file))
# SVG_FLS = $(foreach file,$(notdir $(SRC_FLS)), $(SVG_DIR)/$(file))
LATEX_OPTS := -output-directory=$(WDIR)/$(PDF_DIR) -interaction=nonstopmode -shell-escape
.PHONY: default release clean scripts
default: $(SVG_FLS)
allpdf: $(PDF_FLS)
allsvg: $(SVG_FLS)
$(DIRS):
mkdir -p $@
# Default target
$(PDF_DIR)/%.pdf: $(SRC_DIR)/%.tex $(DEPS) | $(PDF_DIR)
cd $(SRC_DIR) && lualatex $(LATEX_OPTS) $(notdir $<)
$(TMP_DIR)/%.svg: $(PDF_DIR)/%.pdf | $(TMP_DIR)
inkscape --export-filename=$@ $<
# pdf2svg $< $@
$(SVG_DIR)/%.svg: $(TMP_DIR)/%.svg | $(SVG_DIR)
$(REPL_COLORS) --input $< --output $@
clean:
rm -r $(SVG_FLS) $(TMP_DIR) $(PDF_DIR)
print:
@echo '$(notdir $(SRC_FLS))'
@echo '$(PDF_FLS)'
@echo '$(TMP_FLS)'
@echo '$(SVG_FLS)'
.PHONY: all clean allpdf allsvg print

View File

@ -0,0 +1,56 @@
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\input{.common.tex}
\begin{document}
\begin{tikzpicture}[x=0.4cm,y=0.4cm]
\node (M0) at (0,0) {};
\node[below=of M0] (W0) {};
\node[below=of W0] (m0) {};
\foreach \i in {0,...,2} {
\pgfmathsetmacro{\j}{int(\i+1)}
\node[right=of M\i] (M\j) {}; % $M^{[\the\numexpr\i+1]}$
\node[right=of W\i] (W\j) {}; % $W^{[\the\numexpr\i+1]}$
\node[right=of m\i] (m\j) {}; % $m^{[\the\numexpr\i+1]}$
% horizontal
}
% \pgfmathsetmacro{\dx}{0.3*\nodeDistance}
% \pgfmathsetmacro{\dy}{0.3*\nodeDistance}
\def\dx{0.4}
\def\dy{0.4}
% \node[draw, dashed, rounded corners=5pt, fit=(M0) (M2) (m0) (m2)] (group) {};
\begin{scope}[on background layer]
\draw[fill=\colorHeff,rounded corners=2]
($(M0)+(-\dx, \dy)$) --
($(M2)+( \dx, \dy)$) --
($(m2)+( \dx,-\dy)$) --
($(m0)+(-\dx,-\dy)$) --
cycle;
\draw[fill=\colorTheta,rounded corners=2pt]
($(M3)+(-\dx, \dy)$) --
($(M3)+( \dx, \dy)$) --
($(m3)+( \dx,-\dy)$) --
($(m3)+(-\dx,-\dy)$) --
cycle;
% \draw[fill=\colorTheta,rounded corners=2pt]
% ($(M3)+(-\dx, \dy)$) --
% ($(M3)+( \dx, \dy)$) --
% ($(m3)+( \dx,-\dy)$) --
% ($(m3)+(-\dx,-\dy)$) --
% cycle;
\end{scope}
% \draw node[above left=of M0] {} -- node[above right=of M2] {} -- node[above right=of W2] {};
\node[above=0.1 of M1] (Heff) {$H_\text{eff}$};
\node[above=0.1 of M3] (Theta) {$\Theta$};
\end{tikzpicture}
\end{document}

View File

@ -0,0 +1,83 @@
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\input{.common.tex}
% Heff with Theta and Theta*
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm]
\node[ten] (M0) at (0,0) {};
\node[mpo,below=of M0] (W0) {};
\node[ten,below=of W0] (m0) {};
\draw[leg] (M0) -- (W0);
\draw[leg] (W0) -- (m0);
\pgfmathsetmacro{\N}{9}
\pgfmathsetmacro{\iMax}{\N-2}
\foreach \i in {0,...,\iMax} {
\pgfmathsetmacro{\j}{int(\i+1)}
\node[ten, right=of M\i] (M\j) {}; % $M^{[\the\numexpr\i+1]}$
\node[mpo, right=of W\i] (W\j) {}; % $W^{[\the\numexpr\i+1]}$
\node[ten, right=of m\i] (m\j) {}; % $m^{[\the\numexpr\i+1]}$
% horizontal
\pgfmathparse{\j>5 || \j<3 || \j==4}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (M\j);
\draw[leg] (m\i) -- (m\j);
\fi
\draw[leg] (W\i) -- (W\j);
% vertical
\pgfmathparse{\j>4 || \j<3}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\j) -- (W\j);
\draw[leg] (W\j) -- (m\j);
\fi
}
% \pgfmathsetmacro{\dx}{0.3*\nodeDistance}
% \pgfmathsetmacro{\dy}{0.3*\nodeDistance}
\def\dx{0.4}
\def\dy{0.4}
% \node[draw, dashed, rounded corners=5pt, fit=(M0) (M2) (m0) (m2)] (group) {};
\begin{scope}[on background layer]
\draw[fill=\colorHeff,rounded corners=2]
($(M0)+(-\dx, \dy)$) --
($(M2)+( \dx, \dy)$) --
($(W2)+( \dx, \dy)$) --
($(W5)+(-\dx, \dy)$) --
($(M5)+(-\dx, \dy)$) --
($(M8)+( \dx, \dy)$) --
($(m8)+( \dx,-\dy)$) --
($(m5)+(-\dx,-\dy)$) --
($(W5)+(-\dx,-\dy)$) --
($(W2)+( \dx,-\dy)$) --
($(m2)+( \dx,-\dy)$) --
($(m0)+(-\dx,-\dy)$) --
cycle;
\draw[fill=\colorTheta,rounded corners=2pt]
($(M3)+(-\dx, \dy)$) --
($(M4)+( \dx, \dy)$) --
($(M4)+( \dx,-\dy)$) --
($(M3)+(-\dx,-\dy)$) --
cycle;
\draw[fill=\colorTheta,rounded corners=2pt]
($(m3)+(-\dx, \dy)$) --
($(m4)+( \dx, \dy)$) --
($(m4)+( \dx,-\dy)$) --
($(m3)+(-\dx,-\dy)$) --
cycle;
\end{scope}
% \draw node[above left=of M0] {} -- node[above right=of M2] {} -- node[above right=of W2] {};
% \node[left=of W0] (Heff) {$H_\text{eff}$ = };
\node[anchor=south,above=0.1 of M1] (Heff) {$H_\text{eff}$};
\node[anchor=south] (Theta) at ($(M3)+0.5*(M4)-0.5*(M3)+(0,0.4)$) {$\Theta$};
\node[anchor=north] (ThetaC) at ($(m3)+0.5*(m4)-0.5*(m3)-(0,0.4)$) {$\overline{\Theta}$};
\end{tikzpicture}
\end{document}

28
images/src/.old/dmrg.tex Normal file
View File

@ -0,0 +1,28 @@
\documentclass[tikz]{standalone}
\input{.common.tex}
\begin{document}
\begin{tikzpicture}
\node[ten] (M0) at (0,0) {};
\node[mpo,below=of M0] (W0) {};
\node[ten,below=of W0] (m0) {};
\draw[leg] (M0) -- (W0);
\draw[leg] (W0) -- (m0);
\foreach \i in {0,...,6} {
\pgfmathsetmacro{\j}{int(\i+1)}
\node[ten, right=of M\i] (M\j) {}; % $M^{[\the\numexpr\i+1]}$
\node[mpo, right=of W\i] (W\j) {}; % $W^{[\the\numexpr\i+1]}$
\node[ten, right=of m\i] (m\j) {}; % $m^{[\the\numexpr\i+1]}$
% horizontal
\draw[leg] (M\i) -- (M\j);
\draw[leg] (W\i) -- (W\j);
\draw[leg] (m\i) -- (m\j);
% vertical
\draw[leg] (M\j) -- (W\j);
\draw[leg] (W\j) -- (m\j);
}
\end{tikzpicture}
\end{document}

View File

@ -0,0 +1,29 @@
\ProvidesPackage{colorscheme}
\RequirePackage{xcolor}
\definecolor{fg0}{HTML}{1d2021}
\definecolor{bg0}{HTML}{f9f5d7}
\definecolor{fg1}{HTML}{3c3836}
\definecolor{fg2}{HTML}{504945}
\definecolor{fg3}{HTML}{665c54}
\definecolor{fg4}{HTML}{7c6f64}
\definecolor{bg1}{HTML}{ebdbb2}
\definecolor{bg2}{HTML}{d5c4a1}
\definecolor{bg3}{HTML}{bdae93}
\definecolor{bg4}{HTML}{a89984}
\definecolor{fg-red}{HTML}{9d0006}
\definecolor{fg-orange}{HTML}{af3a03}
\definecolor{fg-yellow}{HTML}{b57614}
\definecolor{fg-green}{HTML}{79740e}
\definecolor{fg-aqua}{HTML}{427b58}
\definecolor{fg-blue}{HTML}{076678}
\definecolor{fg-purple}{HTML}{8f3f71}
\definecolor{fg-gray}{HTML}{7c6f64}
\definecolor{bg-red}{HTML}{795040}
\definecolor{bg-orange}{HTML}{775b3a}
\definecolor{bg-yellow}{HTML}{78683f}
\definecolor{bg-green}{HTML}{6b673d}
\definecolor{bg-aqua}{HTML}{63684e}
\definecolor{bg-blue}{HTML}{616354}
\definecolor{bg-purple}{HTML}{715c54}
\definecolor{bg-gray}{HTML}{686050}

View File

@ -0,0 +1,79 @@
\documentclass[tikz]{standalone}
\usepackage{tensorstyle}
\begin{document}
% 1: color
% 2: pos
\newcommand\drawParticle[2]{
\draw[fill=#1] #2 circle (0.15);
}
% 1: pos
% 2: n particles
\newcommand\drawSite[2]{
\pgfmathsetmacro\dx{0.06}
\pgfmathparse{#2 > 5}
\ifnum\pgfmathresult=1 \relax
\drawParticle{bg4}{($#1+(+\dx,-\dx)$)}
\fi
\pgfmathparse{#2 > 4}
\ifnum\pgfmathresult=1 \relax
\drawParticle{bg3}{($#1+(+\dx,-\dx)$)}
\fi
\pgfmathparse{#2 > 3}
\ifnum\pgfmathresult=1 \relax
\drawParticle{bg2}{($#1+(-\dx,+\dx)$)}
\fi
\pgfmathparse{#2 > 2}
\ifnum\pgfmathresult=1 \relax
\drawParticle{bg3}{($#1+(-\dx,-\dx)$)}
\fi
\pgfmathparse{#2 > 1}
\ifnum\pgfmathresult=1 \relax
\drawParticle{bg1}{($#1+(+\dx,+\dx)$)}
\fi
\pgfmathparse{#2 > 0}
\ifnum\pgfmathresult=1 \relax
\drawParticle{bg2}{($#1+(+0.00,+0.00)$)}
\fi
}
\begin{tikzpicture}[x=\unitCm cm,y=\unitCm cm, scale=\scale, transform shape]
% \begin{scope}[shift={(0,0)}]
% \pgfmathsetmacro{\xlen}{0.3}
% \draw[->] (0,0) -- (\xlen,\xlen) node[anchor=south west] {$x$};
% \draw[->] (0,0) -- (0,2*\xlen) node[anchor=south] {$z$};
% \draw[->] (0,0) -- (2*\xlen,0) node[anchor=west] {$y$};
% \end{scope}
\begin{scope}[shift={(1.5,0.3)}]
\pgfmathsetmacro\N{8} % N spins
\pgfmathsetmacro\iMax{\N-1} % B idx
\pgfmathsetmacro\siteDistance{1}
\pgfmathsetmacro\labelY{1}
\foreach \i in {0,...,\iMax} {
\node (S\i) at (\siteDistance*\i,0) {};
\node at ($(S\i)-(0,\labelY)$) {\i};
}
\node at ($(S0)-(,\labelY)$) {Site:};
% spins
\draw[thick] (S0) -- (S\iMax);
\drawSite{(S0)}{5}
\drawSite{(S1)}{2}
\drawSite{(S2)}{3}
\drawSite{(S3)}{4}
\drawSite{(S4)}{0}
\drawSite{(S5)}{5}
\drawSite{(S6)}{1}
\drawSite{(S7)}{3}
% \drawSite{(S8)}{1}
\end{scope}
\end{tikzpicture}
\end{document}

View File

@ -0,0 +1,233 @@
\documentclass[tikz]{standalone}
\usepackage[small]{tensorstyle}
\begin{document}
\def\colorTheta{bg-red}
\def\colorHeff{bg-blue}
\newcommand\setScopeMacros[5]{
\directlua{
tex.sprint("\\pgfmathsetmacro{\\#1x}{#2}")
tex.sprint("\\pgfmathsetmacro{\\#1y}{#3}")
tex.sprint("\\pgfmathsetmacro{\\#1w}{#4}")
tex.sprint("\\pgfmathsetmacro{\\#1h}{#5}")
}
}
\begin{tikzpicture}[x=\unitCm cm,y=\unitCm cm, scale=\scale, transform shape]
\pgfmathsetmacro{\margin}{0.3}
\pgfmathsetmacro{\scopeDistance}{1}
\setScopeMacros{scopeA}{0}{0}{8}{2} % Heff*Theta
\setScopeMacros{scopeB}{0}{-5}{3}{2} % Heffmat * Theta
\setScopeMacros{scopeC}{8}{\scopeBy}{1}{2} % ThetaTwiddle
\setScopeMacros{scopeD}{2+0.5}{\scopeCy-4}{2}{0} % SVD
\setScopeMacros{scopeE}{-1}{\scopeDy-4}{3}{2} % L
\setScopeMacros{scopeF}{5}{\scopeDy-4}{5}{2} % R
% for positioning
% \drawGrid{-1}{10}{-20}{1}
% \pgfmathsetmacro{\dx}{0.3*\nodeDistance}
% \pgfmathsetmacro{\dy}{0.3*\nodeDistance}
% Heffmat
\begin{scope}
\pgfmathsetmacro{\N}{9}
\pgfmathsetmacro{\iMax}{\N-1}
\foreach \i in {0,...,\iMax} {
\node[ten] (M\i) at (\i,0) {}; % $M^{[\the\numexpr\i+1]}$
\node[mpo] (W\i) at (\i,-1) {}; % $W^{[\the\numexpr\i+1]}$
\node[ten] (m\i) at (\i,-2) {}; % $m^{[\the\numexpr\i+1]}$
}
\foreach \i in {0,...,\iMax} {
\pgfmathsetmacro{\j}{int(\i+1)}
% horizontal, top bot, skip the legs for the theta tensors
% \pgfmathparse{\i < \iMax && (\i>4 || \i<2 || \i==3) } % dont connect Heff and Theta
\pgfmathparse{\i < \iMax}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (M\j);
\draw[leg] (m\i) -- (m\j);
\fi
% horizontal middle
\pgfmathparse{\i < \iMax}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (W\i) -- (W\j);
\fi
% vertical
% \pgfmathparse{\i>4 || \i<3} % dont connect Heff and Theta
\pgfmathparse{1}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (W\i);
\draw[leg] (W\i) -- (m\i);
\fi
}
% \node[draw, dashed, rounded corners=5pt, fit=(M0) (M2) (m0) (m2)] (group) {};
\begin{scope}[on background layer]
\draw[draw=none,fill=\colorHeff,tensorcorners]
($(M0)+(-\tdx, \tdx)$) --
($(M2)+( \tdx, \tdx)$) --
($(W2)+( \tdx, \tdx)$) --
($(W5)+(-\tdx, \tdx)$) --
($(M5)+(-\tdx, \tdx)$) --
($(M8)+( \tdx, \tdx)$) --
($(m8)+( \tdx,-\tdx)$) --
($(m5)+(-\tdx,-\tdx)$) --
($(W5)+(-\tdx,-\tdx)$) --
($(W2)+( \tdx,-\tdx)$) --
($(m2)+( \tdx,-\tdx)$) --
($(m0)+(-\tdx,-\tdx)$) --
cycle;
\drawAroundRect[draw=none,fill=\colorTheta,tensorcorners]{(M3)}{1}{0}
\drawAroundRect[draw=none,fill=\colorTheta,tensorcorners]{(m3)}{1}{0}
\end{scope}
\node[anchor=south,above=0.1 of M1] (L) {$L^{[n]}$};
\node[anchor=south,above=0.1 of M7] (R) {$R^{[n+1]}$};
\node[anchor=south] (Theta) at ($(M3)+0.5*(M4)-0.5*(M3)+(0,0.4)$) {$\Theta$};
\node[anchor=north] (ThetaC) at ($(m3)+0.5*(m4)-0.5*(m3)-(0,0.4)$) {$\overline{\Theta}$};
\node[anchor=west] at (\iMax+\dLabel, 0) {$\big\}M^{[i]}$};
\node[anchor=west] at (\iMax+\dLabel,-1) {$\big\}W$};
\node[anchor=west] at (\iMax+\dLabel,-2) {$\big\}\overline{M}^{[i]}$};
\end{scope}
\draw[->] (\scopeAx-1,\scopeAy-\scopeAh/2) -- ++(-1, 0) -- ++(0,-\scopeAy+\scopeBy) node[midway,right] {Reshape }-- ++(1, 0) ;
% Heff mat * Theta
\begin{scope}[shift={(\scopeBx, \scopeBy)}]
% "fake" points to keep the same size
\foreach \i in {0,...,3} {
\node[ten,draw=none] (M\i) at (\i, 0) {}; % $M^{[\the\numexpr\i+1]}$
\node[ten,draw=none] (W\i) at (\i,-1) {}; % $W^{[\the\numexpr\i+1]}$
\node[ten,draw=none] (m\i) at (\i,-2) {}; % $m^{[\the\numexpr\i+1]}$
}
\node[ten,draw,inner sep=0,tensorcorners,fit=(M0)(m2)] {};
\node[ten,draw,inner sep=0,tensorcorners,fit=(M3)(m3)] {};
\begin{scope}[on background layer]
\drawAroundPoints[fill=\colorHeff,tensorcorners]{(M0)(m2)}
\drawAroundPoints[fill=\colorTheta,tensorcorners]{(M3)(m3)}
\end{scope}
\draw[leg] (W2) -- (W3);
\draw[leg] (W0) -- ++(-\legLength,0);
\node[anchor=south] (Heff) at (1,\dLabel) {$H_\text{eff}$};
\node[anchor=south] (Theta) at (3,\dLabel) {$\Theta$};
\end{scope}
\draw[->] (\scopeBx+\scopeBw+1,\scopeBy-\scopeBh/2) -- (\scopeCx-1,\scopeBy-\scopeBh/2) node[midway,above] {Ground} node[midway,below] {state};
% Theta Twiddle <3
\begin{scope}[shift={(\scopeCx, \scopeCy)}]
\node[ten,draw=none] (M0) at (0, 0) {};
\node[ten,draw=none] (w0) at (0,-1) {};
\node[ten,draw=none] (m0) at (0,-2) {};
\node[ten,draw,inner sep=0,tensorcorners,fit=(M0)(m0)] {};
\draw[leg] (w0) -- ++(-\legLength,0);
\begin{scope}[on background layer]
\drawAroundPoints[fill=\colorTheta,tensorcorners]{(M0)(m0)}
\end{scope}
\node[anchor=south] at (0,\dLabel) {$\tilde{\Theta}$};
\end{scope}
\draw[->] (\scopeCx+1,\scopeCy-\scopeCh/2) -- ++(1,0) -- ++(0, +\scopeDy-\scopeCy+\scopeCh/2) node[midway,right] {SVD} -- (\scopeDx+\scopeDw+1,\scopeDy);
% Theta Twiddle SVD
\def\colorATensor{bg-green}
\def\colorLTensor{bg-yellow}
\def\colorBTensor{bg-purple}
\begin{scope}[shift={(\scopeDx, \scopeDy)}]
\node[ten,fill=\colorATensor] (M0) at (0,0) {};
\node[ten,fill=\colorLTensor] (M1) at (1,0) {};
\node[ten,fill=\colorBTensor] (M2) at (2,0) {};
\draw[leg] (M0) -- ++(-\legLength,0);
\draw[leg] (M0) -- (M1);
\draw[leg] (M1) -- (M2);
\draw[leg] (M2) -- ++(\legLength,0);
\begin{scope}[on background layer]
\drawAroundRect[draw=none,fill=\colorTheta,tensorcorners]{(0,0)}{2}{0}
\end{scope}
\node[anchor=south] at (1,\dLabel) {$\tilde{\Theta}$};
\end{scope}
% L n+1
\begin{scope}[shift={(\scopeEx, \scopeEy)}]
\pgfmathsetmacro{\N}{4}
\pgfmathsetmacro{\iMax}{\N-1}
\foreach \i in {0,...,\iMax} {
\node[ten] (M\i) at (\i, 0) {};
\node[mpo] (W\i) at (\i,-1) {};
\node[ten] (m\i) at (\i,-2) {};
}
\foreach \i in {0,...,\iMax} {
\pgfmathsetmacro{\j}{int(\i+1)}
% horizontal
\pgfmathparse{\j < \N}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (M\j);
\draw[leg] (W\i) -- (W\j);
\draw[leg] (m\i) -- (m\j);
\fi
% vertical
\draw[leg] (M\i) -- (W\i);
\draw[leg] (W\i) -- (m\i);
}
% sticking out legs
\draw[leg] (M3) -- ++(\legLength,0);
\draw[leg] (W3) -- ++(\legLength,0);
\draw[leg] (m3) -- ++(\legLength,0);
\node[ten,fill=\colorATensor] (M3c) at (M3) {};
\node[ten,fill=\colorATensor] (m3c) at (m3) {};
\begin{scope}[on background layer]
\drawAroundRect[fill=\colorHeff,tensorcorners]{(M0)}{\iMax}{-2}
\end{scope}
\node[anchor=south] at (1,\dLabel) {$L^{[n+1]}$};
\end{scope}
% R
\begin{scope}[shift={(\scopeFx, \scopeFy)}]
\pgfmathsetmacro{\N}{5}
\pgfmathsetmacro{\iMax}{\N-1}
\foreach \i in {0,...,\iMax} {
\node[ten] (M\i) at (\i, 0) {};
\node[mpo] (W\i) at (\i,-1) {};
\node[ten] (m\i) at (\i,-2) {};
}
\foreach \i in {0,...,\iMax} {
\pgfmathsetmacro{\j}{int(\i+1)}
% horizontal
\pgfmathparse{\j < \N}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (M\j);
\draw[leg] (W\i) -- (W\j);
\draw[leg] (m\i) -- (m\j);
\fi
% vertical
\draw[leg] (M\i) -- (W\i);
\draw[leg] (W\i) -- (m\i);
}
% sticking out legs
\draw[leg] (M0) -- ++(-\legLength,0);
\draw[leg] (W0) -- ++(-\legLength,0);
\draw[leg] (m0) -- ++(-\legLength,0);
\node[ten,fill=\colorBTensor] (M0c) at (M0) {};
\node[ten,fill=\colorBTensor] (m0c) at (m0) {};
\begin{scope}[on background layer]
\drawAroundRect[fill=\colorHeff,tensorcorners]{(M0)}{\iMax}{-2}
\end{scope}
\node[anchor=south] at (\iMax-1,\dLabel) {$R^{[n]}$};
\end{scope}
\draw[->] (\scopeDx+\scopeDw/2,\scopeDy-1) -- (\scopeEx+\scopeEw,\scopeEy+1);
\draw[->] (\scopeDx+\scopeDw/2,\scopeDy-1) -- (\scopeFx,\scopeFy+1) node[midway,right] {Update};
\end{tikzpicture}
\end{document}

View File

@ -0,0 +1,45 @@
\documentclass[tikz]{standalone}
\usepackage{tensorstyle}
\begin{document}
\def\colorPsi{bg-red}
\pagecolor{bg0}
\begin{tikzpicture}[x=\unitCm cm,y=\unitCm cm, scale=\scale, transform shape]
% for positioning
% \drawGrid{-1}{10}{-7}{1}
\pgfmathsetmacro{\N}{8}
\pgfmathsetmacro{\iMax}{\N-1}
% Psi with Ms
\begin{scope}[shift={(0,-1.5)}]
\foreach \i in {0,...,\iMax} {
\node[ten] (M\i) at (\i,0) {$M^{[\i]}$};
\pgfmathsetmacro{\j}{int(\i-1)}
\pgfmathparse{\j >= 0}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (M\j);
\fi
\draw[leg] (M\i) -- ++(0,-0.5);
}
% \begin{scope}[on background layer]
% \node[fill=\colorPsi, fit=(M0)(M\iMax), inner sep=\dx cm, tensorcorners] {};
% \end{scope}
\end{scope}
% Psi
\getNodeDimensions{M0}
\begin{scope}[shift={(0,0)}]
% \draw[ten] ($(0,0)-(M0.width)+(M0.height)$) rectangle ($(0,0)+(M9.width)$);
\draw[ten] (-0.5*\nodeWidth,-0.5*\nodeHeight) rectangle ($(\iMax,0)+(0.5*\nodeWidth,0.5*\nodeHeight)$) node[midway] (psi) {$\psi$};
\draw[leg] (psi) -- ++(0,-0.5);
% \begin{scope}[on background layer]
% \node[fill=\colorPsi, fit=(M0)(M\iMax), inner sep=\dx cm, tensorcorners] {};
% \end{scope}
\end{scope}
\node at (\iMax/2,-0.9) {$\approx$};
\end{tikzpicture}
\end{document}

View File

@ -0,0 +1,145 @@
\documentclass[tikz]{standalone}
\usepackage[small]{tensorstyle}
\begin{document}
\def\colorPsi{bg-red}
\newcommand\setScopeMacros[5]{
\directlua{
tex.sprint("\\pgfmathsetmacro{\\#1x}{#2}")
tex.sprint("\\pgfmathsetmacro{\\#1y}{#3}")
tex.sprint("\\pgfmathsetmacro{\\#1w}{#4}")
tex.sprint("\\pgfmathsetmacro{\\#1h}{#5}")
}
}
% 1: number of tensors
% 2: shift in (x,y)
% 3: prefix of input points names
% 4: prefix of output points names
\newcommand{\drawBrickwall}[4]{
\begin{scope}[shift={#2}]
\pgfmathsetmacro{\N}{#1}
\pgfmathsetmacro{\iMax}{\N/2-1}
% invisible tensor sized nodes
\tikzstyle{U} = [minimum size=\tensorSize cm, rounded corners=2pt]
\foreach \i in {0,...,\iMax} {
\pgfmathsetmacro{\j}{int(2*\i)}
\pgfmathsetmacro{\k}{int(2*\i+1)}
\pgfmathsetmacro{\l}{int(2*\i-1)}
% Node points
% First row
\node[U] (#4\j-1) at (\j,0) {};
\node[U] (#4\k-1) at (\k,0) {};
% Second row, use place the outpoint for the first in last tensor in the first row
\pgfmathparse{\i==0}
\ifnum\pgfmathresult=1 \relax
\node[U] (#4\j) at (\j, 0) {};
\node[U] (#4\k) at (\k,-1) {};
\else
\pgfmathparse{\i>=\iMax}
\ifnum\pgfmathresult=1 \relax
\node[U] (#4\j) at (\j,-1) {};
\node[U] (#4\k) at (\k,0) {};
\else
\node[U] (#4\j) at (\j,-1) {};
\node[U] (#4\k) at (\k,-1) {};
\fi
\fi
% first row tensor
% workaround for getting a two-size tensor with the same height as the
% single site node tensor
\begingroup
\node[draw, fit=(#4\j-1)(#4\k-1), inner sep=0, tensorcorners] {};
\endgroup
% connect to previous
\ifstrempty{#3}{}{
\draw[leg] (#3\j) -- (#4\j-1);
\draw[leg] (#3\k) -- (#4\k-1);
}
% second row tensor
\pgfmathparse{\i>0}
\ifnum\pgfmathresult=1 \relax
\node[draw, fit=(#4\l)(#4\j), inner sep=0, tensorcorners] {};
\fi
\pgfmathparse{\i<=\iMax}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (#4\j-1) -- (#4\j);
\draw[leg] (#4\k-1) -- (#4\k);
\fi
}
\end{scope}
}
\begin{tikzpicture}[x=\unitCm cm,y=\unitCm cm, scale=\scale, transform shape]
% for positioning
% \drawGrid{-1}{10}{-20}{1}
\pgfmathsetmacro{\N}{10}
\pgfmathsetmacro{\iMax}{\N-1}
% Heffmat
\begin{scope}[shift={(0,0)}]
% Psi
\foreach \i in {0,...,\iMax} {
\node[ten] (M\i) at (\i,0) {};
\pgfmathsetmacro{\j}{int(\i-1)}
\pgfmathparse{\j >= 0}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (M\i) -- (M\j);
\fi
}
\begin{scope}[on background layer]
\drawAroundRect[draw=none, fill=\colorPsi,tensorcorners]{(M0)}{\iMax}{0}
\end{scope}
% \node[anchor=west] at (\iMax+\dLabel, 0) {$\big\}M^{[i]}$};
\node[anchor=west] at (\iMax+\dLabel, 0) {$\psi(t=0)$};
\end{scope}
\drawBrickwall{\N}{(0,-1)}{M}{U1}
\drawBrickwall{\N}{(0,-3)}{U1}{U2}
\drawBrickwall{\N}{(0,-7)}{}{U3}
\begin{scope}[on background layer]
\drawAroundRect[draw=none,fill=bg2,tensorcorners]{(U10-1)}{\N-1}{-1}
\drawAroundRect[draw=none,fill=bg2,tensorcorners]{(U20-1)}{\N-1}{-1}
\drawAroundRect[draw=none,fill=bg2,tensorcorners]{(U30-1)}{\N-1}{-1}
% \drawAroundPoints[U]{(#4\j-1)(#4\k-1)}
\end{scope}
\node[anchor=west] at (\iMax+\dLabel, -1.5) {$n = 1$};
\node[anchor=west] at (\iMax+\dLabel, -3.5) {$n = 2$};
\node[anchor=west] at (\iMax+\dLabel, -7.5) {$n = n_\text{steps}$};
% connect dashed
\foreach \i in {0,...,\iMax} {
\draw[leg] (U2\i) -- (\i,-5);
\draw[leg,dotted] (\i,-5) -- (\i,-6);
\draw[leg] (\i,-6) -- (U3\i-1);
}
\begin{scope}[shift={(0,-9)}]
% PsiTilde
\foreach \i in {0,...,\iMax} {
\node[ten] (m\i) at (\i,0) {};
\pgfmathsetmacro{\j}{int(\i-1)}
\pgfmathparse{\j >= 0}
\ifnum\pgfmathresult=1 \relax
\draw[leg] (m\i) -- (m\j);
\fi
% leg to Us
\draw[leg] (U3\i) -- (m\i);
}
\begin{scope}[on background layer]
\drawAroundRect[draw=none,fill=\colorPsi,tensorcorners]{(m0)}{\iMax}{0}
\end{scope}
% \node[anchor=west] at (\iMax+\dLabel, 0) {$\big\}\tilde{M}^{[i]}$};
\node[anchor=west] at (\iMax+\dLabel, 0) {${\psi}(t=n_\text{steps}\delta t)$};
\end{scope}
% \node[draw, dashed, rounded corners=5pt, fit=(M0) (M2) (m0) (m2)] (group) {};
\end{tikzpicture}
\end{document}

49
images/src/illu_tfi.tex Normal file
View File

@ -0,0 +1,49 @@
\documentclass[tikz]{standalone}
\usepackage{tensorstyle}
\begin{document}
\newcommand\drawSpin[2]{
\pgfmathsetmacro\spinLength{0.8}
\draw[fill] #1 circle (0.1);
\draw[thick,->, rotate around={#2:#1},shift={(0,-0.5*\spinLength)}] #1 -- ++(0,\spinLength);
}
\begin{tikzpicture}[x=\unitCm cm,y=\unitCm cm, scale=\scale, transform shape]
\begin{scope}[shift={(0,0)}]
\pgfmathsetmacro{\xlen}{0.3}
\draw[->] (0,0) -- (\xlen,\xlen) node[anchor=south west] {$x$};
\draw[->] (0,0) -- (0,2*\xlen) node[anchor=south] {$z$};
\draw[->] (0,0) -- (2*\xlen,0) node[anchor=west] {$y$};
\end{scope}
\begin{scope}[shift={(1.5,0.3)}]
\edef\BColor{fg2}
\pgfmathsetmacro\BLength{1.5}
\pgfmathsetmacro\Bdistance{0.25}
\pgfmathsetmacro\N{8} % N spins
\pgfmathsetmacro\NB{2*\N-2} % B idx
\foreach \i in {0,...,\NB} {
\node (B\i) at (\Bdistance*\i,0) {};
\draw[->,draw=\BColor,rotate around={-45:(B\i)}] ($(B\i)+(0,-0.5*\BLength)$) -- ++(0,\BLength);
}
\node[color=\BColor] at (\N/4-3/4,-0.8) {$\vec{B}$};
% spins
\draw[thick] (0,0) -- (3.5,0);
\drawSpin{(0,0)}{0}
\drawSpin{(0.5,0)}{-5}
\drawSpin{(1.0,0)}{10}
\drawSpin{(1.5,0)}{0}
\drawSpin{(2.0,0)}{-24}
\drawSpin{(2.5,0)}{-13}
\drawSpin{(3.0,0)}{8}
\drawSpin{(3.5,0)}{3}
\end{scope}
\end{tikzpicture}
\end{document}

119
images/src/tensorstyle.sty Normal file
View File

@ -0,0 +1,119 @@
\ProvidesPackage{tensorstyle}
\NeedsTeXFormat{LaTeX2e}
\def\tensorsize@default{large}
\DeclareOption{small}{
\def\tensorsize@small{small}
}
\ProcessOptions\relax
% --------------------------------------------------
\ifdefined\tensorsize@small
\pgfmathsetmacro\unitCm{0.6}
\pgfmathsetmacro\nodeDistance{0.5}
\else
\pgfmathsetmacro\unitCm{1.0}
\pgfmathsetmacro\nodeDistance{0.5}
\fi
\edef\scale{1.2}
\RequirePackage{etoolbox}
\RequirePackage{amsmath}
\RequirePackage{tikz}
\usetikzlibrary{shapes,fit,positioning}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\RequirePackage{colorscheme}
\pagecolor{bg1} \color{fg0}
% distance of above/right... of
\tikzset{
node distance=\nodeDistance cm
}
\newcommand{\setTikzStyles}{
\pgfmathsetmacro\tensorSize{\unitCm * 0.5}
% Define styles for tensors, Schmidt values, and legs
\tikzstyle{ten} = [draw, rectangle, minimum size=\tensorSize cm, rounded corners=2pt]
\tikzstyle{mpo} = [draw, rectangle, minimum size=\tensorSize cm]
\tikzstyle{val} = [draw, circle, minimum size=\tensorSize cm]
\tikzstyle{tensorcorners} = [rounded corners=2pt]
\tikzstyle{leg} = []
\pgfmathsetmacro\dx{0.08}
\pgfmathsetmacro\dy{0.08}
% tensor + dx
\pgfmathsetmacro\tdx{\tensorSize+\dx}
\pgfmathsetmacro\dLabel{0.6 * \unitCm}
% length of free legs
\pgfmathsetmacro\legLength{0.6}
}
% Define a combined style for labeled small tensors
% \newcommand{\smalltensor}[3]{
% \node[tensor_small] (#1) at (#2) {};
% \node[above=1pt of #1] {#3};
% }
% Draw a grid with numbers, for easily positioning things
\newcommand\drawGrid[4]{
\pgfmathsetmacro{\xMin}{#1}%
\pgfmathsetmacro{\xMax}{#2}%
\pgfmathsetmacro{\yMin}{#3}%
\pgfmathsetmacro{\yMax}{#4}%
\foreach \i in {\xMin,...,\xMax} {
\draw [very thin,gray] (\i,\yMin) -- (\i,\yMax) node [below] at (\i,\yMin) {$\i$};
}
\foreach \i in {\yMin,...,\yMax} {
\draw [very thin,gray] (\xMin,\i) -- (\xMax,\i) node [left] at (\xMin,\i) {$\i$};
}
}
% Draw around 4 points
% [1]: draw options
% 2: nodes to contain, eg (M1)(M2)
\newcommand\drawAroundPoints[2][]{
\node[#1, fit=#2, inner sep=\dx cm] {};
}
% Draw around 4 points
% [1]: draw options
% 2: (x,y)
% 3: w
% 4: h
\newcommand\drawAroundRect[4][]{
\draw[#1]
($#2+( 0, 0)+(-\tdx, \tdx)$) --
($#2+(#3, 0)+( \tdx, \tdx)$) --
($#2+(#3,#4)+( \tdx,-\tdx)$) --
($#2+( 0,#4)+(-\tdx,-\tdx)$) --
cycle;
}
\newcommand\getNodeDimensions[1]{
\pgfpointanchor{#1}{east}
\pgfgetlastxy{\eastX}{\eastY}
\pgfpointanchor{#1}{west}
\pgfgetlastxy{\westX}{\westY}
\pgfpointanchor{#1}{north}
\pgfgetlastxy{\northX}{\northY}
\pgfpointanchor{#1}{south}
\pgfgetlastxy{\southX}{\southY}
\pgfmathsetlengthmacro{\nodeWidth}{\eastX - \westX}
\pgfmathsetlengthmacro{\nodeHeight}{\northY - \southY}
}
\setTikzStyles