Skip to content

Python solver for Time Dependant Schrodinger's Equation using Crank-Nicholson method.

Notifications You must be signed in to change notification settings

MaxMnr/SchrodingerCrankNicholson

Repository files navigation

SchrodingerCrankNicholson

solver.py

This project contains the implementation of the Schrodinger class, which serves as a solver for the Time-Dependent Schrödinger's Equation (TDSE) using the Crank-Nicholson method. The class provides a flexible framework to simulate the behavior of a 1D-particle trapped in a box under various potential conditions.

Class: Schrodinger

Initialization Parameters:

  • Nx: Number of spatial grid points.
  • Nt: Number of time steps.
  • kappa, sigma: Parameters for the Gaussian wave packet.
  • L: Length of the spatial domain.
  • x0: Initial position of the wave packet.
  • potential: Type of potential (default is Infinite Square Well).
  • tmax: Maximum time for simulation.

Methods:

  • getPotential(choice): Method to define the potential energy based on the chosen potential type ("ISW", "tunneling", "double_part").
  • infiniteSquareWell(): Method to define the infinite square well potential.
  • tunneling(x, x1, width, amp): Method to define the tunneling potential.
  • getAB(): Method to calculate matrices A and B for Crank-Nicholson.
  • gaussianPacket(x, x0, kappa, sigma, norm=True): Method to generate a Gaussian wave packet.
  • solve(): Method to solve the time-dependent Schrödinger equation.

utils.py

This file contains functions used to visualize various aspects of the simulation results generated by the Schrodinger class defined in solver.py.

Function: animRealImag(schrodinger)

Generates an animated plot showing the real and imaginary parts of the wave function as it evolves over time.

animModulus(schrodinger)

Generates an animated plot showing the modulus squared of the wave function as it evolves over time.

plotUncertainty(schrodinger)

Plots the uncertainty (variance) of the wave function's position over time.

plotNormalization(schrodinger)

Plots the normalization of the wave function over time.

plotExpectedPosition(schrodinger, ret=False)

Plots the expected position of the particle over time. If ret=True, returns the expected position array instead of plotting it.

plotTimeEvolution(schrodinger)

Plots the time evolution of the wave function as a color map, showing its magnitude at each position and time.

plotSome(schrodinger)

Other

Three example scripts are provided to demonstrate the usage of the Schrodinger class with different potential types:

  • infinite_square_well.py: Example script for simulating a particle trapped in an Infinite Square Well potential.
real_imag_anim_isw.mp4

expect_pos_plot_isw

  • harmonic.py: Example script for simulating a particle trapped in a Harmonic Potential.
animation_1sur100.mp4
  • tunneling.py: Example script for simulating a particle with tunneling effect.

https://github.com/MaxMnr/SchrodingerCrankNicholson/assets/88986446/b81eae2a-b1bc-4086-8e9a-1d12de723b31 expect_plot_tunneling

  • double_part.py: Example script for simulating a two particles system.

https://github.com/MaxMnr/SchrodingerCrankNicholson/assets/88986446/77517442-d06b-474e-ac33-5c5bfb4f9439 expected_plot_double_hr

About

Python solver for Time Dependant Schrodinger's Equation using Crank-Nicholson method.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages