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
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.
X = Function('X')
eqn = Derivative(X(x),x,x)+k**2*X(x)
eqn
dsoln = dsolve(eqn , X(x)).rewrite(sin)
dsoln
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
dsoln.rhs.subs(x,0)
dsoln.rhs.subs(x,L)
simplify(dsoln.rhs.subs([(x,L), (C2, -C1)]))
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.