{ "cells": [ { "cell_type": "markdown", "id": "d7ef9799", "metadata": {}, "source": [ "# schroedinger_hydrogen\n", "\n", "Visualize the Amplitude of a Hydrogen Atom in the n = 2, l = 0, m = 0 state.\n", "Demonstrates how TH2F can be used in Quantum Mechanics.\n", "\n", "The formula for Hydrogen in this energy state is $ \\psi_{200} = \\frac{1}{4\\sqrt{2\\pi}a_0\n", "^{\\frac{3}{2}}}(2-\\frac{\\sqrt{x^2+y^2}}{a_0})e^{-\\frac{\\sqrt{x^2+y^2}}{2a_0}} $\n", "\n", "\n", "\n", "\n", "**Author:** Advait Dhingra \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:37 PM." ] }, { "cell_type": "markdown", "id": "bf32c43d", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 1, "id": "0f4fcc46", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:28.364015Z", "iopub.status.busy": "2026-05-19T20:37:28.363905Z", "iopub.status.idle": "2026-05-19T20:37:28.378931Z", "shell.execute_reply": "2026-05-19T20:37:28.378394Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "\n", "#include \n", "\n", "double WaveFunction(double x, double y)\n", "{\n", " double r = sqrt(x * x + y * y);\n", "\n", " double w = (1 / pow((4 * sqrt(2 * TMath::Pi()) * 1), 1.5)) *\n", " (2 - (r / 1) * pow(TMath::E(), (-1 * r) / 2)); // Wavefunction formula for psi 2,0,0\n", "\n", " return w * w; // Amplitude\n", "}" ] }, { "cell_type": "code", "execution_count": 2, "id": "3be3b2d5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:28.380824Z", "iopub.status.busy": "2026-05-19T20:37:28.380690Z", "iopub.status.idle": "2026-05-19T20:37:29.050047Z", "shell.execute_reply": "2026-05-19T20:37:29.049681Z" } }, "outputs": [], "source": [ "TH2F *h2D = new TH2F(\"Hydrogen Atom\",\n", " \"Hydrogen in n = 2, l = 0, m = 0 state; Position in x direction; Position in y direction\", 200,\n", " -10, 10, 200, -10, 10);\n", "\n", "for (float i = -10; i < 10; i += 0.01) {\n", " for (float j = -10; j < 10; j += 0.01) {\n", " h2D->Fill(i, j, WaveFunction(i, j));\n", " }\n", "}\n", "\n", "gStyle->SetPalette(kCividis);\n", "gStyle->SetOptStat(0);\n", "\n", "TCanvas *c1 = new TCanvas(\"c1\", \"Schroedinger's Hydrogen Atom\", 750, 1500);\n", "c1->Divide(1, 2);\n", "\n", "auto c1_1 = c1->cd(1);\n", "c1_1->SetRightMargin(0.14);\n", "h2D->GetXaxis()->SetLabelSize(0.03);\n", "h2D->GetYaxis()->SetLabelSize(0.03);\n", "h2D->GetZaxis()->SetLabelSize(0.03);\n", "h2D->SetContour(50);\n", "h2D->Draw(\"colz\");\n", "\n", "TLatex *l = new TLatex(\n", " -10, -12.43,\n", " \"The Electron is more likely to be found in the yellow areas and less likely to be found in the blue areas.\");\n", "l->SetTextFont(42);\n", "l->SetTextSize(0.02);\n", "l->Draw();\n", "\n", "auto c1_2 = c1->cd(2);\n", "c1_2->SetTheta(42.);\n", "\n", "TH2D *h2Dc = (TH2D *)h2D->Clone();\n", "h2Dc->SetTitle(\"3D view of probability amplitude;;\");\n", "h2Dc->Draw(\"surf2\");" ] }, { "cell_type": "markdown", "id": "d8c3fc21", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 3, "id": "3b980171", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:29.051906Z", "iopub.status.busy": "2026-05-19T20:37:29.051789Z", "iopub.status.idle": "2026-05-19T20:37:29.842374Z", "shell.execute_reply": "2026-05-19T20:37:29.841674Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }