Because I wanted to be able to do quick Mie calculations without needing to compile Mie code each and every time, I created an interactive web page that allows me (and you!) to do your own Mie scattering calculations!
This does not help you much if you need to run many simulations, or you actually want to numbers from the simulation. Let me state that the best Mie codes are in Fortran. Period. The C versions have not been validated nearly as rigorously.
I particularly recommend Wiscombe's code, which used to be on-line, but it has been moved so the link is gone. So, to help, I zipped the version that I had and you can do with it what you will.
If you must have C code, then you can either use a the Fortran code with a FORTRAN-to-C converter, or write your own. I am embarrassed to say that I wrote my own. I have used Wiscombe's Mie testing data to validate this code and I can say that it only fails in a few extreme cases. These fail because FORTRAN has much better extended precision support than C. Perhaps if all the variables were converted from doubles to "long doubles" then these errors might go away. In any case, the code that I wrote is used with the interactive calculator above.
So I looked at my hard disk to see when I did this work. I was reminded that I translated the Bohren and Huffman code into Pascal in 1990, but did not rewrite everything in C using more robust algorithms until 1995.
The source code is written in CWEB, which allows excellent documentation of scientific programs. Basically, there is a program 'ctangle' that converts the cweb code to C. There is another program 'cweave' that converts the cweb code to TeX. This then generates really nice documentation, however if you are using the C code directly it means that you see none of my comments. Since I never look at the C source, it does not bother me.
Basically, you just download the code and type 'make'. There are a bunch of command-line options which can be found by running mie with the option '-h'. This is what I use, but it may not be your cup of tea. (Thanks to Michael V. for pointing out the mistake in calculation of the anisotropy that is now fixed in version 2-4-0.)
Steve Jacques and Tony Durkin translated the Fortran code written in Bohren's book on Mie Scattering into ANSI C in September of 1993. It is pretty easy to get running because it just has a single code file 'miesphr.c'.
A useful MATLAB version of Mie theory for homogeneous spheres was prepared by Christian Maetzler in 2002, based on the appendix in Bohren and Huffman (1982).
Matzler's program mie.m utilizes his subroutine mie_abcd.m. In 2010, Steve Jacques prepared a subroutine getMieScatter.m that calls mie.m for one wavelength, and a program demoMie.m that iteratively calls getMieScatter.m for a series of wavelengths and 3 particle sizes, and plots the scattering, anisotropy and reduced scattering versus wavelength.
© 2012 Scott Prahl