admin 管理员组

文章数量: 1087649


2024年3月19日发(作者:perl实用教程)

MeepTutorialMeep教程

FromAbInitio从AbInitio

Jumpto:navigation,search跳转到:导航,搜索

MeepMeep

Download下载

Releasenotes发行说明

FAQ常见问题

MeepmanualMeep手册

Introduction简介

Installation安装

Tutorial教程

Reference参考

C++TutorialC++教程

C++ReferenceC++参考

Acknowledgements致谢

LicenseandCopyright许可和版权

Inthispage,we'llgothroughacoupleofsimpleexamplesthatillustratetheprocessofcomputing

fields,transmission/reflectionspectra,andresonantmodesinMeep.在这个页面中,我们将通过

几个简单的例子,说明计算领域,传输/反射光谱,并在Meep谐振模式的过程中去。Allof

theexamplesherearetwo-dimensionalcalculations,simplybecausetheyarequickerthan3d

computationsandtheyillustratemostoftheessentialfeatures,butofcourseMeepcandosimilar

calculationsin3d.这里的例子是二维的计算,仅仅是因为他们比3D运算更快,它们说明了大

部分的本质特征,但Meep当然可以做类似的计算,在3D。

Thistutorialusesthelibctl/SchemescriptinginterfacetoMeep,whichiswhatweexpectmost

userstoemploymostofthetime.本教程使用的libctl/计划的脚本接口Meep,这是我们所期望

的大多数用户采用的大部分时间。ThereisalsoaC++interfacethatmaygiveadditional

flexibilityinsomesituations;thatisdescribedintheC++tutorial.还有一个C++的接口,可能

会给在某些情况下,额外的灵活性;在C++的教程描述。

InordertoconverttheHDF5outputfilesofMeepintoimagesofthefieldsandsoon,thistutorial

usesourfreeh5utilsprograms.为了转换HDF5Meep领域等的图像输出文件,本教程使用我们

的免费h5utils计划。(Youcouldalsouseanyotherprogram,suchasMatlab,thatsupports

readingHDF5files.)(您也可以使用任何其他程序,如,MATLAB,支持阅读HDF5的文

件。)

Contents目录

[hide]

•1Thectlfile1ctl文件

o

2Fieldsinawaveguide2波导领域2.1Astraightwaveguide2.1直波

2.2A90°bend2.290°弯头2.2.1Outputtipsandtricks2.2.1

输出的技巧和窍门

3Transmissionspectrumaroundawaveguidebend3波导弯曲周围的透射谱

o

4Modesofaringresonator4的一环谐振器模式4.1Exploiting

symmetry4.1开发利用对称

5Moreexamples5更多的例子

6Editorsandctl6编辑和CTL

[edit][编辑]

Thectlfilectl文件

TheuseofMeeprevolvesaroundthecontrolfile,abbreviated"ctl"andtypicallycalledsomething

(althoughyoucanuseanyfilenameyouwish).Meep使用围绕控制文件,简称

“CTL”,通常称为像(尽管你可以使用你想要的任何文件名)。Thectlfile

specifiesthegeometryyouwishtostudy,thecurrentsources,theoutputscomputed,and

文件指定你想研究的几何形状,电流源,输出计

算,和其他一切针对你的计算。Ratherthanaflat,inflexiblefileformat,however,thectlfileis

actuallywritteninascriptinglanguage.然而,而不是一个单位,不灵活的文件格式,ctl文件

实际上是在一种脚本语言编写。Thismeansthatitcanbeeverythingfromasimplesequenceof

commandssettingthegeometry,etcetera,toafull-fledgedprogramwithuserinput,loops,and

anythingelsethatyoumightneed.这意味着,它可以从一个简单的几何形状,等等,用户的输

入,循环和其他任何您可能需要一个全面的计划的命令序列的一切。

Don'tworry,though—simplethingsaresimple(youdon'tneedtobeaRealProgrammer),and

eventhereyouwillappreciatetheflexibilitythatascriptinglanguagegivesyou.不要担心,虽然

简单的事情是简单的(你不需要成为一个真正的程序员),甚至出现了你会明白一种脚本语

言,为您提供的灵活性。(egyoucaninputthingsinanyorder,withoutregardforwhitespace,

)(例如,

您可以方面为空白,没有任何顺序输入的东西,插入注释,请您,省略的东西时,合理的默

认值是...)

Thectlfileisactuallyimplementedontopofthelibctllibrary,asetofutilitiesthatareinturnbuilt

文件实际上是实施libctl库之上,Scheme语言之上的工具

集。Thus,therearethreesourcesofpossiblecommandsandsyntaxforactlfile:因此,有三种可

能的命令和语法的CTL文件来源:

•Scheme,apowerfulandbeautifulprogramminglanguagedevelopedatMIT,whichhasa

particularlysimplesyntax:allstatementsareoftheform(

).在麻省理

工学院开发的,其中有一个特别简单的语法:所有报表的形式(

)的

计划,一个强大和美丽的编程语言。WerunSchemeundertheGNUGuileinterpreter

(designedtobepluggedintoprogramsasascriptingandextensionlanguage).我们在该计划

下运行GNU狡诈解释器设计成插入和延伸作为一种脚本语言方案。Youdon'tneedto

knowmuchSchemeforabasicctlfile,butitisalwaysthereifyouneedit;youcanlearn

moreaboutitfromtheseGuileandSchemelinks.你不需要知道一个基本的CTL文件的计

划,但它是永远存在的,如果您需要,您可以了解更多内容从这些狡诈和计划链接。

•libctl,alibrarythatwebuiltontopofGuiletosimplifycommunicationbetweenScheme

,狡诈的顶部建库,以简化计划和科学计算软

件之间的通信。libctlsetsthebasictoneoftheinterfaceanddefinesanumberofuseful

functions(suchasmulti-variableoptimization,numericintegration,andsoon).libctl设置接

口的基本色调,并定义了一些有用的功能(如多变量优化,数值积分,依此类推)。See

手册页。

•Meepitself,whichdefinesalltheinterfacefeaturesthatarespecifictoFDTDcalculations.

Meep本身,它定义了所有的接口功能,具体的FDTD计算。Thismanualisprimarily

focusedondocumentingthesefeatures.本手册主要集中在记录这些功能。

Atthispoint,pleasetakeamomenttoleafthroughthelibctltutorialtogetafeelforthebasicstyle

oftheinterface,beforewegettotheMeep-specificstuffbelow.在这一点上,请花点时间通过

libctl教程叶得到一个接口的基本风格的感觉,我们得到下面的Meep,具体的东西之前。(If

you'veusedMPB,allofthisstuffshouldalreadybefamiliar,althoughMeepissomewhatmore

complexbecauseitcanperformawidervarietyofcomputations.)(如果你已经使用了MPB的,

这东西应该已经很熟悉,虽然Meep是比较复杂的,因为它可以进行更广泛的计算。)

Okay,let'scontinuewithourtutorial.好吧,让我们继续我们的教程。TheMeepprogramis

normallyinvokedbyrunningsomethinglikethefollowingattheUnixcommand-line(herein

denotedbytheunix%prompt):Meep程序通常是调用运行在Unix命令行(以下简称记由类似

下面的unix%提示符):

unix%meep

>&

UNIX%meep

>&

executesit,.它读取的CTL

,并执行它的输出保存文件。However,ifyouinvokemeepwithno

arguments,youaredroppedintoan

interactive

modeinwhichyoucantypecommandsandsee

theirresultsimmediately.不过,如果你不带参数调用meep,你投进一个

互动

的模式,可以在

其中键入命令,并立即看到其结果。Ifyoudothatnow,youcanpasteinthecommandsfromthe

tutorialasyoufollowitandseewhattheydo.如果你这样做,现在,你可以从本教程粘贴,只

要您遵循它,看看他们做什么,在命令。

[edit][编辑]

Fieldsinawaveguide在波导的字段

Forourfirstexample,let'sexaminethefieldpatternexcitedbyalocalizedCWsourceina

waveguide—firststraight,thenbent.对于我们的第一个例子,让我们来看看场模式本地化的

CW源激发波导第一直线,然后弯曲。Ourwaveguidewillhave(non-dispersive)我们的波导

(非色散)andwidth1.宽度为1。Thatis,wepickunitsoflengthsothatthewidthis

1,anddefineeverythingintermsofthat(seealsounitsinmeep).也就是说,我们挑选的长度单

位,这样的宽度是1,定义在该方面的一切(也见meep单位)。

[edit][编辑]

Astraightwaveguide一条直波导

Beforewedefinethestructure,however,wehavetodefinethecomputationalcell.在我们定义的

结构,但是,我们必须定义的计算单元。We'regoingtoputasourceatoneendandwatchit

propagatedownthewaveguideinthe

x

direction,solet'suseacelloflength16inthe

x

direction

togiveitsomedistancetopropagate.我们将一端源,并观看它传播到波导

x方向,让我们

x方向上的长度为16的单元格的使用,给它一段距离传播。Inthe

y

direction,wejustneed

enoughroomsothattheboundaries(below)don'taffectthewaveguidemode;let'sgiveitasizeof

8.

y方向上,我们只需要足够的空间,使边界(下同)不影响波导模式,让我们给它一

个大小为8。Wenowspecifythesesizesinourctlfileviathegeometry-latticevariable:我们现在

在我们通过ctl文件中指定这些geometry-lattice晶格变量:

(set!geometry-lattice(makelattice(size168no-size)))(set!几何晶格(使晶格(大小为168

无大小)))

(Thenamegeometry-latticecomesfromMPB,whereitcanbeusedtodefineamoregeneral

ghMeepsupportsperiodicstructures,itislessgeneralthanMPBinthat

affinegridsarenotsupported.)set!isaSchemecommandtosetthevalueofaninputvariable.

