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

Make Koma compatible by eliminating the need of the titlesec package (by...

Make Koma compatible by eliminating the need of the titlesec package (by redefining new sections within koma). Add script for producing directly input-able notebooks' latex files. Plus minor things.
parent 87f4c21a
......@@ -5,6 +5,7 @@
% For the licensing details of the documentation see license.CCBYSA.
\documentclass[10pt,modern]{scrartcl}
%\documentclass[10pt,modern]{article}
\usepackage{graphicx}
\usepackage[margin=2.5cm]{geometry}
\usepackage[T1]{fontenc}
......@@ -30,7 +31,8 @@
\usepackage[breaklinks=true,colorlinks,pdfborder={0 0 0}]{hyperref}
\usepackage{float}
\usepackage{pdfpages}
\usepackage{titlesec}
%\usepackage{titlesec} % incompatible with Koma
\usepackage{relsize}
\usepackage[framemethod=default]{mdframed}
\usepackage{showexpl}
......@@ -92,40 +94,50 @@
\makesavenoteenv{table}
% % only for the scrartcl class:
\setkomafont{author}{\large}
\setkomafont{date}{\large}
% \RedeclareSectionCommand[style=section,indent=0pt]{part}
% \renewcommand*\partformat{\thepart\autodot\enskip}
%\setkomafont{author}{\large}
%\setkomafont{date}{\large}
%% \RedeclareSectionCommand[style=section,indent=0pt]{part}
%% \renewcommand*\partformat{\thepart\autodot\enskip}
\RedeclareSectionCommand[style=section,indent=0pt,font=\huge,beforeskip=4ex,afterskip=4ex]{part}
\renewcommand*\partformat{{\partname~\thepart\autodot\enskip}}
\DeclareNewSectionCommand[style=section,level=1,font=\sffamily\Large\bfseries,afterskip=2.3ex plus .2ex,beforeskip=-3.5ex plus -1ex minus -.2ex,tocindent=3.38em,tocnumwidth=2.3em]{exercise}
\renewcommand*\exerciseformat{{Exercise \theexercise~--~}}
\DeclareNewSectionCommand[style=section,level=2,font=\sffamily\large\bfseries,afterskip=1.5ex plus .2ex,beforeskip=-3.25ex plus -1ex minus -.2ex,tocindent=3.8em,tocnumwidth=3.2em]{exerciseitem}
\renewcommand*\exerciseitemformat{{\theexercise{\hspace{.2ex}}\alph{exerciseitem})~}}
\numberwithin{exerciseitem}{exercise} % reset counter ; depends on the amsmath package
\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\mycomment}[1]{{\color{red} #1}}
\newcommand{\FAcomment}[1]{{\color{red} #1}}
%%%%%%%%%%%%%%% -- uses package titlesec -- %%%%%%%%%%%%%%%
%%% tweaking the form of Part
\titleclass{\part}{straight} % "straght": no new page; "top" is another option
\titleformat{\part}[block] % "block": no new line between "Part #." and "<part_title>"
{\sffamily\huge\bfseries}{\partname~\thepart.}{0.5em}{}
\titlespacing*{\part} {0pt}{20pt}{20pt} % {}{vertical spacing before}{vertical spacing after}
%\titleclass{\part}{straight} % "straght": no new page; "top" is another option
%\titleformat{\part}[block] % "block": no new line between "Part #." and "<part_title>"
%{\sffamily\huge\bfseries}{\partname~\thepart.}{0.5em}{}
%\titlespacing*{\part} {0pt}{20pt}{20pt} % {}{vertical spacing before}{vertical spacing after}
%%% define section-like "exercise"
\titleclass{\exercise}{straight}[\subsection]
\newcounter{exercise}
\titleformat{\exercise}
%{\sffamily\Large\bfseries}{}{0em}{Exercise \Roman{part}.\theexercise~--~}
{\sffamily\Large\bfseries}{}{0em}{Exercise \theexercise~--~}
\titlespacing*{\exercise}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
%\numberwithin{exercise}{part} % reset exercise number and apend Part counter to it; depends on the amsmath package
%%%
%\titleclass{\exercise}{straight}[\subsection]
%\newcounter{exercise}
%\titleformat{\exercise}
%%{\sffamily\Large\bfseries}{}{0em}{Exercise \Roman{part}.\theexercise~--~}
%{\sffamily\Large\bfseries}{}{0em}{Exercise \theexercise~--~}
%\titlespacing*{\exercise}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
%%\numberwithin{exercise}{part} % reset exercise number and apend Part counter to it; depends on the amsmath package
%%% define subsection-like "exerciseitem"
\titleclass{\exerciseitem}{straight}[\subsection]
\newcounter{exerciseitem}
\titleformat{\exerciseitem}
%{\sffamily\large\bfseries}{}{0em}{\Roman{part}.\theexercise.\alph{exerciseitem})~}
{\sffamily\large\bfseries}{}{0em}{ \theexercise{\hspace{.2ex}}\alph{exerciseitem})~}
\titlespacing*{\exerciseitem}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\numberwithin{exerciseitem}{exercise} % reset counter ; depends on the amsmath package
%%%
%\titleclass{\exerciseitem}{straight}[\subsection]
%\newcounter{exerciseitem}
%\titleformat{\exerciseitem}
%%{\sffamily\large\bfseries}{}{0em}{\Roman{part}.\theexercise.\alph{exerciseitem})~}
%{\sffamily\large\bfseries}{}{0em}{ \theexercise{\hspace{.2ex}}\alph{exerciseitem})~}
%\titlespacing*{\exerciseitem}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
%\numberwithin{exerciseitem}{exercise} % reset counter ; depends on the amsmath package
%%%%%%%%%%%%%%% -- END of "uses package titlesec" -- %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{Notebooks/notebooks_preamble.tex}
......@@ -137,9 +149,10 @@
\makeindex
\begin{document}
%---------------------------------------------------------------------------------------------------------
\title{ ALF Tutorial }
\title{ ALF Tutorial \\
\smaller\smaller The \emph{ALF} (\emph{A}lgorithms for \emph{L}attice \emph{F}ermions) project release 2.0 tutorial}
\subtitle{The \emph{ALF} (\emph{A}lgorithms for \emph{L}attice \emph{F}ermions) project release 2.0 tutorial}
%\subtitle{The \emph{ALF} (\emph{A}lgorithms for \emph{L}attice \emph{F}ermions) project release 2.0 tutorial} % only for the scrartcl class
\author{Florian Goth, Johannes S. Hofmann, Jonas Schwab,\\ Jefferson S. E. Portela, Fakher F. Assaad }
%---------------------------------------------------------------------------------------------------------
\maketitle
......@@ -194,28 +207,21 @@ jupyter notebook
which opens the "notebook dashboard" in your default browser, where you can navigate through your file structure to the pyALF directory. There you will find the interface's core module, \texttt{py\_alf.py}, some auxiliary files, and notebooks such as the ones included bellow. Have fun.
\section*{Notebooks}
%\includepdf[pages=-,pagecommand={},width=1.2\textwidth]{Notebooks/minimal_ALF_run.pdf}
\input{Notebooks/minimal_ALF_run.tex}
\input{Notebooks/minimal_ALF_run-content.tex}
%\begin{figure}[h]
% \begin{center}
% \includegraphics[scale=.9]{Figures/Ener_B2.pdf}
% \end{center}
% \caption{ $\Delta \tau t $ extrapolation for the 4-site Hubbard ring. }
%\end{figure}
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.9]{Figures/Ener_B2.pdf}
\end{center}
\caption{ $\Delta \tau t $ extrapolation for the 4-site Hubbard ring. }
\end{figure}
%\newpage
%%%%%%%%%%%%%%%%%%%%
......
1) Download latex version of the notebook from Jupyter server (in the browser):
```
example.tex
```
2) Apply `get_content_from_notebook_latex.sh` script:
```
get_content_from_notebook_latex.sh example.tex
```
which outputs a file called `example-content.tex` with only the lines of `example.tex` found between `\maketitle` and `\end{document}`.
---
Content of script `get_content_from_notebook_latex.sh`:
```bash
#/bin/bash
file=$1 # 1st argument: "file"
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' \
$file > $newfile # Where:
# 1st: delete lines NOT in the range between expressions
# 2nd: delete lines containing the expressions
```
---
* The file `notebooks_preamble.tex` is the preamble of the downloaded example.tex, minus the lines:
```
\documentclass[11pt]{article}
\usepackage{mathpazo}
```
#/bin/bash
file=$1 # 1st argument: "file"
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' \
$file > $newfile # Where:
# 1st: delete lines NOT in the range between expressions
# 2nd: delete lines containing the expressions
\hypertarget{a-minimal-alf-run}{%
\section{A minimal ALF run}\label{a-minimal-alf-run}}
In this bare-bones example we use the
\href{https://git.physik.uni-wuerzburg.de/ALF/pyALF}{pyALF} interface to
run the canonical Hubbard model on a default configuration: a
\(6\times6\) square grid, with interaction strength \(U=4\) and inverse
temperature \(\beta = 5\).
Bellow we go through the steps for performing the simulation and
outputting observables.
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
\textbf{1.} Import \texttt{Simulation} class from the \texttt{py\_alf}
python module, which provides the interface with ALF:
\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}{import} \PY{n}{Simulation} \PY{c+c1}{\PYZsh{} Interface with ALF}
\end{Verbatim}
\end{tcolorbox}
\textbf{2.} Create an instance of \texttt{Simulation}, setting
parameters as desired:
\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}{sim} \PY{o}{=} \PY{n}{Simulation}\PY{p}{(}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Hubbard}\PY{l+s+s2}{\PYZdq{}}\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+s2}{\PYZdq{}}\PY{l+s+s2}{Model}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Hubbard}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Base model}
\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Lattice\PYZus{}type}\PY{l+s+s2}{\PYZdq{}}\PY{p}{:} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Square}\PY{l+s+s2}{\PYZdq{}}\PY{p}{\PYZcb{}}\PY{p}{,} \PY{c+c1}{\PYZsh{} Lattice type}
\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\textbf{3.} Compile ALF, downloading it first from the
\href{https://git.physik.uni-wuerzburg.de:ALF}{ALF repository} 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}{sim}\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=\\\{\}]
Repository /home/stafusa/ALF/pyALF/Notebooks/ALF does not exist, cloning from
git@git.physik.uni-wuerzburg.de:ALF/ALF.git
Compiling ALF{\ldots} Done.
\end{Verbatim}
\textbf{4.} Perform the simulation as specified in \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{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/Notebooks/Hubbard\_Square" for Monte
Carlo run.
Create new directory.
Run /home/stafusa/ALF/pyALF/Notebooks/ALF/Prog/Hubbard.out
\end{Verbatim}
\textbf{5.} Perform some simple analyses:
\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}{sim}\PY{o}{.}\PY{n}{analysis}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Perform default analysis; list observables}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
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
Analysing SpinXY\_tau
Analysing SpinZ\_tau
Analysing Den\_tau
Analysing Green\_tau
Analysing SpinT\_tau
\end{Verbatim}
\textbf{6.} Store computed observables list:
\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}{obs} \PY{o}{=} \PY{n}{sim}\PY{o}{.}\PY{n}{get\PYZus{}obs}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} Dictionary for the observables}
\end{Verbatim}
\end{tcolorbox}
which are available for further analyses. For instance, the internal
energy of the system (and its error) is accessed by:
\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}{obs}\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}{]}
\end{Verbatim}
\end{tcolorbox}
\begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0]
\prompt{Out}{outcolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
array([[-29.983503, 0.232685]])
\end{Verbatim}
\end{tcolorbox}
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
\textbf{7.} Running again: The simulation can be resumed to increase the
precision of the results.
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{8}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{sim}\PY{o}{.}\PY{n}{run}\PY{p}{(}\PY{p}{)}
\PY{n}{sim}\PY{o}{.}\PY{n}{analysis}\PY{p}{(}\PY{p}{)}
\PY{n}{obs2} \PY{o}{=} \PY{n}{sim}\PY{o}{.}\PY{n}{get\PYZus{}obs}\PY{p}{(}\PY{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{obs2}\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{p}{)}
\PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s2}{Running again reduced the error from }\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{obs}\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{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ to }\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{obs2}\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{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{Verbatim}[commandchars=\\\{\}]
Prepare directory "/home/stafusa/ALF/pyALF/Notebooks/Hubbard\_Square" for Monte
Carlo run.
Resuming previous run.
Run /home/stafusa/ALF/pyALF/Notebooks/ALF/Prog/Hubbard.out
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
Analysing SpinXY\_tau
Analysing SpinZ\_tau
Analysing Den\_tau
Analysing Green\_tau
Analysing SpinT\_tau
[[-29.819654 0.135667]]
Running again reduced the error from 0.232685 to 0.135667 .
\end{Verbatim}
\textbf{Note}: To run a fresh simulation - instead of performing a
refinement over previous run(s) - the Monte Carlo run directory should
deleted before rerunning.
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
\hypertarget{exercises}{%
\subsection{Exercises}\label{exercises}}
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
Rerun once again and check the new improvement in precision.
\item
Look at a few other observables (\texttt{sim.analysis()} outputs the
names of those available).
\item
Change the lattice size by adding, e.g., \texttt{"L1":\ 4,} and
\texttt{"L2":\ 1,} to the simulation parameters definitions of
\texttt{sim} (step 2).
\end{enumerate}
% Add a bibliography block to the postdoc
This diff is collapsed.
\relax
\providecommand\hyper@newdestlabel[2]{}
\providecommand\zref@newlabel[2]{}
\@setckpt{Notebooks/minimal_ALF_run.tex}{
\setcounter{page}{3}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
\setcounter{enumiii}{0}
\setcounter{enumiv}{0}
\setcounter{footnote}{0}
\setcounter{mpfootnote}{0}
\setcounter{part}{1}
\setcounter{section}{0}
\setcounter{subsection}{0}
\setcounter{subsubsection}{0}
\setcounter{paragraph}{0}
\setcounter{subparagraph}{0}
\setcounter{figure}{0}
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{subfigure}{0}
\setcounter{lofdepth}{1}
\setcounter{subtable}{0}
\setcounter{lotdepth}{1}
\setcounter{tcbbreakpart}{0}
\setcounter{tcblayer}{0}
\setcounter{lstnumber}{2}
\setcounter{Item}{0}
\setcounter{Hfootnote}{0}
\setcounter{bookmark@seq@number}{0}
\setcounter{float@type}{16}
\setcounter{AM@survey}{0}
\setcounter{mdf@globalstyle@cnt}{0}
\setcounter{mdfcountframes}{0}
\setcounter{mdf@env@i}{0}
\setcounter{mdf@env@ii}{0}
\setcounter{mdf@zref@counter}{0}
\setcounter{ltxexample}{0}
\setcounter{exercise}{0}
\setcounter{exerciseitem}{0}
\setcounter{lstlisting}{0}
\setcounter{section@level}{0}
}
\usepackage[breakable]{tcolorbox}
\usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\else
\usepackage{fontspec}
\fi
% Basic figure setup, for now with no caption control since it's done
% automatically by Pandoc (which extracts ![](path) syntax from Markdown).
\usepackage{graphicx}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment