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
128 stars 51 forks source link

Fix caspol, excluding direct field in DGF and allowing XikBloch mode #227

Open congzlwag opened 4 years ago

congzlwag commented 4 years ago

scuff-caspol was not able to calculate compact geometries as was in 9c6d0cb , not even for a simple square slab. It turns out there are several data type mismatch, and a bug that the dyadic Green's function should have been the scattering part only.

220 is a parent of this pull request.

Data type mismatches:

M->LUSolve(RFSource) in GetDyadicGFs.cc : M was real, RFSource is complex

XMatrix in RWGGeometry::GetDyadicGFs: created as complex but based on memory of double array

XBuffer is a pointer to a double array, but XMatrix was created as HMatrix XMatrix(1,6,LHM_COMPLEX,LHM_NORMAL,XBuffer) . It is verified from the source that XMatrix being complex is unnecessary. Fixed by 44e48b3 .

Direct field should have been excluded when calculating Dyadic Green's Function for caspol

6fb404e fixed this. There must be an explicit ScatterOnly=true .

With these patches, scuff-caspol is able to calculate the potential by a finite PEC slab, and the outcome is very close to the outcome from setting --PECPlate (which invokes a closed form DGF) at those locations close to the slab.

congzlwag commented 4 years ago

Update May 21st

In principle we only need one-point DGF, so a7070c0 and 237df82 have reshaped the XMatrix passed into GetDyadics to be (1,3), which hints TwoPointDGF=false later on.

To prune unnecessary memory cost, for compact geometry RFSource, RFDest and M are now all real valued. 00cfc22 , 181ffcb , c5cc8f4 and 79d592e did this.

Later on I realized that in the --XikBlochFile mode, the polarizability was never looked up. Instead, it is loaded only in GetXiIntegrand, which is why this is not a problem in --XiFile mode nor in the full integration mode. To solve it, I separated this procedure into LoadPolarizability, which is called right before the calculation at a certain imaginary frequency, including GetXiIntegrand and GetCPIntegrand . 7bfb0f8 , 97f24be , 81bda29 , 030b1aa and 692739c did this.