12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

pde waves: string, quantum packet, and e&m 507We take the phases to be φ x = π/2 and φ y =0, so that their difference φ x − φ y = π/2,which leads to circular polarization. We include the initial conditions in the samemanner as we did the Gaussian pulse, only now with these cosine functions.Listing 18.4 gives our implementation EMcirc.java for waves with transversetwo-component E and H fields. Some results of the simulation are shown inFigure 18.14, where you will note the difference in phase between E and H.✞/ / EMcirc . java : FDTD Propgation of circularly polarized EM waveimport java . io .∗ ;import java . util .∗ ;☎public class EMcirc {public static double Exini ( int tim , double x, double phx ) // Initial Ex{ return Math . cos ( tim−2∗Math . PI∗x/200. +phx ) ; }public static double Eyini ( int tim , double x, double phy ) // Initial Ey{ return Math . cos ( tim−2∗Math . PI∗x/200. +phy ) ; }public static double Hxini ( int tim , double x, double phy ) // Inital Hx{ return Math . cos ( tim−2∗Math . PI∗x/200. +phy+Math . PI ) ; }public static double Hyini ( int tim , double x, double phx ) // Initial Hy{ return Math . cos ( tim−2∗Math . PI∗x/200.0 +phx) ; }public static void main ( String [] argv ) throws IOException , FileNotFoundException {double dx, dt , beta , c0 , phx, phy;int time = 100 , max = 200 , i , n, j , k;phx = 0.5∗Math . PI ; phy = 0.0; / / Phase , difference is pi/2beta = 0.1; // beta = c /( dz/ dt ) < 0.5 for stabilitydouble Ex [ ] = new double [max+1]; double Hy [ ] = new double [max+1]; // Ex, Hydouble Ey [ ] = new double [max+1]; double Hx [ ] = new double [max+1]; // Ey, Hxfor ( i=0; i < max; i++) {Ex[ i ]=0; Ey[ i ]=0; Hx[ i ]=0; Hy[ i ]=0;} // Initializefor ( k = 0 ; k < max ; k++) // Initialize{ Ex[k]=Exini (0 ,( double )k,phx) ; Ey[k]=Eyini (0 ,( double ) k , phy ) ;Hx[k]=Hxini (0 ,( double )k ,phy) ; Hy[k]=Hyini (0 ,( double )k , phx ) ; }PrintWriter w = new PrintWriter ( new FileOutputStream ( "Efield .dat" ), true );PrintWriter q = new PrintWriter ( new FileOutputStream ( "Hfield .dat" ), true );for (n = 0; n < time ; n++ ) {for ( k = 1 ; k < max ; k++ ) { / / New Ex , EyEx[k] = Ex[k] + beta ∗ (Hy[k−1] − Hy[ k ] ) ;Ey[k] = Ey[k] + beta ∗ (Hx[k] − Hx[ k−1]) ;}for ( j = 0 ; j < max−1; j ++ ) { / / New Hx , HyHy[ j ] = Hy[ j ] + beta ∗ (Ex[ j ] − Ex[ j +1]) ;Hx[ j ] = Hx[ j ] + beta ∗ (Ey[ j +1] − Ey [ j ] ) ;}} / / Timefor ( k = 0 ; k < max ; k = k+4 ) { // Plot every 4 pointsw. println (""+0.0+" "+0.0+" "+k+" "+Ex [ k]+" "+Ey [ k]+" "+0.0) ;q. println (""+0.0+" "+0.0+" "+k+" "+Hx[ k ]+" "+Hy[ k ]+" "+0.0) ;}✝} }Listing 18.4 EMcirc.java solves Maxwell’s equations via FDTD time-stepping for circularlypolarized wave propagation in the z direction in free space.−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 507

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

Saved successfully!

Ooh no, something went wrong!