(geometry-lattice的名称来自MPB的,它可以被用来定义一个更一般的周期点阵,虽然

Meep支持周期性结构,它是比一般在该仿射电网MPB的不支持set!设置!是一个计划的命

令设置输入变量的值。Thelastno-sizeparametersaysthatthecomputationalcellhasnosizein

the

z

direction,ieitistwo-dimensional.最后no-size参数表示,计算单元没有

z方向的大小,

也就是说,它是二维的。

Now,wecanaddthewaveguide.现在,我们可以添加波导。Mostcommonly,thestructureis

specifiedbyalistofgeometricobjects,storedinthegeometryvariable.最常见的,指定的结构是

由一个list中存储的几何对象geometry几何可变。Here,wedo:在这里,我们:

(set!geometry(list(set!几何(名单

(makeblock(center00)(sizeinfinity1infinity)(块(中心00)(大小1无

穷无穷)

(material(makedielectric(epsilon12))))))(材料(电介质(EPSILON

12))))))

Dielectricfunction(black=high,white=air),forstraightwaveguidesimulation.介电函数(黑=

高,白色=空气),直波导模拟。

Thewaveguideisspecifiedbya

block

(parallelepiped)ofsize波导是指定一个大小

块(平行)

,withε=12,centeredat(0,0)(thecenterofthecomputationalcell).,ε=12,

中心位于(0,0)(计算单元格的中心)。Bydefault,anyplacewheretherearenoobjectsthereis

air(ε=1),althoughthiscanbechangedbysettingthedefault-materialvariable.默认情况下,任何

地方,有没有对象有是空气(ε=1),虽然这可以通过设置改变default-material变量。The

resultingstructureisshownatright.由此产生的结构如右图所示。

Nowthatwehavethestructure,weneedtospecifythecurrentsources,whichisspecifiedasalist

calledsourcesofsourceobjects.现在,我们的结构,我们需要到指定的电流源,被指定为一个

list称为源对象sources来源。Thesimplestthingistoaddapointsource

J

z

:最简单的是加点

J

ž

(set!sources(list(set!来源(名单

(makesource(源

(src(makecontinuous-src(frequency0.15)))(SRC(连续SRC(频率

0.15)))

(componentEz)(组件EZ)

(center-70))))(中心-70))))

Here,wegavethesourceafrequencyof0.15,andspecifiedacontinuous-srcwhichisjusta

fixed-frequencysinusoidexp(−

i

ω

t

)that(bydefault)isturnedonat

t

=that,inMeep

units,frequencyisspecifiedinunitsof2π

c

,whichisequivalenttotheinverseofvacuum

wavelength.在这里,我们给源的频率为0.15,并指定一个continuous-srcSRC这仅仅是一个

固定频率的正弦波EXP(

-

ωT)。

打开(默认

),

在t=0召回,在Meep单位,频率是在

单位

2πC,

这是相当于真空中的波长反指定。Thus,0.15correspondstoavacuumwavelength

ofabout1/0.15=6.67,orawavelengthofabout2inthe因此,0.15对应的约1/0.15=6.67真

空中的波长,或在波长约2material—thus,ourwaveguideishalfawavelengthwide,

whichshouldhopefullymakeitsingle-mode.材料,因此,我们的波导是半波长范围内,应该

有希望使单一模式。(Infact,thecutoffforsingle-modebehaviorinthiswaveguideis

analyticallysolvable,andcorrespondstoafrequencyof1/2√11orroughly0.15076.)Notealso

thattospecifya

J

z

,wespecifyacomponent

Ez

(egifwewantedamagneticcurrent,wewould

specifyHx,Hy,orHz).(事实上,截止单模在此波导的行为是解析解,并对应一个频率的

1/2√11或大约0.15076。)另请注意,指定

一个

J

ž,我们指定一个

部分E

于(例如,如果我

们想要一个磁流,我们将指定HxHyHY,HzHz)。Thecurrentislocatedat(−7,0),which

is1unittotherightoftheleftedgeofthecell—wealwayswanttoleavealittlespacebetween

sourcesandthecellboundaries,tokeeptheboundaryconditionsfrominterferingwiththem.(-

7,0),目前是位于左边缘的权利,这是1个单位的细胞,我们始终要离开一个来源和单元格

边界之间的空间不大,保持边界条件的干扰他们。

Speakingofboundaryconditions,wewanttoaddabsorbingboundariesaroundourcell.边界条件

来讲,我们要添加吸收我们的细胞周围的边界。AbsorbingboundariesinMeeparehandledby

perfectlymatchedlayers(PML)—whicharen'treallyaboundaryconditionatall,butrathera

fictitiousabsorbingmaterialaddedaroundtheedgesofthecell.在Meep吸收边界的处理完全匹

配层(PML)的-这不是一个真正的边界条件,但周围的细胞边缘而不是一个虚构的吸波材

料补充。Toaddanabsorbinglayerofthickness1aroundallsidesofthecell,wedo:要添加一个

吸收周围的细胞各方层厚度为1,我们做到:

(set!pml-layers(list(makepml(thickness1.0))))(set!PML层(清单(使PML(厚度为1.0))))

pml-layersisalistofpmlobjects—youmayhavemorethanonepmlobjectifyouwantPML

layersonlyoncertainsidesofthecell,eg(makepml(thickness1.0)(directionX)(sideHigh))

specifiesaPMLlayerononlythe+

x

-layerspml对象的列表,您可能有一个以上的

pml的对象,如果你想只在某些细胞,如双方的(makepml(thickness1.0)(directionX)(side

High))))的指定PML层只

+

X方。Now,wenoteanimportantpoint:thePMLlayeris

inside

thecell,overlappingwhateverobjectsyouhavethere.现在,我们注意到了一个重要的观点:在

PML层是在细胞

,你有重叠的任何对象有。So,inthiscaseourPMLoverlapsour

waveguide,whichiswhatwewantsothatitwillproperlyabsorbwaveguidemodes.因此,在这种

情况下,我们PML的重叠我们的波导,这是我们想要的,所以,它一定会妥善吸收波导模

式。ThefinitethicknessofthePMLisimportanttoreducenumericalreflections;seeperfectly

的有限厚度是很重要的,以减少数字的反射;看到有

关更多信息,完全匹配层。

Meepwilldiscretizethisstructureinspaceandtime,andthatisspecifiedbyasinglevariable,

resolution,将这种结构在空间和时间离

散,这是由一个单一的变量,指定的resolution,使每单位距离的像素数量。We'llsetthis

resolutionto10,whichcorrespondstoaround67pixels/wavelength,oraround20

pixels/wavelengthinthehigh-dielectricmaterial.这项决议,我们将设置10,这相当于约67像素

/波长,或大约20像素/高介电常数材料的波长。(Ingeneral,atleast8pixels/wavelengthinthe

highestdielectricisagoodidea.)Thiswillgiveusa(一般情况下,至少有8个像素/最高介质

中的波长是一个好主意。),这将为我们提供一个

(set!resolution10)(set!第10号决议)

cell.细胞。

Now,wearereadytorunthesimulation!现在,我们已经准备好运行仿真!Wedothisbycalling

therun-untilfunction.我们可以通过调用run-until功能。Thefirstargumenttorun-untilisthe

timetorunfor,andthesubsequentargumentsspecifyfieldstooutput(orotherkindsofanalysesat

eachtimestep):run-until第一个参数是运行的时间,和随后的参数指定输出(或其他类型的

分析,在每一个时间步)的领域:

(run-until200(运行,直到200

(at-beginningoutput-epsilon)(在开始输出-ε)

(at-endoutput-efield-z))(在高端输出efield-Z))

Here,weareoutputtingthedielectricfunctionεandtheelectric-fieldcomponent

E

z

,buthave

wrappedtheoutputfunctions(whichwouldotherwiserunat

every

timestep)inat-beginningand

at-end,whichdojustwhattheysay.在这里,我们输出的介电函数ε和电场

部分

E

ž

但包裹输

出功能(否则就会在

每一个

时间步运行)at-beginningat-end,这只是他们说什么。There

areseveralothersuchfunctionstomodifytheoutputbehavior—andyoucan,ofcourse,writeyour

own,andinfactyoucandoanycomputationoroutputyouwantatanytimeduringthetime

evolution(andevenmodifythesimulationwhileitisrunning).还有其他几个这样的函数来修改

输出的行为当然,你可以写自己的,而事实上,你可以在任何时间做任何计算或输出你想要

的时间演化过程中(甚至修改模拟而正在运行)。

Itshouldcompleteinafewseconds.它应该在几秒钟内完成。Ifyouarerunninginteractively,

thetwooutputfileswillbecalledeps-000000.00.h5andez-000200.00.h5(noticethatthefile

namesincludethetimeatwhichtheywereoutput).如果您以交互方式运行,两个输出文件将被

称为eps-000000.00.h5和ez-000200.00.h5(请注意,文件名,包括他们输出的时刻)。

e,thentheoutputswillbetutorial-eps-000000.00.h5and

tutorial-ez-000200.00.h5.如果我们运行的文件,那么输出tutorial-eps-000000.00.h5

000000.00.h5tutorial-ez-000200.00.h5000200.00.h5。Inanycase,wecannowanalyzeand

visualizethesefileswithawidevarietyofprogramsthatsupporttheHDF5format,includingour

ownh5utils,andinparticulartheh5topngprogramtoconvertthemtoPNGimages.在任何情况

下,我们现在可以分析和可视化的方案,支持多种HDF5的这些文件的格式,包括我们自己

的h5topng,h5topng方案,特别是将它们转换为PNG图像。

unix%h5topng-S3eps-000000.00.h5UNIX%h5topng-S3EPS-000000.00.h5

,wherethe-S3increasestheimagescaleby3(sothatitis

around450pixelswide,inthiscase).这将创建,其中3-S3增加图像的比例

(因此,它是宽450像素左右,在这种情况下,)。Infact,preciselythiscommandiswhat

createdthedielectricimageabove.事实上的,正是这个命令是什么创造了介质的形象以上。

Muchmoreinteresting,however,arethefields:然而,更有趣的是字段:

unix%h5topng-S3-Zcdkbluered-ayarg-Aeps-000000.00.h5ez-000200.00.h5UNIX%

h5topng-S3-ZCdkbluered一个yarg-EPS-000000.00.h5EZ-000200.00.h5

Briefly,the-Zcdkblueredmakesthecolorscalegofromdarkblue(negative)towhite(zero)to

darkred(positive),andthe-a/-Aoptionsoverlaythedielectricfunctionaslightgraycontours.简

言之,-Zcdkbluered使色阶从深蓝色(负),白(零)到暗红色(阳性),-a/-A选项覆盖

介电函数为浅灰色轮廓。Thisresultsintheimage:图像中的这个结果:

Here,weseethatthethesourcehasexcitedthewaveguidemode,buthasalsoexcitedradiating

fieldspropagatingawayfromthewaveguide.在这里,我们看到,源具有兴奋波导模式,但也

兴奋辐射领域的传播距离波导。Attheboundaries,thefieldquicklygoestozeroduetothe

