~emmanuel-lambert/python-meep/intec

« back to all changes in this revision

Viewing changes to doc/html/python_meep_documentation.html

  • Committer: emmanuel.lambert at ugent
  • Date: 2010-01-19 13:14:50 UTC
  • Revision ID: emmanuel.lambert@intec.ugent.be-20100119131450-7ee8icbh1rdjd095
update of documentation / restoring INTEC specific init files / logo

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
* EL-01/12/2009 : alignment with version 0.8 - III
57
57
* EL-01/12/2009 : release 1.0 / added info about environment variables for inline C/C++
58
58
* EL-02/12/2009 : minor change for complex_time function + section 1 | v3
59
 
* EL-15/01/2010 : missing parameter library_dirs in pars 3.3.2 and 8.3</pre>
 
59
* EL-15/01/2010 : missing parameter library_dirs in pars 3.3.2 and 8.3
 
60
* EL-19/10/2010 : example for exploiting mirror symmetry / added information on how to shift the origin</pre>
60
61
</div>
61
62
<p>Meep is a free finite-difference time-domain (FDTD) simulation software package developed at MIT to model electromagnetic systems.
62
63
The default scripting language for Meep is Scheme.</p>
146
147
</li>
147
148
</ul>
148
149
</blockquote>
149
 
<p class="last">e.g.: <tt class="docutils literal"><span class="pre">v</span> <span class="pre">=</span> <span class="pre">volone(6,</span> <span class="pre">10)</span></tt> defines a 1-dimensional computational volume of lenght 6, with 10 pixels per distance unit.</p>
 
150
<p class="last">e.g.: <tt class="docutils literal"><span class="pre">v</span> <span class="pre">=</span> <span class="pre">volone(6,</span> <span class="pre">10)</span></tt> defines a 1-dimensional computational volume of length 6, with 10 pixels per distance unit.</p>
150
151
</dd>
151
152
</dl>
152
153
</div>
173
174
</li>
174
175
<li><dl class="first docutils">
175
176
<dt><em>optional</em> <span class="classifier-delimiter">:</span> <span class="classifier">a function defining a symmetry to exploit, in order to speed up the FDTD calculation (reference to an object of type <tt class="docutils literal"><span class="pre">symmetry</span></tt>). The following predefined functions can be used to create a <tt class="docutils literal"><span class="pre">symmetry</span></tt> object:</span></dt>
176
 
<dd><ul class="first last simple">
 
177
<dd><ul class="first simple">
177
178
<li><tt class="docutils literal"><span class="pre">identity</span></tt> : no symmetry</li>
178
179
<li><tt class="docutils literal"><span class="pre">rotate4(direction,</span> <span class="pre">grid_volume)</span></tt> : defines a 90° rotational symmetry with &#8216;direction&#8217; the axis of rotation.</li>
179
180
<li><tt class="docutils literal"><span class="pre">rotate2(direction,</span> <span class="pre">grid_volume)</span></tt> : defines a 180° rotational symmetry with &#8216;direction&#8217; the axis of rotation.</li>
180
181
<li><tt class="docutils literal"><span class="pre">mirror(direction,</span> <span class="pre">grid_volume)</span></tt> : defines a mirror symmetry plane with &#8216;direction&#8217; normal to the mirror plane.</li>
181
182
<li><tt class="docutils literal"><span class="pre">r_to_minus_r_symmetry</span></tt> : defines a mirror symmetry in polar coordinates</li>
182
183
</ul>
 
184
<p class="last">You can apply a phase factor to the symmetry simply by using the <tt class="docutils literal"><span class="pre">*</span></tt> operator, e.g. if <tt class="docutils literal"><span class="pre">symm</span></tt> is a symmetry object, then you can apply a phase factor of -1 as follows : <tt class="docutils literal"><span class="pre">symm</span> <span class="pre">=</span> <span class="pre">symm</span> <span class="pre">*</span> <span class="pre">complex(-1,0)</span></tt>.</p>
183
185
</dd>
184
186
</dl>
185
187
</li>
194
196
<dd><tt class="docutils literal"><span class="pre">s</span> <span class="pre">=</span> <span class="pre">structure(v,</span> <span class="pre">one,</span> <span class="pre">no_pml(),</span> <span class="pre">identity(),</span> <span class="pre">1)</span></tt></dd>
195
197
</dl>
196
198
<p>Another example : <tt class="docutils literal"><span class="pre">s</span> <span class="pre">=</span> <span class="pre">structure(v,</span> <span class="pre">EPS,</span> <span class="pre">pml(0.1,Y)</span> <span class="pre">)</span></tt> with EPS a custom material function, which is explained in the note below.</p>
 
