Monday, March 24, 2014

Spin Wires in Diamond!

Check out our new paper that came out in Nature Nanotechnology!

Sunday, March 2, 2014

Batch Convert Pages to DOCX or PDF

Here are some programs to batch convert Pages files to .docx or .PDF. This is written in applescript, and saved as an "application", so just drag and drop the files you want to convert onto the application.

Choose your desired program to download:
Convert Batch Pages to Docx_v1 --> deletes .pages file that you are converting
Convert Batch Pages to Docx_v2 --> keeps original .pages file that you are converting

Convert Batch Pages to PDF_v1 --> deletes .pages file that you are converting
Convert Batch Pages to PDF_v2 --> keeps original .pages file that you are converting

The code that these applications (droplets) use is this:

on open theFiles
tell application "Pages"
repeat with aFile in theFiles
open aFile
set sourceFolder to POSIX path of aFile
set newsourceFolder to characters 1 thru -8 of sourceFolder as string
set theFolder to newsourceFolder & ".docx"
export front document to POSIX file theFolder as Word
close front document
end repeat
end tell
tell application "Finder"
repeat with aFile in theFiles
delete aFile
end repeat
end tell
end open

Tuesday, May 22, 2012

Diffraction of a Cross

This was an assignment for my E+M class (836) that calculates the diffraction of light around a cross which is expressed exactly by the Fresnel integral:
$E(x,y,z)=\frac{z}{i \lambda}\int E(x',y',0) \frac{e^{ikr}}{r^2}dx'dy'$,

where $E(x',y',0)$ is the electric field of the aperture, and

So, the electric field of a cross would be some amplitude $E(x',y',0) = E_o$ where the cross is located, and $0$ everywhere else. Plug that in, and now you have the diffracted electric field $E(x,y,z)$ everywhere in space...mod-square that to see what our eyes see! In the mathematica file I calculate the intensity on a screen located just 1micron away up to 100 microns away from the aperture screen, and you can gradually see more and more interference. Note that on a screen an "infinite" distance away (called Fraunhofer diffraction) the E-field is just the 2D Fourier transform of the initial electric field!

How to Embed Mathematica CDF in a Blogger Blog Post

In Blogger go to
Template-> Edit HTML-> Click "proceed" when warned about messing with your HTML

Insert the following code after <head>, like in the image below:
<script src='' type='text/javascript'/>

Create a new post, and click Edit HTML for that post (different from the Edit HTML for the template), and then insert the following code into the body of your post where you want a CDF to appear:
<script type="text/javascript" src=""></script> <script type="text/javascript"> var cdf = new cdfplugin(); cdf.embed('', 400, 300); </script>
 Then, publish your post, and it looks like this:

Now to put your CDF in your blog, just change "" to the URL to your CDF, and change the values "400, 300" = "width, height" to the values that best fit your blog.
I get my URL by uploading my CDFs to the "public" folder of my free Dropbox account, and copy-pasting the "public link" of the file.