HomerReid / scuff-em

A comprehensive and full-featured computational physics suite for boundary-element analysis of electromagnetic scattering, fluctuation-induced phenomena (Casimir forces and radiative heat transfer), nanophotonics, RF device engineering, electrostatics, and more. Includes a core library with C++ and python APIs as well as many command-line applications.
http://www.homerreid.com/scuff-em
GNU General Public License v2.0
125 stars 50 forks source link

Fix a critical bug in scuff-tmatrix (undesired VSWF scaling) #197

Open texnokrates opened 5 years ago

texnokrates commented 5 years ago

Hi Homer,

with scuff-tmatrix, I struggled with inconsistent results while rescaling particle dimensions, as I mentioned in #141. After some lengthy debugging and learning a lot about the internals, I found that the problem was apparently in a forgotten (and effectively swapped) argument in a GetVSWRadialFunctions() call from GetWaveMatrix(). This resulted into a crippled "reference" spherical wave (the one from the scalar product with the surface currents in eq. (52) of your scuffSpherical memo).

All scuff-tmatrix output before this fix is most likely wrong, unfortunately except for unit spheres, which is probably why you didn't notice the problem earlier, benchmarking only against unit sphere Mie-Lorentz solution.

Some little code cleansing and const hygiene done along the way is also included in the PR.

Best regards, Marek

HomerReid commented 5 years ago

Thanks for taking the time to investigate this and especially for contributing a fix! That is a very meticulous and impressive piece of detective work. As you say, I had only ever computed T-matrix elements of spheres, so I would never have caught this. Actually I had not envisioned doing much testing of this feature in general, because I had mostly convinced myself that computing T-matrix elements for non-spherical bodies was not a particularly useful thing to do in SCUFF-EM and that this capability would not attract much interest among users---something I obviously got wrong!

I have been totally overwhelmed by a separate project that has unfortunately forced a total hiatus of work on SCUFF-EM for the past several months, but finally the week after next I will be back to pick up where I had trailed off midstream on the tasks of implementing a full-featured python interface and modernizing the unit-test suite. I will write a test that exercises your bugfix and confirm that it fails/passes before/after I merge your PR. I will also be soliciting input from users on what they are doing or would like to be doing with SCUFF, and hope to hear about the goals of your T_matrix studies.

Thanks again for devoting so much time and effort to identifying and fixing this issue.

baptiste commented 3 years ago

I'd be very keen to see this PR merged into the main branch; we've developed a superposition T-matrix code for multiple-scattering calculations and besides our built-in spheres and spheroids it'd be quite nice to be able to import T-matrices from arbitrary particle shapes as input.