199
<p>An example of exploiting symmetry:</p>
197
200
</blockquote>
 
201
<div class="highlight-python"><div class="highlight"><pre><span class="c">#we define a computational volume of 16x32 with resolution 10</span>
 
202
<span class="n">vol</span> <span class="o">=</span> <span class="n">voltwo</span><span class="p">(</span><span class="mf">16</span><span class="p">,</span><span class="mf">32</span><span class="p">,</span><span class="mf">10</span><span class="p">)</span>
 
203
<span class="c">#reposition the origin to the center of the computational volume (symmetry is always defined with relative to the origin)</span>
 
204
<span class="n">vol</span><span class="o">.</span><span class="n">center_origin</span><span class="p">()</span>
 
205
<span class="c">#create a symmetry through the origin with the Y-axis normal to the mirror plane</span>
 
206
<span class="n">symm</span> <span class="o">=</span> <span class="n">mirror</span><span class="p">(</span><span class="n">Y</span><span class="p">,</span> <span class="n">vol</span><span class="p">)</span>
 
207
<span class="c">#apply a phase factor to the symmetry</span>
 
208
<span class="n">symm</span> <span class="o">=</span> <span class="n">symm</span> <span class="o">*</span> <span class="nb">complex</span><span class="p">(</span><span class="o">-</span><span class="mf">1</span><span class="p">,</span><span class="mf">0</span><span class="p">)</span>
 
209
<span class="c">#define the structure and refer to the symmetry with the 4th parameter</span>
 
210
<span class="n">s</span> <span class="o">=</span> <span class="n">structure</span><span class="p">(</span><span class="n">vol</span><span class="p">,</span> <span class="n">EPS</span><span class="p">,</span> <span class="n">pml</span><span class="p">(</span><span class="mf">1.0</span><span class="p">),</span> <span class="n">symm</span><span class="p">)</span>
 
211
</pre></div>
 
212
</div>
198
213
<div class="section" id="defining-a-material-function">
199
214
<h3>3.1. Defining a material function<a class="headerlink" href="#defining-a-material-function" title="Permalink to this headline">¶</a></h3>
200
215
<p>In order to describe the geometry of the waveguide, we have to provide a &#8216;material function&#8217; returning the dielectric variable epsilon as a function of the position (identified by a vector). In python-meep, we can do this by defining a class that inherits from class <tt class="docutils literal"><span class="pre">Callback</span></tt>. Through this inheritance, the core meep library (written in C++) will be able to call back to the Python function which describes the material properties.
1254
1269
</div>
1255
1270
<div class="section" id="differences-between-python-meep-and-scheme-meep-libctl">
1256
1271
<h2><strong>10. Differences between Python-Meep and Scheme-Meep (libctl)</strong><a class="headerlink" href="#differences-between-python-meep-and-scheme-meep-libctl" title="Permalink to this headline">¶</a></h2>
1257
 
<p><strong>note</strong>: this section does NOT apply to the UGent Intec Photonics Research Group (apart from the coordinate system, the default behaviour for us is made consistent with Scheme-Meep)</p>
1258
 
<p>The general rule is that Python-Meep has consistent behaviour with the <strong>C++ core of Meep</strong>.
1259
 
The default version of Python-Meep has 3 differences compared with the Scheme version of Meep :</p>
1260
 
<blockquote>
 
1272
<p><strong>note</strong>: this section does <strong>NOT apply to the UGent Intec Photonics Research Group</strong> (apart from the coordinate system, the default behaviour for us is made consistent with Scheme-Meep)</p>
 
1273
<p>The general rule is that Python-Meep has consistent behaviour with the <strong>C++ core of Meep</strong>.</p>
 
1274
<p>The default version of Python-Meep has 3 differences compared with the Scheme version of Meep :</p>
1261
1275
<ul class="simple">
1262
 
