Computer Lab 8: Lecture 23

In our computer lab lectures we will work together through concepts and challanges we have discussed over the week in class.  As with your after-class Exercises, you will be expected to turn in your computer lab notebooks before the nect lecture. Please do so by e-mailing your completed *nb file to Lan Yu (ece329.uiuc@gmail.com), make sure you name the file using the following notation: “Exn_Last_Last.nb”, where n is the Lecture number (in this case, 23), and First and Last would be your first and last name.  So my submission to Lan for this computer lab would be titled “Ex23_Wasserman_Dan.nb”.  You will receive full credit for your copmputer lab if it turned in before the next lecture (Lecture n+1).  No late submissions will be accepted.

Objective/Overview:

In class this week we discussed the wave equation, and solutions to the wave equation for waves propagating in lossy media (σ≠0).  Wave propagation in lossy media is an extremely important concept, since most every time you try to send information or energy in the real world, you will be dealing with losses.  Thus, understand the frequency-response of wave propagation as a function of loss is essential for a wide range of applications.  In today’s class, we are going to make a CDF that allows the user to input the μ, ϵ, and σ of a material, and the ω of the wave.  The output of the program should give the user a full picture of wave propagation in the medium.

Inputs and Outputs

Before we begin our program, let’s make sure we are on the same page in terms of what we want the user to input, and what we want the user to get out of the program.  Let’s assume that our wave is generated on the xy plane at z=0, and let’s only consider the forward-propagating E&M wave.  So we can think of this wave as generated by a harmonic surface current at the xy plane:
 
First, we will want to define our material system.  This means our (Subscript[μ, r]), our (Subscript[ϵ, r]), and our σ.  We also want the user to be able to choose the frequency of the wave generated. These will be the inputs to the program.
We want the program to output complex propagation vector [γ], propagation length [1/α], wavelength [2π/β], phase velocity [ω/β], characteristic impedance [|η|,∠η], and animated plots of E(z) and H(z) vs time.  In addition, we need to be careful, because if we have a wave with a very large wavelength that decays in less than a wavelength, and we compare it to a wave with a short wavelength which propagates for many wavelengths, it might appear as though our large wavelength wave has a longer propagation length...this is true, technically, but that doesn’t mean propagation is better...in general, we like to normalize propagation to wavelength, so we will also want to show a normalized propagation length [(1/α)/λ=β/2πα].
Input ranges: To model real-world materials, we can make some assumptions about reasonable ranges of our inputs
ϵ-> Will usually go from 1 (vacuum) to ~20 (high index semiconductor) 
μ-> For most materials, this will be ~1, but we can let this range from 0.5-2
σ->A perfect dielectric has conductivity of 0 and a high conductivity metal can have conductivity as high as (10^8)S/m.  A perfect conductor is said to have conductivity of ∞, but capping the range at (10^8)S/m is probably reasonable.  You will probably want to allow the user to choose conductivity in factors of 10, so this input should be a list.
ω->It’s probably reasonable to allow this to vary from radio waves (1MHz) to UV frequencies (3,000THz), just remember that ω=2πf.  You will probably want to allow the user to choose frequency in units of Hz (frequency, not ω] and convert to ω in your program.  Again, increment in factors of 10..input should be a list.

So we will work through the code here, but then you will have the chance to make the CDF on your own in the remainder of the class period...
You will notice that some of the data you will want to present is in the form of numbers (not plots).  The best way to do this is probably a table.

TableForm[{{1,"m/s"},{4,"V/m"}},TableHeadings->{{"speed","electric field"},{"value","Units"}}]

Let’s also make sure we label our plots so the user knows what they are looking at

p1=Plot[Sin[x],{x,0,10},AxesLabel->{x, "E(x)"},PlotLabel->Style[Framed["Electric Field vs. z, [V/m]"],16,Blue]];

p2=Graphics[Text[{{"Frequency=","1MHz"},{"ϵ=",10}},{5,.8}]];

Show[p1,p2]

Basic Code

Let’s assemble the code we will need for our CDF. First we define our constants:

muo=1.2566*10^-6;epso=8.85*10^-12;

Now we can define the propagation constants of our waves:
First, remember that γ=(Sqrt[jωμ(σ+jωϵ)])

gamma[sigma_,eps_,mu_,f_]:=Sqrt[I*2*Pi*f*mu*muo*(sigma+I*2*Pi*f*eps*epso)]

Our propagation constant β is simply the imaginary part of γ, β=Im[γ]

beta[sigma_,eps_,mu_,f_]:=Im[gamma[sigma,eps,mu,f]]

And our decay constant α is simply the real part of γ, α=Re[γ]

alpha[sigma_,eps_,mu_,f_]:=Re[gamma[sigma,eps,mu,f]]

Next, recall that η=(Sqrt[jωμ/(σ+jωϵ)])

eta[sigma_,eps_,mu_,f_]:=Sqrt[I*2*Pi*f*mu*muo/(sigma+I*2*Pi*f*epso*eps)]

Which we write in terms of magnitude, |η|, and phase (e^(jτ)), where τ=∡η=Arg(η)

abseta[sigma_,eps_,mu_,f_]:=Abs[eta[sigma,eps,mu,f]]

argeta[sigma_,eps_,mu_,f_]:=Arg[eta[sigma,eps,mu,f]]

We know that our wavelength is simply λ=2π/β

lam[sigma_,eps_,mu_,f_]:=2*Pi/beta[sigma,eps,mu,f]

and our decay length (how far until wave is 1/e of its original value) is 1/α

dl[sigma_,eps_,mu_,f_]:=1/alpha[sigma,eps,mu,f]

So we can now write our expression for the Electric Field (including time)

