orig_y = (np.arange(Ny / 2) + (0 if (Ny % 2) else .5)) * py

orig_xy = np.stack(np.meshgrid(orig_x, orig_y), axis=-1)

omega = ap.omega

bspec = BaseSpec(lMax=a.lMax)
medium = EpsMuGenerator(ap.background_epsmu)
particles = [
    Particle(orig_xy[i], ap.tmgen, bspec)
    for i in np.ndindex(orig_xy.shape[:-1])
]

sym = FinitePointGroup(point_group_info['D2h'])
ss, ssw = ScatteringSystem.create(particles=particles,
                                  medium=medium,
                                  omega=omega,
                                  sym=sym)

wavenumber = ap.background_epsmu.k(
    omega
)  # Currently, ScatteringSystem does not "remember" frequency nor wavenumber

# Mapping between ss particles and grid positions
positions = ss.positions
xpositions = np.unique(positions[:, 0])
assert (len(xpositions) == Nx)
ypositions = np.unique(positions[:, 1])
assert (len(ypositions == Ny))
# particle positions as integer indices
posmap = np.empty((positions.shape[0], 2), dtype=int)
invposmap = np.empty((Nx, Ny), dtype=int)
Пример #2
0
px = 571*nm; py = 621*nm
n = 1.52
Nx = int(sys.argv[1])
Ny = int(sys.argv[2])

orig_x = (np.arange(Nx/2) + (0 if (Nx % 2) else .5)) * px
orig_y = (np.arange(Ny/2) + (0 if (Ny % 2) else .5)) * py

orig_xy = np.stack(np.meshgrid(orig_x, orig_y), axis = -1)

#tmatrix = interp(omega)
tmatrix = CTMatrix.spherical_perm(bspec, eqv_sph_radius, omega, mi(omega), n**2)
particles = [Particle(orig_xy[i], tmatrix) for i in np.ndindex(orig_xy.shape[:-1])]


ss = ScatteringSystem(particles, sym)


k = n * omega / c


for iri in range(ss.nirreps):
    destpath = os.path.join(outputdatadir, 'Nx%d_Ny%d_%geV_ir%d_r%gnm.npz'%(Nx, Ny, omega/eV*hbar, iri, eqv_sph_radius/nm))
    touchpath = os.path.join(outputdatadir, 'Nx%d_Ny%d_%geV_ir%d_r%gnm.done'%(Nx, Ny, omega/eV*hbar, iri, eqv_sph_radius/nm))
    if (os.path.isfile(destpath) or os.path.isfile(touchpath)) and not rewrite_output:
      print(destpath, 'already exists, skipping')
      continue
    mm_iri = ss.modeproblem_matrix_packed(k, iri)
    U, S, Vh = np.linalg.svd(mm_iri)
    del U
    print(iri, ss.irrep_names[iri], S[-1])
Пример #3
0
#Particle positions
orig_x = (np.arange(Nx / 2) + (0 if (Nx % 2) else .5)) * px
orig_y = (np.arange(Ny / 2) + (0 if (Ny % 2) else .5)) * py

orig_xy = np.stack(np.meshgrid(orig_x, orig_y), axis=-1)

bspec = BaseSpec(lMax=a.lMax)
medium = EpsMuGenerator(ap.background_epsmu)
particles = [
    Particle(orig_xy[i], ap.tmgen, bspec)
    for i in np.ndindex(orig_xy.shape[:-1])
]

sym = FinitePointGroup(point_group_info['D2h'])
logging.info("Creating scattering system object")
ss, ssw = ScatteringSystem.create(particles, medium, sym, a.centre * eh)

if a.irrep == 'none':
    iri = None  # no irrep decomposition
    irname = 'full'
    logging.info(
        "Not performing irrep decomposition and working with the full space of dimension %d."
        % ss.fecv_size)
else:
    try:
        iri = int(a.irrep)
    except ValueError:
        iri = ss.irrep_names.index(a.irrep)
    irname = ss.irrep_names[iri]
    logging.info("Using irrep subspace %s (iri = %d) of dimension %d." %
                 (irname, iri, ss.saecv_sizes[iri]))
Пример #4
0
omega = 1.475 * eV / hbar
sv_threshold = 0.5

# Now place the particles and set background index.
px = 571 * nm
py = 621 * nm
n = 1.51
Nx = 5
Ny = 7

orig_x = (np.arange(Nx / 2) + (0 if (Nx % 2) else .5)) * px
orig_y = (np.arange(Ny / 2) + (0 if (Ny % 2) else .5)) * py

orig_xy = np.stack(np.meshgrid(orig_x, orig_y), axis=-1)

tmatrix = interp(omega)
particles = [
    Particle(orig_xy[i], tmatrix) for i in np.ndindex(orig_xy.shape[:-1])
]

ss = ScatteringSystem(particles, sym)
k = n * omega / c

for iri in range(ss.nirreps):
    mm_iri_orig = ss.modeproblem_matrix_packed(k, iri, version=None)
    mm_iri_alt = ss.modeproblem_matrix_packed(k, iri, version='R')
    mm_iri_paral = ss.modeproblem_matrix_packed(k, iri, version='pR')
    print(np.amax(abs(mm_iri_orig - mm_iri_alt)),
          np.amax(abs(mm_iri_orig - mm_iri_paral)))
Пример #5
0
orig_x = [0]
orig_y = [0]
orig_xy = np.stack(np.meshgrid(orig_x, orig_y), axis=-1)

omegas = ap.omegas

logging.info("%d frequencies from %g to %g eV" %
             (len(omegas), omegas[0] / eh, omegas[-1] / eh))

bspec = BaseSpec(lMax=a.lMax)
nelem = len(bspec)
# The parameters here should probably be changed (needs a better qpms_c.Particle implementation)
pp = Particle(orig_xy[0][0], ap.tmgen, bspec=bspec)

ss, ssw = ScatteringSystem.create([pp],
                                  ap.background_emg,
                                  omegas[0],
                                  latticebasis=ap.direct_basis)
k = np.array([0., 0., 0])
# Auxillary finite scattering system for irrep decomposition, quite a hack
ss1, ssw1 = ScatteringSystem.create([pp],
                                    ap.background_emg,
                                    omegas[0],
                                    sym=FinitePointGroup(
                                        point_group_info[thegroup]))

wavenumbers = np.empty(omegas.shape)
SVs = [None] * ss1.nirreps
for iri in range(ss1.nirreps):
    SVs[iri] = np.empty(omegas.shape + (ss1.saecv_sizes[iri], ))
for i, omega in enumerate(omegas):
    ssw = ss(omega)
Пример #6
0
a1 = ap.direct_basis[0]
a2 = ap.direct_basis[1]

#Particle positions
orig_x = [0]
orig_y = [0]
orig_xy = np.stack(np.meshgrid(orig_x, orig_y), axis=-1)

bspec = BaseSpec(lMax=a.lMax)
# The parameters here should probably be changed (needs a better qpms_c.Particle implementation)
pp = Particle(orig_xy[0][0], ap.tmgen, bspec=bspec)
par = [pp]

ss, ssw = ScatteringSystem.create(par,
                                  ap.background_emg,
                                  ap.allomegas[0],
                                  latticebasis=ap.direct_basis)

## Plane wave data
a.theta = np.array(a.theta)
dir_sph_list = np.stack((np.broadcast_to(
    1, a.theta.shape), a.theta, np.broadcast_to(a.phi, a.theta.shape)),
                        axis=-1)
sψ, cψ = math.sin(a.psi), math.cos(a.psi)
sχ, cχ = math.sin(a.chi), math.cos(a.chi)
E_sph = (0., cψ * cχ + 1j * sψ * sχ, sψ * cχ + 1j * cψ * sχ)

dir_cart_list = sph2cart(dir_sph_list)
E_cart_list = sph_loccart2cart(E_sph, dir_sph_list)

nfreq = len(ap.allomegas)
Пример #7
0
np.random.seed(666)
dbgmsg_enable(2)

part_radius = 80e-9
p = 1580e-9

set_gsl_pythonic_error_handling()

sym = FinitePointGroup(point_group_info['D4h'])
bspec1 = BaseSpec(lMax=3)
medium = EpsMuGenerator(EpsMu(1.52**2))
t1 = TMatrixGenerator.sphere(medium,
                             EpsMuGenerator(lorentz_drude['Au']),
                             r=part_radius)
p1 = Particle((0, 0, 0), t1, bspec=bspec1)
ss, ssw = ScatteringSystem.create([p1], EpsMuGenerator(EpsMu(1.52**2)),
                                  1.4 * eh, sym)

points = np.random.random((100, 3)) * p
points = points[np.linalg.norm(points, axis=-1) > part_radius]
t, l, m = bspec1.tlm()

fails = 0

for i in range(ss.fecv_size):
    fvc = np.zeros((ss.fecv_size, ), dtype=complex)
    fvc[i] = 1

    E = ssw.scattered_E(fvc, points)
    E_alt = ssw.scattered_E(fvc, points, alt=True)
    diff = abs(E - E_alt)
    reldiffavg = np.nanmean(diff / (abs(E) + abs(E_alt)))
Пример #8
0
                "A2'":"$A_2'$", 
                "B1'":"$B_1'$",
                "E'":"$E'$",
                "E''":"$E''$",}

dbgmsg_enable(DebugFlags.INTEGRATION)



omegas = ap.omegas

logging.info("%d frequencies from %g to %g eV" % (len(omegas), omegas[0]/eh, omegas[-1]/eh))

particles = ap.get_particles()

ss, ssw = ScatteringSystem.create(particles, ap.background_emg, omegas[0], latticebasis=ap.direct_basis)
k = np.array([ap.k[0], ap.k[1], 0])
# Auxillary finite scattering system for irrep decomposition, quite a hack
ss1, ssw1 = ScatteringSystem.create(particles, ap.background_emg, omegas[0],sym=FinitePointGroup(point_group_info[ap.little_group]))

wavenumbers = np.empty(omegas.shape)
SVs = [None] * ss1.nirreps
for iri in range(ss1.nirreps):
    SVs[iri] = np.empty(omegas.shape+(ss1.saecv_sizes[iri],))
for i, omega in enumerate(omegas):
    ssw = ss(omega)
    wavenumbers[i] = ssw.wavenumber.real
    if ssw.wavenumber.imag: 
        warnings.warn("Non-zero imaginary wavenumber encountered")
    with pgsl_ignore_error(15): # avoid gsl crashing on underflow; maybe not needed
        ImTW = ssw.modeproblem_matrix_full(k)