Thursday, April 9, 2015

Appendix - A beginner's guide to calculating photonic band diagrams: Getting setup

Calculating Photonic Band Structures Using MIT’s Photonic Bands Package (MPB)


1. Getting setup (Introduction, Getting Linux, Getting MPB, Running MPB)

INTRODUCTION
Photonic band diagrams are directional and frequency dependent plots of optical modes within a periodic material that are valuable in understanding a material’s photonic properties.  MPB is a free software package designed specifically for calculating a photonic crystal’s photonic band structure, but includes other useful functionality, that must be run in the Linux environment.  This document gives an overview of the steps required to calculate a photonic band diagram, in “How-To” fashion.  While the instructions here should be detailed enough to calculate a simple band diagram, they should not replace the excellent tutorial instructions published on the web along with the MPB software. This brief guide is intended to be even more basic, for somebody who may have never used Linux before.

GETTING LINUX
Linux is an operating system, largely developed and maintained by a global community of computer users committed to the idea that software should be free.  It used to be that getting, installing, and using Linux required a lot of frustration and learning.  Now, there are several very easy ways to get and install versions of Linux for a Windows user to begin with.

  1. Download the Linux installer for Windows.  Certain distributions of Linux have been specially developed for people starting to use it and who are used to Windows.  Ubuntu is user friendly, has excellent support, and is easy to install.  Go to http://www.ubuntu.com/ and follow the instructions to get Ubuntu.  One of the options is “Run with Windows.” This doesn’t mean run Linux WITHIN Windows, it means have the ability to install and uninstall it within Windows. In other words, Linux and Windows will not both be running at the same time with this choice. This is the easiest option to install Linux.  You will decide at boot up which operating system you want to use, simply select Ubuntu.
  2. Download and burn the Linux installer to a disk or USB. This will give you the option to install Linux on its own, without Windows. You can use it to install Linux on a computer with Windows, but keep in mind that it will replace Window’s boot manager (the bit of software that right after you turn on your computer knows where to look for operating systems) with Linux’s boot manager GRUB2. There is nothing wrong with this method, it is the one the author uses, but keep in mind that it can be tricky if you ever want to go back to having only Windows.
  3. Run Linux natively within Windows. You can download software that runs Linux within the Windows environment.  It isn’t exactly an emulator, but a “compatibility layer” between Linux and Windows.  The author has used this method as well with andLinux http://www.andlinux.org/ and found it to be fine for most routine calculations.
  4. Run Linux within an Emulator. You can download a free computer emulator, a virtual box, http://www.virtualbox.org/ from SunMicrosystems. This creates a virtual computer within Windows that you can boot up as a program, and install Linux on using a CD or a USB key just like you would on a real computer. Of course, the virtual computer shares resources with the real computer so that both are running with less than the whole.  For example, if the computer has 12 logical cores and 6 GB of ram, virtual box is used, and the resources are split evenly, both Linux and Windows would have 6 logical cores and 3 GB ram. This situation is fine unless the computer’s resources are small. Also, the difference between using 6 cores and 12 cores on a calculation can be significant depending on how large the calculation is.


GETTING MPB
Within Linux, getting the MPB software is easy.  Each distribution or version of Linux comes with a software package manager, a localized and organized way to download, install, and uninstall programs.  This is one of the nicest features of Linux, all the software you could ever want to download and install is cataloged.  Within the software package manager (called "Ubuntu Software Center" in Ubuntu) search for MPB.  The latest version of MPB should show up, which you should simply click and select install.  The installer may ask you for your password and if you are okay with installing all of the other programs that MPB needs to work properly.  After installing MPB, it would be useful to install Mayavi2 which is used to visualize 3 dimensional dielectric functions.

RUNNING MPB, NAVIGATING IN LINUX

MPB, like many programs in Linux, is run from the command line or terminal.  When linux installs software, it connects the name of the program with its location on the hard drive so that the program may be executed from any folder.  For example, when the terminal is opened the default location is /home/username, MPB can be executed from there by simply typing "mpb" (no quotation marks and lowercase, case is important in Linux).  While a band structure calculation can be done interactively at the command prompt (see the MPB tutorial), it is much more useful to enter all of the information needed for the calculation into a text file (called a control file), and pass the control file to the program as it is executed, like this: "mpb opal.ctl" where opal.ctl would be the text file with all the instructions.  It is beneficial to keep all of your control file together in a folder.  It is recommended that this folder is kept on a hard drive readable by Windows.  By default, the partition on which Linux is installed is not readable by Windows, but Linux can read the Windows partition.  If all of your research is on the C: drive in Windows, then keep your files there.  Navigate to the folder on your Windows partition using cd and ls commands in the terminal Window.  For example, see the following commands entered in the following terminal window, where everything following the $ symbol was typed:

navigating in Linux MPB


*This tutorial was created in 2010, by the author as he left graduate school. The intended audience was whatever graduate student would follow him, who he assumed would have no knowledge of Linux

2 comments: