Пример #1
0
#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])
    starti = max(0,len(S) - np.searchsorted(S[::-1], sv_threshold, side='left')-1)
    np.savez(destpath,
        S=S[starti:], omega=omega, Vh = Vh[starti:], iri=iri, Nx = Nx, Ny= Ny )
    del S
    del Vh
    Path(touchpath).touch()
    # Don't forget to conjugate Vh before transforming it to the full vector!

Пример #2
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)))