def squarepot(VV = np.array([0,1,0]), xx = np.array([-2, -1, 1, 2]), neigs = 40): """ Compute resonances of a one-dimensional piecewise-constant potential. The value of the potential will be VV(i) on the interval ( xx(i), xx(i+1) ). Input: VV -- Value of the potential on each interval xx -- Coordinates of the interval endpoints neigs -- Max eigenvalues or resonances to be computed (default: 40) Output: l -- Vector of resolved resonance poles in the lambda (wave number) plane """ elt = square_well(xx, VV) f, axarr = plt.subplots(2) plot_potential1( VV, xx, axarr[0] ) l = checked_resonances(elt, neigs) # #TODO: Fix plot point sizes l_full = checked_resonances(elt) axarr[1].scatter(l_full.real, l_full.imag) axarr[1].set_title('Pole locations') # plt.axis('equal') plt.show() return l
def data_gen(): t = 0.0 for pot in potentials: elt = square_well(ab=[-pot]) (x,V) = plot_potential(elt) l = checked_resonances(elt, 20) yield x, V, l.real, l.imag
from plotting import plot_potential from square_well import square_well from compute_scatter import compute_scatter from plotting import plot_fields from plotting import animate_wave print 'In the first example, we show how the eigenvalues and resonances \ change as the depth of a square potential well changes.' raw_input('Press Enter to begin\n') potentials = np.linspace(6,10,20) sq_potential(potentials) print '\nNow we consider the scattering from a plane wave of the form exp(-ikx), where k = pi. The real part of the scattered wave is in red; the imaginary part is in blue.' raw_input('Press Enter to begin\n') elt = square_well([-10]) u = compute_scatter(elt, -np.pi) (x,V) = plot_potential(elt) x_u = plot_fields(elt, u) fig, (ax1, ax2) = plt.subplots(2,1) # intialize two line objects (one in each axes) ax1.set_ylim(-11, 1) for ax in [ax1, ax2]: ax.set_xlim(-2, 2) ax.grid() ax1.plot(x, V, marker='o', linestyle='-',color='r') ax2.plot(x_u, u.real, marker='o', linestyle='-',color='r') ax2.plot(x_u, u.imag, marker='o', linestyle='-',color='b') plt.show()