PMLlayers.该领域的界限,迅速变为零的PML层。Ifwelookcarefully(clickontheimageto

seealargerview),weseesomethingeelse—theimageis"speckled"towardstherightside.如果我

们仔细看(点击图片查看大图),我们看到somethinge别人的形象是“斑点”向右侧。Thisis

because,byturningonthecurrentabruptlyat

t

=0,wehaveexcitedhigh-frequencycomponents

(veryhighordermodes),andwehavenotwaitedlongenoughforthemtodieaway;we'll

eliminatetheseinthenextsectionbyturningonthesourcemoresmoothly.这是因为,在

t

=0时

突然打开当前,我们兴奋的高频成分(非常高的顺序模式),我们已经等了很久,他们消失,

我们将在未来消除这些部分更顺利打开源。

[edit][编辑]

A90°bend

一个

90°

的弯曲90°

Now,we'llstartanewsimulationwherewelookatthefieldsina

bent

waveguide,andwe'lldoa

coupleofotherthingsdifferentlyaswell.现在,我们将开始一个新的模拟,我们看在

弯曲

波导

等领域,我们会做其他事情的不同以及夫妇。IfyouarerunningMeepinteractively,youwill

wanttogetridoftheoldstructureandfieldssothatMeepwillre-initializethem:如果您正在运行

Meep交互方式,你将要摆脱旧的结构和领域,使Meep他们将重新初始化:

(reset-meep)(复位meep)

Thenlet'ssetupthebentwaveguide,inaslightlybiggercomputationalcell,via:然后让设置的弯

曲波导,在一个稍微大的计算单元,通过:

(set!geometry-lattice(makelattice(size1616no-size)))(set!几何晶格(使晶格(大小为1616

无大小)))

(set!geometry(list(set!几何(名单

(makeblock(center-2-3.5)(size121infinity)(块(中心-2-3.5)(大小12

1无穷)

(material(makedielectric(epsilon12))))(材料(使介质(EPSILON

12))))

(makeblock(center3.52)(size112infinity)(块(中心3.52)(大小为112

无穷)

(material(makedielectric(epsilon12))))))(材料(电介质(EPSILON

12))))))

(set!pml-layers(list(makepml(thickness1.0))))(set!PML层(清单(使PML(厚度为1.0))))

(set!resolution10)(set!第10号决议)

Bentwaveguidedielectricfunctionandcoordinatesystem.弯曲波导介质的功能和坐标系统。

Notethatwenowhave

two

blocks,bothoff-centertoproducethebentwaveguidestructure

picturedatright.请注意,我们现在有

两大

块,都偏离中心,产生弯曲的波导结构,右图。As

illustratedinthefigure,theorigin(0,0)ofthecoordinatesystemisatthecenterofthe

computationalcell,withpositive

y

beingdownwardsinh5topng,andthustheblockofsize12×1

iscenteredat(−2,−3.5).正如图所示,坐标系统的原点(0,0)是在计算单元的中心,

Y

在h5topngh5topng,从而块大小为12×1中心(-2,-3.5)。Alsoshowningreenisthe

sourceplaneat

x

=−7(seebelow).此外,显示为绿色,是

x=源飞机-7(见下文)。

Wealsoneedtoshiftoursourceto

y

=−3.5sothatitisstillinsidethewaveguide.我们还需要转

变我们的源代码

Y

=-3.5,所以,它仍然是波导内。Whilewe'reatit,we'llmakeacoupleof

otherchanges.虽然我们在它的时候,我们会让其他几个变化。First,apointsourcedoesnot

coupleveryefficientlytothewaveguidemode,sowe'llexpandthisintoalinesourcethesame

widthasthewaveguidebyaddingasizepropertytothesource(afutureversionofMeepwill

allowyoutouseacurrentwiththeexactfieldpatternascomputedbyMPB).首先,一个点源并不

夫妇非常有效地波导的模式,因此我们将扩展成一条线源加入了相同的宽度为波导size大小

属性源(未来版本的Meep将允许您使用目前一个由模式计算的确切领域MPB)。Second,

insteadofturningthesourceonsuddenlyat

t

=0(whichexcitesmanyotherfrequenciesbecause

ofthediscontinuity),wewillrampitonslowly(technically,Meepusesatanhturn-onfunction)

overatimeproportionaltothewidthof20timeunits(alittleoverthreeperiods).第二,而不是转

向源头上突然

t=0(兴奋,因为许多其他频率的不连续性),我们将坡道上慢慢(在技术

上,Meep使用一个TANH开启功能),超过时间width宽度成正比20个时间单位(多一点三

个时期)。Finally,justforvariety,we'llspecifythe(vacuum)wavelengthinsteadofthe

frequency;again,we'lluseawavelengthsuchthatthewaveguideishalfawavelengthwide.最

后,只是品种,我们将指定的(真空),而不是wavelengthfrequencywavelength波长;再次,

我们将使用一个波长,波导是半波长广泛。

(set!sources(list(set!来源(名单

(makesource(源

(src(makecontinuous-src(SRC(连续SRC

(wavelength(*2(sqrt12)))(width20)))(波长(*2(12SQRT)))

(宽20)))

(componentEz)(组件EZ)

(center-7-3.5)(size01))))(中心-7-3.5)(大小为0,1))))

Finally,we'llrunthesimulation.最后,我们运行仿真。Insteadofrunningoutput-efield-zonlyat

the

end

ofthesimulation,however,we'llrunitatevery0.6timeunits(about10timesperperiod)

via(at-every0.6output-efield-z).相反的运行output-efield-z只在仿真

结束

,但是,我们将在

每0.6个时间单位(每个周期约10倍),通过运行它(at-every0.6output-efield-z)Byitself,this

wouldoutputaseparatefileforeverydifferentoutputtime,butinsteadwe'lluseanotherfeatureof

Meeptooutputtoa

single

three-dimensionalHDF5file,wherethethirddimensionis

time

:就其

本身而言,这将输出一个单独的文件中为每一个不同的输出的时间,但相反,我们将使用

Meep的另一个

特点

输出到一个单一的立体HDF5文件,其中第三

维度是时间:

(run-until200(运行,直到200

(at-beginningoutput-epsilon)(在开始输出-ε)

(to-appended"ez"(at-every0.6output-efield-z)))(以追加“EZ”(AT-每0.6输出

efield-Z)))

Here,"ez"determinesthenameoftheoutputfile,whichwillbecalledez.h5ifyouarerunning

interactivelyorwillbeprefixedwiththenameofthefilenameforactlfile(egtutorial-ez.h5for

).在这里,"ez"确定输出文件的名称,将被称为ez.h5如果您以交互方式运行,或

将一个ctl文件的名称(如文件tutorial-ez.h5教程教程。)。Ifwerunh5ls

onthisfile(astandardutility,includedwithHDF5,thatliststhecontentsoftheHDF5file),weget:

如果我们运行这个文件h5ls上(一个标准的工具,包括与HDF5,列出HDF5文件的内容),

我们可以得到:

unix%h5lsez.h5UNIX%h5lsez.h5

ezDataset{161,161,330/Inf}EZ数据集{161,161,330/Inf}

Thatis,thefilecontainsasingledatasetezthatisa162×162×330array,wherethelastdimension

istime.也就是说,该文件包含一个单一的数据ezEZ,是一个162×162×330阵列,其中最

后一维的时间。(Thisisratheralargefile,69MB;later,we'llseewaystoreducethissizeifwe

onlywantimages.)Now,wehaveanumberofchoicesofhowtooutputthefields.(这是相当大

的文件,69MB;后,我们将看到的方法来减少这种规模的,如果我们只希望图像。)现在,

我们有一个如何输出领域的选择。Tooutputasingletimeslice,wecanusethesameh5topng

commandasbefore,butwithanadditional-toptiontospecifythetimeindex:egh5topng-t229

willoutputthelasttimeslice,similartobefore.要输出一个时间片,我们可以使用相同h5topng

h5topng像以前一样,但有一个额外的-t选项指定的时间指标:h5topng-t229229,将输出

的最后一个时间片,类似前。Instead,let'screateananimationofthefieldsasafunctionoftime.

相反,让我们创建一个动画等领域,作为时间的函数。First,wehavetocreateimagesfor

all

ofthetimeslices:首先,我们要为

所有

的时间片创建的图像:

unix%h5topng-t0:329-R-Zcdkbluered-ayarg-Aeps-000000.00.h5ez.h5UNIX%h5topng

0:329吨R-ZCdkbluered一个yarg,每股盈利000000.00.h5ez.h5

Thisissimilartothecommandbefore,withtwonewoptions:-t0:329outputsimagesfor

all

time

indicesfrom0to329,ieallofthetimes,andthethe-Rflagtellsh5topngtouseaconsistentcolor

scaleforeveryimage(insteadofscalingeachimageindependently).这是类似的命令之前,有两

个新选项:-t0:329输出图像的

所有

时间指数从0到329,即所有的时代,和-R标志告诉

h5topng使用一致的色标每幅图像(而不是独立的每幅图像缩放)。Then,wehavetoconvert

theseimagesintoananimationinsomeformat.然后,我们这些图像转换成某种格式动画。For

this,we'llusethefreeImageMagickconvertprogram(althoughthereisothersoftwarethatwilldo

thetrickaswell).为此,我们将使用ImageMagick的convert程序(虽然有其他的软件,以及

会做的伎俩)。

unix%convertez.t*.X%转换ez.t*.

Here,weareusingananimatedGIFformatfortheoutput,whichisnotthemostefficient

animationformat(,forMPEGformat,wouldbebetter),butitisunfortunatelytheonly

formatsupportedbythisWikisoftware.在这里,我们使用一个动画的GIF格式输出,这是不是

最有效的动画格式(,MPEG格式,效果会更好),但不幸的是,这个Wiki

软件支持的唯一格式。Thisresultsinthefollowinganimation:在下面的动画这样的结果:

xbytimesliceofbentwaveguide(vertical=time).x通过时间片弯曲波导(垂直=时间)。

Itisclearthatthetransmissionaroundthebendisratherlowforthisfrequencyand

structure—bothlargereflectionandlargeradiationlossareclearlyvisible.很显然,围绕弯曲的传

输是相当低的的,这个频率和结构都大反思,大辐射损失都清晰可见。Moreover,sincewe

operatingarejustbarelybelowthecutoffforsingle-modebehavior,weareabletoexciteasecond

leaky

