The following relates to the linked question:
Scattering of waves in a symmetrical potential (using python)
I have attempted to solve the problem for $U(r)$ using odeint
. From this, I need to find $\mathrm{arctan}(U(r))$ and continue the integration to a large $r$
I am aware that for $\mathrm{arctan}$ I should use np.arctan
My issue is that I am getting dimensional errors with my code and hence cannot solve for $U(r)$
I am also unsure as to how to continue the integration to a large value.
I have attached my code (I am new to Python so apologies for the obvious errors.)
I really could do with help here thanks.
"""
Code to integrate ODE to numerically solve phase-shifts for given
values of k and r
"""
import numpy as np
import scipy.special as sp
import matplotlib.pyplot as plt
from scipy.integrate import odeint
def pend(U, r, l, k, A):
theta, omega = U
dUdr = [r, (-k*(A**2)/(r**2))([sp.spherical_jn(l, z, derivative=False) \
-(sp.spherical_yn(l, z, derivative=False)*U(r))])**2]
return dUdr
# Set limits and step
rmin = 0
rmax = 100
dr = 1
# Set up array of r-values
r = np.arange(rmin, rmax+dr, dr);
N = len(r);
# Set Constants
A = 35.3
l = [0.0, 1.0]
k = 0.5
r = 7
z = k*r
# set initial conditions
U0 = [0.0]
# Solve
sol = odeint(pend, U0, r, args=(l, k, A))
# Plot
plt.legend(loc='best')
plt.xlabel('r')
plt.ylabel('U(r)')
plt.grid()
plt.show()
```