# example script for Problem 1.8 in Ulaby # which is problem on 4 on Problem Set 1 of 518 in 2012. # Brian Hornbuckle, January 16, 2012. # Converted to Python by Jason Patton, January 16, 2012 from __future__ import division # this forces float division from numpy import * from matplotlib.pyplot import * # let's visualize the wave # easiest perhaps to do this first by looking how the wave behaves in space # at a certain time alpha = 1; # attenuation constant, Np (I just made up this value in order to visualize the wave) f = 1e9; # frequency, Hz T = 1/f; # period, s lambd = 0.2; # wavelength, m omega = 2*pi*f; # radial frequency, rad/s beta = 2*pi/lambd; # wavenumber, rad/m t = 2.5; # what does the wave look like at t = 2.5 s? z = linspace(0,10*lambd,1001); # space coordinate, m v = 3*exp(-alpha*z)*sin(omega*t - beta*z); # voltage of wave, V rc('mathtext', fontset='stix') # fix font glitch in Fedora figure(1) subplot(121) plot(z,v,'m-'); xlabel('space, m'); ylabel('voltage, V'); grid(True); legend(['using $\\alpha$ = %d Np' % (alpha)]); # so the amplitude of the wave decreases in space, like we discussed in class # now let's solve the problem, # look at how the wave behaves in time at a certain point in space z = 2; # position, m t = linspace(0,6*T,1001); # let's look at, say, six periods of this wave v = 3*exp(-alpha*z)*sin(omega*t - beta*z); # voltage of wave, V subplot(122) plot(t,v,'m-'); legend(['z = %d m' % (z)]); xlabel('time, s'); ylabel('voltage, V'); grid(True); show() # what does alpha need to be so that the amplitude at z = 2 m is equal to 1 V? # right now with alpha = 1 the amplitude is about 0.4 V