modeafterthewaveguidebend,whosesecond-ordermodepattern(superimposedwiththe

fundamentalmode)isapparentintheanimation.此外,由于我们经营刚好低于截止单模行为,

我们是能够激发波导弯曲后的第二个

漏水的

模式,其二阶模式模式叠加的基本模式是在动画

明显。Atright,weshowafieldsnapshotfromasimulationwithalargercellalongthe

y

direction,

inwhichyoucanseethatthesecond-orderleakymodedecaysaway,leavinguswiththe

fundamentalmodepropagatingdownward.正确的,我们将展示一个

沿

y方向的一个较大的细

胞,在其中你可以看到,二阶泄漏模式衰变,从模拟领域的快照,留给我们的基本模式向下

传播。

Insteadofdoingananimation,anotherinterestingpossibilityistomakeanimagefroma而不是

做一个动画,另外一个有趣的可能性是从图像slice.分一杯羹。Hereisthe

y

=−3.5

slice,whichgivesusanimageofthefieldsinthefirstwaveguidebranchasafunctionoftime.这

里是

Y

=-3.5片,这让我们在第一时间的函数波导分支领域的形象。

unix%h5topng-0y-35-Zcdkblueredez.h5UNIX%h5topng0Y-35-ZCdkblueredez.h5

Here,the-0y-35specifiesthe

y

=−3.5slice,wherewehavemultipliedby10(ourresolution)to

getthepixelcoordinate.在这里,-0y-35指定

Y

=-3.5片,在这里我们有10(我们的决议)相

乘得到的像素坐标。

[edit][编辑]

Outputtipsandtricks输出的技巧和窍门

Above,weoutputtedthefull2ddatasliceatevery0.6timeunits,resultingina69MBfile.最重要

的,我们输出的完整的2D数据切片每0.6个时间单位,在一个69MB的文件。Thisisnottoo

badbytoday'sstandards,butyoucanimaginehowbigtheoutputfilewouldgetifweweredoing

a3dsimulation,orevenalarger2dsimulation—onecaneasilygenerategigabytesoffiles,which

isnotonlywastefulbutisalsoslow.这是不是太用今天的标准不好,但你能想象有多大的输出

文件会得到,如果我们是做一个三维仿真,或者甚至是一个较大的二维模拟,之一可以

轻松地生成文件千兆字节,这是不是唯一的浪费,但是也慢。Instead,itispossibletooutput

moreefficientlyifyouknowwhatyouwanttolookat.相反,它可以输出更有效,如果你知道你

想看看。

Tocreatethemovieabove,allwereallyneedarethe

images

correspondingtoeachtime.要创建上

面的电影,我们真正需要的是相应的

图像

每次。Imagescanbestoredmuchmoreefficiently

thanrawarraysofnumbers—toexploitthisfact,Meepallowsyouto

outputPNGimagesinstead

G

ofHDF5files.图像可存储比原始阵列更有效数字的利用这一事实,Meep允许你输出的PNPNG

图像,而不是HDF5文件。Inparticular,insteadofoutput-efield-zasabove,wecanuse

(output-pngEz"-Zcdkbluered"),whereEzisthecomponenttooutputandthe"-Zcdkbluered"

areoptionsforh5topng(whichistheprogramthatisactuallyusedtocreatetheimagefiles).在特

定的,而不是output-efield-z如上,我们可以使用(output-pngEz"-Zcdkbluered")其中EZ组

件输出和"-Zcdkbluered"选项h5topng(这是计划,实际上是用来创建图像文件)。Thatis:

这就是:

(run-until200(at-every0.6(output-pngEz"-Zcbluered")))(运行,直到200(AT-0.6(输出

PNGEZ“ZCbluered”)))

willoutputaPNGfilefileevery0.6timeunits,whichcanthenbecombinedwithconvertas

abovetocreateamovie.将输出文件每0.6个时间单位,然后可以结合上面创建一个影片

convert为PNG文件。Themoviewillbesimilartotheonebefore,butnotidenticalbecauseof

howthecolorscaleisdetermined.影片将前一个类似,但不是因为色阶是如何确定的相同。

Before,weusedthe-Roptiontomakeh5topngusea

uniform

colorscaleforallimages,basedon

theminimum/maximumfieldvaluesoveralltimesteps.在此之前,-RR选项,使h5topng使用

一个

为所有图像

色泽均匀,规模,最小/最大all字段值超过所有基于时间的步骤。Thatisnot

possible,here,becauseweoutputanimagebeforeknowingthefieldvaluesatfuturetimesteps.那

是不可能的,在这里,因为我们才知道在未来的时间步长的字段值输出图像。Thus,what

output-pngdoesistosetitscolorscalebasedontheminimum/maximumfieldvaluesfromall

past

times—therefore,thecolorscalewillslowly"rampup"asthesourceturnson.因此,output-png

不其颜色设置规模的基础上从

过去

所有的时间,因此最小/最大的字段值,色标会慢慢地“上

升”作为源打开。

es,anditissomewhatannoyingtohavethem

clutterupourdirectory.上面的命令输出的不计其数.png文件,它是有点讨厌他们扰乱我们的

目录。Instead,wecanusethefollowingcommandbeforerun-until:相反,我们可以使用之前

run-until下面的命令:

(use-output-directory)(使用输出目录)

Thiswillput

all

oftheoutputfiles(.h5,.png,etcetera)intoanewly-createdsubdirectory,called

bydefault

filename

-out/ifourctlfileis

filename

.ctl.这将会把

所有

的输出文件(.

filename

-out/

filename

.ctl.h5,进入一个新创建的子目录中,默认情况下调用,的,等等)

filename

-out/文件名

filename

.ctl是文件名。CTL。

Whatifwewanttooutputan如果我们要输出一个slice,asabove?片,上面?Todo

this,weonlyreallywantedthevaluesat

y

=−3.5,andthereforewecanexploitanotherpowerful

Meepoutputfeature—Meepallowsustooutputonly

asubsetofthecomputationalcell

.要做到

这一点,我们才真正希望

y=值-3.5,因此,我们可以利用另一种强大的Meep输出功能

Meep的,让我们只输出计算单元的一个子集。Thisisdoneusingthein-volumefunction,

which(likeat-everyandto-appended)isanotherfunctionthatmodifiesthebehaviorofother

outputfunctions.这是使用的in-volume功能,是另一个函数,修改其他输出功能的行为

(at-everyto-appended附加)。Inparticular,wecando:特别是,我们可以这样做:

(run-until200(运行,直到200

(to-appended"ez-slice"(到追加“EZ片”

(at-every0.6(在每0.6

(in-volume(volume(center0-3.5)(size160))(在卷(卷(中心0-3.5)(大小为160))

output-efield-z))))输出efield-Z))))

Thefirstargumenttoin-volumeisavolume,specifiedby()()),which

-volume的第一个参数是指定的卷(volume

()())大小,它适用于所有的嵌套输出功能。(Notethatto-appended,at-every,

andin-volumearecumulativeregardlessofwhatorderyouputthemin.)Thiscreatestheoutput

fileez-slice.h5whichcontainsadatasetofsize162×330correspondingtothedesired(注意

to-appendedat-every,并in-volume是累积的,不管什么样的顺序,你把他们进来)创建

ez-slice.h5EZ-slice.h5其中包含一个数据集大小162×330对应于所需

羹。

[edit][编辑]

slice.分一杯

Transmissionspectrumaroundawaveguidebend围绕波导弯

曲的透射谱

Above,wecomputedthefieldpatternsforlightpropagatingaroundawaveguidebend.以上,我们

计算波导弯曲周围的光线传播领域的模式。Whilethisispretty,theresultsarenot

quantitativelysatisfying.虽然这是很漂亮,结果是不定量满足。We'dliketoknowexactlyhow

muchpowermakesitaroundthebend,howmuchisreflected,andhowmuchisradiatedaway.我

们想知道它周围的弯曲,多少反映,又有多少是辐射距离究竟多大的权力,使。Howcanwe

dothis?如何才能做到这一点?

ThebasicprinciplesweredescribedintheMeepintroduction;pleasere-readthatsectionifyou

引进的基本原则,描述了,请重新阅读该节,如果您忘记了。Basically,

we'lltellMeeptokeeptrackofthefieldsandtheirFouriertransformsinacertainregion,andfrom

thiscomputethefluxofelectromagneticenergyasafunctionofω.基本上,我们会告诉Meep的

领域和傅立叶变换在一定区域内的轨道,并从这个计算作为一个函数ω的电磁能量通

量。Moreover,we'llgetanentirespectrumofthetransmissioninasinglerun,by

Fourier-transformingtheresponsetoashortpulse.此外,我们将在一个单一的运行整个频谱的

传输,通过傅立叶转换一个短脉冲响应。However,inordertonormalizethetransmission(to

gettransmissionasafractionofincidentpower),we'llhavetodo

two

runs,onewithandone

withoutabend.然而,为了规范传输(入射功率的一小部分传输),

我们

将有两个运行,一

个与一个没有一个弯。

Thiscontrolfilewillbemorecomplicatedthanbefore,soyou'lldefinitelywantitasaseparatefile

ratherthantypingitinteractively.这个控制文件将会比以前更复杂,所以你一定会希望它作为

一个单独的文件中,而比交互式键入。eincludedwithMeepinits

examples/directory.见的examples/目录中的文件包括与Meep。

Above,wehard-codedalloftheparameterslikethecellsize,thewaveguidewidth,etcetera.上面,

我们硬编码就像是细胞的大小,波导宽度,等等的所有参数。Forseriouswork,however,this

isinefficient—weoftenwanttoexploremanydifferentvaluesofsuchparameters.然而,对于严肃

的工作,这是低效的,我们经常要探索许多不同的值等参数。Forexample,wemaywantto

changethesizeofthecell,sowe'lldefineitas:例如,我们可能要改变细胞的大小,因此我们将

它定义为:

(define-paramsx16);sizeofcellinXdirection(定义参数SX16);在X方向的单元尺寸

(define-paramsy32);sizeofcellinYdirection(定义参数SY3​2);在Y方向的单元尺寸

(set!geometry-lattice(makelattice(sizesxsyno-size)))(set!几何格(使晶格(大小SXSY无

大小)))

(Noticethatasemicolon";"beginsacomment,whichisignoredbyMeep.)define-paramisa

libctlfeaturetodefinevariablesthatcanbeoverriddenfromthecommandline.(注意分号“;“。

开始一个注释,这是Meep忽略)define-param是一个libctl的功能来定义变量可以在命令

