Add parameters for python script, edit method, and add result for problem 7.

This commit is contained in:
Janita Willumsen 2023-12-22 10:00:18 +01:00
parent e7a32bebab
commit 288bfb7058
9 changed files with 165 additions and 15 deletions

View file

@ -34,15 +34,64 @@ Using Equation \eqref{eq:schrodinger_dimensionless}, we get
&= -\frac{i \Delta t}{2} \bigg[ - \frac{u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1}}{2 \Delta x^{2}} \\
& \quad - \frac{u_{\ivec, \jvec+1}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec, \jvec-1}^{n+1}}{2 \Delta y^{2}} + \frac{1}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n+1} \\
& \quad - \frac{u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n}}{2 \Delta x^{2}} \\
& \quad - \frac{u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n}}{2 \Delta y^{2}} + \frac{1}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \bigg] \\
& \quad - \frac{u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n}}{2 \Delta y^{2}} + \frac{1}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \bigg]
\end{align*}
We rewrite the expression,
We rewrite the expression and gather all terms containing the $n+1$ time step on
the left hand side, and the terms containing $n$ time step on the right hand side.
\begin{align*}
& u_{\ivec, \jvec}^{n+1} - \frac{i \Delta t}{2 \Delta x^{2}} \big[ u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1} \big] \\
& - \frac{i \Delta t}{2 \Delta y^{2}} \big[ u_{\ivec, \jvec+1}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec, \jvec-1}^{n+1} \big] + \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n+1} \\
&= u_{\ivec, \jvec}^{n} + \frac{i \Delta t}{2 \Delta x^{2}} \big[ u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n} \big] \\
& \quad + \frac{i \Delta t}{2 \Delta y^{2}} \big[ u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n} \big] - \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \\
& \quad + \frac{i \Delta t}{2 \Delta y^{2}} \big[ u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n} \big] - \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n}
\end{align*}
In addition, since we will use an equal step size $h$ in both $x$ and $y$ direction,
we can use
\begin{align*}
\frac{i \Delta t}{2 \Delta h^{2}} = \frac{i \Delta t}{2 \Delta x^{2}} = \frac{i \Delta t}{2 \Delta y^{2}} \ ,
\end{align*}
and define
\begin{align*}
r \equiv \frac{i \Delta t}{2 \Delta h^{2}}
\end{align*}
Now, the discretized Schrödinger equation can be written as
\begin{align*}
& u_{\ivec, \jvec}^{n+1} - r \big[ u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1} \big] \\
& - r \big[ u_{\ivec, \jvec+1}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec, \jvec-1}^{n+1} \big] + \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n+1} \\
&= u_{\ivec, \jvec}^{n} + r \big[ u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n} \big] \\
& \quad + r \big[ u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n} \big] - \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \ .
\end{align*}
\section{Matrix structure}\label{ap:matrix_structure}
For $u$ vector of length $(M-2) = 3$, the matrices $A$ and $B$ have size
$(M-2)^{2} \times (M-2)^{2} = 9 \times 9$ given by
\begin{align*}
A =
\begin{bmatrix}
a_{0} & -r & 0 & -r & 0 & 0 & 0 & 0 & 0 \\
-r & a_{1} & -r & 0 & -r & 0 & 0 & 0 & 0 \\
0 & -r & a_{2} & 0 & 0 & -r & 0 & 0 & 0 \\
-r & 0 & 0 & a_{3} & -r & 0 & -r & 0 & 0 \\
0 & -r & 0 & -r & a_{4} & -r & 0 & -r & 0 \\
0 & 0 & -r & 0 & -r & a_{5} & 0 & 0 & -r \\
0 & 0 & 0 & -r & 0 & 0 & a_{6} & -r & 0 \\
0 & 0 & 0 & 0 & -r & 0 & -r & a_{7} & -r \\
0 & 0 & 0 & 0 & 0 & -r & 0 & -r & a_{8} \\
\end{bmatrix}
\end{align*}
\begin{align*}
B =
\begin{bmatrix}
b_{0} & r & 0 & r & 0 & 0 & 0 & 0 & 0 \\
r & b_{1} & r & 0 & r & 0 & 0 & 0 & 0 \\
0 & r & b_{2} & 0 & 0 & r & 0 & 0 & 0 \\
r & 0 & 0 & b_{3} & r & 0 & r & 0 & 0 \\
0 & r & 0 & r & b_{4} & r & 0 & r & 0 \\
0 & 0 & r & 0 & r & b_{5} & 0 & 0 & r \\
0 & 0 & 0 & r & 0 & 0 & b_{6} & r & 0 \\
0 & 0 & 0 & 0 & r & 0 & r & b_{7} & r \\
0 & 0 & 0 & 0 & 0 & r & 0 & r & b_{8} \\
\end{bmatrix}
\end{align*}
\end{document}