\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{setspace}
\usepackage{listings}
\usepackage{color}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{float}
\usepackage[justification=centering]{caption}
\usepackage{subcaption}
\usepackage[margin=0.75in]{geometry}
\usepackage[parfill]{parskip} 
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{cancel}
\usepackage{siunitx}
\usepackage{adjustbox}

\titleformat{\subsection}[runin]{\normalfont \large \bfseries}
    {\thesubsection}{1em}{}

\captionsetup[figure]{width=0.75\textwidth,labelfont=normalfont,font=it,labelsep=period}

\DeclareMathOperator*{\sinc}{sinc}
\DeclareMathOperator*{\rect}{rect}
\renewcommand{\thesubsection}{\indent(\alph{subsection})}

    \definecolor{dkgreen}{rgb}{0,0.6,0}
    \definecolor{gray}{rgb}{0.5,0.5,0.5}
    \definecolor{mauve}{rgb}{0.58,0,0.82}


    \definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
    \definecolor{mylilas}{RGB}{170,55,241}


    \lstset{language=Matlab,%
        %basicstyle=\color{red},
        breaklines=true,%
        morekeywords={matlab2tikz},
        keywordstyle=\color{blue},%
        morekeywords=[2]{1}, keywordstyle=[2]{\color{black}},
        identifierstyle=\color{black},%
        stringstyle=\color{mylilas},
        commentstyle=\color{mygreen},%
        showstringspaces=false,%without this there will be a symbol in the places where there is a space
        numbers=left,%
        numberstyle={\tiny \color{black}},% size of th_sume numbers
        numbersep=9pt, % this defines how far the numbers are from the text
        emph=[1]{for,end,break},emphstyle=[1]\color{red}, %some words to emphasise
        %emph=[2]{word1,word2}, emphstyle=[2]{style},    
        xleftmargin=2em
    }
    %\lstset{basicstyle=\small,
    %        keywordstyle=\color{mauve},
    %        identifierstyle=\color{dkgreen},
    %        stringstyle=\color{gray},
    %        numbers=left,
    %        xleftmargin=5em
    %        }


\newcommand{\angstrom}{\textup{\AA}}

\title{ECE 456 - Problem Set 3 (Part 1)}
\date{2021-03-31}
\author{David Lenfesty \\ lenfesty@ualberta.ca
    \and Phillip Kirwin \\ pkirwin@ualberta.ca}
    
\pagestyle{fancy}

\fancyhead[L]{\textbf{ECE 456} - Problem Set 3 (Part 1)}
\fancyhead[R]{David Lenfesty and Phillip Kirwin}
\fancyfoot[C]{Page \thepage}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

\begin{document}
    \doublespacing
    \maketitle
    \thispagestyle{empty}
    \singlespacing
    \newpage

    \section*{Problem 1}

        \begin{enumerate}[align=left,leftmargin=*,labelsep=1em,label=\bfseries(\alph*)] 
            \item %1a
            \begin{enumerate}[align=left,leftmargin=*,labelsep=0em,label=(\roman*)] 
                \item %1bi
                The matrix equation is 
                \begin{equation*}
                    [\hat{H}]\left\{\phi\right\} = E \left\{\phi\right\},
                \end{equation*}
                where \([\hat{H}]\) is an \(N\)-by-\(N\) matrix with \([\hat{H}]_{nm} = 0\) except for the following elements:
                \begin{align*}
                    &[\hat{H}]_{nn} = 2t_0 + U_n \\
                    &[\hat{H}]_{n,n \pm 1} = -t_0 \\
                    &[\hat{H}]_{0,N} = [\hat{H}]_{N,0} = -t_0,
                \end{align*}
                with \(t_0 = \hbar^2/(2ma^2)\) and \(U_n = U(na)\). The \(N\)-vector \(\left\{\phi\right\}\) has elements \(\phi_n\) which each represent
                the value of the eigenvector at the point \(na = x_n\).
                \item %1bii

                The expression of the wave function \( \phi (x) \) as a sum of basis functions is as below:

                \begin{equation*}
                    \phi (x) = \sum _{n = 1} ^{N} \phi _n u_n(x)
                \end{equation*}

                The derived matrix equation:

                \begin{equation*}
                    [\hat{H}] _u \{ \phi \} = [S]_u \{ \phi \}
                \end{equation*}

                Where \( [\hat{H}]_u \) is a matrix with the elements:
                
                \begin{equation*}
                    H_{nm} = \int u _n ^* (x) \hat{H} u_m(x) dx
                \end{equation*}

                and \( [S]_u \) is a matrix with the elements:

                \begin{equation*}
                    S_{nm} = \int u _n ^* (x) u_m(x) dx
                \end{equation*}

                \([\hat{H}]_u\) and \([S]_u\) are both of size \(N\)-by-\(N\). The elements
                of \(\left\{\phi\right\}\), \(\phi_n\), are the expansion coefficients of \(\phi(x)\).
            \end{enumerate}

            \item %1b
            \begin{enumerate}[align=left,leftmargin=*,labelsep=0em,label=(\roman*)] 
                \item %1bi
                code:
                \begin{lstlisting}
