2019-03-13 23:44:12 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# coding: utf-8
|
2019-06-19 11:57:03 +03:00
|
|
|
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator, scatsystem_set_nthreads
|
2019-03-13 23:44:12 +02:00
|
|
|
from qpms.symmetries import point_group_info
|
|
|
|
import numpy as np
|
|
|
|
import os
|
|
|
|
import sys
|
2019-06-19 11:57:03 +03:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
if 'SLURM_CPUS_PER_TASK' in os.environ:
|
|
|
|
scatsystem_set_nthreads(int(os.environ['SLURM_CPUS_PER_TASK']))
|
2019-03-13 23:44:12 +02:00
|
|
|
nm = 1e-9
|
|
|
|
|
2019-06-19 11:57:03 +03:00
|
|
|
rewrite_output = '--rewrite-output' in sys.argv
|
|
|
|
|
2019-03-13 23:44:12 +02:00
|
|
|
sym = FinitePointGroup(point_group_info['D2h'])
|
|
|
|
bspec = BaseSpec(lMax = 2)
|
2019-06-19 11:57:03 +03:00
|
|
|
tmfile = '/m/phys/project/qd/Marek/tmatrix-experiments/Cylinder/AaroBEC/cylinder_50nm_lMax4_longer.TMatrix'
|
2019-03-13 23:44:12 +02:00
|
|
|
#outputdatadir = '/home/necadam1/wrkdir/AaroBECfinite_new'
|
|
|
|
outputdatadir = '/u/46/necadam1/unix/project/AaroBECfinite_new'
|
|
|
|
os.makedirs(outputdatadir, exist_ok = True)
|
|
|
|
interp = TMatrixInterpolator(tmfile, bspec, symmetrise = sym, atol = 1e-8)
|
|
|
|
# There is only one t-matrix in the system for each frequency. We initialize the matrix with the lowest frequency data.
|
|
|
|
# Later, we can replace it using the tmatrix[...] = interp(freq) and s.update_tmatrices NOT YET; TODO
|
|
|
|
|
|
|
|
omega = float(sys.argv[3]) * eV/hbar
|
|
|
|
sv_threshold = float(sys.argv[4])
|
|
|
|
|
|
|
|
# Now place the particles and set background index.
|
|
|
|
px = 571*nm; py = 621*nm
|
2019-06-19 11:57:03 +03:00
|
|
|
n = 1.52
|
2019-03-13 23:44:12 +02:00
|
|
|
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)
|
2019-06-19 15:09:16 +03:00
|
|
|
#print(tmatrix.m)
|
2019-03-13 23:44:12 +02:00
|
|
|
|
2019-06-19 11:57:03 +03:00
|
|
|
particles = [Particle(orig_xy[i], tmatrix) for i in np.ndindex(orig_xy.shape[:-1])]
|
2019-03-13 23:44:12 +02:00
|
|
|
|
|
|
|
ss = ScatteringSystem(particles, sym)
|
|
|
|
|
|
|
|
k = n * omega / c
|
|
|
|
|
|
|
|
for iri in range(ss.nirreps):
|
2019-06-19 11:57:03 +03:00
|
|
|
destpath = os.path.join(outputdatadir, 'Nx%d_Ny%d_%geV_ir%d.npz'%(Nx, Ny, omega/eV*hbar, iri,))
|
|
|
|
touchpath = os.path.join(outputdatadir, 'Nx%d_Ny%d_%geV_ir%d.done'%(Nx, Ny, omega/eV*hbar, iri,))
|
|
|
|
if (os.path.isfile(destpath) or os.path.isfile(touchpath)) and not rewrite_output:
|
|
|
|
print(destpath, 'already exists, skipping')
|
|
|
|
continue
|
2019-03-13 23:44:12 +02:00
|
|
|
mm_iri = ss.modeproblem_matrix_packed(k, iri)
|
2019-06-19 15:09:16 +03:00
|
|
|
#print(mm_iri)
|
2019-03-13 23:44:12 +02:00
|
|
|
U, S, Vh = np.linalg.svd(mm_iri)
|
2019-06-19 11:57:03 +03:00
|
|
|
del U
|
2019-03-13 23:44:12 +02:00
|
|
|
print(iri, ss.irrep_names[iri], S[-1])
|
2019-03-14 01:34:04 +02:00
|
|
|
starti = max(0,len(S) - np.searchsorted(S[::-1], sv_threshold, side='left')-1)
|
2019-06-19 11:57:03 +03:00
|
|
|
np.savez(destpath,
|
2019-03-14 01:34:04 +02:00
|
|
|
S=S[starti:], omega=omega, Vh = Vh[starti:], iri=iri, Nx = Nx, Ny= Ny )
|
2019-06-19 11:57:03 +03:00
|
|
|
del S
|
|
|
|
del Vh
|
|
|
|
Path(touchpath).touch()
|
2019-03-14 01:34:04 +02:00
|
|
|
# Don't forget to conjugate Vh before transforming it to the full vector!
|
2019-03-13 23:44:12 +02:00
|
|
|
|