Skip to content

Commit

Permalink
'lin var documented'
Browse files Browse the repository at this point in the history
  • Loading branch information
DPotoyan committed Nov 13, 2023
1 parent e53ed08 commit 9a58b7d
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions ch06/demo_lin_var.ipynb
Expand Up @@ -168,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 42,
"metadata": {},
"outputs": [
{
Expand All @@ -185,20 +185,20 @@
"num_basis_functions = 2\n",
"\n",
"# Compute the overlap matrix and Hamiltonian matrix\n",
"overlap_matrix = np.zeros((num_basis_functions, num_basis_functions))\n",
"hamiltonian_matrix = np.zeros((num_basis_functions, num_basis_functions))\n",
"S = np.zeros((num_basis_functions, num_basis_functions))\n",
"H = np.zeros((num_basis_functions, num_basis_functions))\n",
"\n",
"for i in range(num_basis_functions):\n",
" for j in range(num_basis_functions):\n",
"\n",
" fi, fj = basis_functions(x, i), basis_functions(x, j)\n",
"\n",
" overlap_matrix[i, j] = np.trapz(fi * fj, x=x)\n",
" S[i, j] = np.trapz(fi * fj, x=x)\n",
"\n",
" hamiltonian_matrix[i, j] = np.trapz(fi * KE(fj, dx) + fi * PE(fj, x), x=x)\n",
" H[i, j] = np.trapz(fi * KE(fj, dx) + fi * PE(fj, x), x=x)\n",
"\n",
"# Diagonalize the matrices to find eigenvalues and eigenvectors\n",
"eigenvalues, eigenvectors = eigh(hamiltonian_matrix, overlap_matrix)\n",
"eigenvalues, eigenvectors = eigh(H, S)\n",
"\n",
"# Find the ground-state energy (lowest eigenvalue) and corresponding eigenfunction\n",
"ground_state_energy = eigenvalues[0]\n",
Expand All @@ -212,7 +212,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### visualize Eigenfunctions and eigenvalues"
"### Visualize Eigenfunctions and eigenvalues"
]
},
{
Expand Down Expand Up @@ -266,13 +266,6 @@
"ax2.set_xlim(-3, 4)\n",
"ax2.set_title('Energy levels')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 9a58b7d

Please sign in to comment.