Commit e5d8366d authored by Jefferson Stafusa E. Portela's avatar Jefferson Stafusa E. Portela
Browse files

Update bash script for the latex version of the notebooks; update correponding...

Update bash script for the latex version of the notebooks; update correponding description; add new notebooks.
parent 09d9e6be
......@@ -33,6 +33,7 @@
\usepackage{pdfpages}
%\usepackage{titlesec} % incompatible with Koma
\usepackage{relsize}
\graphicspath{{./Figures/}{./Notebooks/}}
\usepackage[framemethod=default]{mdframed}
\usepackage{showexpl}
......@@ -238,13 +239,15 @@ which opens the ``notebook dashboard'' in your default browser, where you can na
% \caption{ $\Delta \tau t $ extrapolation for the 4-site Hubbard ring. }
%\end{figure}
\input{Notebooks/testing_against_ED-content.tex}
%\input{Notebooks/.tex}
%\newpage
%%%%%%%%%%%%%%%%%%%%
\part{Getting your hands dirty - changing the code}
\part{Getting your hands dirty - writing new code}
%\setcounter{exercise}{0}
Part II consists in a set of guided advanced exercises.
......@@ -356,7 +359,7 @@ In the program \texttt{Hamiltonian\_Examples.f90 } to be found in the directory
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.8]{Figures/Ladder.pdf}
\includegraphics[scale=.8]{Ladder.pdf}
\end{center}
\caption{ \label{Ladder.fig} Spin correlation functions along one leg for the Hubbard ladder. As $t_y$ grows the spin gap becomes large enough so as to detect the exponential decal of the spin correlation function on this small lattice size. The underlying physics of odd-even ladder systems is introduced in the article: Elbio Dagotto and T. M. Rice, Surprises on the way from one- to two-dimensional quantum magnets: The ladder materials, Science 271 (1996), no. 5249, 618?623. }
\end{figure}
......@@ -428,7 +431,7 @@ You can now run the code for various values of $V/t$. A Jordan-Wigner transform
with $J_{zz} = V $ and $J_{xx} = 2t$. Hence when $V/t = 2$ we reproduce the Heisenberg model. For $V/t > 2$ the model is in the Ising regime with long-range charge density wave order and is an insulator. In the regime $ -2 < V/t < 2$ the model is metallic and corresponds to a Luttinger liquid. Finally, at $ V/t < - 2$ phase separation between hole rich and electron rich phases occur. Fig.~\ref{tV.fig} shows typical results.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.8]{Figures/tV.pdf}
\includegraphics[scale=.8]{tV.pdf}
\end{center}
\caption{ \label{tV.fig} Density-Density correlation functions of the t-V model. In the Luttinger liquid phase, $-2 < V/t < 2$ it is known that the density -density correlations decay as
$ \langle n(r) n(0)\rangle \propto \cos(\pi r) r^{-\left(1+K_\rho \right) } $ with $\left(1+K_\rho \right)^{-1}= \frac{1}{2} + \frac{1}{\pi} \arcsin \left( \frac{V}{2 | t | }\right) $
......
1) Download latex version of the notebook from Jupyter server (in the browser):
Create usable Latex notebook files
---
Three steps:
1. Download the latex version of the notebook from the Jupyter server [ in the browser: File > Download as > LaTeX (.tex) ], say `example01.zip`, which contains:
```
example01.tex
output_12_2.png
```
example.tex
2. Rename any figures by preceding their original name with `example01-`, i.e., `$(basename <filename> .png)-`:
```
mv output_12_2.png example01-output_12_2.png
```
2) Apply `get_content_from_notebook_latex.sh` script:
3. Apply `get_content_from_notebook_latex.sh` script:
```
get_content_from_notebook_latex.sh example.tex
get_content_from_notebook_latex.sh example01.tex
```
which outputs a file called `example-content.tex` with only the lines of `example.tex` found between `\maketitle` and `\end{document}`.
which outputs a file called `example01-content.tex` with only the lines of `example01.tex` found between `\maketitle` and `\end{document}`. It also changes `{example.png}` to `{example01-example.png}`, since different downloaded latex notebooks may have figures with the same name.
---
Content of script `get_content_from_notebook_latex.sh`:
Remarks
---
```bash
#/bin/bash
- The file **`notebooks_preamble.tex`** is the preamble of the downloaded `minimal_ALF_run.tex`, minus the lines:
```
\documentclass[11pt]{article}
\usepackage{mathpazo}
\usepackage{titling}
```
file=$1 # 1st argument: "file"
newfile="${file%.tex}-content.tex" # "file" minus ".tex" extension followed by "-content.tex"
- TO DO: instead of downloading notebooks' html and latex versions, use nbconvert command line
sed -e '/maketitle/,/end{document}/!d' \
-e '/maketitle/d;/end{document}/d' \
$file > $newfile # Where:
# 1st: delete lines NOT in the range between expressions
# 2nd: delete lines containing the expressions
- TO DO: include in the pipeline the creation of notebooks' html and latex versions
```
---
* The file `notebooks_preamble.tex` is the preamble of the downloaded example.tex, minus the lines:
```
\documentclass[11pt]{article}
\usepackage{mathpazo}
\usepackage{titling}
Content of script `get_content_from_notebook_latex.sh`:
---
```bash
#/bin/bash
# Usage: get_content_from_notebook_latex.sh <notebook_tex_file>
file=$1 # 1st argument -> "file", notebook latex filename
newfile="${file%.tex}-content.tex" # "file" minus ".tex" extension followed by "-content.tex"
sed -e '/maketitle/,/end{document}/!d' \
-e '/maketitle/d;/end{document}/d' \
-e "s/{\([^{]*.png}\)/{${file%.tex}-\1/g" \
$file > $newfile # Where:
# 1st: delete lines NOT in the range between expressions
# 2nd: delete lines containing the expressions
# 3rd: change {example.png} to {notebookname-example.png} ,
# \1 refers to the previous subexpression enclosed by
# \( \), and [^{]* matches the longest sequence of
# characters not including {
```
#/bin/bash
file=$1 # 1st argument: "file"
newfile="${file%.tex}-content.tex" # "file" minus ".tex" extension followed by "-content.tex"
# Usage: get_content_from_notebook_latex.sh <notebook_tex_file>
sed -e '/maketitle/,/end{document}/!d' \
-e '/maketitle/d;/end{document}/d' \
$file > $newfile # Where:
# 1st: delete lines NOT in the range between expressions
# 2nd: delete lines containing the expressions
file=$1 # 1st argument -> "file", notebook latex filename
newfile="${file%.tex}-content.tex" # "file" minus ".tex" extension followed by "-content.tex"
sed -e '/maketitle/,/end{document}/!d' \
-e '/maketitle/d;/end{document}/d' \
-e "s/{\([^{]*.png}\)/{${file%.tex}-\1/g" \
$file > $newfile # Where:
# 1st: delete lines NOT in the range between expressions
# 2nd: delete lines containing the expressions
# 3rd: change {example.png} to {notebookname-example.png} ,
# \1 refers to the previous subexpression enclosed by
# \( \), and [^{]* matches the longest sequence of
# characters not including {
\hypertarget{testing-against-ed---hubbard-on-a-ring}{%
\section{Testing against ED - Hubbard on a
ring}\label{testing-against-ed---hubbard-on-a-ring}}
In this example we use the
\href{https://git.physik.uni-wuerzburg.de/ALF/pyALF}{pyALF} interface to
run ALF with the Mz choice of Hubbard Stratonovitch transformation on a
four site ring, at \(U/t=4\) and inverse temperature \(\beta t = 2\).
For this set of parameters, the exact internal energy reads:\\
\[
\left\langle -t \sum_{\langle i,j\rangle, \sigma} c_{i,\sigma}^{\dagger} c_{j,\sigma}^{\phantom\dagger} + U \sum_{i=1}^{N} n_{i,\uparrow}n_{j,\downarrow} \right\rangle = -1.47261997 t
\]
To reproduce this result we will have to carry out a systematic
\(\Delta \tau t\) extrapolation keeping
\(\Delta \tau t L_\text{Trotter} = 2\) constant.\\
Recall that the formulation of the auxiliary field QMC approach is based
on the Trotter decomposition \[
e^{-\Delta \tau \left( A + B \right ) } = e^{-\Delta \tau A } e^{-\Delta \tau B } + {\cal O} \left( \Delta \tau^2 \right)
\] The overall error produced by this approximation is of the order
\(\Delta \tau^2\).
Bellow we go through the steps for performing this extrapolation:
setting the simulation parameters, running it and analyzing the data.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\textbf{1.} Import \texttt{Simulation} class from the \texttt{py\_alf}
python module, which provides the interface with ALF, as well as
mathematics and plotting packages:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{1}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{from} \PY{n+nn}{py\PYZus{}alf} \PY{k+kn}{import} \PY{n}{Simulation} \PY{c+c1}{\PYZsh{} Interface with ALF}
\PY{c+c1}{\PYZsh{} }
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np} \PY{c+c1}{\PYZsh{} Numerical library}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{optimize} \PY{k+kn}{import} \PY{n}{curve\PYZus{}fit} \PY{c+c1}{\PYZsh{} Numerical library}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt} \PY{c+c1}{\PYZsh{} Plotting library}
\end{Verbatim}
\end{tcolorbox}
\textbf{2.} Create instances of \texttt{Simulation}, specifying the
necessary parameters, in particular the different \(\Delta \tau\)
values:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{2}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{sims} \PY{o}{=} \PY{p}{[}\PY{p}{]} \PY{c+c1}{\PYZsh{} Vector of Simulation instances}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{dtau values used:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{k}{for} \PY{n}{dtau} \PY{o+ow}{in} \PY{p}{[}\PY{l+m+mf}{0.05}\PY{p}{,} \PY{l+m+mf}{0.1}\PY{p}{,} \PY{l+m+mf}{0.15}\PY{p}{]}\PY{p}{:} \PY{c+c1}{\PYZsh{} Values of dtau}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{dtau}\PY{p}{)}
\PY{n}{sim} \PY{o}{=} \PY{n}{Simulation}\PY{p}{(}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hubbard}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Hamiltonian}
\PY{p}{\PYZob{}} \PY{c+c1}{\PYZsh{} Model and simulation parameters for each Simulation instance}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Model}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hubbard}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Base model}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Lattice\PYZus{}type}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{N\PYZus{}leg\PYZus{}ladder}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice type}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{L1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{4}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice length in the first unit vector direction}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{L2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{1}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice length in the second unit vector direction}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Checkerboard}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k+kc}{False}\PY{p}{,} \PY{c+c1}{\PYZsh{} Whether checkerboard decomposition is used or not}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Symm}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k+kc}{True}\PY{p}{,} \PY{c+c1}{\PYZsh{} Whether symmetrization takes place}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ham\PYZus{}T}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{1.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} Hopping parameter}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ham\PYZus{}U}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{4.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} Hubbard interaction}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ham\PYZus{}Tperp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{0.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} For bilayer systems}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{beta}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{2.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} Inverse temperature}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ltau}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{0}\PY{p}{,} \PY{c+c1}{\PYZsh{} \PYZsq{}1\PYZsq{} for time\PYZhy{}displaced Green functions; \PYZsq{}0\PYZsq{} otherwise }
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NSweep}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{400}\PY{p}{,} \PY{c+c1}{\PYZsh{} Number of sweeps}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NBin}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{100}\PY{p}{,} \PY{c+c1}{\PYZsh{} Number of bins}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dtau}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{n}{dtau}\PY{p}{,} \PY{c+c1}{\PYZsh{} Only dtau varies between simulations, Ltrot=beta/Dtau}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Mz}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k+kc}{True}\PY{p}{,} \PY{c+c1}{\PYZsh{} If true, sets the M\PYZus{}z\PYZhy{}Hubbard model: Nf=2, N\PYZus{}sum=1,}
\PY{p}{\PYZcb{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} HS field couples to z\PYZhy{}component of magnetization}
\PY{n}{alf\PYZus{}dir}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZti{}/Programs/ALF}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Local ALF copy, if present}
\PY{p}{)}
\PY{n}{sims}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{sim}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
dtau values used:
0.05
0.1
0.15
\end{Verbatim}
\textbf{3.} Compile ALF, downloading it first if not found locally. This
may take a few minutes:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{3}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{sims}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{.}\PY{n}{compile}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Compilation needs to be performed only once}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
Compiling ALF{\ldots} Done.
\end{Verbatim}
\textbf{4.} Perform the simulations, as specified in each element of
\texttt{sim}:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{4}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{sim} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{:}
\PY{n}{sim}\PY{o}{.}\PY{n}{run}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Perform the actual simulation in ALF}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
Prepare directory "/home/stafusa/ALF/pyALF/Hubbard\_N\_leg\_ladder\_L1=4\_L2=1\_Checke
rboard=False\_Symm=True\_T=1.0\_U=4.0\_Tperp=0.0\_beta=2.0\_Dtau=0.05\_Mz=True" for
Monte Carlo run.
Resuming previous run.
Run /home/stafusa/Programs/ALF/Prog/Hubbard.out
Prepare directory "/home/stafusa/ALF/pyALF/Hubbard\_N\_leg\_ladder\_L1=4\_L2=1\_Checke
rboard=False\_Symm=True\_T=1.0\_U=4.0\_Tperp=0.0\_beta=2.0\_Dtau=0.1\_Mz=True" for
Monte Carlo run.
Resuming previous run.
Run /home/stafusa/Programs/ALF/Prog/Hubbard.out
Prepare directory "/home/stafusa/ALF/pyALF/Hubbard\_N\_leg\_ladder\_L1=4\_L2=1\_Checke
rboard=False\_Symm=True\_T=1.0\_U=4.0\_Tperp=0.0\_beta=2.0\_Dtau=0.15\_Mz=True" for
Monte Carlo run.
Resuming previous run.
Run /home/stafusa/Programs/ALF/Prog/Hubbard.out
\end{Verbatim}
\textbf{5.} Calculate the internal energies:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{5}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{ener} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)} \PY{c+c1}{\PYZsh{} Matrix for storing energy values}
\PY{n}{dtaus} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{,}\PY{p}{)}\PY{p}{)} \PY{c+c1}{\PYZsh{} Matrix for Dtau values, for plotting}
\PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{sim} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{:}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{sim}\PY{o}{.}\PY{n}{sim\PYZus{}dir}\PY{p}{)} \PY{c+c1}{\PYZsh{} Directory containing the simulation output}
\PY{n}{sim}\PY{o}{.}\PY{n}{analysis}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Perform default analysis}
\PY{n}{dtaus}\PY{p}{[}\PY{n}{i}\PY{p}{]} \PY{o}{=} \PY{n}{sim}\PY{o}{.}\PY{n}{sim\PYZus{}dict}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dtau}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{c+c1}{\PYZsh{} Store Dtau value}
\PY{n}{ener}\PY{p}{[}\PY{n}{i}\PY{p}{]} \PY{o}{=} \PY{n}{sim}\PY{o}{.}\PY{n}{get\PYZus{}obs}\PY{p}{(}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ener\PYZus{}scalJ}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ener\PYZus{}scalJ}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{obs}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]} \PY{c+c1}{\PYZsh{} Store internal energy}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
/home/stafusa/ALF/pyALF/Hubbard\_N\_leg\_ladder\_L1=4\_L2=1\_Checkerboard=False\_Symm=T
rue\_T=1.0\_U=4.0\_Tperp=0.0\_beta=2.0\_Dtau=0.05\_Mz=True
Analysing Ener\_scal
Analysing Part\_scal
Analysing Pot\_scal
Analysing Kin\_scal
Analysing Den\_eq
Analysing SpinZ\_eq
Analysing Green\_eq
Analysing SpinXY\_eq
Analysing SpinT\_eq
/home/stafusa/ALF/pyALF/Hubbard\_N\_leg\_ladder\_L1=4\_L2=1\_Checkerboard=False\_Symm=T
rue\_T=1.0\_U=4.0\_Tperp=0.0\_beta=2.0\_Dtau=0.1\_Mz=True
Analysing Ener\_scal
Analysing Part\_scal
Analysing Pot\_scal
Analysing Kin\_scal
Analysing Den\_eq
Analysing SpinZ\_eq
Analysing Green\_eq
Analysing SpinXY\_eq
Analysing SpinT\_eq
/home/stafusa/ALF/pyALF/Hubbard\_N\_leg\_ladder\_L1=4\_L2=1\_Checkerboard=False\_Symm=T
rue\_T=1.0\_U=4.0\_Tperp=0.0\_beta=2.0\_Dtau=0.15\_Mz=True
Analysing Ener\_scal
Analysing Part\_scal
Analysing Pot\_scal
Analysing Kin\_scal
Analysing Den\_eq
Analysing SpinZ\_eq
Analysing Green\_eq
Analysing SpinXY\_eq
Analysing SpinT\_eq
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{6}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{For Dtau values}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{dtaus}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{the measured energies are:}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{ener}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
For Dtau values [0.05 0.1 0.15] the measured energies are:
[[-1.473383 0.002569]
[-1.478316 0.002525]
[-1.46798 0.002359]]
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{plt}\PY{o}{.}\PY{n}{errorbar}\PY{p}{(}\PY{n}{dtaus}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{ener}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{ener}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{k}{def} \PY{n+nf}{func}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y0}\PY{p}{,} \PY{n}{a}\PY{p}{)}\PY{p}{:}
\PY{k}{return} \PY{n}{y0} \PY{o}{+} \PY{n}{a}\PY{o}{*}\PY{n}{x}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}
\PY{n}{popt1}\PY{p}{,} \PY{n}{pcov} \PY{o}{=} \PY{n}{curve\PYZus{}fit}\PY{p}{(}\PY{n}{func}\PY{p}{,} \PY{n}{dtaus}\PY{p}{,} \PY{n}{ener}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{sigma}\PY{o}{=}\PY{n}{ener}\PY{p}{[}\PY{p}{:}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,} \PY{n}{absolute\PYZus{}sigma}\PY{o}{=}\PY{k+kc}{True}\PY{p}{)}
\PY{n}{perr1} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{diag}\PY{p}{(}\PY{n}{pcov}\PY{p}{)}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{popt1}\PY{p}{,} \PY{n}{perr1}\PY{p}{)}
\PY{n}{xs} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mf}{0.}\PY{p}{,} \PY{n}{dtaus}\PY{o}{.}\PY{n}{max}\PY{p}{(}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{xs}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{,} \PY{n}{func}\PY{p}{(}\PY{n}{xs}\PY{p}{,} \PY{o}{*}\PY{n}{popt1}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{errorbar}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{popt1}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{n}{perr1}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
[-1.47718877 0.3429858 ] [0.00254357 0.17130454]
\end{Verbatim}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
<ErrorbarContainer object of 3 artists>
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.6\linewidth}{0.9\paperheight}}{testing_against_ED-output_12_2.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\hypertarget{exercises}{%
\subsection{Exercises}\label{exercises}}
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
Redo the extrapolation for different values of \(\beta t\) (e.g., for
\(\beta t =\) 1, the internal energy is -0.62186692\(t\), and for
\(\beta t =\) 4, it is -1.90837196\(t\)).
\item
Experiment with different settings for \texttt{Checkerboard} and
\texttt{Symm}.
\end{enumerate}
% Add a bibliography block to the postdoc
This diff is collapsed.
This diff is collapsed.
\hypertarget{trotter-systematic-error---hubbard-on-the-square-lattice}{%
\section{Trotter systematic error - Hubbard on the square
lattice}\label{trotter-systematic-error---hubbard-on-the-square-lattice}}
In this example we use the
\href{https://git.physik.uni-wuerzburg.de/ALF/pyALF}{pyALF} interface to
run ALF with the Mz choice of Hubbard-Stratonovich transformation (i.e.,
coupled to the \(z\)-component of the spin) on a \(6\times 6\) site
square lattice, at \(U/t=4\) half-band filling, and inverse temperature
\(\beta t = 5\).
We carry out a systematic \(\Delta \tau t\) extrapolation keeping
\(\Delta \tau t L_\text{Trotter} = 2\) constant. Recall that the
formulation of the auxiliary field QMC approach is based on the Trotter
decomposition \[
e^{-\Delta \tau \left( A + B \right ) } = e^{-\Delta \tau A } e^{-\Delta \tau B } + {\cal O} \left( \Delta \tau^2 \right)
\] The overall error produced by this approximation is of the order
\(\Delta \tau^2\).
Bellow we go through the steps for performing this extrapolation:
setting the simulation parameters, running it and analysing the data. A
reference plot for this analyses is found in
\href{https://git.physik.uni-wuerzburg.de/ALF/ALF_code/-/blob/master/Documentation/ALF_v1.0.pdf}{ALF
documentation}, Sec. 2.3.2 (Symmetric Trotter decomposition).
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\textbf{1.} Import \texttt{Simulation} class from the \texttt{py\_alf}
python module, which provides the interface with ALF, as well as
mathematics and plotting packages:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{1}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{from} \PY{n+nn}{py\PYZus{}alf} \PY{k+kn}{import} \PY{n}{Simulation} \PY{c+c1}{\PYZsh{} Interface with ALF}
\PY{c+c1}{\PYZsh{} }
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np} \PY{c+c1}{\PYZsh{} Numerical library}
\PY{k+kn}{from} \PY{n+nn}{scipy}\PY{n+nn}{.}\PY{n+nn}{optimize} \PY{k+kn}{import} \PY{n}{curve\PYZus{}fit} \PY{c+c1}{\PYZsh{} Numerical library}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt} \PY{c+c1}{\PYZsh{} Plotting library}
\end{Verbatim}
\end{tcolorbox}
\textbf{2.} Create instances of \texttt{Simulation}, specifying the
necessary parameters, in particular the different \(\Delta \tau\)
values:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{2}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{sims} \PY{o}{=} \PY{p}{[}\PY{p}{]} \PY{c+c1}{\PYZsh{} Vector of Simulation instances}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{dtau values used:}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{k}{for} \PY{n}{dtau} \PY{o+ow}{in} \PY{p}{[}\PY{l+m+mf}{0.05}\PY{p}{,} \PY{l+m+mf}{0.1}\PY{p}{,} \PY{l+m+mf}{0.15}\PY{p}{]}\PY{p}{:} \PY{c+c1}{\PYZsh{} Values of dtau}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{dtau}\PY{p}{)}
\PY{n}{sim} \PY{o}{=} \PY{n}{Simulation}\PY{p}{(}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hubbard}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Hamiltonian}
\PY{p}{\PYZob{}} \PY{c+c1}{\PYZsh{} Model and simulation parameters for each Simulation instance}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Model}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Hubbard}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Base model}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Lattice\PYZus{}type}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Square}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice type}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{L1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{6}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice length in the first unit vector direction}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{L2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{6}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice length in the second unit vector direction}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Checkerboard}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k+kc}{False}\PY{p}{,} \PY{c+c1}{\PYZsh{} Whether checkerboard decomposition is used or not}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Symm}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k+kc}{True}\PY{p}{,} \PY{c+c1}{\PYZsh{} Whether symmetrization takes place}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ham\PYZus{}T}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{1.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} Hopping parameter}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ham\PYZus{}U}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{4.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} Hubbard interaction}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ham\PYZus{}Tperp}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{0.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} For bilayer systems}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{beta}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mf}{5.0}\PY{p}{,} \PY{c+c1}{\PYZsh{} Inverse temperature}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ltau}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{0}\PY{p}{,} \PY{c+c1}{\PYZsh{} \PYZsq{}1\PYZsq{} for time\PYZhy{}displaced Green functions; \PYZsq{}0\PYZsq{} otherwise }
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NSweep}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{200}\PY{p}{,} \PY{c+c1}{\PYZsh{} Number of sweeps}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{NBin}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{l+m+mi}{10}\PY{p}{,} \PY{c+c1}{\PYZsh{} Number of bins}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Dtau}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{n}{dtau}\PY{p}{,} \PY{c+c1}{\PYZsh{} Only dtau varies between simulations, Ltrot=beta/Dtau}
\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Mz}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k+kc}{True}\PY{p}{,} \PY{c+c1}{\PYZsh{} If true, sets the M\PYZus{}z\PYZhy{}Hubbard model: Nf=2, N\PYZus{}sum=1,}
\PY{p}{\PYZcb{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} HS field couples to z\PYZhy{}component of magnetization}
\PY{n}{alf\PYZus{}dir}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZti{}/Programs/ALF}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Local ALF copy, if present}
\PY{p}{)}
\PY{n}{sims}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{sim}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
dtau values used:
0.05
0.1
0.15
\end{Verbatim}
\textbf{3.} Compile ALF, downloading it first if not found locally. This
may take a few minutes:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{3}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{sims}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{.}\PY{n}{compile}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Compilation needs to be performed only once}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
Compiling ALF{\ldots} Done.
\end{Verbatim}
\textbf{4.} Perform the simulations, as specified in each element of
\texttt{sim}:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{4}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{sim} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{:}
\PY{n}{sim}\PY{o}{.}\PY{n}{run}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Perform the actual simulation in ALF}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
Prepare directory "/home/stafusa/ALF/pyALF/Hubbard\_Square\_L1=6\_L2=6\_Checkerboard
=False\_Symm=True\_T=1.0\_U=4.0\_Tperp=0.0\_beta=5.0\_Dtau=0.05\_Mz=True" for Monte
Carlo run.
Resuming previous run.
Run /home/stafusa/Programs/ALF/Prog/Hubbard.out
Prepare directory "/home/stafusa/ALF/pyALF/Hubbard\_Square\_L1=6\_L2=6\_Checkerboard
=False\_Symm=True\_T=1.0\_U=4.0\_Tperp=0.0\_beta=5.0\_Dtau=0.1\_Mz=True" for Monte
Carlo run.
Resuming previous run.
Run /home/stafusa/Programs/ALF/Prog/Hubbard.out
Prepare directory "/home/stafusa/ALF/pyALF/Hubbard\_Square\_L1=6\_L2=6\_Checkerboard
=False\_Symm=True\_T=1.0\_U=4.0\_Tperp=0.0\_beta=5.0\_Dtau=0.15\_Mz=True" for Monte
Carlo run.
Resuming previous run.
Run /home/stafusa/Programs/ALF/Prog/Hubbard.out
\end{Verbatim}
\textbf{5.} Calculate the internal energies:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{5}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{ener} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{,} \PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)} \PY{c+c1}{\PYZsh{} Matrix for storing energy values}
\PY{n}{dtaus} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{,}\PY{p}{)}\PY{p}{)} \PY{c+c1}{\PYZsh{} Matrix for Dtau values, for plotting}
\PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{sim} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{sims}\PY{p}{)}\PY{p}{:}
\PY{n+nb}{print}\PY{p