行覆盖。Wecouldnowdomeepsx=hangetheXsizeto17,without

editingthectlfile,forexample.我们现在可以做meepsx=编辑ctl文

件,例如,没有改变X尺寸17。We'llalsodefineacoupleofparameterstosetthewidthofthe

waveguideandthe"padding"betweenitandtheedgeofthecomputationalcell:我们还将定义的

参数设置波导的宽度和它和计算细胞的边缘之间的“填充”:

(define-parampad4);paddingdistancebetweenwaveguideandcelledge(定义参数垫4);波

导和小区边缘之间的填充距离

(define-paramw1);widthofwaveguide(定义参数W1);波导的宽度

Inordertodefinethewaveguidepositions,etcetera,wewillnowhavetousearithmetic.为了确定

波导的位置,等等,我们现在必须使用算术。Forexample,the

y

centerofthehorizontal

waveguidewillbegivenby-0.5*(sy-w-2*pad).例如,水平波导

Ÿ

中心将给予-0.5*(sy-w-

2*pad)。Atleast,thatiswhattheexpressionwouldlooklikeinC;inScheme,thesyntaxfor1+

2is(+12),andsoon,sowewilldefinetheverticalandhorizontalwaveguidecentersas:至少,

这是看起来像在C的表达;计划,语法1+2(+12)等等,所以我们将定义的纵向和横向的波

导中心:

(definewvg-ycen(*-0.5(-syw(*2pad))));ycenterofhoriz.(定义wvg-ycen(*-0.5(-SY

W(*2片))));YHORIZ中心。wvgwvg

(definewvg-xcen(*0.5(-sxw(*2pad))));xcenterofvert.(定义wvgxcen(*0.5(-SXW

(*2片))));X的垂直中心。wvgwvg

Now,wehavetomakethegeometry,asbefore.现在,我们已经使几何形状,如前。Thistime,

however,wereallywant

two

geometries:thebend,andalsoastraightwaveguidefor

normalization.然而,这一次,我们真的要

两个

几何弯曲,也是一个正常化的直波导。Wecould

dothiswithtwoseparatectlfiles,butthatisannoying.我们可以用两个独立的CTL文件,但是

这很烦人。Instead,we'lldefineaparameterno-bend?whichistrueforthestraight-waveguide

caseandfalseforthebend.相反,我们将定义一个参数no-bend?直波导的情况下true是false

的和虚假的弯曲。

(define-paramno-bend?false);iftrue,havestraightwaveguide,notbend(定义参数不弯假

的?);如果情况属实,有直波导,不能弯曲

Now,wedefinethegeometryviatwocases,withanifstatement—theSchemesyntaxis(if

predicate?if-trueif-false

).现在,我们通过两起案件中定义的几何与语句的计划(if

predicate?

if-trueif-false

)的)。

(set!geometry(set!几何

(ifno-bend?(如果没有弯曲?

(list(名单

(makeblock(使块

(center0wvg-ycen)(中心0wvg-ycen)

(sizeinfinitywinfinity)(大小无穷瓦特无穷)

(material(makedielectric(epsilon12)))))(材料(电介质(EPSILON12)))))

(list(名单

(makeblock(使块

(center(*-0.5pad)wvg-ycen)(中心(-0.5垫)wvgycen)

(size(-sxpad)winfinity)(大小(-SX垫)W无穷大)

(material(makedielectric(epsilon12))))(材料(使介质(EPSILON12))))

(makeblock(使块

(centerwvg-xcen(*0.5pad))(中心wvgxcen(*0.5垫))

(sizew(-sypad)infinity)(尺寸W(垫-SY)无穷远)

(material(makedielectric(epsilon12)))))))(材料(电介质(EPSILON12)))))))

Thus,ifno-bend?istruewemakeasingleblockforastraightwaveguide,andotherwisewemake

twoblocksforabentwaveguide.因此,如果no-bend?是true的,我们作出了直波导一个单独

的块,否则我们两个弯曲波导块。

Thesourceisnowagaussian-srcinsteadofacontinuous-src,parameterizedbyacenterfrequency

andafrequencywidth(thewidthoftheGaussianspectrum),whichwe'lldefineviadefine-param

asusual.源是一个gaussian-src,而不是一个continuous-src,由一个中心频率参数和频率宽

度(高斯频谱的宽度),我们将通过define-param参数,像往常一样。

(define-paramfcen0.15);pulsecenterfrequency(定义参数fcen0.15);脉冲中心频率

(define-paramdf0.1);pulsewidth(infrequency)(定义参数DF0.1);脉冲宽度(频率)

(set!sources(list(set!来源(名单

(makesource(源

(src(makegaussian-src(frequencyfcen)(fwidthdf)))(SRC(使高斯-SRC

(频率fcen)(fwidthDF)))

(componentEz)(组件EZ)

(center(+1(*-0.5sx))wvg-ycen)(中心(+1(*-0.5SX))wvgycen)

(size0w))))(大小为0W))))

Noticehowwe'reusingourparameterslikewvg-ycenandw:ifwechangethedimensions,

everythignwillnowshiftautomatically.请注意我们如何使用像我们wvg-ycenwycen和w:如

果我们改变尺寸,everythign现在将自动切换。Theboundaryconditionsandresolutionareset

asbefore,exceptthatnowwe'lluseset-param!sothatwecanoverridetheresolutionfromthe

commandline.:边界条件和分辨率设置之前,除了现在我们将使用set-param!,使我们可以

覆盖命令行的决议。

(set!pml-layers(list(makepml(thickness1.0))))(set!PML层(清单(使PML(厚度为1.0))))

(set-param!resolution10)(set-param!决议10)

Finally,wehavetospecifywherewewantMeeptocomputethefluxspectra,andatwhat

frequencies.最后,我们指定的地方,我们要Meep计算通量光谱,和在什么频率。(Thismust

bedone

after

specifyingthegeometry,sources,resolution,etcetera,becauseallofthefield

parametersareinitializedwhenfluxplanesarecreated.)(这必须在指定的几何形状,来源,决

议,

等等

后完成的,因为所有的字段参数被初始化创建时通量飞机。)

(define-paramnfreq100);numberoffrequenciesatwhichtocomputeflux(定义参数nfreq

100);频率时计算通量

(definetrans;transmittedflux(定义跨传输通量

(add-fluxfcendfnfreq(添加通量fcenDFnfreq

(ifno-bend?(如果没有弯曲?

(makeflux-region(通量区域

(center(-(/sx2)1.5)wvg-ycen)(size0(*w2)))(中心(-(2)/SX

1.5)wvgycen)(大小为0(2*宽)))

(makeflux-region(通量区域

(centerwvg-xcen(-(/sy2)1.5))(size(*w2)0)))))(中心wvg-xcen

(-(SY/2)1.5))(大小(2*宽)0)))))

(definerefl;reflectedflux(定义REFL;反映通量

(add-fluxfcendfnfreq(添加通量fcenDFnfreq

(makeflux-region(通量区域

(center(+(*-0.5sx)1.5)wvg-ycen)(size0(*w2)))))(中心(+(*SX

-0.5)1.5)wvgycen)(大小为0(*宽2)))))

Wecomputethefluxesthroughalinesegmenttwicethewidthofthewaveguide,locatedatthe

beginningorendofthewaveguide.我们通过线段的两倍宽度的波导,波导的开头或结尾位于

通量计算。(Notethatthefluxlinesareseparatedby1fromtheboundaryofthecell,sothatthey

donotliewithintheabsorbingPMLregions.)Again,therearetwocases:thetransmittedfluxis

eithercomputedattherightorthebottomofthecomputationalcell,dependingonwhetherthe

waveguideisstraightorbent.(注意,磁力线是分开的1细胞的边界,使他们不在于吸收PML

的地区内)同样,有两种情况:传输通量是计算在右侧或底部计算单元,根据波导是否是直

的或弯曲的。

Here,thefluxeswillbecomputedfor100(nfreq)frequenciescenteredonfcen,fromfcen-df/2

tofcen+df/2.在这里,通量将被计算为100(nfreq)为中心频率fcen,从fcen-df/2fcen+df/2。

Thatis,weonlycomputefluxesforfrequencieswithinourpulsebandwidth.也就是说,我们只计

算为我们的脉冲带宽内频率通量。Thisisimportantbecause,tofaroutsidethepulsebandwidth,

thespectralpowerissolowthatnumericalerrorsmakethecomputedfluxesuseless.这是很重要

的,因为,远远超出脉冲带宽,光谱功率是如此之低,数值误差计算通量没用。

Now,asdescribedintheMeepintroduction,computingreflectionspectraisabittrickybecause

weneedtoseparatetheincidentandreflectedfields.现在,在Meep引进,计算反射光谱是一

个有点棘手,因为我们需要单独的事件,并反映领域。WedothisinMeepbysavingthe

Fourier-transformedfieldsfromthenormalizationrun(no-bend?=true),andloadingthem,

negated

,

before

theotherruns.保存的规范化运行(傅立叶变换的领域,我们在Meep

no-bend?=true=TRUE),并加载

它们,

否定之前的其他运行。Thelattersubtractsthe

Fourier-transformedincidentfieldsfromtheFouriertransformsofthescatteredfields;logically,

wemightsubtractthese

after

therun,butitturnsouttobemoreconvenienttosubtractthe

incidentfieldsfirstandthenaccumulatetheFouriertransform.后者减去傅立叶变换的事件领

域,从傅立叶变换的散射场;逻辑上,

我们可能

会运行后减去这些,但事实证明,以更方便

减去事件领域的第一次,然后积累的傅立叶变换。Allofthisisaccomplishedwithtwo

commands,save-flux(afterthenormalizationrun)andload-minus-flux(beforetheotherruns).所

有这一切都完成了两个命令,save-flux(正常化之后运行)和load-minus-flux(其他运行

前)。Wecancallthemasfollows:我们可以把它们如下:

(if(notno-bend?)(load-minus-flux"refl-flux"refl))(如果(没有不弯吗?)(负载负通量

“REFL通量”REFL))

(run-sources+500(at-beginningoutput-epsilon))(运行源+500(在开始输出-ε))

(ifno-bend?(save-flux"refl-flux"refl))(如果没有弯曲?(保存通量“REFL通量”REFL))

