The provided Python code is designed to solve the eigenvalue problem for a particle bound in a one-dimensional potential well. The code calculates the energy eigenvalues and plots the corresponding eigenfunctions. Below is an explanation of the code, broken down into its components:
1. Imports
numpy: Provides support for array operations.
scipy.integrate.odeint: Used to solve ordinary differential equations (ODEs).
scipy.integrate.simps: For numerical integration using Simpson's rule.
matplotlib.pyplot: For plotting graphs.
scipy.optimize: For finding roots of transcendental equations.
2. Functions for Parity Conditions
evenparity(z, z0): Represents the transcendental equation for even parity states.
oddparity(z, z0): Represents the transcendental equation for odd parity states.
- These functions are used to find the eigenvalues, corresponding to the points where these functions equal zero.
3. Potential Parameters and Energy Range
L = 4: Width of the potential well.
V0 = 10: Depth of the potential well.
h_bar = 1, m = 1: Reduced Planck's constant and mass of the particle, respectively.
Erange: Array representing the range of energies considered, from just above -V0 to 0.
x: Array representing spatial coordinates.
4. Dimensionless Parameters
z: Dimensionless quantity related to the energy and well width.
z0: Dimensionless quantity related to the well depth.
5. Plotting the Transcendental Equations
- The code plots the functions for
tan(z) and cot(z) against sqrt((z0/z)^2 - 1) to visualize the transcendental equations.
- These plots help in visually identifying the approximate locations of the eigenvalues.
6. Guessing Roots from the Graphs
evenroot_guess, oddroot_guess: Initial guesses for the roots (eigenvalues) based on the plots.
opt.root: Function to compute the roots of the parity conditions (i.e., the eigenvalues).
7. Energy Eigenvalues
- The roots found are converted back to physical energy values using the relation
E = (z*h_bar*2/L)**2/(2*m) - V0.
- The computed eigenvalues for even and odd parity states are printed.
8. Potential Function V(x)
- A step function defining the potential well:
- Inside the well (
-L/2 < x < L/2), the potential is -V0.
- Outside the well, the potential is 0.
9. Solving the Schrödinger Equation
f(u, x, E): Defines the system of ODEs for the wavefunction psi(x) and its derivative psi'(x).
odeint: Solves the ODE for each eigenvalue E to obtain the wavefunction psi(x).
10. Normalization and Plotting
- The wavefunctions are normalized using Simpson's rule for integration.
- The code then plots the normalized wavefunctions alongside the potential well for each eigenvalue.
- Each subplot corresponds to an eigenfunction, showing the wavefunction shape and energy level.
11. Output
- The plots of the eigenfunctions are saved as
psi.png, and the plots of the transcendental equations are saved as plot.png.
Purpose and Summary
- Goal: To find the eigenvalues of a particle bound in a one-dimensional potential well and to plot the corresponding eigenfunctions.
- Method: Solves the transcendental equation that governs the eigenvalue condition, then solves the Schrödinger equation to obtain the wavefunctions.
- Output: Plots of the transcendental equation, energy eigenvalues, and normalized eigenfunctions.