\documentclass[11pt]{article}

    \usepackage[breakable]{tcolorbox}
    \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
    
    \usepackage{iftex}
    \ifPDFTeX
    	\usepackage[T1]{fontenc}
    	\usepackage{mathpazo}
    \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}
    % Maintain compatibility with old templates. Remove in nbconvert 6.0
    \let\Oldincludegraphics\includegraphics
    % Ensure that by default, figures have no caption (until we provide a
    % proper Figure object with a Caption API and a way to capture that
    % in the conversion process - todo).
    \usepackage{caption}
    \DeclareCaptionFormat{nocaption}{}
    \captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}

    \usepackage{float}
    \floatplacement{figure}{H} % forces figures to be placed at the correct location
    \usepackage{xcolor} % Allow colors to be defined
    \usepackage{enumerate} % Needed for markdown enumerations to work
    \usepackage{geometry} % Used to adjust the document margins
    \usepackage{amsmath} % Equations
    \usepackage{amssymb} % Equations
    \usepackage{textcomp} % defines textquotesingle
    % Hack from http://tex.stackexchange.com/a/47451/13684:
    \AtBeginDocument{%
        \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
    }
    \usepackage{upquote} % Upright quotes for verbatim code
    \usepackage{eurosym} % defines \euro
    \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
    \usepackage{fancyvrb} % verbatim replacement that allows latex
    \usepackage{grffile} % extends the file name processing of package graphics 
                         % to support a larger range
    \makeatletter % fix for old versions of grffile with XeLaTeX
    \@ifpackagelater{grffile}{2019/11/01}
    {
      % Do nothing on new versions
    }
    {
      \def\Gread@@xetex#1{%
        \IfFileExists{"\Gin@base".bb}%
        {\Gread@eps{\Gin@base.bb}}%
        {\Gread@@xetex@aux#1}%
      }
    }
    \makeatother
    \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
    \adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}

    % The hyperref package gives us a pdf with properly built
    % internal navigation ('pdf bookmarks' for the table of contents,
    % internal cross-reference links, web links for URLs, etc.)
    \usepackage{hyperref}
    % The default LaTeX title has an obnoxious amount of whitespace. By default,
    % titling removes some of it. It also provides customization options.
    \usepackage{titling}
    \usepackage{longtable} % longtable support required by pandoc >1.10
    \usepackage{booktabs}  % table support for pandoc > 1.12.2
    \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
    \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
                                % normalem makes italics be italics, not underlines
    \usepackage{mathrsfs}
    

    
    % Colors for the hyperref package
    \definecolor{urlcolor}{rgb}{0,.145,.698}
    \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
    \definecolor{citecolor}{rgb}{.12,.54,.11}

    % ANSI colors
    \definecolor{ansi-black}{HTML}{3E424D}
    \definecolor{ansi-black-intense}{HTML}{282C36}
    \definecolor{ansi-red}{HTML}{E75C58}
    \definecolor{ansi-red-intense}{HTML}{B22B31}
    \definecolor{ansi-green}{HTML}{00A250}
    \definecolor{ansi-green-intense}{HTML}{007427}
    \definecolor{ansi-yellow}{HTML}{DDB62B}
    \definecolor{ansi-yellow-intense}{HTML}{B27D12}
    \definecolor{ansi-blue}{HTML}{208FFB}
    \definecolor{ansi-blue-intense}{HTML}{0065CA}
    \definecolor{ansi-magenta}{HTML}{D160C4}
    \definecolor{ansi-magenta-intense}{HTML}{A03196}
    \definecolor{ansi-cyan}{HTML}{60C6C8}
    \definecolor{ansi-cyan-intense}{HTML}{258F8F}
    \definecolor{ansi-white}{HTML}{C5C1B4}
    \definecolor{ansi-white-intense}{HTML}{A1A6B2}
    \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
    \definecolor{ansi-default-inverse-bg}{HTML}{000000}

    % common color for the border for error outputs.
    \definecolor{outerrorbackground}{HTML}{FFDFDF}

    % commands and environments needed by pandoc snippets
    % extracted from the output of `pandoc -s`
    \providecommand{\tightlist}{%
      \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
    \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
    % Add ',fontsize=\small' for more characters per line
    \newenvironment{Shaded}{}{}
    \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
    \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
    \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
    \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
    \newcommand{\RegionMarkerTok}[1]{{#1}}
    \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\NormalTok}[1]{{#1}}
    
    % Additional commands for more recent versions of Pandoc
    \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
    \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
    \newcommand{\ImportTok}[1]{{#1}}
    \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
    \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
    \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
    \newcommand{\BuiltInTok}[1]{{#1}}
    \newcommand{\ExtensionTok}[1]{{#1}}
    \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
    \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
    \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    
    
    % Define a nice break command that doesn't care if a line doesn't already
    % exist.
    \def\br{\hspace*{\fill} \\* }
    % Math Jax compatibility definitions
    \def\gt{>}
    \def\lt{<}
    \let\Oldtex\TeX
    \let\Oldlatex\LaTeX
    \renewcommand{\TeX}{\textrm{\Oldtex}}
    \renewcommand{\LaTeX}{\textrm{\Oldlatex}}
    % Document parameters
    % Document title
    \title{Lennard\_Jones}
    
    
    
    
    
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
    \let\PY@ul=\relax \let\PY@tc=\relax%
    \let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
    \PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
    \PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}

\expandafter\def\csname PY@tok@w\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\expandafter\def\csname PY@tok@c\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\expandafter\def\csname PY@tok@k\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\expandafter\def\csname PY@tok@o\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@ow\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\expandafter\def\csname PY@tok@nb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@nf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@nc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@nn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@ne\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\expandafter\def\csname PY@tok@nv\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@no\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@nl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\expandafter\def\csname PY@tok@ni\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\expandafter\def\csname PY@tok@na\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\expandafter\def\csname PY@tok@nt\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@nd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\expandafter\def\csname PY@tok@s\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sd\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@si\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\expandafter\def\csname PY@tok@se\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\expandafter\def\csname PY@tok@sr\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\expandafter\def\csname PY@tok@ss\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@sx\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@m\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@gh\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@gu\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@gd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@gi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\expandafter\def\csname PY@tok@gr\endcsname{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\expandafter\def\csname PY@tok@ge\endcsname{\let\PY@it=\textit}
\expandafter\def\csname PY@tok@gs\endcsname{\let\PY@bf=\textbf}
\expandafter\def\csname PY@tok@gp\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\expandafter\def\csname PY@tok@go\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\expandafter\def\csname PY@tok@gt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\expandafter\def\csname PY@tok@err\endcsname{\def\PY@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}
\expandafter\def\csname PY@tok@kc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kd\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@kr\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@bp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\expandafter\def\csname PY@tok@fm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\expandafter\def\csname PY@tok@vc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vg\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@vm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\expandafter\def\csname PY@tok@sa\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@dl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@s2\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@sh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@s1\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\expandafter\def\csname PY@tok@mb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@il\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@mo\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\expandafter\def\csname PY@tok@ch\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cm\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cpf\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@c1\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\expandafter\def\csname PY@tok@cs\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}

\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother


    % For linebreaks inside Verbatim environment from package fancyvrb. 
    \makeatletter
        \newbox\Wrappedcontinuationbox 
        \newbox\Wrappedvisiblespacebox 
        \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}} 
        \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}} 
        \newcommand*\Wrappedcontinuationindent {3ex } 
        \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox} 
        % Take advantage of the already applied Pygments mark-up to insert 
        % potential linebreaks for TeX processing. 
        %        {, <, #, %, $, ' and ": go to next line. 
        %        _, }, ^, &, >, - and ~: stay at end of broken line. 
        % Use of \textquotesingle for straight quote. 
        \newcommand*\Wrappedbreaksatspecials {% 
            \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}% 
            \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}% 
            \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}% 
            \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}% 
            \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}% 
            \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}% 
            \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}% 
            \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}% 
            \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}% 
            \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}% 
            \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}% 
            \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}% 
            \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}% 
            \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}% 
        } 
        % Some characters . , ; ? ! / are not pygmentized. 
        % This macro makes them "active" and they will insert potential linebreaks 
        \newcommand*\Wrappedbreaksatpunct {% 
            \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}% 
            \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}% 
            \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}% 
            \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}% 
            \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}% 
            \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}% 
            \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}% 
            \catcode`\.\active
            \catcode`\,\active 
            \catcode`\;\active
            \catcode`\:\active
            \catcode`\?\active
            \catcode`\!\active
            \catcode`\/\active 
            \lccode`\~`\~ 	
        }
    \makeatother

    \let\OriginalVerbatim=\Verbatim
    \makeatletter
    \renewcommand{\Verbatim}[1][1]{%
        %\parskip\z@skip
        \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
        \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
        \def\FancyVerbFormatLine ##1{\hsize\linewidth
            \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
                \doublehyphendemerits\z@\finalhyphendemerits\z@
                \strut ##1\strut}%
        }%
        % If the linebreak is at a space, the latter will be displayed as visible
        % space at end of first line, and a continuation symbol starts next line.
        % Stretch/shrink are however usually zero for typewriter font.
        \def\FV@Space {%
            \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
            \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
            {\kern\fontdimen2\font}%
        }%
        
        % Allow breaks at special characters using \PYG... macros.
        \Wrappedbreaksatspecials
        % Breaks at punctuation characters . , ; ? ! and / need catcode=\active 	
        \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
    }
    \makeatother

    % Exact colors from NB
    \definecolor{incolor}{HTML}{303F9F}
    \definecolor{outcolor}{HTML}{D84315}
    \definecolor{cellborder}{HTML}{CFCFCF}
    \definecolor{cellbackground}{HTML}{F7F7F7}
    
    % prompt
    \makeatletter
    \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
    \makeatother
    \newcommand{\prompt}[4]{
        {\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
    }
    

    
    % Prevent overflowing lines due to hard-to-break entities
    \sloppy 
    % Setup hyperref package
    \hypersetup{
      breaklinks=true,  % so long urls are correctly broken across lines
      colorlinks=true,
      urlcolor=urlcolor,
      linkcolor=linkcolor,
      citecolor=citecolor,
      }
    % Slightly bigger margins than the latex defaults
    
    \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
    
    

\begin{document}
    
    \maketitle
    
    

    
    \hypertarget{the-lennard-jones-potential}{%
\subsection{The Lennard-Jones
Potential}\label{the-lennard-jones-potential}}

\hypertarget{the-model-fluid}{%
\subsubsection{The Model Fluid}\label{the-model-fluid}}

The topic of the fundamental molecular dynamics of non-bonded
interactions is studied using a soft-disk fluid simulation, which is an
implementation of the Equation of Motion in which a spherical particle
(atoms) interact with one another. Interactions between pairs of atoms
are calculated for providing the two principal features of interatomic
forces:

Repulsive forces: resistance to compression.

Attractive forces: mutual attraction of pairs of particles over a range
of separations (dipole-dipole, dipole-induced dipole, van der Waals
forces encompassing London dispersion forces).

The genral equation that calculates these features is the Lennard-Jones
potential (LJP).

    This potential governs the strength of the interaction and repulsion for
a pair of atoms \(i\) and \(j\) located at \(r_i\) and \(r_j\)
positions. It calculates their accelerations and forces based on their
distance of separation \(r\).

\$ u(r\_\{ij\}) = 4ϵ
\bigg[ \bigg( \frac{\sigma}{r_{ij}}\bigg)^{12} - \bigg(\frac{\sigma}{r_{ij}}\bigg)^{6} \bigg]\$

The LJP model is composed of two components: the repulsive \((σ/r)¹²\)
and the attractive term \((σ/r)⁶\), which respectively denote repulsive
and attractive forces. The parameter \(r\) is the distance between the
two atoms (in \(Å\) units);

\(σ\) is a length scale representing the distance at which the
intermolecular potential between the two atoms is \(= 0\) (in \(Å\)
units), and \(ε\) governs the strength of the interaction (in \(eV\)
units). In essence, it's a measure of how strongly two atoms attract
each other.

Finally, \(u\) is the intermolecular potential between the two
particles. The interaction repels at close range, then attracts, and is
cut off at some limiting separation \(r_c\): as the parameter \(r\)
increases towards \(r_c\), the force drops to \(0\).

    \hypertarget{the-ljp-curve}{%
\subsubsection{The LJP Curve}\label{the-ljp-curve}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}

\PY{k}{def} \PY{n+nf}{potential}\PY{p}{(}\PY{n}{r}\PY{p}{,} \PY{n}{epsilon}\PY{p}{,} \PY{n}{sigma}\PY{p}{)}\PY{p}{:}

  \PY{k}{return} \PY{l+m+mi}{48} \PY{o}{*} \PY{n}{epsilon} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{sigma}\PY{p}{,} \PY{l+m+mi}{12}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{r}\PY{p}{,} \PY{l+m+mi}{13}\PY{p}{)}\PY{o}{\PYZhy{}} \PY{l+m+mi}{24} \PY{o}{*} \PY{n}{epsilon} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{sigma}\PY{p}{,} \PY{l+m+mi}{6}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{r}\PY{p}{,} \PY{l+m+mi}{7}\PY{p}{)}



\PY{n}{r} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mf}{3.5}\PY{p}{,} \PY{l+m+mi}{8}\PY{p}{,} \PY{l+m+mi}{300}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{r}\PY{p}{,}\PY{n}{potential}\PY{p}{(}\PY{n}{r}\PY{p}{,} \PY{l+m+mf}{0.0103}\PY{p}{,} \PY{l+m+mf}{3.34}\PY{p}{)}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{xlabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{distance}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{ylabel}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{energy}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_3_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    For computational simplicity, Rapaport has modified the LJP in the
example reported in Chapter Two, simplifying the interaction by ignoring
the attractive tail represented by the van der Waals forces. Moreover,
\(ε\) and \(σ\) are set to \(1\).

The Limiting separation is:

\$ r\_\{ij\} \textless{} r\_\{c\} = 2\^{}\{1/6\} σ\$

If we construct the model fluid with this kind of potential, the
simulation will look like a little more than a collection of
\(\textbf{colliding softballs}\)

    \hypertarget{including-newtonian-mechanics}{%
\subsubsection{Including Newtonian
Mechanics}\label{including-newtonian-mechanics}}

Considering Newton's second law of motion, where \(F\) is the force for
each pair of particles at a position \(r\). The Equation becomes:

\$ F\_\{i\}(r\_\{ij\}) = 48 ϵ
\bigg[ \bigg( \frac{\sigma^{12}}{r_{ij}^{13}}\bigg) - 24 ϵ \bigg(\frac{\sigma^6}{r_{ij}^7}\bigg) \bigg]\$

Also, Newton's third law implies that \(F_{ji}\) is equal to
-\(F_{ij}\), so the force on particle \(i\) from the pairwise
interaction \(u(r_{ij})\) has the opposite direction of the force on
particle \(j\). The calculation of forces will need to be numerically
integrated, and it will allow us to derives coordinates, velocities, and
accelerations of each atom within the simulation.

    \hypertarget{soft-disk-fluid-algorithm-for-a-2-dimension}{%
\subsection{Soft-Disk Fluid Algorithm for a
2-Dimension}\label{soft-disk-fluid-algorithm-for-a-2-dimension}}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  The Main coordinates the flux, firstly calling \texttt{SetParams} and
  \texttt{SetupJob} that are two functions for the program
  initialization. \texttt{SetParams} serves to set many global
  parameters, while \texttt{SetupJob} embodies \texttt{InitCoords},
  \texttt{InitVels}, and \texttt{InitAccels}, which are functions for
  the initialization of the coordinates, the velocities, and the
  accelerations of all the atoms, respectively.
\item
  Everything Main has to do will be calling \texttt{SingleStep}, which
  represents the function that handles the whole process.
  \texttt{SingleStep} will call \texttt{LeapFrogStep}, which performs
  the integration of Equation of Motion using a simple numerical
  technique: the leapfrog method. This method has excellent energy
  conservation properties, integrating the coordinates and velocities of
  the particles. The LeapFrogStep appears twice in the listing of
  \texttt{SingleStep}, with the argument 1 or 2 that determines which
  portion of the two-step leapfrog process is to be performed. Finally,
  \texttt{SingleStep} encompasses \texttt{ComputeForces}, which
  implements the LJP and the forces and updates atom accelerations, and
  two functions for the properties measurements: \texttt{EvalProps} and
  \texttt{AccumProps}
\end{enumerate}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{import} \PY{n+nn}{pandas} \PY{k}{as} \PY{n+nn}{pd}
\PY{k+kn}{import} \PY{n+nn}{math}
\PY{k+kn}{import} \PY{n+nn}{os}
\PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}
\PY{n}{plt}\PY{o}{.}\PY{n}{style}\PY{o}{.}\PY{n}{use}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{seaborn\PYZhy{}whitegrid}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k}{as} \PY{n+nn}{np}
\PY{k+kn}{from} \PY{n+nn}{PIL} \PY{k+kn}{import} \PY{n}{Image}
\PY{k+kn}{import} \PY{n+nn}{glob}
\PY{k+kn}{import} \PY{n+nn}{moviepy}\PY{n+nn}{.}\PY{n+nn}{editor} \PY{k}{as} \PY{n+nn}{mp}
\PY{k+kn}{from} \PY{n+nn}{datetime} \PY{k+kn}{import} \PY{n}{datetime}
\PY{k+kn}{import} \PY{n+nn}{time}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Imageio: 'ffmpeg-linux64-v3.3.1' was not found on your computer; downloading it
now.
Try 1. Download from https://github.com/imageio/imageio-
binaries/raw/master/ffmpeg/ffmpeg-linux64-v3.3.1 (43.8 MB)
Downloading: 8192/45929032 bytes
(0.0\%)1957888/45929032 bytes
(4.3\%)5013504/45929032 bytes
(10.9\%)8347648/45929032 bytes
(18.2\%)11403264/45929032 bytes
(24.8\%)14606336/45929032 bytes
(31.8\%)17850368/45929032 bytes
(38.9\%)21118976/45929032 bytes
(46.0\%)24174592/45929032 bytes
(52.6\%)27377664/45929032 bytes
(59.6\%)30523392/45929032 bytes
(66.5\%)33595392/45929032 bytes
(73.1\%)36683776/45929032 bytes
(79.9\%)40050688/45929032 bytes
(87.2\%)43188224/45929032 bytes
(94.0\%)45929032/45929032 bytes (100.0\%)
  Done
File saved as /root/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1.
    \end{Verbatim}

    Introducing one Python class for the molecule definition (class Mol) and
one for the properties (class Prop).

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{class} \PY{n+nc}{Mol}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    \PY{k}{def} \PY{n+nf+fm}{\PYZus{}\PYZus{}init\PYZus{}\PYZus{}}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{r}\PY{p}{,} \PY{n}{rv}\PY{p}{,} \PY{n}{ra}\PY{p}{)}\PY{p}{:}
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{r} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)} 
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{rv} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)}
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{ra} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)}
        
        
\PY{k}{class} \PY{n+nc}{Prop}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    \PY{k}{def} \PY{n+nf+fm}{\PYZus{}\PYZus{}init\PYZus{}\PYZus{}}\PY{p}{(}\PY{n+nb+bp}{self}\PY{p}{,} \PY{n}{val}\PY{p}{,} \PY{n}{sum1}\PY{p}{,} \PY{n}{sum2} \PY{p}{)}\PY{p}{:}
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{val}\PY{o}{=}\PY{n}{val}
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{sum1}\PY{o}{=}\PY{n}{sum1}
        \PY{n+nb+bp}{self}\PY{o}{.}\PY{n}{sum2}\PY{o}{=}\PY{n}{sum2}   
\end{Verbatim}
\end{tcolorbox}

    Replacing all the functions for the vector operations with linear
algebra functions from NumPy. Also, written all the necessary functions
for the randomness and for updating the coordinates in periodic
boundaries

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} BASIC FUNCTIONS}

\PY{c+c1}{\PYZsh{} Sqr and Cube functions:}

\PY{k}{def} \PY{n+nf}{Sqr}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{:}
    \PY{k}{return} \PY{p}{(}\PY{n}{x} \PY{o}{*} \PY{n}{x}\PY{p}{)} 

\PY{k}{def} \PY{n+nf}{Cube}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{:}
    \PY{k}{return} \PY{p}{(}\PY{p}{(}\PY{n}{x}\PY{p}{)} \PY{o}{*} \PY{p}{(}\PY{n}{x}\PY{p}{)} \PY{o}{*} \PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{)}

  
\PY{c+c1}{\PYZsh{} Randomness functions: }

\PY{k}{def} \PY{n+nf}{RandR}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    \PY{k}{global} \PY{n}{randSeedP}
    \PY{n}{randSeedP} \PY{o}{=} \PY{p}{(}\PY{n}{randSeedP} \PY{o}{*} \PY{n}{IMUL} \PY{o}{+} \PY{n}{IADD}\PY{p}{)} \PY{o}{\PYZam{}} \PY{n}{MASK}
    \PY{k}{return} \PY{p}{(}\PY{n}{randSeedP} \PY{o}{*} \PY{n}{SCALE}\PY{p}{)}

\PY{k}{def} \PY{n+nf}{VRand}\PY{p}{(}\PY{n}{p}\PY{p}{)}\PY{p}{:}
    \PY{n}{s}\PY{p}{:} \PY{n+nb}{float}
    \PY{n}{s} \PY{o}{=} \PY{l+m+mf}{2.} \PY{o}{*} \PY{n}{math}\PY{o}{.}\PY{n}{pi} \PY{o}{*} \PY{n}{RandR}\PY{p}{(}\PY{p}{)}
    \PY{n}{p}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{n}{math}\PY{o}{.}\PY{n}{cos}\PY{p}{(}\PY{n}{s}\PY{p}{)}
    \PY{n}{p}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{=} \PY{n}{math}\PY{o}{.}\PY{n}{sin}\PY{p}{(}\PY{n}{s}\PY{p}{)}
    \PY{k}{return} \PY{n}{p}


\PY{c+c1}{\PYZsh{} Toroidal functions:}
\PY{k}{def} \PY{n+nf}{VWrapAll}\PY{p}{(}\PY{n}{v}\PY{p}{)}\PY{p}{:}
    \PY{k}{if} \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{\PYZgt{}}\PY{o}{=} \PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{:}
        \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{\PYZhy{}}\PY{o}{=} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
    \PY{k}{elif} \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{\PYZlt{}} \PY{o}{\PYZhy{}}\PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{:}
        \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{+}\PY{o}{=} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}
        
    \PY{k}{if} \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{\PYZgt{}}\PY{o}{=} \PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{:}
        \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{\PYZhy{}}\PY{o}{=} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}
    \PY{k}{elif} \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{\PYZlt{}} \PY{o}{\PYZhy{}}\PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{:}
        \PY{n}{v}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{+}\PY{o}{=} \PY{n}{region}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}        
        
    
\PY{c+c1}{\PYZsh{} This function updates coordinates taking care of periodic boundaries    }
\PY{k}{def} \PY{n+nf}{ApplyBoundaryCond}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
        \PY{n}{VWrapAll}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{r}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    The initialization functions for coordinates, velocities, and
accelerations, are included in the following code

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} INITIALIZE COORDINATES.}
\PY{c+c1}{\PYZsh{} Here a simple square lattice (with the option of unequal edge lenghts) is used,}
\PY{c+c1}{\PYZsh{} so that each cell contains just one atom and the system is centered about the origin}
\PY{k}{def} \PY{n+nf}{InitCoords}\PY{p}{(}\PY{p}{)}\PY{p}{:}

    \PY{n}{c} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} Coords}
    \PY{n}{gap} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{divide}\PY{p}{(}\PY{n}{region}\PY{p}{,} \PY{n}{initUcell}\PY{p}{)}
    \PY{n}{n} \PY{o}{=} \PY{l+m+mi}{0}
    \PY{k}{for} \PY{n}{ny} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,} \PY{n+nb}{int}\PY{p}{(}\PY{n}{initUcell}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{:}
        \PY{k}{for} \PY{n}{nx} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,} \PY{n+nb}{int}\PY{p}{(}\PY{n}{initUcell}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{:}
            
            \PY{c+c1}{\PYZsh{}c = np.asarray([nx+0.5, ny+0.5])}
            \PY{c+c1}{\PYZsh{}c = np.multiply(c, gap)}
            \PY{c+c1}{\PYZsh{}c = np.add(c, np.multiply(\PYZhy{}0.5, region))}
            \PY{c+c1}{\PYZsh{}mol[n].r = c   }
            
            \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{r} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{n}{nx}\PY{o}{+}\PY{l+m+mf}{0.5}\PY{p}{,} \PY{n}{ny}\PY{o}{+}\PY{l+m+mf}{0.5}\PY{p}{]}\PY{p}{)}\PY{p}{,} \PY{n}{gap}\PY{p}{)}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mf}{0.5}\PY{p}{,} \PY{n}{region}\PY{p}{)}\PY{p}{)} 
            \PY{n}{n} \PY{o}{=} \PY{n}{n}\PY{o}{+}\PY{l+m+mi}{1}
            
            
\PY{c+c1}{\PYZsh{} INITIALIZE VELOCITIES.}
\PY{c+c1}{\PYZsh{} The initial velocities are set to fixed magnitude (velMag)}
\PY{c+c1}{\PYZsh{} that depends on the temperature. After assigning random velocity directions}
\PY{c+c1}{\PYZsh{} the velocoties are adjusted to ensure that the center of mass is stationary.}
\PY{c+c1}{\PYZsh{} The function vRand serves as a source of uniformly distribuited radnom unit vectors.}
\PY{k}{def} \PY{n+nf}{InitVels}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    
    \PY{k}{global} \PY{n}{vSum}
    \PY{n}{vSum} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n}{vSum}\PY{o}{.}\PY{n}{shape}\PY{p}{)}    
    
    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
        \PY{n}{VRand}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{)}
        \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{,} \PY{n}{velMag}\PY{p}{)}                
        \PY{n}{vSum} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{vSum}\PY{p}{,} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{)}


    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
        \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{p}{(}\PY{o}{\PYZhy{}} \PY{l+m+mf}{1.0} \PY{o}{/} \PY{n}{nMol}\PY{p}{)}\PY{p}{,}  \PY{n}{vSum}\PY{p}{)}\PY{p}{)}
        
        
\PY{c+c1}{\PYZsh{} INITIALIZE ACCELERATIONS.}
\PY{c+c1}{\PYZsh{} The accelerations are initilized to zero}
\PY{k}{def} \PY{n+nf}{InitAccels}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
        \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{ra} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{ra}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    The two functions \texttt{SetParams} and \texttt{SetupJob} are presented

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} Set parameters}
\PY{k}{def} \PY{n+nf}{SetParams}\PY{p}{(}\PY{p}{)}\PY{p}{:}

    \PY{k}{global} \PY{n}{rCut}
    \PY{k}{global} \PY{n}{region}
    \PY{k}{global} \PY{n}{velMag} \PY{c+c1}{\PYZsh{} velocity magnitude}
    
    \PY{n}{rCut} \PY{o}{=} \PY{n}{math}\PY{o}{.}\PY{n}{pow}\PY{p}{(}\PY{l+m+mf}{2.}\PY{p}{,} \PY{l+m+mf}{1.}\PY{o}{/}\PY{l+m+mf}{6.} \PY{o}{*} \PY{n}{sigma}\PY{p}{)}
    \PY{c+c1}{\PYZsh{} Define the region}
    \PY{n}{region} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(} \PY{l+m+mf}{1.}\PY{o}{/}\PY{n}{math}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n}{density}\PY{p}{)}\PY{p}{,} \PY{n}{initUcell}\PY{p}{)}    
    \PY{n}{nMol} \PY{o}{=} \PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)} 
    \PY{c+c1}{\PYZsh{}velocity magnitude depends on the temperature}
    \PY{n}{velMag} \PY{o}{=} \PY{n}{math}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n}{NDIM} \PY{o}{*} \PY{p}{(}\PY{l+m+mf}{1.} \PY{o}{\PYZhy{}}\PY{l+m+mf}{1.} \PY{o}{/}\PY{n}{nMol}\PY{p}{)} \PY{o}{*} \PY{n}{temperature}\PY{p}{)}

        
\PY{c+c1}{\PYZsh{} Setup Job}
\PY{k}{def} \PY{n+nf}{SetupJob}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    
    \PY{k}{global} \PY{n}{stepCount} \PY{c+c1}{\PYZsh{}  timestep counter }

    \PY{n}{stepCount} \PY{o}{=} \PY{l+m+mi}{0} 
    \PY{n}{InitCoords}\PY{p}{(}\PY{p}{)}
    \PY{n}{InitVels}\PY{p}{(}\PY{p}{)}
    \PY{n}{InitAccels}\PY{p}{(}\PY{p}{)}
    \PY{n}{AccumProps}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    Introducing the attractive tail represented by the van der Waals forces

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} FORCES COMPUTATION}
\PY{l+s+sd}{\PYZsq{}\PYZsq{}\PYZsq{}}
\PY{l+s+sd}{ComputeForces}
\PY{l+s+sd}{ComputeForces is responsible for the interaction computations, and the interactions occur between pairs of atoms. }
\PY{l+s+sd}{The function implements the LJP, and calculates the accelerations and the forces for each pairs of atoms i and j }
\PY{l+s+sd}{located at ri and rj.}
\PY{l+s+sd}{rCut = Limiting separation cutoff (rc), and it is: rCut = math.pow(2., 1./6.)}
\PY{l+s+sd}{As r increases towards rCut, the force drops to 0.}
\PY{l+s+sd}{Newton\PYZsq{}s third law inplies that fji = \PYZhy{}fij, so each atom pair need only be examined once.}
\PY{l+s+sd}{The amount of work is proportional to N\PYZca{}2.}
\PY{l+s+sd}{\PYZsq{}\PYZsq{}\PYZsq{}}

\PY{k}{def} \PY{n+nf}{ComputeForces}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    
    \PY{k}{global} \PY{n}{virSum}
    \PY{k}{global} \PY{n}{uSum} 
    \PY{n}{fcVal} \PY{o}{=} \PY{l+m+mi}{0} \PY{c+c1}{\PYZsh{}  The force that atom j exerts on atom i}
 
    \PY{c+c1}{\PYZsh{} rCut: Rc}
    \PY{n}{rrCut} \PY{o}{=} \PY{n}{Sqr}\PY{p}{(}\PY{n}{rCut}\PY{p}{)}
    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
        \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{ra} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{ra}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
    \PY{n}{uSum} \PY{o}{=} \PY{l+m+mf}{0.}
    \PY{n}{virSum} \PY{o}{=} \PY{l+m+mf}{0.}

    \PY{n}{n} \PY{o}{=} \PY{l+m+mi}{0}
    \PY{k}{for} \PY{n}{j1} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{:}
        \PY{k}{for} \PY{n}{j2} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{j1}\PY{o}{+}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{nMol}\PY{p}{)}\PY{p}{:}
            
            \PY{c+c1}{\PYZsh{} Make DeltaRij: (sum of squared RJ1\PYZhy{}RJ2)}
            \PY{n}{dr} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{subtract}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{j1}\PY{p}{]}\PY{o}{.}\PY{n}{r}\PY{p}{,} \PY{n}{mol}\PY{p}{[}\PY{n}{j2}\PY{p}{]}\PY{o}{.}\PY{n}{r}\PY{p}{)} \PY{c+c1}{\PYZsh{} dr contains the delta between Rj1 and Rj2}
            \PY{n}{VWrapAll}\PY{p}{(}\PY{n}{dr}\PY{p}{)} \PY{c+c1}{\PYZsh{} toroidal function}
            \PY{n}{rr}\PY{o}{=} \PY{p}{(}\PY{n}{dr}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{*} \PY{n}{dr}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{+} \PY{n}{dr}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{*} \PY{n}{dr}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} dr2}
            \PY{n}{r}\PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n}{rr}\PY{p}{)} \PY{c+c1}{\PYZsh{}dr}
            
            \PY{c+c1}{\PYZsh{} if dr2 \PYZlt{} Rc\PYZca{}2 }
            \PY{k}{if} \PY{p}{(}\PY{n}{rr} \PY{o}{\PYZlt{}} \PY{n}{rrCut}\PY{p}{)}\PY{p}{:}
                \PY{n}{rri} \PY{o}{=} \PY{n}{sigma} \PY{o}{/} \PY{n}{rr}                
                \PY{n}{rri3} \PY{o}{=} \PY{n}{Cube}\PY{p}{(}\PY{n}{rri}\PY{p}{)}
                
                \PY{c+c1}{\PYZsh{} Forces calculation by Lennard\PYZhy{}Jones potential (original from Rapaport)}
                \PY{c+c1}{\PYZsh{} fcVal = 48. * rri3 * (rri3 \PYZhy{} 0.5) * rri}
                \PY{c+c1}{\PYZsh{} Forces calculated with the completed Lennard\PYZhy{}Jones.}
                \PY{n}{fcVal} \PY{o}{=} \PY{l+m+mi}{48} \PY{o}{*} \PY{n}{epsilon} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{sigma}\PY{p}{,} \PY{l+m+mi}{12}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{r}\PY{p}{,} \PY{l+m+mi}{13}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{l+m+mi}{24} \PY{o}{*} \PY{n}{epsilon} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{sigma}\PY{p}{,} \PY{l+m+mi}{6}\PY{p}{)} \PY{o}{/} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{r}\PY{p}{,} \PY{l+m+mi}{7}\PY{p}{)} 

                \PY{c+c1}{\PYZsh{} Update the accelerations multiplying force for DeltaRij}
                \PY{n}{mol}\PY{p}{[}\PY{n}{j1}\PY{p}{]}\PY{o}{.}\PY{n}{ra} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{j1}\PY{p}{]}\PY{o}{.}\PY{n}{ra}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{n}{fcVal}\PY{p}{,} \PY{n}{dr}\PY{p}{)}\PY{p}{)}
                \PY{n}{mol}\PY{p}{[}\PY{n}{j2}\PY{p}{]}\PY{o}{.}\PY{n}{ra} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{j2}\PY{p}{]}\PY{o}{.}\PY{n}{ra}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{fcVal}\PY{p}{,} \PY{n}{dr}\PY{p}{)}\PY{p}{)}
                
                \PY{c+c1}{\PYZsh{} Lennard\PYZhy{}Jones potential (original from Rapaport)}
                \PY{c+c1}{\PYZsh{} uSum += 4. * rri3 * (rri3 \PYZhy{} 1.) +1. }
                \PY{c+c1}{\PYZsh{} The completed Lennard\PYZhy{}Jones.}
                \PY{n}{uSum} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{4} \PY{o}{*} \PY{n}{epsilon} \PY{o}{*} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{sigma}\PY{o}{/}\PY{n}{r}\PY{p}{,} \PY{l+m+mi}{12}\PY{p}{)}\PY{o}{/}\PY{n}{r} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{power}\PY{p}{(}\PY{n}{sigma}\PY{o}{/}\PY{n}{r}\PY{p}{,} \PY{l+m+mi}{6}\PY{p}{)} \PY{c+c1}{\PYZsh{} balanced              }



                \PY{n}{virSum} \PY{o}{+}\PY{o}{=} \PY{n}{fcVal} \PY{o}{*} \PY{n}{rr}
\end{Verbatim}
\end{tcolorbox}

    Below code includes the leapfrog method for the Integration of the
Equation of Motion

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} INTEGRATION}
\PY{l+s+sd}{\PYZsq{}\PYZsq{}\PYZsq{}}
\PY{l+s+sd}{INTEGRATION OF COORDINATES AND VELOCITIES.}
\PY{l+s+sd}{Integration of Equation of Motion uses a simple numerical techniques: the leapfrog method.}
\PY{l+s+sd}{The method has excellent energy conservation properties.}
\PY{l+s+sd}{LeapfrogStep integrates the coordinates and velocities. It appears twice in the listing of}
\PY{l+s+sd}{SingleStep, with the argument part determinating which portion of the two\PYZhy{}step leapfrog process}
\PY{l+s+sd}{is to be performed:}
\PY{l+s+sd}{vix(t + h/2) = vix(t) + (h/2)aix(t)}
\PY{l+s+sd}{rix(t + h) = rix(t) + hvix (t + h/2)}
\PY{l+s+sd}{\PYZsq{}\PYZsq{}\PYZsq{}}
\PY{k}{def} \PY{n+nf}{LeapfrogStep}\PY{p}{(}\PY{n}{part}\PY{p}{)}\PY{p}{:}
    
    \PY{k}{if} \PY{n}{part} \PY{o}{==} \PY{l+m+mi}{1}\PY{p}{:}
        \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
            \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{deltaT}\PY{p}{,} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{ra}\PY{p}{)}\PY{p}{)}            
            \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{r} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{r}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{n}{deltaT}\PY{p}{,} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{)}\PY{p}{)}                        
            
    \PY{k}{else} \PY{p}{:}
        \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
            \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{,} \PY{n}{np}\PY{o}{.}\PY{n}{multiply}\PY{p}{(}\PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{deltaT}\PY{p}{,} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{ra}\PY{p}{)}\PY{p}{)}   
\end{Verbatim}
\end{tcolorbox}

    Below code provides all the functions for the properties measurements
(Temperature, Energy, and Pressure).

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} PROPERTIES MEASUREMENTS}

\PY{k}{def} \PY{n+nf}{EvalProps}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    
    \PY{k}{global} \PY{n}{vSum}
    \PY{n}{vvSum} \PY{o}{=} \PY{l+m+mf}{0.}
    \PY{n}{vSum} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n}{vSum}\PY{o}{.}\PY{n}{shape}\PY{p}{)}
    
    \PY{k}{global} \PY{n}{kinEnergy}
    \PY{k}{global} \PY{n}{totEnergy}
    \PY{k}{global} \PY{n}{pressure}
    
    
    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{nMol}\PY{p}{)}\PY{p}{:}
        \PY{n}{vSum}\PY{o}{=}\PY{n}{np}\PY{o}{.}\PY{n}{add}\PY{p}{(}\PY{n}{vSum}\PY{p}{,} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{)}
        \PY{n}{vv}\PY{o}{=} \PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{*} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{+} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{*} \PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{rv}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
        \PY{n}{vvSum} \PY{o}{+}\PY{o}{=} \PY{n}{vv}
        
    \PY{n}{kinEnergy}\PY{o}{.}\PY{n}{val} \PY{o}{=} \PY{p}{(}\PY{l+m+mf}{0.5} \PY{o}{*} \PY{n}{vvSum}\PY{p}{)} \PY{o}{/} \PY{n}{nMol}
    \PY{n}{totEnergy}\PY{o}{.}\PY{n}{val} \PY{o}{=} \PY{n}{kinEnergy}\PY{o}{.}\PY{n}{val} \PY{o}{+} \PY{p}{(}\PY{n}{uSum} \PY{o}{/} \PY{n}{nMol}\PY{p}{)}
    \PY{n}{pressure}\PY{o}{.}\PY{n}{val} \PY{o}{=} \PY{n}{density} \PY{o}{*} \PY{p}{(}\PY{n}{vvSum} \PY{o}{+} \PY{n}{virSum}\PY{p}{)} \PY{o}{/} \PY{p}{(}\PY{n}{nMol} \PY{o}{*} \PY{n}{NDIM}\PY{p}{)}
    
    
    
\PY{c+c1}{\PYZsh{} AccumProps functions}

\PY{k}{def} \PY{n+nf}{PropZero}\PY{p}{(}\PY{n}{v}\PY{p}{)}\PY{p}{:}
    \PY{n}{v}\PY{o}{.}\PY{n}{sum1} \PY{o}{=} \PY{n}{v}\PY{o}{.}\PY{n}{sum2} \PY{o}{=} \PY{l+m+mf}{0.}
    \PY{k}{return} \PY{n}{v}    
    
\PY{k}{def} \PY{n+nf}{PropAccum}\PY{p}{(}\PY{n}{v}\PY{p}{)}\PY{p}{:}
    \PY{n}{v}\PY{o}{.}\PY{n}{sum1} \PY{o}{+}\PY{o}{=} \PY{n}{v}\PY{o}{.}\PY{n}{val}
    \PY{n}{v}\PY{o}{.}\PY{n}{sum2} \PY{o}{+}\PY{o}{=} \PY{n}{Sqr}\PY{p}{(}\PY{n}{v}\PY{o}{.}\PY{n}{val}\PY{p}{)}
    \PY{k}{return} \PY{n}{v}    
    
\PY{k}{def} \PY{n+nf}{PropAvg}\PY{p}{(}\PY{n}{v}\PY{p}{,} \PY{n}{n}\PY{p}{)}\PY{p}{:}
    \PY{n}{v}\PY{o}{.}\PY{n}{sum1} \PY{o}{/}\PY{o}{=} \PY{n}{n}
    \PY{n}{v}\PY{o}{.}\PY{n}{sum2} \PY{o}{=} \PY{n}{math}\PY{o}{.}\PY{n}{sqrt}\PY{p}{(}\PY{n+nb}{max}\PY{p}{(}\PY{n}{v}\PY{o}{.}\PY{n}{sum2} \PY{o}{/} \PY{n}{n} \PY{o}{\PYZhy{}} \PY{n}{Sqr}\PY{p}{(}\PY{n}{v}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}\PY{p}{,} \PY{l+m+mf}{0.}\PY{p}{)}\PY{p}{)} 
    \PY{k}{return} \PY{n}{v}    
    

\PY{c+c1}{\PYZsh{} AccumProps: collects results of the measurements and evaluates means and standard deviation}
\PY{k}{def} \PY{n+nf}{AccumProps}\PY{p}{(}\PY{n}{icode}\PY{p}{)}\PY{p}{:}
    
    
    \PY{k}{if} \PY{n}{icode} \PY{o}{==} \PY{l+m+mi}{0}\PY{p}{:}
        \PY{n}{PropZero}\PY{p}{(}\PY{n}{totEnergy}\PY{p}{)}
        \PY{n}{PropZero}\PY{p}{(}\PY{n}{kinEnergy}\PY{p}{)}
        \PY{n}{PropZero}\PY{p}{(}\PY{n}{pressure}\PY{p}{)} 
    \PY{k}{if} \PY{n}{icode} \PY{o}{==} \PY{l+m+mi}{1}\PY{p}{:}
        \PY{n}{PropAccum}\PY{p}{(}\PY{n}{totEnergy}\PY{p}{)}
        \PY{n}{PropAccum}\PY{p}{(}\PY{n}{kinEnergy}\PY{p}{)}
        \PY{n}{PropAccum}\PY{p}{(}\PY{n}{pressure}\PY{p}{)}    
    \PY{k}{if} \PY{n}{icode} \PY{o}{==} \PY{l+m+mi}{2}\PY{p}{:}
        \PY{n}{PropAvg}\PY{p}{(}\PY{n}{totEnergy}\PY{p}{,} \PY{n}{stepAvg}\PY{p}{)}
        \PY{n}{PropAvg}\PY{p}{(}\PY{n}{kinEnergy}\PY{p}{,} \PY{n}{stepAvg}\PY{p}{)}
        \PY{n}{PropAvg}\PY{p}{(}\PY{n}{pressure}\PY{p}{,} \PY{n}{stepAvg}\PY{p}{)} 
\end{Verbatim}
\end{tcolorbox}

    Function for plotting the trajectories of the atoms (plotMolCoo), which
makes all the plots step by step, and a second function that creates an
mp4 video from all the coordinates plot tiles. The two functions have to
work together. Also,including GraphOutput, a function for printing
properties in a pandas dataframe shape.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} OUTPUT FUNCTIONS:}

\PY{k}{def} \PY{n+nf}{plotMolCoo}\PY{p}{(}\PY{n}{mol}\PY{p}{,} \PY{n}{workdir}\PY{p}{,} \PY{n}{n}\PY{p}{)}\PY{p}{:}
    
    \PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{patches} \PY{k}{as} \PY{n+nn}{mpatches}
    \PY{k+kn}{import} \PY{n+nn}{matplotlib}\PY{n+nn}{.}\PY{n+nn}{pyplot} \PY{k}{as} \PY{n+nn}{plt}

    \PY{n}{Time} \PY{o}{=} \PY{n}{timeNow}
    \PY{n}{Sigma\PYZus{}v} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{vSum}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{/} \PY{n}{nMol}\PY{p}{)}
    \PY{n}{E} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{totEnergy}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}
    \PY{n}{Sigma\PYZus{}E} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{totEnergy}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}
    \PY{n}{Ek} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{kinEnergy}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}
    \PY{n}{Sigma\PYZus{}Ek} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{kinEnergy}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}
    \PY{n}{P\PYZus{}1} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{pressure}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}
    \PY{n}{P\PYZus{}2} \PY{o}{=} \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{pressure}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}    
    
    
    \PY{o}{\PYZpc{}}\PY{k}{matplotlib} inline
    
    \PY{n}{TileName} \PY{o}{=} \PY{p}{(}\PY{n}{workdir}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo/}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n+nb}{str}\PY{p}{(}\PY{n}{n}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

    \PY{n}{x} \PY{o}{=} \PY{p}{[}\PY{p}{]}
    \PY{n}{y} \PY{o}{=} \PY{p}{[}\PY{p}{]}
    
    \PY{k}{for} \PY{n}{n} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)}\PY{p}{)}\PY{p}{:}
        \PY{n}{x}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{r}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}
        \PY{n}{y}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{mol}\PY{p}{[}\PY{n}{n}\PY{p}{]}\PY{o}{.}\PY{n}{r}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
        
    \PY{n}{mark\PYZus{}1} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)}\PY{o}{/}\PY{l+m+mi}{2} \PY{o}{+} \PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)}\PY{o}{/}\PY{l+m+mi}{8}\PY{p}{)}
    \PY{n}{mark\PYZus{}2} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)}\PY{o}{/}\PY{l+m+mi}{2} \PY{o}{+} \PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)}\PY{o}{/}\PY{l+m+mi}{8} \PY{o}{+} \PY{l+m+mi}{1}\PY{p}{)}
    
    \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{n}{y}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{o}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{black}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{p}{[}\PY{n}{mark\PYZus{}1}\PY{p}{]}\PY{p}{,} \PY{n}{y}\PY{p}{[}\PY{n}{mark\PYZus{}1}\PY{p}{]}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{o}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{red}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{p}{[}\PY{n}{mark\PYZus{}2}\PY{p}{]}\PY{p}{,} \PY{n}{y}\PY{p}{[}\PY{n}{mark\PYZus{}2}\PY{p}{]}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{o}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{yellow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}  
    

    \PY{n}{plt}\PY{o}{.}\PY{n}{title}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{timestep:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{timeNow}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{Sigma v\PYZdl{}:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{Sigma\PYZus{}v}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{E:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{E}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{sigma E\PYZdl{}:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{Sigma\PYZus{}E}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{;}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ek:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{Ek}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}} \PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{sigma Ek\PYZdl{}:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{Sigma\PYZus{}Ek}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{P.sum1:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{P\PYZus{}1}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PYZbs{}
              \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{P.sum2:}\PY{l+s+s1}{\PYZsq{}}\PY{o}{+}\PY{n}{P\PYZus{}2}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{; }\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{loc}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{left}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}
    
    \PY{c+c1}{\PYZsh{}plt.rcParams[\PYZdq{}figure.figsize\PYZdq{}] = (200,3)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{savefig}\PY{p}{(}\PY{n}{TileName}\PY{p}{,} \PY{n}{dpi}\PY{o}{=}\PY{l+m+mi}{100}\PY{p}{)}
    
    
\PY{k}{def} \PY{n+nf}{makeMov}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    \PY{c+c1}{\PYZsh{} For more information about the use of the glob package with Python, and for the convertion from }
    \PY{c+c1}{\PYZsh{} gif to mp4 video formats visit the documentation   }
    
    
    \PY{n}{t} \PY{o}{=} \PY{n}{time}\PY{o}{.}\PY{n}{localtime}\PY{p}{(}\PY{p}{)}
    \PY{n}{current\PYZus{}time} \PY{o}{=} \PY{n}{time}\PY{o}{.}\PY{n}{strftime}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{\PYZpc{}}\PY{l+s+s2}{D:}\PY{l+s+s2}{\PYZpc{}}\PY{l+s+s2}{H:}\PY{l+s+s2}{\PYZpc{}}\PY{l+s+s2}{M:}\PY{l+s+s2}{\PYZpc{}}\PY{l+s+s2}{S}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{t}\PY{p}{)}
    \PY{n}{current\PYZus{}time} \PY{o}{=} \PY{n}{current\PYZus{}time}\PY{o}{.}\PY{n}{replace}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{/}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZhy{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}


    \PY{c+c1}{\PYZsh{} Create the frames}
    \PY{n}{frames} \PY{o}{=} \PY{p}{[}\PY{p}{]}
    \PY{n}{imgs} \PY{o}{=} \PY{n+nb}{sorted}\PY{p}{(}\PY{n}{glob}\PY{o}{.}\PY{n}{glob}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo/*.png}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{,} \PY{n}{key}\PY{o}{=}\PY{n}{os}\PY{o}{.}\PY{n}{path}\PY{o}{.}\PY{n}{getmtime}\PY{p}{)}
    \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{imgs}\PY{p}{:}
        \PY{n}{temp} \PY{o}{=} \PY{n}{Image}\PY{o}{.}\PY{n}{open}\PY{p}{(}\PY{n}{i}\PY{p}{)}
        \PY{n}{keep} \PY{o}{=} \PY{n}{temp}\PY{o}{.}\PY{n}{copy}\PY{p}{(}\PY{p}{)}
        \PY{n}{frames}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{keep}\PY{p}{)}
        \PY{n}{temp}\PY{o}{.}\PY{n}{close}\PY{p}{(}\PY{p}{)}
    \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{imgs}\PY{p}{:}
        \PY{n}{os}\PY{o}{.}\PY{n}{remove}\PY{p}{(}\PY{n}{i}\PY{p}{)}        

    \PY{c+c1}{\PYZsh{} Save into a GIF file that loops forever}
    \PY{n}{frames}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{.}\PY{n}{save}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo/coordinates.gif}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n+nb}{format}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{GIF}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}
                   \PY{n}{append\PYZus{}images}\PY{o}{=}\PY{n}{frames}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{:}\PY{p}{]}\PY{p}{,}
                   \PY{n}{save\PYZus{}all}\PY{o}{=}\PY{k+kc}{True}\PY{p}{,}
                   \PY{n}{duration}\PY{o}{=}\PY{l+m+mi}{30}\PY{p}{,} \PY{n}{loop}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{)}


    \PY{n}{clip} \PY{o}{=} \PY{n}{mp}\PY{o}{.}\PY{n}{VideoFileClip}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{coo/coordinates.gif}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{clip}\PY{o}{.}\PY{n}{write\PYZus{}videofile}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{coo/}\PY{l+s+s2}{\PYZdq{}}\PY{o}{+}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{coordinates\PYZus{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{+}\PY{n}{current\PYZus{}time}\PY{o}{+}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{.mp4}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{os}\PY{o}{.}\PY{n}{remove}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{coo/coordinates.gif}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}



\PY{k}{def} \PY{n+nf}{PrintSummary}\PY{p}{(}\PY{p}{)}\PY{p}{:}

    \PY{n+nb}{print}\PY{p}{(}\PY{n}{stepCount}\PY{p}{,} \PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{timeNow}\PY{p}{)}\PY{p}{,} \PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{vSum}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{/} \PY{n}{nMol}\PY{p}{)} \PY{p}{,}\PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{totEnergy}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}\PY{p}{,}\PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{totEnergy}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}\PY{p}{,} \PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{kinEnergy}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}\PY{p}{,} \PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{kinEnergy}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}\PY{p}{,}\PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{pressure}\PY{o}{.}\PY{n}{sum1}\PY{p}{)}\PY{p}{,}\PYZbs{}
          \PY{l+s+s2}{\PYZdq{}}\PY{l+s+si}{\PYZob{}0:.4f\PYZcb{}}\PY{l+s+s2}{\PYZdq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{pressure}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}\PY{p}{)}
    
    \PY{k}{return} \PY{p}{(}\PY{n}{stepCount}\PY{p}{,} \PYZbs{}
          \PY{n}{timeNow}\PY{p}{,} \PYZbs{}
          \PY{p}{(}\PY{n}{vSum}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{/} \PY{n}{nMol}\PY{p}{)} \PY{p}{,}\PYZbs{}
          \PY{n}{totEnergy}\PY{o}{.}\PY{n}{sum1}\PY{p}{,}\PYZbs{}
          \PY{n}{totEnergy}\PY{o}{.}\PY{n}{sum2}\PY{p}{,} \PYZbs{}
          \PY{n}{kinEnergy}\PY{o}{.}\PY{n}{sum1}\PY{p}{,} \PYZbs{}
          \PY{n}{kinEnergy}\PY{o}{.}\PY{n}{sum2}\PY{p}{,}\PYZbs{}
          \PY{n}{pressure}\PY{o}{.}\PY{n}{sum1}\PY{p}{,}\PYZbs{}
          \PY{n}{pressure}\PY{o}{.}\PY{n}{sum2}\PY{p}{)}    


\PY{k}{def} \PY{n+nf}{GraphOutput}\PY{p}{(}\PY{p}{)}\PY{p}{:}

    \PY{n}{ax} \PY{o}{=} \PYZbs{}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{Sigma v\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{E}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{ax}\PY{o}{=}\PY{n}{ax}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{C1}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{sigma E\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{ax}\PY{o}{=}\PY{n}{ax}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{C2}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,}  \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ek}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{ax}\PY{o}{=}\PY{n}{ax}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{C3}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{sigma Ek\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{ax}\PY{o}{=}\PY{n}{ax}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{C4}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{P\PYZus{}1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{ax}\PY{o}{=}\PY{n}{ax}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{C9}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
    \PY{n}{df\PYZus{}systemParams}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{timestep}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{y}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{P\PYZus{}2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{kind}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{line}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{ax}\PY{o}{=}\PY{n}{ax}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{C9}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}

    \PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}
    \PY{c+c1}{\PYZsh{}plt.savefig(\PYZsq{}plot.jpg\PYZsq{}, dpi=300)}
\end{Verbatim}
\end{tcolorbox}

    Here, the SingleStep function: the real gear of the whole algorithm.

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} HANDLING FUNCTION (SingleStep())}
\PY{l+s+sd}{\PYZsq{}\PYZsq{}\PYZsq{}}
\PY{l+s+sd}{SingleStep: Is the function that handles the processing for a single timestep, including: }
\PY{l+s+sd}{1) the force evaluation}
\PY{l+s+sd}{2) integration of the equation of motion, }
\PY{l+s+sd}{3) adjustments required by periodic boundaries, and}
\PY{l+s+sd}{4) property measurements}
\PY{l+s+sd}{\PYZsq{}\PYZsq{}\PYZsq{}}
\PY{k}{def} \PY{n+nf}{SingleStep}\PY{p}{(}\PY{p}{)}\PY{p}{:}
    
    \PY{k}{global} \PY{n}{stepCount} \PY{c+c1}{\PYZsh{}  timestep counter}
    \PY{k}{global} \PY{n}{timeNow}    

    \PY{n}{stepCount} \PY{o}{+}\PY{o}{=}\PY{l+m+mi}{1}
    \PY{n}{timeNow} \PY{o}{=} \PY{n}{stepCount} \PY{o}{*} \PY{n}{deltaT}
    \PY{n}{LeapfrogStep}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{)}
    \PY{n}{ApplyBoundaryCond}\PY{p}{(}\PY{p}{)}
    \PY{n}{ComputeForces}\PY{p}{(}\PY{p}{)} \PY{c+c1}{\PYZsh{} 1) The force evaluation}
    \PY{n}{LeapfrogStep}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{)} \PY{c+c1}{\PYZsh{} 2) Integration of coordinates and velocities}
    \PY{n}{EvalProps}\PY{p}{(}\PY{p}{)}
    \PY{n}{AccumProps}\PY{p}{(}\PY{l+m+mi}{1}\PY{p}{)} \PY{c+c1}{\PYZsh{} Accumulate properties}

    \PY{k}{if} \PY{p}{(}\PY{n}{stepCount} \PY{o}{\PYZpc{}} \PY{n}{stepAvg} \PY{o}{==} \PY{l+m+mi}{0}\PY{p}{)}\PY{p}{:}
        \PY{n}{AccumProps}\PY{p}{(}\PY{l+m+mi}{2}\PY{p}{)} \PY{c+c1}{\PYZsh{} Calculate averages}
        \PY{n}{systemParams}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{PrintSummary}\PY{p}{(}\PY{p}{)}\PY{p}{)}
        \PY{n}{AccumProps}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{)} \PY{c+c1}{\PYZsh{} Set to zero all the properties.}
\end{Verbatim}
\end{tcolorbox}

    And the Main Loop

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{ }{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} 2D SOFT\PYZhy{}DISK SIMULATION: THE MAIN LOOP}

\PY{c+c1}{\PYZsh{} Import libraries for system operations}
\PY{k+kn}{import} \PY{n+nn}{os}\PY{n+nn}{.}\PY{n+nn}{path}
\PY{k+kn}{from} \PY{n+nn}{os} \PY{k+kn}{import} \PY{n}{path}
\PY{k+kn}{import} \PY{n+nn}{shutil}

\PY{c+c1}{\PYZsh{} PARAMETERS}
\PY{n}{mov} \PY{o}{=} \PY{l+m+mi}{1} \PY{c+c1}{\PYZsh{} set mov=1 if you want make a video}

\PY{c+c1}{\PYZsh{} Set a working directory for all the png and videos}
\PY{n}{workdir} \PY{o}{=} \PY{n+nb}{str}\PY{p}{(}\PY{n}{os}\PY{o}{.}\PY{n}{getcwd}\PY{p}{(}\PY{p}{)}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{/}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}

\PY{c+c1}{\PYZsh{} If the /coo directory doesn\PYZsq{}t exist make it, else remove /coo (and its contents) and }
\PY{c+c1}{\PYZsh{} create a new /coo directory.}
\PY{k}{if} \PY{n}{path}\PY{o}{.}\PY{n}{exists}\PY{p}{(}\PY{n+nb}{str}\PY{p}{(}\PY{n}{workdir}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}\PY{o}{==}\PY{k+kc}{False}\PY{p}{:}
    \PY{n}{os}\PY{o}{.}\PY{n}{makedirs}\PY{p}{(}\PY{n+nb}{str}\PY{p}{(}\PY{n}{workdir}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
\PY{k}{else}\PY{p}{:}
    \PY{n}{shutil}\PY{o}{.}\PY{n}{rmtree}\PY{p}{(}\PY{n+nb}{str}\PY{p}{(}\PY{n}{workdir}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}
    \PY{n}{os}\PY{o}{.}\PY{n}{makedirs}\PY{p}{(}\PY{n+nb}{str}\PY{p}{(}\PY{n}{workdir}\PY{o}{+}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{coo}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{)}

\PY{c+c1}{\PYZsh{} Load the input parameter file}
\PY{n}{df\PYZus{}params} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{read\PYZus{}csv}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Rap\PYZus{}3\PYZus{}LJP1.in}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{sep}\PY{o}{=}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+se}{\PYZbs{}t}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{header}\PY{o}{=}\PY{k+kc}{None}\PY{p}{,} \PY{n}{names}\PY{o}{=}\PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{parameter}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{value}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{p}{)}

\PY{n}{NDIM} \PY{o}{=} \PY{l+m+mi}{2} \PY{c+c1}{\PYZsh{} Two\PYZhy{}Dimension setting}
\PY{n}{vSum} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} velocity sum}
\PY{n}{kinEnergy} \PY{o}{=}\PY{n}{Prop}\PY{p}{(}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{)} \PY{c+c1}{\PYZsh{}Ek (and average)}
\PY{n}{totEnergy} \PY{o}{=}\PY{n}{Prop}\PY{p}{(}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{)} \PY{c+c1}{\PYZsh{}E (and average)}
\PY{n}{pressure}  \PY{o}{=}\PY{n}{Prop}\PY{p}{(}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{)} \PY{c+c1}{\PYZsh{}P (and average) }

\PY{n}{systemParams} \PY{o}{=} \PY{p}{[}\PY{p}{]}

\PY{n}{IADD} \PY{o}{=} \PY{l+m+mi}{453806245}
\PY{n}{IMUL} \PY{o}{=} \PY{l+m+mi}{314159269}
\PY{n}{MASK} \PY{o}{=} \PY{l+m+mi}{2147483647}
\PY{n}{SCALE} \PY{o}{=} \PY{l+m+mf}{0.4656612873e\PYZhy{}9}
\PY{n}{randSeedP} \PY{o}{=} \PY{l+m+mi}{17}

\PY{n}{deltaT} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{density} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}

\PY{n}{initUcell} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)} \PY{c+c1}{\PYZsh{} initialize cell}
\PY{n}{initUcell}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{initUcell}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}

\PY{n}{stepAvg} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{4}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{stepEquil} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{5}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{stepLimit} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{6}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n}{temperature} \PY{o}{=} \PY{n+nb}{float}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{7}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
\PY{n+nb}{float}\PY{p}{(}\PY{n}{df\PYZus{}params}\PY{o}{.}\PY{n}{values}\PY{p}{[}\PY{l+m+mi}{7}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}

\PY{c+c1}{\PYZsh{}Define an array of Mol}
\PY{n}{mol} \PY{o}{=} \PY{p}{[}\PY{n}{Mol}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)}\PY{p}{,} \PYZbs{}
           \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)}\PY{p}{,} \PYZbs{}
           \PY{n}{np}\PY{o}{.}\PY{n}{asarray}\PY{p}{(}\PY{p}{[}\PY{l+m+mf}{0.0}\PY{p}{,} \PY{l+m+mf}{0.0}\PY{p}{]}\PY{p}{)}\PY{p}{)} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n+nb}{int}\PY{p}{(}\PY{n}{initUcell}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{*}\PY{n}{initUcell}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{)}\PY{p}{]}


\PY{c+c1}{\PYZsh{} Define the number of molecules}
\PY{k}{global} \PY{n}{nMol}
\PY{n}{nMol} \PY{o}{=} \PY{n+nb}{len}\PY{p}{(}\PY{n}{mol}\PY{p}{)}

\PY{c+c1}{\PYZsh{} LJP parameters:}
\PY{n}{epsilon} \PY{o}{=}  \PY{l+m+mi}{1}
\PY{n}{sigma} \PY{o}{=} \PY{l+m+mi}{1}


\PY{c+c1}{\PYZsh{} START THE MAIN LOOP}
\PY{n}{SetParams}\PY{p}{(}\PY{p}{)}
\PY{n}{SetupJob}\PY{p}{(}\PY{p}{)}
\PY{n}{moreCycles} \PY{o}{=} \PY{l+m+mi}{1}

\PY{n}{n} \PY{o}{=} \PY{l+m+mi}{0}
\PY{k}{while} \PY{n}{moreCycles}\PY{p}{:}
    \PY{n}{SingleStep}\PY{p}{(}\PY{p}{)}
    \PY{k}{if} \PY{n}{mov}\PY{o}{==}\PY{l+m+mi}{1}\PY{p}{:}
        \PY{n}{plotMolCoo}\PY{p}{(}\PY{n}{mol}\PY{p}{,} \PY{n}{workdir}\PY{p}{,} \PY{n}{n}\PY{p}{)} \PY{c+c1}{\PYZsh{} Make a graph of the coordinates}
    \PY{n}{n} \PY{o}{+}\PY{o}{=} \PY{l+m+mi}{1}
    \PY{k}{if} \PY{n}{stepCount} \PY{o}{\PYZgt{}}\PY{o}{=} \PY{n}{stepLimit}\PY{p}{:}
        \PY{n}{moreCycles} \PY{o}{=} \PY{l+m+mi}{0}
        

\PY{n}{columns} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{timestep}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{timeNow}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{Sigma v\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{E}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{sigma E\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Ek}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{\PYZdl{}}\PY{l+s+s1}{\PYZbs{}}\PY{l+s+s1}{sigma Ek\PYZdl{}}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{P\PYZus{}1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{P\PYZus{}2}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{df\PYZus{}systemParams} \PY{o}{=} \PY{n}{pd}\PY{o}{.}\PY{n}{DataFrame}\PY{p}{(}\PY{n}{systemParams}\PY{p}{,} \PY{n}{columns}\PY{o}{=}\PY{n}{columns}\PY{p}{)}        

\PY{c+c1}{\PYZsh{} Make a video}
\PY{k}{if} \PY{n}{mov}\PY{o}{==}\PY{l+m+mi}{1}\PY{p}{:}
    \PY{n}{makeMov}\PY{p}{(}\PY{p}{)}

\PY{n}{GraphOutput}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
100 0.5800 -0.0000 3.4858 0.0727 0.7264 0.1011 9.3004 0.6564
200 1.1600 -0.0000 3.3542 0.0576 0.7734 0.0407 8.6998 0.3304
300 1.7400 -0.0000 3.3417 0.0280 0.7800 0.0217 8.6296 0.1709
400 2.3200 -0.0000 3.3639 0.0366 0.7749 0.0265 8.7324 0.1871
500 2.9000 -0.0000 3.3500 0.0472 0.7878 0.0376 8.6357 0.2886
600 3.4800 -0.0000 3.2881 0.0333 0.8088 0.0239 8.3788 0.1793
700 4.0600 -0.0000 3.2814 0.0277 0.8158 0.0321 8.3252 0.2033
800 4.6400 -0.0000 3.2723 0.0398 0.8099 0.0357 8.3430 0.2661
900 5.2200 -0.0000 3.3138 0.0399 0.7862 0.0370 8.5363 0.2595
1000 5.8000 -0.0000 3.2623 0.0462 0.8127 0.0395 8.2851 0.2814
1100 6.3800 -0.0000 3.2426 0.0496 0.8400 0.0345 8.1235 0.2614
1200 6.9600 -0.0000 3.2230 0.0467 0.8341 0.0372 8.1137 0.2950
1300 7.5400 -0.0000 3.2821 0.0236 0.8197 0.0223 8.3052 0.1504
1400 8.1200 -0.0000 3.2981 0.0294 0.7968 0.0292 8.4482 0.1944
1500 8.7000 -0.0000 3.2730 0.0365 0.8189 0.0344 8.2660 0.2435
1600 9.2800 -0.0000 3.2818 0.0366 0.8228 0.0280 8.2618 0.2096
1700 9.8600 0.0000 3.2275 0.0532 0.8442 0.0410 8.0404 0.3129
1800 10.4400 -0.0000 3.2257 0.0455 0.8483 0.0365 8.0252 0.2582
1900 11.0200 -0.0000 3.2345 0.0609 0.8446 0.0490 8.0702 0.3672
2000 11.6000 -0.0000 3.2516 0.0293 0.8308 0.0307 8.2041 0.2052
[MoviePy] >>>> Building video coo/coordinates\_11-19-21:16:05:55.mp4
[MoviePy] Writing video coo/coordinates\_11-19-21:16:05:55.mp4
    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
100\%|██████████| 2000/2000 [00:24<00:00, 80.86it/s]
    \end{Verbatim}

    \begin{Verbatim}[commandchars=\\\{\}]
[MoviePy] Done.
[MoviePy] >>>> Video ready: coo/coordinates\_11-19-21:16:05:55.mp4

    \end{Verbatim}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_27_3.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_27_4.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    A Soft-Disk fluid simulation based on the Lennard-Jones Potential
represents a microscopic model of a fluid or gas. It is based on
spherical particles simulating atoms that interact among them. The
interactions occur between pairs of particles exploiting repulsive and
attractive forces. As seen in the video, after 500 timesteps, the two
colored atoms, which initially were close, tend to move in different
directions.


    % Add a bibliography block to the postdoc
    
    
    
\end{document}
