



1. Electrostatics of a spherical shellFor our first example, we'll consider the electrostatics of a spherical dielectric shell in a constant electric field. (By "electrostatics" we really mean the lowfrequency limit of a fullwave calculation, and we approximate our "constant electric field" by the field of a plane wave, which at our low frequency is essentially constant over the size of the object.) This geometry can be treated analytically, and is discussed thoroughly as an example of a scuffscatter calculation. Our goal here will be to reproduce in python what we needed to use a shell script to do in scuffscatter  namely, to compute the electric field at the origin as a function of the shell permittivity.
The following script is available in the
scuffem distribution as the file
import sys sys.path.append("/path/to/scuffeminstallation/lib/python2.7/sitepackages"); import scuff; import numpy.linalg; # create the geometry, preload the cache G = scuff.RWGGeometry("SphericalShell.scuffgeo"); scuff.PreloadCache("SphericalShell.cache"); Omega=0.001; # create the incident field PW=scuff.PlaneWave([0,0,1],[1,0,0]); # read in matrix of evalpoint coordinates X=scuff.HMatrix("CenterPoint") # loop over shell permittivity values for Eps in range(2,102,2): # set shell permittivity G.SetEps("OuterSphere",Eps); # set up and solve the BEM problem M=G.AssembleBEMMatrix(Omega); RHS=G.AssembleRHSVector(Omega, PW); KN=numpy.linalg.solve(M,RHS); # compute and print scattered fields # (note Fields is a 6element array, whose third element is Ez) Fields = G.GetFields(PW, KN, Omega, X ); print Eps, Fields[0][2].real # clean up del M del RHS del KN del Fields A sample run looks like this:
% python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> execfile("PythonScript") 2 0.911366542492 4 0.695193402985 6 0.551800770349 8 0.455746982211 10 0.387685173336 12 0.337125356655 ...
2. Maxwell stress tensor near a hole in a metallic plate

Accessing the scuffEM core library from python programs, by Homer Reid 

Last Modified: 11/16/16 