Thisusesafilecalledrefl-flux.h5,oractuallybend-flux-refl-flux.h5(thectlfilenameisusedasa

prefix)tostore/loadtheFouriertransformedfieldsinthefluxplanes.这将使用称为refl-flux.h5文

件,或bend-flux-refl-flux.h5(CTL文件名作为前缀使用)存储/加载助焊剂中的飞机

傅立叶变换领域。The(run-sources+500)runsthesimulationuntiltheGaussiansourcehas

turnedoff(whichisdoneautomaticallyonceithasdecayedforafewstandarddeviations),plusan

additional500timeunits.(run-sources+500)运行仿真,直到高斯源已关闭(这是自动完成的,

一旦有几个标准偏差腐烂),另加500个时间单位。

Whydowekeeprunningafterthesourcehasturnedoff?为什么我们源关闭后继续运行?

Becausewemustgivethepulsetimetopropagatecompletelyacrossthecell.因为我们必须给脉

冲时间传播到细胞完全。Moreover,thetimerequiredisabittrickytopredictwhenyouhave

complexstructures,becausetheremightberesonantphenomenathatallowthesourcetobounce

aroundforalongtime.此外,所需的时间是有点棘手,预测当你有复杂的结构,因为有可能

会允许源反弹很长一段时间的共振现象。Therefore,itisconvenienttospecifytheruntimeina

differentway:insteadofusingafixedtime,werequirethatthe|

E

z

|

2

attheendofthewaveguide

musthavedecayedbyagivenamount(eg1/1000)fromitspeakvalue.因此,它是方便以不同的

个人

方式指定运行时间,而不是使用一个固定的时间,我们

需要

|

于2月底在波导|必须有一个

给定的金额(如1/1000)腐朽其峰值。Wecandothisvia:我们可以做到这一点通过:

(run-sources+(运行源+

(stop-when-fields-decayed50Ez(停止时领域腐烂50EZ

(ifno-bend?(如果没有弯曲?

(vector3(-(/sx2)1.5)wvg-ycen)(vector3(-(2)/SX

1.5)wvgycen)

(vector3wvg-xcen(-(/sy2)1.5)))(vector3wvgxcen(-

(2/SY)1.5)))

1e-3))1E-3))

stop-when-fields-decayedtakesfourarguments:(stop-when-fields-decayed

dTcomponentpt

decay-by

).stop-when-fields-decayed有四个参数:(stop-when-fields-decayed

dTcomponentpt

decay-by

)。Whatitdoesis,afterthesourceshaveturnedoff,itkeepsrunningforanadditional

dTtimeunitseverytimethegiven|component|

2

atthegivenpointhasnotdecayedbyatleast

decay-byfromitspeakvalueforalltimeswithinthepreviousdT.它所做的是,来源已关闭后,

它使额外运行dT时间单位,每次|组件

|

2在给定的点并没有decay-by衰变峰值所有时间内至

少以前dT。Inthiscase,dT=50,thecomponentis

E

z

,thepointisatthecenterofthefluxplane

attheendofthewaveguide,anddecay-by=0.001.在这种情况下,dT=50,该组件

E

ž

点通

量面波导年底的中心decay-by=0.0010.001。So,itkeepsrunningforanadditional50time

unitsuntilthesquareamplitudehasdecayedby1/1000fromitspeak:thisshouldbesufficientto

ensurethattheFouriertransformshaveconverged.因此,保持一个额外的50个时间单位的运行,

直到平方米的幅度已经腐烂的1/1000,从高峰:这应该是足够的,以确保傅立叶变换融合。

Finally,wehavetooutputthefluxvalues:最后,我们输出的光通量值:

(display-fluxestransrefl)(显示器通量反REFL)

Thisprintsaseriesofoutputslike:这将打印一系列如输出:

flux1:,0.1,7.975e-7,-3.196e-7flux1:0.1,7.975e-7-

3.196e-7

flux1:,0.101,1.1841e-6,-4.85527604203706e-7

0.101,1.1841e-6-4.85527604203706e-7

flux1:,0.102,1.772e-6,-7.37944901819701e-7

0.102,1.772e-6-7.37944901819701e-7

flux1:,0.103,2.63e-6,-1.327e-6

0.103,2.63e-6-1.327e-6

flux1:

flux1:

flux1:

flux1:,...flux1:......

Thisiscomma-delimiteddata,whichcaneasilybeimportedintoanyspreadsheetorplotting

program(egMatlab):thefirstcolumnisthefrequency,thesecondisthetransmittedpower,and

thethirdisthereflectedpower.这是逗号分隔的数据,可以很容易地进入任何表格或绘图程序

(如MATLAB)进口的:第一列的频率,二是发射功率,第三个是反射功率。

Now,weneedtorunthesimulation

twice

,oncewithno-bend?=trueandoncewith

no-bend?=false(thedefault):现在,我们需要

两次

模拟运行,一旦no-bend?=true,一旦

no-bend?=false(默认):

unix%meepno-bend?=|X%meep无弯曲=真正的弯曲

|?发球

unix%|X%meep弯曲|T恤

(TheteecommandisausefulUnixcommandthatsavestheoutputtoafile

and

displaysitonthe

screen,sothatwecanseewhatisgoingonasitruns.)Then,weshouldpullouttheflux1lines

intoaseparatefiletoimportthemintoourplottingprogram:(tee命令是一个有用的Unix命

令输出保存到一个

文件

,它在屏幕上显示,使我们可以看到什么是运行。)那么,我们应该

拉出来flux1flux1行成一个单独的文件它们导入到我们的绘图程序:

unix%grepflux1:>X%GREPflux1:>

unix%grepflux1:>X%GREPflux1:>

Now,weimportthemtoMatlab(usingitsdlmreadcommand),andplottheresults:现在,我们将

其导入到Matlab(使用dlmread命令),并绘制的结果:

Whatareweplottinghere?我们有什么阴谋在这里?Thetransmissionisthetransmittedflux

()

dividedby

theincidentflux(),togive

usthe

fraction

ofpowertransmitted.传输是传输通量(第二列)

分为

事件

通量(第二列),给我们传播的力量

的一小

部分。Thereflectionisthereflectedflux(third

)

dividedby

theincidentflux();wealsohaveto

multiplyby−1becauseallfluxesinMeeparecomputedinthepositive-coordinatedirectionby

default,andwewantthefluxinthe−

x

direction.反思是反映通量(第三列)

分为

事件通量(第二列);我们也有乘-1,因为在Meep所有通量在积极协调的方向计

算默认情况下,我们要在助焊剂-

X

方向。Finally,thelossissimply1-transmission-reflection.

最后,损失简直是1-传播-反射。

Weshouldalsocheckwhetherourdataisconverged,byincreasingtheresolutionandcellsizeand

seeingbyhowmuchthenumberschange.我们还应该检查我们的数据是否融合,通过提高分辨

率和细胞大小和看到的数字的变化有多大。Inthiscase,we'lljusttrydoublingthecellsize:在

这种情况下,我们就尝试单元的大小增加一倍:

unix%meepsx=32sy=64no-bend?=|X%meepSX=64

=32SY没有弯=真正的弯曲|?发球

unix%meepsx=32sy=|X%meepSX=32SY=64弯

|T恤弯曲

Again,wemustrun

both

simulationsinordertogetthenormalizationright.再次,我们必须

同时

运行模拟,以获得正常化的权利。Theresultsareincludedintheplotaboveasdottedlines—you

canseethatthenumbershavechangedslightlyfortransmissionandloss,probablystemmingfrom

interferencebetweenlightradiateddirectlyfromthesourceandlightpropagatingaroundthe

waveguide.结果包括在上述地积虚线可以看到数字传输和损失略有改变,可能产生的干扰,

直接从源头上和周围的波导传播的光之间的光辐射。Tobereallyconfident,weshould

probablyrunthesimulationagainwithanevenbiggercell,butwe'llcallitenoughforthistutorial.

要真正有信心,我们或许应该运行的模拟再次用一个更大的细胞,但我们会打电话给本教程,

就足够。

[edit][编辑]

Modesofaringresonator一环谐振器模式

AsdescribedintheMeepintroduction,anothercommontaskforFDTDsimulationistofindthe

resonantmodes—frequenciesanddecayrates—介

绍中所描述的的,FDTD模拟的另一个常见的任务是找到共振模式的频率和衰变率的一些电

磁腔结构。(Youmightwanttoreadthatintroductionagaintorecallthebasiccomputational

strategy.)Here,wewillshowhowthisworksforperhapsthesimplestexampleofadielectric

cavity:aringresonator,whichissimplyawaveguidebentintoacircle.(您可能想再次阅读,

引进召回的基本计算策略)在这里,我们将展示如何为工程电介质腔也许是最简单的例子:

一环谐振器,这简直是波导弯曲成一个圆圈。(Thiscanbealsofoundintheexamples/

fileincludedwithMeep.)Infact,sincethisstructurehascylindricalsymmetry,wecansimulateit

much

moreefficientlybyusingcylindricalcoordinates,butforillustrationherewe'lljustusean

ordinary2dsimulation.(这可以还发现Meep包括在examples/文件。)事实上,因为

这种结构具有圆柱对称,我们可以模拟

有效地使用圆柱坐标系,但为了说明这里我们只

使用一个普通的2D模拟。

Asbefore,we'lldefinesomeparameterstodescribethegeometry,sothatwecaneasilychangethe

structure:一如以往,我们会定义一些参数来描述的几何形状,使我们可以很容易地改变结构:

(define-paramn3.4);indexofwaveguide(定义参数ñ3.4);波导指数

(define-paramw1);widthofwaveguide(定义参数W1);波导的宽度

(define-paramr1);innerradiusofring(定义参数R1);内圈半径

(define-parampad4);paddingbetweenwaveguideandedgeofPML(定义参数垫4);填充波

导和PML的边缘

(define-paramdpml2);thicknessofPML(定义参数dpml2);PML的厚度

(definesxy(*2(+rwpaddpml)));cellsize(定义SXY(*2(+RW垫dpml)));细胞大小

(set!geometry-lattice(makelattice(sizesxysxyno-size)))(set!几何晶格(使晶格(大小SXY

SXY无大小)))

Howdowemakeacircularwaveguide?我们如何做一个圆形波导?Sofar,we'veonlyseen

blockobjects,butMeepalsoletsyouspecifycylinders,spheres,ellipsoids,andcones,aswellas

user-specifieddielectricfunctions.到目前为止,我们只看到block对象,但Meep也可以让你

