analysis-tutorial.html
来自「麻省理工的计算光子晶体的程序」· HTML 代码 · 共 504 行 · 第 1/2 页
HTML
504 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><TITLE>Data Analysis Tutorial</TITLE><LINK rel="Contents" href="index.html"><LINK rel="Copyright" href="license.html"><LINK rel="Start" href="index.html"></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF">Go to the <a href="user-ref.html">next</a>, <a href="user-tutorial.html">previous</a>, or <a href="index.html">main</a> section.<hr><h1>Data Analysis Tutorial</h1><p>In the previous section, we focused on how to perform a calculationin MPB. Now, we'll give a brief tutorial on what you might do withthe results of the calculations, and in particular how you mightvisualize the results. We'll focus on two systems, onetwo-dimensional and one three-dimensional.<h2><a name="tri-rods">Triangular Lattice of Rods</a></h2><p>First, we'll return to the two-dimensional <ahref="user-tutorial.html#tri-rods">triangular lattice of rods</a> inair from the tutorial. The control file for this calculation, whichcan also be found in <code>mpb-ctl/examples/tri-rods.ctl</code>, willconsist of:<h3><a name="tri-rods-ctl">The tri-rods.ctl control file</a></h3><pre>(set! num-bands 8)(set! geometry-lattice (make lattice (size 1 1 no-size) (basis1 (/ (sqrt 3) 2) 0.5) (basis2 (/ (sqrt 3) 2) -0.5)))(set! geometry (list (make cylinder (center 0 0 0) (radius 0.2) (height infinity) (material (make dielectric (epsilon 12))))))(set! k-points (list (vector3 0 0 0) ; Gamma (vector3 0 0.5 0) ; M (vector3 (/ -3) (/ 3) 0) ; K (vector3 0 0 0))) ; Gamma(set! k-points (interpolate 4 k-points))(set! resolution 32)(run-tm (output-at-kpoint (vector3 (/ -3) (/ 3) 0) fix-efield-phase output-efield-z))(run-te)</pre><p>Notice that we're computing both TM and TE bands (where we expect agap in the TM bands), and are outputting the z component of theelectric field for the TM bands at the K point. (The<code>fix-efield-phase</code> will be explained below.)<p>Now, run the calculation, directing the output to a file, byentering the following command at the Unix prompt:<pre>unix% mpb tri-rods.ctl >& tri-rods.out</pre><p>It should finish after a minute or two.<h3><a name="tri-rods-eps">The tri-rods dielectric function</a></h3><p>In most cases, the first thing we'll want to do is to look at thedielectric function, to make sure that we specified the correctgeometry. We can do this by looking at the <code>epsilon.h5</code>output file.<p>The first thing that might come to mind would be to examine<code>epsilon.h5</code> directly, say by converting it to a <ahref="http://www.cdrom.com/pub/png/">PNG</a> image with<code>h5topng</code> (from my free <ahref="http://ab-initio.mit.edu/h5utils/">h5utils</a> package),magnifying it by 3:<pre>unix% h5topng -S 3 epsilon.h5</pre><p><img align="right" src="tri-rods-eps-1.gif" border="1" width="96"height="96" alt="epsilon unit cell">The resulting image(<code>epsilon.png</code>) is shown at right, and it initially seemswrong! Why is the rod oval-shaped and not circular? Actually, thedielectric function is correct, but the image is distorted because theprimitive cell of our lattice is a rhombus (with 60-degree acuteangles). Since the output grid of MPB is defined over thenon-orthogonal unit cell, while the image produced by<code>h5topng</code> (and most other plotting programs) is square, theimage is skewed.<p>We can fix the image in a variety of ways, but the best way isprobably to use the <code>mpb-data</code> utility included (andinstalled) with MPB. <code>mpb-data</code> allows us to rearrange thedata into a rectangular cell (<code>-r</code>) with the samearea/volume, expand the data to include multiple periods (<code>-m<i>periods</i></code>), and change the resolution per unit distance ineach direction to a fixed value (<code>-n <i>resolution</i></code>).<code>man mpb-data</code> or run <code>mpb-data -h</code> for moreoptions. In this case, we'll rectify the cell, expand it to threeperiods in each direction, and fix the resolution to 32 pixels per<i>a</i>:<br clear="right"><pre>unix% mpb-data -r -m 3 -n 32 epsilon.h5</pre><p>It's important to use <code>-n</code> when you use <code>-r</code>,as otherwise the non-square unit cell output by <code>-r</code> willhave a different density of grid points in each direction, and appeardistorted. The output of <code>mpb-data</code> is by default anadditional dataset within the input file, as we can see by running<code>h5ls</code>:<pre>unix% h5ls epsilon.h5 data Dataset {32, 32}data-new Dataset {96, 83}description Dataset {SCALAR}lattice\ copies Dataset {3}lattice\ vectors Dataset {3, 3}</pre><p><img align="right" src="tri-rods-eps-2.gif" border="1" width="83"height="96" alt="epsilon 3x3 cell, rectified">Here, the new datasetoutput by <code>mpb-data</code> is the one called<code>data-new</code>. We can examine it by running<code>h5topng</code> again, this time explicitly specifying the nameof the dataset (and no longer magnifying):<pre>unix% h5topng epsilon.h5:data-new</pre><p> The new <code>epsilon.png</code> output image is shown at right.As you can see, the rods are now circular as desired, and they clearlyform a triangular lattice.<br clear="right"><h3><a name="tri-rods-bands">Gaps and and band diagram for tri-rods</a></h3><p>At this point, let's check for band gaps by picking out lines withthe word "<code>Gap</code>" in them:<pre>unix% grep Gap tri-rods.outGap from band 1 (0.275065617068082) to band 2 (0.446289918847647), 47.4729292989213%Gap from band 3 (0.563582903703468) to band 4 (0.593059066215511), 5.0968516236891%Gap from band 4 (0.791161222813268) to band 5 (0.792042731370125), 0.111357548663006%Gap from band 5 (0.838730315053238) to band 6 (0.840305955160638), 0.187683867865441%Gap from band 6 (0.869285340346465) to band 7 (0.873496724070656), 0.483294361375001%Gap from band 4 (0.821658212109559) to band 5 (0.864454087942874), 5.07627823271133%</pre><p>The first five gaps are for the TM bands (which we ran first), andthe last gap is for the TE bands. Note, however that the < 1% gapsare probably false positives due to band crossings, as described inthe <a href="user-tutorial.html#sq-rods">user tutorial</a>. There areno complete (overlapping TE/TM) gaps, and the largest gap is the 47%TM gap as expected. (To be absolutely sure of this and other band gaps, wewould also check k-points within the interior of the Brillouin zone,but we'll omit that step here.)<p>Next, let's plot out the band structure. To do this, we'll firstextract the TM and TE bands as comma-delimited text, which can then beimported and plotted in our favorite spreadsheet/plotting program.<pre>unix% grep tmfreqs tri-rods.out > tri-rods.tm.datunix% grep tefreqs tri-rods.out > tri-rods.te.dat</pre><p>The TM and TE bands are both plotted below against the "k index"column of the data, with the special k-points labelled. TM bands areshown in blue (filled circles) with the gaps shaded light blue, whileTE bands are shown in red (hollow circles) with the gaps shaded lightred.<p align="center"><img src="tri-rods-bands.gif" width="520"height="454" alt="tri-rods band diagram"><p>Note that we truncated the upper frequencies at a cutoff of 1.0 c/a.Although some of our bands go above that frequency, we didn't computeenough bands to fill in all of the states in that range. Besides, weonly really care about the states around the gap(s), in most cases.<h3><a name="tri-rods-modes">The source of the TM gap: examining themodes</a></h3><p>Now, let's actually examine the electric-field distributions forsome of the bands (which were saved at the K point, remember).Besides looking neat, the field patterns will tell us about thecharacters of the modes and provide some hints regarding the origin ofthe band gap.<p>As before, we'll run <code>mpb-data</code> on the field outputfiles (named <code>e.k11.b*.z.tm.h5</code>), and then run<code>h5topng</code> to view the results:<pre>unix% mpb-data -r -m 3 -n 32 e.k11.b*.z.tm.h5unix% h5topng -C epsilon.h5:data-new -c bluered -Z -d z.r-new e.k11.b*.z.tm.h5</pre><p>Here, we've used the <code>-C</code> option to superimpose (crude)black contours of the dielectric function over the fields, <code>-cbluered</code> to use a blue-white-red color table, <code>-Z</code> tocenter the color scale at zero (white), and <code>-d</code> to specifythe dataset name for all of the files at once. <code>manh5topng</code> for more information. (There are plenty ofdata-visualization programs available if you want more sophisticatedplotting capabilities than what <code>h5topng</code> offers, ofcourse; you can use <code>h5totxt</code> to convert the data to aformat suitable for import into e.g. spreadsheets.)<p>Note that the dataset name is <code>z.r-new</code>, which is thereal part of the z component of the output of <code>mpb-data</code>.(Since these are TM fields, the z component is the only non-zero partof the electric field.) The real and imaginary parts of the fieldscorrespond to what the fields look like at half-period intervals intime, and in general they are different. However, at K they areredundant, due to the inversion symmetry of that k-point (proof leftas an exercise for the reader). Usually, looking at the real partsalone gives you a pretty good picture of the state, especially if youuse <code>fix-efield-phase</code> (see below), which chooses the phaseto maximize the field energy in the real part. Sometimes, though, youhave to be careful: if the real part happens to be zero, what you'llsee is essentially numerical noise and you should switch to theimaginary part.<p>The resulting field images are shown below:<p><table cellspacing=2 cellpadding=1><tr align="center"><th>TM band 1</th><th>TM band 2</th><th>TM band 3</th><th>TM band 4</th><th>TM band 5</th><th>TM band 6</th><th>TM band 7</th><th>TM band 8</th>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?