Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into msoft_review
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor-96 committed Oct 4, 2023
2 parents 81e425c + 99c284c commit 869e183
Show file tree
Hide file tree
Showing 7 changed files with 338 additions and 155 deletions.
60 changes: 29 additions & 31 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion notebook/quantum-mechanics/asymmetricwell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.11.0"
},
"voila": {
"authors": "Dou Du and Giovanni Pizzi"
Expand Down
Binary file modified notebook/quantum-mechanics/images/SOFT_algorithm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 52 additions & 43 deletions notebook/quantum-mechanics/shooting_method.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Shooting Method with Numerov Algorithm to Solve the Time Independent Schrödinger Equation for 1D Quantum Well**\n",
"# **Using the Shooting Method to Solve the Time-Independent Schrödinger Equation for a 1D Quantum Well**\n",
"\n",
"**Authors:** Dou Du, Taylor James Baird and Giovanni Pizzi \n",
"\n",
"<i class=\"fa fa-home fa-2x\"></i><a href=\"../index.ipynb\" style=\"font-size: 20px\"> Go back to index</a>\n",
"\n",
"**Source code:** https://github.com/osscar-org/quantum-mechanics/blob/master/notebook/quantum-mechancis/shooting_method.ipynb\n",
"\n",
"This notebook demonstrates the shooting method with the Numerov algorithm to search the \n",
"eigenfunctions (wavefunctions) and eigenvalues for a one-dimensional quantum well.\n",
"This notebook demonstrates the use of the shooting method to search for the eigenfunctions (wavefunctions) and eigenvalues of the time-independent Schrödinger equation in the case of a one-dimensional quantum well potential.\n",
"\n",
"<hr style=\"height:1px;border:none;color:#cccccc;background-color:#cccccc;\" />"
]
Expand All @@ -24,12 +23,9 @@
"source": [
"## **Goals**\n",
"\n",
"* Understand the mathematical method to solve the Schrödinger equation \n",
"numerically and the boundary condition for the 1D quantum well.\n",
"* Understand the Numerov algorithm and how to improve the accuracy with \n",
"high order correction.\n",
"* Know how to use the shooting method with the Numerov algorithm to get \n",
"the eigenvalues and eigenfunctions."
"* Understand the mathematical formalism underlying the numerical approach to solving the Schrödinger equation with boundary conditions in the case of a 1D quantum well.\n",
"* Learn how to use the shooting method with a numerical integrator to obtain eigenvalues and eigenfunctions of the Schrödinger equation.\n",
"* Appreciate how the accuracy of the solutions can be improved by including higher-order corrections in the numerical integration scheme."
]
},
{
Expand All @@ -43,43 +39,59 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"## **Tasks and exercises**\n",
"\n",
"1. Move the sliders for the width and depth of the quantum well. Do you understand\n",
"the concept of quantum confinement? Do you know any numerical method to solve \n",
"the Schrödinger equation for 1D quantum well?\n",
"1. Move the sliders which control the width and depth of the quantum well. Do you understand\n",
"the concept of quantum confinement? Can you think of any numerical method that can be used to solve \n",
"the Schrödinger equation for a 1D quantum well?\n",
"\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" Please check the previous notebooks for the \n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
"\n",
" Please check the previous notebook which looks at solving the time-independent Shrödinger equation for the \n",
" <a href=\"./1quantumwell.ipynb\">1D quantum well</a>.\n",
" In that notebook, the one-dimensional Shrödinger equation was solved\n",
" by numerical matrix diagonalization.\n",
" In that notebook, the phenomenon of quantum confinement was investigated for the 1D quantum well and the Shrödinger equation was solved\n",
" by numerical matrix diagonalization. \n",
" </details>\n",
"\n",
"2. With the default width (1.20) and depth (0.20), move the sliders \n",
"(on the left side) to the targeted energies. Report the energy when the tail \n",
"of the wavefunction on the right converge to zero (line color turns to green). \n",
"Is the energy the same as the eigenvalue shown in the right plot? You can also \n",
"use the \"auto search\" button to get the eigenvalues, which searches the next \n",
"solution when increasing the energy (i.e. it searches always upwards).\n",
"2. The goal of this task is to obtain the value of the lowest energy eigenvalue. With the default width (1.20) and depth (0.20), move the sliders \n",
"(on the left side) to target the energy of the lowest state. There are multiple sliders to allow specification of very high precision for the trial eigenvalue. You can also \n",
"use the \"auto search\" button to get the eigenvalues, which searches for the next \n",
"solution in order of increasing energy. Report the value of the energy when the tail \n",
"of the wavefunction on the right converges to zero.\n",
"Comparing visually, is the energy the same as the eigenvalue shown in the plot on the right? \n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" The 1st eigenvalue is about 0.0092. You may need to click the \"Flip\n",
" eigenfunctions\" button to make the comparsion. Check the exact eigenvalue \n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
" The 1st eigenvalue is about 0.00919429. Check the exact eigenvalue \n",
" by clicking on the eigenfunction in the plot.\n",
" </details>\n",
" \n",
"3. Follow the same step to get all the eigenvalues, and make a table to compare \n",
"the results with the eigenvalues from the figure. Compare the results with \n",
"and without using the 4th derivative correction (checkbox). Which values \n",
"should be more accurate and why?\n",
"3. Follow the same steps to get the 2nd, 3rd and 4th eigenvalues (you may have to use the \"flip eigenfunction\" button to match up the trial and target wavefunctions). Report the resulting values of the energy eigenvalues in a table with the full precision outputted in the \"Current value\" field after convergence. Compare the results with the target eigenvalues from the figure. Repeat the the procedure now without using the 4th order correction (uncheck the \"incl. 4th derivative\" checkbox). Which of the eigenvalues is most affected by removal of the 4th order correction? Why do you think this is?\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
" When higher-order terms are included in the construction of the numerical integration scheme, the error in our approximation of the derivatives in the Shrödinger equation decreases accordingly. In the present case, the improvement in accuracy is small but still numerically measurable. In other systems, the need for higher-order integrators is necessary to avoid pathological behaviour and even obtain reasonable results (the quantum harmonic oscillator is one such example). A typical higher-order integration scheme that is used to solve the Shrödinger equation is the Numerov method. You can have a read of the <a href=\"./theory/theory_shooting_method.ipynb\">background theory notebook</a> for additional information and references. You should find that the highest energy eigenvalue is that which is most affected by the accuracy of the numerical integration scheme (what order of approximation to the derivative we are using). Intuitively this makes sense as the wavefunctions corresponding to higher energy eigenvalues possess more nodes and therefore have a more oscillatory nature than lower energy wavefunctions. Consequently, the curvature of these wavefunctions is greater and our ability to correctly capture this is reliant on the accuracy of our approximation to the second derivative.\n",
" </details>\n",
" \n",
"4. As you will have seen in the previous task, we sometimes have to flip our trial wavefunction in order to get it to match up with the target eigenfunction. Firstly, what part of the algorithm causes the need for this flipping to obtain the target wavefunction? Secondly, why is is acceptable for us to do this flipping? \n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
" As is mentioned in the background theory notebook, the initial two values of the trial wavefunction used in our iterative ODE solver at the left-hand-side boundary are chosen to be zero and a small number (in our implementation this small number is chosen to be positive). The exact value of $\\epsilon$ is irrelevant as it just leads to a different normalization factor for the wavefunction. In other words, we have $\\psi(x_0)=0$ and $\\psi(x_1)=\\epsilon > 0$. This forces the derivative at $x_0$, $\\psi'(x_0)$, to be positive. The reason why it is alright for us to flip $\\psi\\to - \\psi$ is due to the fact the time-independent Shrödinger equation equation is symmetric under a sign-flip of the solution wavefunction. Consequently, the negative of a solution is also a solution.\n",
" </details>\n",
" \n",
"4. In comparison with the previous method of solving the time-independent Schrodinger equation we have seen (matrix diagonalization), how does this approach fare in terms of computational expense? \n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" Please check the background theory section for the Numerov algorithm.\n",
" </details>"
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
" Solving for the eigenvalues and eigenfunctions of the time-independent Shrödinger equation equation via matrix diagonalization requires diagonalization of a full matrix on a grid representing our system. This incurs a large cost with regard to required to the memory required. Note also that if we wish to use higher order approximations to the derivative in the matrix diagonalization method, this memory requirement is further increased as bands of nonzero elements in the Hamiltonian matrix shall be wider for these methods (more points are used to approximate the derivatives). On the other hand, the approach discussed in this notebook (shooting method + numerical integration scheme) ultimately let's us solve the time-independent Shrödinger equation by keeping only the values of the trial wavefunction at two previous points plus the current point.\n",
" </details> "
]
},
{
Expand Down Expand Up @@ -474,32 +486,29 @@
"\n",
"## Interactive figures\n",
"\n",
"In the interative figure, the soild lines show the wavefunctions and their\n",
"corresponding eigenvalues, which are solved by matrix diagonalization. \n",
"In the interactive figure, the solid lines show the wavefunctions and their corresponding eigenvalues, which are obtained via matrix diagonalization. \n",
"There is a red dash line at the bottom of the figure, which shows the \n",
"eigenfunction solved by Numerov algorithm. \n",
"eigenfunction obtained via use of the shooting method.\n",
"\n",
"## Controls\n",
"\n",
"There are four vertical sliders to control the targeted eigenvalue E. The first \n",
"\n",
"There are four vertical sliders to control the trial eigenvalue, E, used in the shooting method. Multiple slides are necessary in order to affect precise control over the value of the trial eigenvalue. The first \n",
"slider controls the precision for tenths ($10^{-1}$) and hundredths ($10^{-2}$). \n",
"The second slider controls thousandths ($10^{-3}$) and ten thousandths decimal ($10^{-4}$). The third slider controls hundred thousandths ($10^{-5}$) and \n",
"millionths ($10^{-6}$). The last slider controls ten millionths ($10^{-7}$) \n",
"and hundred millionths ($10^{-8}$). The current value is also displayed under \n",
"the sliders.\n",
"\n",
"You need slowly move the 1st slider and observe the tail of the dashed line on \n",
"You need to slowly move the 1st slider and observe the tail of the dashed line on \n",
"the right edge. Once you see the tail change directions (up or down), the true \n",
"value should be between these two values. You need to go back to a smaller value \n",
"and start to tune the 2nd slider. Then the same procedure is for the 3rd and 4th\n",
"slider. When the absolute value at the right edge is smaller than 0.001, the \n",
"dashed red line will turn green. It reaches the desired accuracy for the \n",
"wavefunction. Then, you can read out the current targeted value, which is the\n",
"value of the eigenvalue should be between these two values. You need to go back to a smaller value and start to tune the 2nd slider. Then the same procedure is used for the 3rd and 4th sliders. When the absolute value at the right edge is smaller than 0.001, the \n",
"dashed red line will turn green. At this point it has reached the desired accuracy for the \n",
"wavefunction. You can then read out the current targeted value, which is the\n",
"corresponding eigenvalue.\n",
"\n",
"You can also use the `Auto search` button, which finds the closest eigenvalue \n",
"and eigenfunction (search in the upward direction). In order to make a comparison, \n",
"you may also need to click the `Flip eigenfunctions` button."
"and eigenfunction to that currently targeted by the sliders (the search is performed in the upward direction). In order to make a comparison between the true eigenfunction and that obtained via solution of the Shrödinger equation with the guess eigenvalue, you may also need to click the `Flip eigenfunctions` button (see task 4)."
]
},
{
Expand All @@ -526,7 +535,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.11.0"
},
"voila": {
"authors": "Dou Du and Giovanni Pizzi"
Expand Down
Loading

0 comments on commit 869e183

Please sign in to comment.