指定的圆柱体,球体,椭球,和锥体,以及用户指定的介质的功能。Inthiscase,we'lluse

two

cylinderobjects,oneinsidetheother:在这种情况下,我们将使用

两个

cylinder的对象,里面的:

(set!geometry(list(set!几何(名单

(makecylinder(center00)(heightinfinity)(缸(中心00)(高度无穷大)

(radius(+rw))(material(makedielectric(indexn))))(半径(+RW))

(材料(使介质(折射率n))))

(makecylinder(center00)(heightinfinity)(缸(中心00)(高度无穷大)

(radiusr)(materialair))))(半径r)(材料的空气))))

(set!pml-layers(list(makepml(thicknessdpml))))(set!PML层(清单(使PML(厚度dpml))))

(set-param!resolution10)(set-param!决议10)

Laterobjectsinthegeometrylisttakeprecedenceover(lie"ontopof")earlierobjects,sothe

secondair(后来在geometry列表对象优先考虑(谎言“之上”),以前的对象,air第二空气

()cylindercutsacircularholeoutofthelargercylinder,leavingaringofwidthw.)

气缸削减一个较大的缸圆孔,留下一个宽度为环w。

Now,wedon'tknowthefrequencyofthemode(s)aheadoftime,sowe'lljusthitthestructurewith

abroadGaussianpulsetoexciteallofthe(TMpolarized)modesinachosenbandwidth:现在,我

们不知道的模式(S)的时间提前的频率,所以我们只打了广阔的高斯脉冲的结构,以激发

在选定的带宽(TM极化)模式:

(define-paramfcen0.15);pulsecenterfrequency(定义参数fcen0.15);脉冲中心频率

(define-paramdf0.1);pulsewidth(infrequency)(定义参数DF0.1);脉冲宽度(频率)

(set!sources(list(set!来源(名单

(makesource(源

(src(makegaussian-src(frequencyfcen)(fwidthdf)))(SRC(使高斯-SRC

(频率fcen)(fwidthDF)))

(componentEz)(center(+r0.1)0))))(组件EZ)(中心(+R0.1),0))))

Finally,wearereadytorunthesimulation.最后,我们已经准备好运行仿真。Thebasicideaisto

rununtilthesourcesarefinished,andthentorunforsomeadditionalperiodoftime.其基本思路

是,运行,直到来源完成,然后运行一段时间的额外期限。Inthatadditionalperiod,we'll

performsomesignal-processingonthefieldsatsomepointwithharminvtoidentifythe

frequenciesanddecayratesofthemodesthatwereexcited:额外的时期,我们将在一些点执行一

些信号处理领域的harminv,以确定被激发模式的频率和衰减率:

(run-sources+300(运行来源+300

(at-beginningoutput-epsilon)(在开始输出-ε)

(after-sources(harminvEz(vector3(+r0.1))fcendf)))(后源(harminvEZ

(vector3(+R0.1))fcenDF)))

Thesignal-processingisperformedbytheharminvfunction,whichtakesfourarguments:thefield

component(hereEz)andposition(here(

r

+0.1,0))toanalyze,andafrequencyrangegivenbya

centerfrequencyandbandwidth(here,thesameasthesourcepulse).harminv功能,它有四个参

数:字段组件(Ez)和位置

((R

+0.1,0))来分析,和频率范围,中心频率和带宽(信号

处理在这里,作为源脉冲相同)。),sinceweonly

wanttoanalyzethefrequenciesinthesource-freesystem(thepresenceofasourcewilldistortthe

analysis).请注意,我们总结),因为我们只是想在源系统(源的存在

会扭曲分析)的频率分析。Attheendoftherun,harminvprintsaseriesoflines(beginningwith

harminv0:,tomakeiteasytogrepfor)listingthefrequenciesitfound:在运行结束后,harminv

打印一系列行(与开始harminv0:的,可以很容易grepgrep)上市的频率,它发现:

harminv0:,frequency,v0:频率,IMAG。freq.,Q,|amp|,amplitude,error频率,

Q|放大器|,振幅,错误

harminv0:,0.1181,-7.351e-4,80.683059081382,

0.04578,-0.94175-0.56404i,1.04e-5

harminv0:,0.1181,7.351e-4,80.683059081382,

0.045780.94175-0.56404i,1.04e-5

harminv0:,0.8154,-2.32636643253225e-4,316.29272471914,

0.8165,0.6469-0.1413i,7.32532621851082e-7

harminv0:,0.8154,2.32636643253225e-4,316.29272471914,

0.8165,0.64690.1413i,7.32532621851082e-7

harminv0:,0.2663,-5.22349801171605e-5,1677.48461212767,

0.56089,-8.1277e-4-0.35085i,1.82e-7

harminv0:,0.2663,5.22349801171605e-5,1677.48461212767,

0.00721​98.1277e-4-0.35085i,

1.82e-7

Therearesixcolumns(inadditiontothelabel),comma-delimitedforeasyimportintoother

programs.有六列(标签),方便导入到其他程序中的逗号分隔。Themeaningofthesecolumns

vanalyzesthefields

f

(

t

)atthegivenpoint,andexpressesthisasasumof

modes(inthespecifiedbandwidth):这些列的含义如下。Harminv分析等领域

的F(T),

在给

定的点,并表示这个模式(在指定的带宽)的总和:

forcomplexamplitudes

a

n

andcomplexfrequenciesω

n

.

A

N

和复杂的频率

ωÑ

复杂的振幅。The

sixcolumnsrelatetothesequantities.六列涉及到这些数量。Thefirstcolumnisthe

real

partof

ω

n

,expressedinourusual2π

c

units,andthesecondcolumnisthe

imaginary

part—a

negative

imaginarypartcorrespondstoanexponentialdecay.第一列是

真实

的一部分

ωñ

我们一贯的

2πC

单位表示,第二列

部分负虚部对应的指数衰减。Thisdecayrate,foracavity,ismore

oftenexpressedasadimensionless"lifetime"

Q

,definedby:这种衰变率,一腔,更多的时候是

作为一个无量纲的“寿命

问定义,表示:

(

Q

isthenumberofopticalperiodsfortheenergytodecaybyexp(−2π),and1/

Q

isthe

fractionalbandwidthathalf-maximumoftheresonancepeakinFourierdomain.)This

Q

isthe

thirdcolumnoftheoutput.

(Q

是光能量衰减EXP时期(-2π),和1/

Q

是在傅立叶域的共

振峰的半高的分数

带宽

。)这个问答是输出第三列。Thefourthandfifthcolumnsarethe

absolutevalue|

a

n

|andcomplexamplitudes

a

n

.第四和第五列的绝对值|

A

N

|

A

N

复杂的振幅。

Thelastcolumnisacrudemeasureoftheerrorinthefrequency(bothrealandimaginary)...ifthe

errorismuchlargerthantheimaginarypart,forexample,thenyoucan'ttrustthe

Q

tobeaccurate.

Note

:

thiserrorisonlytheuncertaintyinthesignalprocessing

,andtellsyounothingaboutthe

errorsfromfiniteresolution,finitecellsize,andsoon!最后一列是原油的频率误差的措施(实数

和虚)......如果错误是远远比想象的部分,例如,那么

不能信任的Q是准确的注意。

个错误只有在信号处理的

不确定性,并告诉你从有限的决议,有限单元尺寸等错误!

Aninterestingquestionishowlongshouldwerunthesimulation,afterthesourcesareturnedoff,

inordertoanalyzethefrequencies.一个有趣的问题是我们应该多长时间运行的模拟的来源是

关闭后,为了分析频率。WithtraditionalFourieranalysis,thetimewouldbeproportionaltothe

frequencyresolutionrequired,butwithharminvthetimeismuchshorter.随着传统的傅立叶分

析,时间将到所需的频率分辨率成正比,但与harminv的时间要短得多。Here,forexample,

therearethreemodes.在这里,例如,有三种模式。Thelasthasa

Q

of1677,whichmeansthat

themodedecaysforabout2000periodsorabout2000/0.175=10

4

timeunits.最后有一个1677年

的Q,

这意味着,约2000期,或约

2000/0.175

=104个时间单位的模式衰变。Wehaveonlyanalyzed

itforabout300timeunits,however,andtheestimateduncertaintyinthefrequencyis10

−7

(with

anactualerrorofabout10

−6

,frombelow)!我们只分析约300个时间单位,但是,和频率估计

确定性是实际

的不10-7(约10的错误

-

从下面6)!Ingeneral,youneedtoincreasetheruntimetoget

moreaccuracy,andtofindveryhigh

Q

values,butnotbymuch—inourownwork,wehave

successfullyfound

Q

=10

9

modesbyanalyzingonly200periods.在一般情况下,你需要增加运

行时间,以获得更高的精度,并

发现非常

高的Q值,但不是很多在我们自己的工作中,我

分析:

Q

们已经成功地

发现只有200

期=109种模式。

Inthiscase,wefoundthreemodesinthespecifiedbandwith,atfrequenciesof0.118,0.147,and

0.175,withcorresponding

Q

valuesof81,316,and1677.在这种情况下,我们发现了三种模式在

指定的带宽,频率为0.118,0.147和0.175,

对应

的Q值(81,316,和1677)。(Aswasshown

byMarcatilliin1969,the

Q

ofaringresonatorincreases

exponentially

withtheproductofωand

ringradius.)Now,supposethatwewanttoactuallyseethefieldpatternsofthesemodes.(由

Marcatilli于1969年,一个环形谐振腔的增加与ω和环半径

的产品

成倍的Q。)现在,假设我

们要真正看到这些模式的实地模式。Noproblem:wejustre-runthesimulationwitha

narrow

-bandsourcearoundeachmodeandoutputthefieldattheend.没问题:我们只是重新运行在结

束与周围每个模式和输出领域

窄带源的模拟。

Inparticular,tooutputthefieldattheendwemightaddan(at-endoutput-efield-z)argumentto

ourrun-sources+function,butthisisproblematic:wemightbeunluckyandoutputatatimewhen

the

E

z

fieldisalmostzero(iewhenalloftheenergyisinthemagneticfield),inwhichcasethe

picturewillbedeceptive.特别是,以输出最终该领域我们可能会添加一个(at-end

output-efield-z)参数我们run-sources+功能,但这是有问题:我们可能是在一个时间时的

Ë

ž

倒霉和输出领域几乎是零(即当所有的能量都在磁场),在这种情况下,画面将欺骗性。