%constants
E1 = -13.6;
R = 0.074;
a0 = 0.0529;

%matrix elements
R0 = R/a0;

a = 2*E1*(1-(1+R0)*exp(-2*R0))/R0;
b = 2*E1*(1+R0)*exp(-R0);
s = exp(-R0)*(1+R0+(R0^2/3));

%matrices
H_u = [E1 + a, E1*s+b; E1*s+b, E1 + a];
S_u = [1, s; s, 1];

%find eigenvalues and eigenvectors
[vectors,energies] = eig(inv(S_u)*H_u);

                \end{lstlisting}
                The bonding and antibonding eigenenergies are \(\boxed{\SI{-32.2567}{eV}}\) and \(\boxed{\SI{-15.5978}{eV}}\) respectively.
                \item %1bii
                Neglecting normalization, we have the following expressions for \(\phi_B(z)\) and \(\phi_A(z)\):
                \begin{align*}
                    \phi_B(z) = u_L(z) + u_R(z) \\
                    \phi_A(z) = u_L(z) - u_R(z).
                \end{align*}
                We obtain the following plot:
                
                \begin{minipage}[t]{\linewidth}

                    \centering
                    \adjustbox{valign=t}{
                        \includegraphics[width=0.5\textwidth]{q1bii.png}
                    }
                    \captionof{figure}{non-normalized probability densities for bonding and antibonding solutions.}
                \end{minipage}

            \end{enumerate}
        \end{enumerate}
    \newpage
    
    \section*{Problem 2}
        \begin{enumerate}[align=left,leftmargin=*,labelsep=1em,label=\bfseries(\alph*)] 
            \item %2a
            \begin{enumerate}[align=left,leftmargin=*,labelsep=0em,label=(\roman*)] 
                \item %2ai

                \begin{minipage}[t]{\linewidth}

                    \centering
                    \adjustbox{valign=t}{
                        \includegraphics[width=0.5\textwidth]{q2ai.png}
                    }
                    % TODO still don't like this caption
                    \captionof{figure}{Energy vs. wave vector relationship (note: not discretized to account for N)}
                \end{minipage}
            
                \item %2aii

                Energy values from \( -2 \) eV to \(2\) eV are allowed.

                \item %2aiii

                The vector \( \{ \phi \} \), which is of length \( N \), and has elements \( n \) is:

                \begin{equation*}
                    \{ \phi \} = C e ^{ i k \cdot n a }
                \end{equation*}

                The corresponding wave function is:

                \begin{equation*}
                    \phi (x) = \sum _ {n = 1} ^ N C e ^ { i k  \cdot n a } u_n (x)
                \end{equation*}
                
                There is one wave function and thus one energy level for each value of \( k \).
                This means that there is one electronic state per \( k \).

            \end{enumerate}
            \item %2b
            \begin{enumerate}[align=left,leftmargin=*,labelsep=0em,label=(\roman*)] 
                \item %2bi
                \begin{align*}
                    \left\{\phi\right\} = \begin{bmatrix}
                                            C_Ae^{ika} \\
                                            C_Be^{ika} \\
                                            C_Ae^{ik2a} \\
                                            C_Be^{ik2a} \\
                                            \vdots \\
                                            C_Ae^{ikNa} \\
                                            C_Ae^{ikNa}
                                            \end{bmatrix} 
                \end{align*}
                \item %2bii
                \begin{equation*}
                    \phi(x) = \sum_{n=1}^{N} C_Ae^{ikna} u_{nA}(x) + C_Be^{ikna} u_{nB}(x)  
                \end{equation*}
                \item %2biii
                \([h(k)]\) is of size 2-by-2. Thus there will be two values of \(E(k)\) for a fixed \(k\).
                This also means there are two \(\phi(x)\) for each \(k\).
            \end{enumerate}
            \item %2c
            \begin{enumerate}[align=left,leftmargin=*,labelsep=0em,label=(\roman*)] 
                \item %2ci

                \begin{align*}
                    \phi _2 + 2 \phi _3 + \phi _4 &= E \phi_1 \\
                    \phi _1 + \phi _3 + 2 \phi _4 &= E \phi_2 \\
                    2 \phi _1 + \phi _2 + \phi _4 &= E \phi_3 \\
                    \phi _1 + 2 \phi _2 + \phi _3 &= E \phi_4 \\
                \end{align*}

                \item %2cii

                \begin{align*}
                    \phi _2 + 2 \phi _3 + \phi _0 &= E \phi_1 \\
                    \phi _1 + \phi _3 + 2 \phi _4 &= E \phi_2 \\
                    2 \phi _5 + \phi _2 + \phi _4 &= E \phi_3 \\
                    \phi _5 + 2 \phi _6 + \phi _3 &= E \phi_4 \\
                \end{align*}

                \item %2ciii

                A generalized form of the $n$th equation is:

                \begin{equation*}
                    E \phi_n = \phi_{n-1} + \phi_{n+1} + 2 \phi_{n+2}
                \end{equation*}

                \item %2civ

                \begin{align}
                    E C e ^{ikna} &= Ce ^ {ik (n + 1)a} + Ce^{ik (n - 1)a} + 2 Ce^{ik (n + 2)a} \nonumber \\
                    E &= e^{ika} + e^{-ika} + 2 e^{2ika} \nonumber \\
                    E(k) &= 2 e^{2ika} + 2\cos(ka) \label{eq:e_k}
                \end{align}

                \item %2cv

                Imposing the repeating boundary conditions \( \phi _{n + 4} = \phi _{n} \), We obtain the following relationship:

                \begin{align*}
                    Ce^{ikna} &= Ce^{ik(n+4)a} \\
                    1 &= e^{i4ka}
                \end{align*}

                For this to hold, \(4ka\) must be some multiple of \(2 \pi \), and this mean \( k = \frac{\pi}{2a} \cdot integer \).

                \item %2cvi

                Using the E-k relationship from equation \ref{eq:e_k},
                we know that \( k \) must always be real, so the \( 2\cos(ka) \) portion of the E-k relationship must be
                real. As well, if we substitute in the equation for \( k \) we obtained in part \nolinebreak (v), we get the following (partial) expression:

                \begin{equation*}
                    2e^{i2ka} = 2 e^{i\pi \cdot integer}
                \end{equation*}
                
                Which we know will always be real (with a value of \( \pm 2 \)).

                \item %2cvii
                Since \(e^{2\pi n} = 1\), we have:
                \begin{align*}
                    \phi_n(k+\frac{2\pi}{a}) &= Ce^{i(k+\frac{2\pi}{a} \cdot nA} = Ce^{i(k \cdot nA} \\
                    \phi_n(k+\frac{2\pi}{a}) &= \phi_n(k).
                \end{align*}
                Therefore wavefunctions for which \(k\) is separated by \(\frac{2\pi}{a}\) are equivalent, and we
                only need consider the range \(k \in [-\frac{\pi}{a}, \frac{\pi}{a}]\).
            \end{enumerate}
        \end{enumerate}

\end{document}