27.12.2012 Views

Wave Propagation in Linear Media | re-examined

Wave Propagation in Linear Media | re-examined

Wave Propagation in Linear Media | re-examined

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

]<br />

];<br />

8 Application of the quadratu<strong>re</strong> rout<strong>in</strong>e<br />

GaussTransNeg,x,t,w,k,n,opts],<br />

_, Message[Phi::<strong>in</strong>validpart,pt]],<br />

_,<br />

Message[Phi::<strong>in</strong>validshape,sh]<br />

PhiTrans[x_, t_, w_, k_, opts___Rule] :=<br />

If[(Shape/.foptsg/.Options[Phi]) === Gauss,<br />

Message[Phi::miss<strong>in</strong>gval],<br />

PhiTrans[x,t,w,k,1,opts]];<br />

Remark (Input check<strong>in</strong>g) Apart from check<strong>in</strong>g the option values, the function provides<br />

other tests of the user's <strong>in</strong>put, too. The parameter n, for example must be g<strong>re</strong>ater than<br />

zero, which is exp<strong>re</strong>ssed with the conditional pattern match<strong>in</strong>g statement n ?Positive.<br />

The<strong>re</strong>fo<strong>re</strong> the function evaluates only if n satis es this <strong>re</strong>qui<strong>re</strong>ment. Otherwise no error<br />

message is generated, but the function is left unevaluated. The same is done with the<br />

additional arguments that match the pattern opts Rule only if they have the syntax of<br />

a rule, that is if they look like lhs->rhs. However, this does not encompass a validity<br />

check for the option names or their values.<br />

The modules PhiTrans and PhiEvan compute the wave function <strong>in</strong>side the barrier, PhiInc and<br />

PhiRef <strong>re</strong>turn the <strong>in</strong>cident and <strong>re</strong> ected wave outside the barrier. A still mo<strong>re</strong> comfortable<br />

driver is the function Phi that decides (based upon the spatial coord<strong>in</strong>ate given by the user)<br />

which module to call. For the boundary case X =0it takes the functions that a<strong>re</strong> de ned<br />

for the <strong>in</strong>terior of the barrier (which must, of course, yield the same <strong>re</strong>sults as those for the<br />

outside). This function also traps the somewhat <strong>in</strong>convenient case X = T = 0 for <strong>re</strong>ctangular<br />

waves and sets the <strong>re</strong>turn value to the exactly known <strong>re</strong>sult 1=2.<br />

Phi[x_, t_, w_, k_, n_?Positive, opts___Rule] :=<br />

Which[t == 0 && x == 0 && Shape/.foptsg/.Options[Phi] === Rect, 0.5,<br />

t < 0, 0,<br />

x >= 0, PhiEvan[x,t,w,k,n,opts] + PhiTrans[x,t,w,k,n,opts],<br />

x < 0, PhiInc[x,t,w,k,n,opts] + PhiRef[x,t,w,k,n]];<br />

Phi[x_, t_, w_, k_, opts___Rule] :=<br />

If[(Shape/.foptsg/.Options[Phi]) === Gauss,<br />

Message[Phi::miss<strong>in</strong>gval],<br />

Phi[x,t,w,k,1,opts]];<br />

All the driver functions deal<strong>in</strong>g with the wave function <strong>in</strong>side the barrier also exist <strong>in</strong> a version<br />

that computes the gradient of the wave function, namely PhiGradTrans, PhiGradEvan, and<br />

PhiGrad. They a<strong>re</strong> implemented only for triangular and Gaussian waves. For a <strong>re</strong>ctangular<br />

shape, the <strong>in</strong>tegral would diverge for the boundary and for T =0.<br />

204

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!