Instead,attheendoftherunwe'lloutput20fieldsnapshotsoverawholeperiod1/fcenby

appendingthecommand:相反,在运行结束后,我们将输出整个时期的1/20场fcenfcen通过

追加命令:

(run-until(/1fcen)(at-every(/1fcen20)output-efield-z))(运行,直到(/1fcen)(每(1/1

fcen20)输出efield-Z))

Now,wecangetourmodesjustbyrunningeg:现在,我们可以得到我们的模式运行,例如:

unix%meepfcen=0.118df=X%meepfcen=0.118DF=

Aftereachoneofthesecommands,we'llconvertthefieldsintoPNGimagesandthenceintoan

animatedGIF(aswiththebendmovie,above),via:每一个这些命令后,我们将转换为PNG图

像,GIF动画(弯曲的电影,上面),并从那里进入的领域,通过:

unix%h5topng-RZcdkbluered-Cring-eps-000000.00.h5ring-ez-*.h5UNIX%h5topngRZC

dkbluered-C环-EPS000000.00.h5环EZ-*.H5

unix%convertring-ez-*.X%转换环EZ-*.PNG环

Theresultinganimationsfor(fromlefttoright)0.118,0.147,and0.175,arebelow,inwhichyou

canclearlyseetheradiatingfieldsthatproducethelosses:(从左至右),0.118,0.147和0.175,

由此产生的动画下面,在这里您可以清楚地看到辐射领域产生的损失:

(Eachofthesemodesis,ofcourse,doubly-degenerateaccordingtotherepresentationsofthe(每

种模式,当然,双变质的陈述symmetrygroup.对称群。Theothermodeissimplya

slightrotationofthismodetomakeit

odd

throughthe

x

axis,whereasweexcitedonlythe

even

modesduetooursourcesymmetry.另一种模式是一个简单的这种模式,使其通过

X

奇的

轻微转动,而我们兴奋只是由于我们

源对称,甚至模式。Equivalently,onecanform

clockwiseandcounter-clockwisepropagatingmodesbytakinglinearcombinationsofthe

even/oddmodes,correspondinganangularφdependence等价地,人们可以采取的奇/偶模式的

线性组合形式顺时针和逆时针的传播模式,相应的一个角φ的依赖

5inthiscase.)

=3,4和5在这种情况下)。

Youmayhavenoticed,bytheway,thatwhenyourunwiththenarrow-bandwidthsource,harminv

givesyouslightlydifferentfrequencyand

Q

estimates,withamuchsmallererrorestimate—thisis

nottoostrange,sincebyexcitingasinglemodeyougenerateacleanersignalthatcanbeanalyzed

for

m

=3,4,and

moreaccurately.估计的方式,您可能已经注意到,当你运行与窄带源,harminv给你一个小

得多的错误略有不同频率

Q的估计,这不是太奇怪了,因为你激动人心的单一模式创造

一个更清洁的信号,可以更准确地分析。Forexample,thenarrow-bandwidthsourcefortheω=

0.175modegives:例如,窄带源为ω=0.175模式使得:

harminv0:,0.8716,-5.21e-5,1682.33949533974,

0.8043,0.0642-0.617i,7.3532e-12

harminv0:,0.8716,5.21e-5,1682.33949533974,

0.8043,0.06420.617i,7.3532e-12

whichdiffersbyabout0.000001(10

−6

)fromtheearlierestimate;thedifferencein

Q

is,of

course,largerbecauseasmallabsoluteerrorinωgivesalargerrelativeerrorinthesmall

imaginaryfrequency.约0.000001(10

-6

从早先的估计不同,不同的是,

Q当然,更大,

因为一个小的绝对误差在ω给出了一个较大的相对误差小虚频率。

[edit][编辑]

Exploitingsymmetry利用对称性

Inthiscase,becausewehaveamirrorsymmetryplane(the

x

axis)thatpreserves

both

the

structure

and

thesources,wecanexploitthismirrorsymmetrytospeedupthecomputation.

在这种情况下,因为我们有一个镜像对称平面

(x

轴)保留

结构

来源,我们可以利用这

个镜像对称,以加快计算。(SeealsoexploitingsymmetryinMeep.)Inparticular,everything

abouttheinputfileisthesameexceptthatweaddasingleline,rightafterwespecifythesources:

(亦见利用Meep对称。)特别是,输入文件的一切除了我们添加一行,右后,我们sources

相同的来源:

(set!symmetries(list(makemirror-sym(directionY))))(set!对称性(列表(镜像对称(方向

Y))))

ThistellsMeeptoexploitamirror-symmetryplanethroughtheoriginperpendiculartothe

y

direction.这告诉Meep利用一个通过原点的垂直

y方向镜像对称面。Meepdoes

notcheck

whetheryoursystemreallyhasthissymmetry—youshouldonlyspecifysymmetriesthatreally

不检查

您的系统是否真的有这种对称性,你应

该只指定对称性,真正维护你的结构和你的源代码。

Everythingelseaboutyoursimulationisthesame:youcanstillgetthefieldsatanypoint,the

outputfilestillcoversthewholering,andtheharminvoutputsareexactlythesame.其他一切有

关你的模拟是相同的:,你仍然可以在任何时候字段,输出文件仍然覆盖整个环,harminv

输出是完全相同的。Internally,however,Meepisonlydoingcomputationswithhalfofthe

structure,andthesimulationisaroundtwiceasfast(YMMV).但是,Meep在内部,只有做与结

构的一半计算,模拟是围绕两次快速(因人而异)。

Ingeneral,thesymmetryofthesourcesmayrequiresomephase.在一般情况下,对称的来源可能

需要一定的阶段。Forexample,ifoursourcewasinthe

y

directioninsteadofthe

z

direction,

thenthesourcewouldbe

odd

undermirrorflipsthroughthe

x

axis.例如,如果我们的源代码是

y方向上,而

不是

z方向,那么源将镜像

下的

奇数通过X轴翻转。Wewouldspecifythisby

(makemirror-sym(directionY)(phase-1)).我们将指定此(makemirror-sym(directionY)(phase

-1))。SeetheMeepreferenceformoresymmetrypossibilities.见Meep参考更多的对称性的可

能性。

Inthiscase,weactuallyhavealotmoresymmetrythatwecouldpotentiallyexploit,ifweare

willingtorestrictthesymmetryofoursource/fieldstoaparticularangularmomentum(ieangular

dependence

e

im

φ

).在这种情况下,我们其实有更多的对称性,我们可能会利用,如果我们愿

即依赖

意以我们的源/领域的对称性限制到一个特定的角动量(

口米φ)。Seealso:Ring

resonatorincylindricalcoordinatesforhowtosolveformodesofthiscylindricalgeometrymuch

moreefficiently.另见:在圆柱坐标系中环谐振器,如何更有效地解决这个圆柱几何模式。

[edit][编辑]

Moreexamples更多的例子

TheexamplesabovesufficetoillustratethemostbasicfeaturesofMeep.上面的例子足以说明

Meep最基本的特征。However,therearemanymoreadvancedfeaturesthathavenotbeen

demonstratedhere.然而,这里还没有被证明有许多更先进的功能。So,wehopetoadd,over

time,asequenceofexamplesthatexhibitmorecomplicatedstructuresandcomputational

techniques.因此,我们希望,随着时间的推移,表现出更复杂的结构和计算技术的一个例子

的顺序添加。Theoneswehavesofararelistedbelow.那些到目前为止,我们已列出如下。

Ifyouhaveagoodexampleyouwouldliketoshare,

feelfree

toregisterforausernameandlog

in,andthenaddalinktoanewpageforyourexamplebelow.如果你有一个很好的例子,你想和

大家分享

,觉得

免费注册一个用户名和登录,然后在下面添加一个链接到你的榜样了新的

一页。(Pleaseprefixthelinkwith"MeepTutorial/".

Simple

examplesillustratinga

specific

conceptarepreferred.)(请前缀“Meep教程/”的联系,

说明了一个特定的概念

简单的例子是

首选。)

•MeepTutorial/RingresonatorincylindricalcoordinatesMeep教程/环谐振器在圆柱坐

•MeepTutorial/Banddiagram,resonantmodes,andtransmissioninaholeywaveguide

Meep教程/带图,共振模式,并在一个多孔波导传输

•MeepTutorial/Thirdharmonicgeneration(Kerrnonlinearity)Meep教程/第三谐波产生

(Kerr非线性)

•MeepTutorial/MaterialdispersionMeep教程/材料色散

[edit][编辑]

Editorsandctl编辑和CTL

Itisusefultohaveemacsuseitsscheme-modeforeditingctlfiles,sothathittingtabindents

nicely,oesthisautomaticallyforfilesendingwith".scm";todoitforfiles

endingwith".ctl"aswell,addthefollowinglinestoyour~/.emacsfile:这是非常有用的emacs

使用scheme-mode编辑CTL文件,以便很好地击中选项卡缩进,和等。emacs结尾的文件

自动“.scm做结尾的文件”.ctl“以及,添加以下几行到您的~/.emacs:

(if(assoc".ctl"auto-mode-alist)(如果(ASSOC“。CTL”自动模式alist)

nil零

(nconcauto-mode-alist'((".ctl".scheme-mode))))(nconc自动模式-alist'((“。CTL。”

计划模式))))

(Incidentally,emacsscriptsarewrittenin"elisp,"alanguagecloselyrelatedtoScheme.)(顺便说

一下,emacs脚本是写在“elisp的,”语言密切相关计划。)

Ifyoudon'tuseemacs(orderivativessuchasAquamacs),itwouldbegoodtofindanothereditor

thatsupportsaSchememode.如果你不使用emacs(或如衍生工具Aquamacs),这将是很好

找到另一个编辑器,支持计划模式。Forexample,jEditisafree/open-sourcecross-platform

editorwithScheme-syntaxsupport.例如,jEdit是一个自由/开源的跨平台支持计划-语法编辑

器。AnotheroptionisGNUgedit(forGNU/LinuxandUnix);infact,MoosaviMehr

hasdonatedahilightingmodeforMeep/MPBthatspeciallyhighlightstheMeep/MPBkeywords.

另一种选择是gedit中的GNU(GNU/Linux和Unix);事实上,Moosavi梅尔捐

赠了Meep/MPB高亮显示的模式,特别强调Meep/MPB的关键字。

Retrievedfrom"/wiki//Meep_Tutorial

/wiki//Meep_Tutorial“

"取自“


本文标签: 波导 模式 时间 输出