Ezt[sigma_,eps_,mu_,f_]:=Re[Exp[-gamma[sigma,eps,mu,f]*z]*Exp[I*2*Pi*f*t]]

Plot[Ezt[1,2,1,1*10^12]/.{t->0},{z,0,10*lam[1,2,1,1*10^12]}, PlotRange->All]

We know that (OverTilde[H])=(1/η)(OverTilde[E]), so we can write our expression for (OverTilde[H]) as

Hzt[sigma_,eps_,mu_,f_]:=Re[(1/eta[sigma,eps,mu,f])*Exp[-gamma[sigma,eps,mu,f]*z]*Exp[I*2*Pi*f*t]]

Plot[Hzt[1,2,1,1*10^12]/.{t->0},{z,0,10*lam[1,2,1,1*10^12]}]

plotEH[sigma_,eps_,mu_,f_]:=Plot[{Ezt[sigma,eps,mu,f]/.{t->0}, Hzt[sigma,eps,mu,f]/.{t->0}},{z,0,10*lam[sigma,eps,mu,f]}, PlotLegends->"Expressions", PlotRange->All]

plotEH[1,2,1,1*10^12]

Obviously, the scale difference between H and E makes it difficult to plot onthe same axes.  
Already, however, we can use this simple program to understand wave propagation in lossy media.  Suppose you want to send signals between two submarines in the ocean, separated by 30m.  If sea water has a conductivity σ=4 S/m, determine a reasonable frequency to use for your communication system.  The permittivity of water is frequency dependent, but let’s assume ϵ=80 and μ=1.  Does permittivity matter?

plotEsaltwater[sigma_,eps_,mu_,f_]:=LogPlot[Exp[-alpha[sigma,eps,mu,f]*z],{z,0,30}, PlotLegends->"Expressions", PlotRange->All]

plotEsaltwater[4,80,1,1*10^6]

Manipulating Our Wave

For the remainder of class, we will develop a CDF for animating wave propagation in lossy media.  By the end of the class you should have a program that allows the user to input material parameters (μ, ϵ, σ) and frequency (f or ω), and the program will spit out a table with the parameters of the wave propagation, as well as an animation of the E and/or H fields.

p3=Manipulate[{Plot[Ezt[sigma,eps,mu,f]/.{t->0},{z,0,10*lam[sigma,eps,mu,f]},AxesLabel->{z, "E(z,0)"},PlotLabel->Style[Framed["Electric Field" ],16,Blue],PlotRange->Full],TableForm[{{sigma,"S/m"},{eps,"F/m"},{mu,"H/m"},{f,"Hz"},{beta[sigma,eps,mu,f],"1/m"},{2*Pi/beta[sigma,eps,mu,f],"m"},{alpha[sigma,eps,mu,f],"1/m"},{If[alpha[sigma,eps,mu,f]==0,"∞",1/alpha[sigma,eps,mu,f],"m"]},{If[alpha[sigma,eps,mu,f]==0,"∞",beta[sigma,eps,mu,f]/(2*Pi*alpha[sigma,eps,mu,f]),"-"]}},TableHeadings->{{"σ","(Subscript[ϵ, r])","(Subscript[μ, r])","f","β","λ","α","1/α","β/2πα"},{"value","Units"}}]},{{sigma,0.0,"σ[S/m]"},{0,0.01,1,10,100,1000,10^4,10^5,10^6,10^7,10^8}},{{eps,1,"(Subscript[ϵ, r])"},1,20},{{mu,1,"(Subscript[μ, r])"},0.5,1.5},{f,{10^6,10^7,10^8,10^9,10^10,10^11,10^12,10^13,10^14,10^15,10^16}},ControlPlacement->Right,Initialization->{muo=1.2566*10^-6,epso=8.85*10^-12,
gamma[sigma_,eps_,mu_,f_]:=Sqrt[I*2*Pi*f*mu*muo*(sigma+I*2*Pi*f*eps*epso)],
beta[sigma_,eps_,mu_,f_]:=Im[gamma[sigma,eps,mu,f]],
alpha[sigma_,eps_,mu_,f_]:=Re[gamma[sigma,eps,mu,f]],
eta[sigma_,eps_,mu_,f_]:=Sqrt[I*2*Pi*f*mu*muo/(sigma+I*2*Pi*f*epso*eps)],
abseta[sigma_,eps_,mu_,f_]:=Abs[eta[sigma,eps,mu,f]],
argeta[sigma_,eps_,mu_,f_]:=Arg[eta[sigma,eps,mu,f]],
lam[sigma_,eps_,mu_,f_]:=2*Pi/beta[sigma,eps,mu,f],
dl[sigma_,eps_,mu_,f_]:=1/alpha[sigma,eps,mu,f],
Ezt[sigma_,eps_,mu_,f_]:=Re[Exp[-gamma[sigma,eps,mu,f]*z]*Exp[I*2*Pi*f*t]],Hzt[sigma_,eps_,mu_,f_]:=Re[(1/eta[sigma,eps,mu,f])*Exp[-gamma[sigma,eps,mu,f]*z]*Exp[I*2*Pi*f*t]]}]

This might look complicated, but really it’s not that bad.  In the plot above, I am not showing an animation, and I only plot the E field of the wave.  I also include a table with the inputs and a few of the wave propagation parameters.  This is enough, however, to learn a lot about wave propagation.  In particular, play around with a fixed sigma, and change frequency, what happens to your propagation length as you increase frequency?  What about a fixed frequency and changing sigma?  

You can take the above as a starter to your CDF.  Open a new file to be your CDF and copy and paste any code you need from this notebook.
In the end, you are trying to make a tool that will be useful for anyone trying to understand wave propagation in lossy media, so try to make your CDF as comprehensive as possible! 
Can you include the H field?