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

Nan output for E-field of a metallic sphere #130

Open amrit-poudel opened 7 years ago

amrit-poudel commented 7 years ago

I am trying to compute the E-field due to a point (electric) dipole in the vicinity (between 1 to 10 microns away from the surface of a sphere) of a metallic (Al) sphere. Sphere radius = 10 micron. Angular frequency = 1 (scuff-em units) --> ~ 3e14 rad/s.

However, the output from my simulation (using scuffem library) is all NaN (both real and imaginary parts of the E-field). I am not sure why this is the case. While I understand that the real part of the field diverges (if source point = field point), the imaginary part must stay finite. I will appreciate any suggestions on how to resolve this error. Thank you.

// Source https://github.com/amrit-poudel/Boundary_Integral_Method/blob/master/Script_sphere_bem.cpp

https://github.com/amrit-poudel/Boundary_Integral_Method/blob/master/Sphere.scuffgeo

https://github.com/amrit-poudel/Boundary_Integral_Method/blob/master/Sphere.geo

HomerReid commented 7 years ago

The implementation of PointSource::GetFields() is not sophisticated enough to know that the imaginary parts of the fields at the source point are finite even as the real part is infinite. One way around this would be to displace the observation point by a small distance from the source point. I think a better way would be to ask SCUFF-EM to compute only the scattered fields, then add in the imaginary parts of the incident fields by hand, since those can be written down in closed form.

Also, you should probably be using the API routine GetDyadicGFs, which will do the same thing that your code is doing but using a more efficient algorithm. It's not well documented in the online API documentation, but the interface should be self-explanatory, and you can look at the source code for SCUFF-LDOS to see how it is used in practice. Feel free to ask any questions about it here.