Пример #1
0
 def data_gen():
     t = 0.0
     (x,V) = plot_potential(elt)
     for k in ks:
         title_str = r'Scattering from $\exp{(%g \pi x i)}$'%k
         u = compute_scatter(elt, k*np.pi)
         umax = np.max(np.abs(u))
         for i in range(N):
             u_real = (u * np.exp(i*2.0j*np.pi/N)).real
             x_grid = plot_fields(elt, u)
             yield x, V, x_grid, u_real, title_str, umax
Пример #2
0
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()