Skip to content

Commit

Permalink
Update of Asymmetric Well App (#223)
Browse files Browse the repository at this point in the history
* Minor modifications in preparation for final review of asymmetric well notebook.

* Revisions of asymmetric well notebook text.

* seperate the images testing

* update the model asymmetricwell image

---------

Co-authored-by: Taylor-96 <[email protected]>
Co-authored-by: Taylor <[email protected]>
  • Loading branch information
3 people authored Feb 13, 2023
1 parent 80cb2cb commit 8e44765
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 48 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/voila-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ jobs:
name: quantum-screenshot
path: './*.png'

- name: Run the figures test
run: |
python3 $GITHUB_WORKSPACE/test/test_figures.py
48 changes: 17 additions & 31 deletions notebook/quantum-mechanics/asymmetricwell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# **Avoided Crossing in One Dimensional Asymmetric Quantum Well**\n",
"# **Avoided Crossing in a One-Dimensional Asymmetric Quantum Well**\n",
"\n",
"**Authors:** Dou Du, Taylor James Baird and Giovanni Pizzi \n",
"\n",
Expand All @@ -22,9 +22,8 @@
"metadata": {},
"source": [
"## **Goals**\n",
" * Familiarize oneself with the phenomenon of avoided crossing.\n",
" * Familiarize yourself with the phenomenon of avoided crossing.\n",
" * Understand the mathematical origin of avoided crossing (i.e. how the behaviour arises from the description of a given system through a dependence on some set of parameters).\n",
" * Appreciate the connection between the presence of regions of avoided crossing in potential energy surfaces and the breakdown of the Born-Oppenheimer approximation for the system being described. \n",
" * Relate the observation of avoided crossing in this toy model to its manifestation in realistic molecular and material systems."
]
},
Expand All @@ -43,50 +42,37 @@
"source": [
"## **Tasks and exercises**\n",
"\n",
"1. For which value of $\\mu$ are the two lowest eigenvalues closest to each other?\n",
"Will the order of the states change by changing the $\\mu$ parameter? And why?\n",
"\n",
"1. For which value of $\\mu$ are the two lowest eigenvalues closest to each other? Will the order of the states change by changing the $\\mu$ parameter? And why?\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
"\n",
" In the figure, the blue and red lines show the lowest and \n",
" second-lowest eigenvalues respectively. The subplot on the bottom shows\n",
" the two lowest eigenvalues as a function of the parameter $\\mu$.\n",
" One can see that these two eigenvalues are closest to each other\n",
" at $\\mu = 0$. For the entire range of plotted $\\mu$ values, the red line is always higher\n",
" than the blue line. The $\\mu x$ term can be considered as a perturbation\n",
" to the original double well potential, which results in the avoided crossing. Please check the detailed\n",
" than the blue line, i.e. the eigenvalues change continuously. However, the nature of the state changes as we change the value of mu! For values $mu << 0$, the lowest eigenstate is localized in the right well, while for $mu >>0$ is is localized in the left well. For values of $mu$ close to zero, the two states mix and we get a symmetric and an antisymmetric solution. The $\\mu x$ term can be considered as a perturbation to the original double well potential, which results in the avoided crossing. Please check the detailed\n",
" information in the background theory section.\n",
" </div> \n",
" </details>\n",
" \n",
"2. How about other states? Is there any changing of energy order of the states?\n",
"\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" By tuning the $\\mu$ slider we observe that the values of the eigenvalues change continuously with the size of the perturbation. However, the order of all the\n",
" plotted states remain unchanged (monitor the top right subplot).\n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
" By tuning the $\\mu$ slider we observe that the values of the eigenvalues change continuously with the size of the perturbation. Also in this case, when the value of $mu$ would tend to make two eigenvalues identical, an anticrossing effect takes place (e.g. between the second and third state at $mu \\sim 0.085$), and we see the appearance of a symmetric and an antisymmetric eigenstate. \n",
" </div>\n",
" </details>\n",
" \n",
"3. What is the connection between the phenomenon of avoided crossing and the Born–Oppenheimer approximation?\n",
"3. What type of molecular system could be described by the asymmetric double well model we consider here? \n",
"\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" The Born–Oppenheimer (BO) approximation is a common approximation employed in quantum chemistry and quantum physics calculations for which one can justify the assumption that the system of interest remains in its electronic ground state. In the\n",
" BO approximation, the non-adiabatic coupling vector linking separate electronic states needs to be\n",
" negligible:\n",
" $$F_{ij}^k(R)=\\frac{<\\psi_i(r;R)|\\nabla_{R_k}H^e|\\psi_j(r;R)>}{V_j-V_i}$$\n",
" where $V_j$ and $V_i$ are the eigenvalues of the electronic\n",
" Shrödinger equation. If $V_j$ and $V_i$ have close values,\n",
" the term is not negligible anymore and BO approximation breaks down. Consequently, we may observe that in the region of an avoided crossing, the validity of the Born-Oppenheimer approximation deteriorates.\n",
" A more detailed discussion of the BO approximation can be found at \n",
" <a href=\"https://en.wikipedia.org/wiki/Born%E2%80%93Oppenheimer_approximation\">\n",
" Wikipedia</a>.\n",
" </details>\n",
" \n",
"4. What type of molecular system could be described by the asymmetric double well model we consider here? \n",
" <div style=\"border:blue; border-width:3px; border-style:outset;\">\n",
"\n",
" <details>\n",
" <summary style=\"color: red\">Solution</summary>\n",
" As demonstrated in the <a href=\"../2quantumwells.ipynb\">notebook</a> illustrating a double quantum well system, this type of potential gives a reasonable description of diatomic molecules. Adding in asymmetry simply accounts for the two atoms comprising the molecule being different (a heteronuclear molecule). This toy model therefore illustrates the fact that, in diatomic systems, which are parameterized by a single value - namely the separation of the two nuclei - the eigenvalues of the system never cross. One must consider polyatomic molecules consisting of three or more atoms before crossing of electronic energy levels is observed (see <a href=\"https://en.wikipedia.org/wiki/Conical_intersection\">Wikipedia</a>).\n",
" As demonstrated in the <a href=\"../2quantumwells.ipynb\">notebook</a>, illustrating a double quantum well system, this type of potential gives a reasonable description of diatomic molecules. Adding in asymmetry simply accounts for the two atoms comprising the molecule being different (a heteronuclear molecule). This toy model therefore illustrates the fact that, in diatomic systems, which are parameterized by a single value - namely the separation of the two nuclei - the eigenvalues of the system never cross. One must consider polyatomic molecules consisting of three or more atoms before crossing of electronic energy levels is observed (see <a href=\"https://en.wikipedia.org/wiki/Conical_intersection\">Wikipedia</a>).\n",
" </div>\n",
" </details>\n"
]
},
Expand Down Expand Up @@ -399,10 +385,10 @@
"\n",
"There is a slider to adjust the $\\mu$ parameter of the potential.\n",
"The zoom factor slider aids in the inspection of the wavefunctions by\n",
"multiplying them by a constant (this is purely for visualization purposes). One can highlight the square modulus of a specific eigenfunction $\\psi$, and its\n",
"multiplying them by a constant (this is purely for visualization purposes). One can highlight the square modulus of a specific eigenfunction, $\\psi$, and its\n",
"eigenvalue, by clicking on the plot. All the other \n",
"states shall be hidden from the plot. By clicking the `Show all` button, one can \n",
"see all states again. Additionally, there is a radio button which enables one to choose whether to plot the wavefunctions $\\psi$ or the probability densities $|\\psi|^2$."
"see all states again if they were previously hidden by clicking on one of them to highlight it. Additionally, there is a radio button which enables one to choose whether to plot the wavefunctions $\\psi$, or the probability densities $|\\psi|^2$."
]
},
{
Expand All @@ -429,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
12 changes: 6 additions & 6 deletions notebook/quantum-mechanics/theory/theory_asymmetricwell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
"and depending on N continuous real parameters, cannot become equal in value \n",
"(\"cross\") except on a manifold of N-2 dimensions. Please read the \n",
"[Wikipedia page](https://en.wikipedia.org/wiki/Avoided_crossing)\n",
"on the avoided crossing for more information.\n",
"on avoided crossing for more information.\n",
"\n",
"In this notebook, we solve the Schrödinger equation for a 1D \n",
"potential. The formula of the potential is:\n",
"\n",
"$$\\large V(x) = x^4 - 0.6x^2 + \\mu x$$\n",
"\n",
"where, $x$ is the position, and $\\mu$ is the potential parameter \n",
"(which can be tuned using a slider in the interactive notebook) that determines the symmetry \n",
"of the two quantum wells. "
"(which can be tuned using a slider in the interactive notebook) that determines the asymmetry \n",
"of the two quantum wells (i.e., the relative \"depth\" of the two quantum wells). "
]
},
{
Expand All @@ -62,9 +62,9 @@
"$$E_+ = \\frac{1}{2}(E_1+E_2) + \\frac{1}{2}\\sqrt{(E_1-E_2)^2+4|W|^2} \\quad (4)$$\n",
"$$E_- = \\frac{1}{2}(E_1+E_2) - \\frac{1}{2}\\sqrt{(E_1-E_2)^2+4|W|^2} \\quad (5)$$\n",
" \n",
"One can see that E$_+$ is always bigger than E$_-$.\n",
"One can see that, by definition, E$_+$ is always bigger than E$_-$.\n",
"The energy difference $E_+ - E_-$ is $\\sqrt{(E_1-E_2)^2+4|W|^2}$.\n",
"Hence, the perturbation prevents the two energy states from crossing.\n"
"Hence, the perturbation prevents the two energy states from crossing. However, we stress that the eigenvectors depend on the value of $W$; they will be closer to the $(1,0)$ eigenvector (associated with the $E_1$ eigenvalue of the unperturbed Hamiltonian $H$) or to $(1,0)$ (associated with $E_2$) depending on the value of $W$.\n"
]
}
],
Expand All @@ -84,7 +84,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.11.0"
}
},
"nbformat": 4,
Expand Down
11 changes: 0 additions & 11 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from PIL import Image, ImageChops, ImageStat

class TestTest01():
def setup_method(self, method):
Expand Down Expand Up @@ -48,13 +47,3 @@ def test_asymmetricwell(self):
test.test_asymmetricwell()
test.teardown_method('Chrome')

image1 = Image.open('asymmetricwell.png')
image2 = Image.open('test/asymmetricwell.png')

diff = ImageChops.difference(image1, image2)
stat = ImageStat.Stat(diff)

if sum(stat.mean) == 0:
print('images are the same')
else:
raise Exception("The result is NOT the same as expected. Please check matplotlib version.")
12 changes: 12 additions & 0 deletions test/test_figures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from PIL import Image, ImageChops, ImageStat

image1 = Image.open('asymmetricwell.png')
image2 = Image.open('test/asymmetricwell.png')

diff = ImageChops.difference(image1, image2)
stat = ImageStat.Stat(diff)

if sum(stat.mean) == 0:
print('images are the same')
else:
raise Exception("The result is NOT the same as expected. Please check matplotlib version.")

0 comments on commit 8e44765

Please sign in to comment.