<li>in Python-meep, the center of the coordinate system is in the upper left corner (in Scheme-Meep v1.1.1, the center of the coordinate system is in the middle of your computational volume).</li>
1263
1276
<li>in Python-meep, eps-averaging is disabled by default (see section 3.2 for details on how to enable eps-averaging)</li>
1264
1277
<li>in Python-meep, calculation is done with complex fields by default (in Scheme-Meep v1.1.1, real fields are used by default). You can call function use_real_fields() on your fields-object to enable calculation with real fields only.</li>
 
1278
<li>in Python-meep, the center of the coordinate system is in the upper left corner (in Scheme-Meep v1.1.1, the center of the coordinate system is in the middle of your computational volume). However, by calling the function <tt class="docutils literal"><span class="pre">center_origin()</span></tt> on the computational volume, you can shift the origin to the center.</li>
1265
1279
</ul>
1266
 
</blockquote>
 
1280
<div class="highlight-python"><div class="highlight"><pre><span class="c">#define a computational volume of size 16x32, with resolution 10</span>
 
1281
<span class="n">v</span> <span class="o">=</span> <span class="n">voltwo</span><span class="p">(</span><span class="mf">16</span><span class="p">,</span><span class="mf">32</span><span class="p">,</span><span class="mf">10</span><span class="p">)</span>
 
1282
<span class="c">#shift the origin of the coordinate system to the center of the volume</span>
 
1283
<span class="n">v</span><span class="o">.</span><span class="n">center_origin</span><span class="p">()</span>
 
1284
</pre></div>
 
1285
</div>
1267
1286
<p>On starting your script, Python-Meep will warn you about these differences. You can suppress these warning by setting the global variables <tt class="docutils literal"><span class="pre">DISABLE_WARNING_COORDINATESYSTEM</span></tt>, <tt class="docutils literal"><span class="pre">DISABLE_WARNING_EPS_AVERAGING</span></tt> and <tt class="docutils literal"><span class="pre">DISABLE_WARNING_REAL_FIELDS</span></tt> to  <tt class="xref docutils literal"><span class="pre">True</span></tt>. You can add site-specific customisations to the file <tt class="docutils literal"><span class="pre">meep-site-init.py</span></tt> : in this script, you can for example suppress the warning, or enable EPS-averaging by default.</p>
1268
1287
<p>Add the following code to <tt class="docutils literal"><span class="pre">meep-site-init.py</span></tt> if you want <em>to calculate with real fields only by default</em> :</p>
1269
1288
<div class="highlight-python"><div class="highlight"><pre><span class="c">#by default enable calculation with real fields only (consistent with Scheme-meep)</span>
1290
1309
</div>
1291
1310
</div>
1292
1311
<div class="section" id="feedback-and-comments">
1293
 
<h2><a href="#id3"><span class="problematic" id="id4">**</span></a>11. Feedback and comments **<a class="headerlink" href="#feedback-and-comments" title="Permalink to this headline">¶</a></h2>
1294
 
<p>You may post your comments or remarks about this documentation on the mailinglist <tt class="docutils literal"><span class="pre">meep-discuss&#64;ab-initio.mit.edu</span></tt></p>
 
1312
<h2><strong>11. Feedback and comments</strong><a class="headerlink" href="#feedback-and-comments" title="Permalink to this headline">¶</a></h2>
 
1313
<p>You may post your questions, comments or remarks about this documentation on the general Meep mailinglist : <tt class="docutils literal"><span class="pre">meep-discuss&#64;ab-initio.mit.edu</span></tt></p>
1295
1314
</div>
1296
1315
</div>
1297
1316
 
1328
1347
</li>
1329
1348
<li><a class="reference external" href="#running-in-mpi-mode-multiprocessor-configuration"><strong>9. Running in MPI mode (multiprocessor configuration)</strong></a></li>
1330
1349
<li><a class="reference external" href="#differences-between-python-meep-and-scheme-meep-libctl"><strong>10. Differences between Python-Meep and Scheme-Meep (libctl)</strong></a></li>
1331
 
<li><a class="reference external" href="#feedback-and-comments">**11. Feedback and comments **</a></li>
 
1350
<li><a class="reference external" href="#feedback-and-comments"><strong>11. Feedback and comments</strong></a></li>
1332
1351
</ul>
1333
1352
</li>
1334
1353
</ul>