In [1]:
from sympy import Derivative, Function, symbols, diff, srepr, dsolve, Rational, \
        integrate, solveset, sqrt, Eq, exp, sin, cos, I, simplify
import sympy

The purpose of this is to try and solve the Schrodinger equation for the infinite square well. I don't really know if my mathematical set up is valid but I am going to solve it as a boundary value problem where the end points are zero.

Set up the symbols that I will be using

In [2]:
x, y, a, b, t = symbols("x y a b t", Real=True)
hbar, m = symbols("hbar m", Real=True, Positive=True)
k, L = symbols("k L", Real=True)
n = symbols("n", Integer=True)

Set up a crude facsimile of the Schrodinger equation but just using contants instead of the actual terms.

The time independent Schrödinger equation can be written as follows:

$$ \left [ \frac{- \hbar^2}{2m} \frac{\partial}{\partial x^2} + V(x,t) \right ] \Psi (x,t) = E \, \Psi (x,t) $$

We assume that V(x) = 0 within the square well and ignore what is happening outside of it.

In [3]:
X = Function('X')
eqn = Derivative(X(x),x,x)+k**2*X(x)
eqn
Out[3]:
$\displaystyle k^{2} X{\left(x \right)} + \frac{d^{2}}{d x^{2}} X{\left(x \right)}$
In [4]:
dsoln = dsolve(eqn , X(x)).rewrite(sin)
dsoln
Out[4]:
$\displaystyle X{\left(x \right)} = C_{1} \left(- i \sin{\left(k x \right)} + \cos{\left(k x \right)}\right) + C_{2} \left(i \sin{\left(k x \right)} + \cos{\left(k x \right)}\right)$
In [5]:
rhs = dsoln.rhs

constants = sorted(
    [s for s in rhs.free_symbols if s.name.startswith('C')],
    key=lambda s: s.name
)
C1, C2 = constants
print(constants)
[C1, C2]

Now try and work out what the arbitrary constants should be for the boundary value conditions of X(0) = X(L) = 0

In [6]:
dsoln.rhs.subs(x,0)
Out[6]:
$\displaystyle C_{1} + C_{2}$
In [7]:
dsoln.rhs.subs(x,L)
Out[7]:
$\displaystyle C_{1} \left(- i \sin{\left(L k \right)} + \cos{\left(L k \right)}\right) + C_{2} \left(i \sin{\left(L k \right)} + \cos{\left(L k \right)}\right)$
In [8]:
simplify(dsoln.rhs.subs([(x,L), (C2, -C1)]))
Out[8]:
$\displaystyle - 2 i C_{1} \sin{\left(L k \right)}$

Therefore $ \sin(Lk) = 0 $ so k must equal $ n \pi / L$ meaning that the wave equation becomes: $$ \sqrt\frac{2}{L} \sin ( n \pi x / L ) $$

We can also look at separable solutions based on Schrödinger's time dependent equation

$$ \frac{- \hbar^2}{2m} \frac{ \phi''(x)}{\phi(x)} + V(x) = i \hbar \frac{ \psi'(t)}{\psi (t) } \\ \Rightarrow \frac{- \hbar^2}{2m} \frac{ \phi''(x)}{\phi(x)} + V(x) = C \\ {\tiny \textbf { and}} \; i \hbar \frac{ \psi'(t)}{\psi (t) } = C $$

This essentially becomes a homogeneous second order equation as :

$$ \frac{- \hbar^2}{2m} \phi''(x) + (V(x)-C) \phi(x) = 0 $$

but we want the leading second order term to be 1 so we multiply through by $ \frac{2m}{- \hbar^2} $

$$ \phi''(x) + \frac{2m}{- \hbar^2}(V(x)-C) \phi(x) = 0 $$

This means in relating it the differential equation:

$$ \frac{d^{2}}{d x^{2}} X{\left(x \right)} + k^{2} X{\left(x \right)} = 0 $$

Then in our case :

$$ k^2 = \frac{2m}{- \hbar^2}(V(x)-C) $$

Which we know already has the following solution:

$$ \require{cancel} \cancel { \phi{\left(x \right)} = C_{1} e^{- i k x} + C_{2} e^{i k x} } $$

The above is no longer true as V(x) is dependent on x.

In [ ]: