3 from qpms
import Particle
, CTMatrix
, BaseSpec
, FinitePointGroup
, ScatteringSystem
, TMatrixInterpolator
, eV
, hbar
, c
, MaterialInterpolator
, scatsystem_set_nthreads
4 from qpms
.symmetries
import point_group_info
5 from pathlib
import Path
12 if 'SLURM_CPUS_PER_TASK' in os
.environ
:
13 scatsystem_set_nthreads(int(os
.environ
['SLURM_CPUS_PER_TASK']))
16 rewrite_output
= '--rewrite-output' in sys
.argv
18 cyr_part_height
= 50*nm
19 cyr_part_radius
= 50*nm
20 cyr_part_volume
= cyr_part_height
* np
.pi
* cyr_part_radius
**2
21 eqv_sph_radius
= (3/4/np
.pi
*cyr_part_volume
)**(1/3)
23 sym
= FinitePointGroup(point_group_info
['D2h'])
24 bspec
= BaseSpec(lMax
= 2)
25 #tmfile = '/m/phys/project/qd/Marek/tmatrix-experiments/Cylinder/AaroBEC/cylinder_50nm_lMax4_cleaned.TMatrix'
26 materialfile
= '/home/necadam1/wrkdir/repo/refractiveindex.info-database/database/data/main/Au/Johnson.yml'
28 #outputdatadir = '/home/necadam1/wrkdir/AaroBECfinite_new'
29 #outputdatadir = '/u/46/necadam1/unix/project/AaroBECfinite_sph'
30 outputdatadir
= '/home/necadam1/wrkdir/AaroBECfinite_sph'
31 os
.makedirs(outputdatadir
, exist_ok
= True)
32 mi
= MaterialInterpolator(materialfile
)
33 #interp = TMatrixInterpolator(tmfile, bspec, symmetrise = sym, atol = 1e-8)
34 # There is only one t-matrix in the system for each frequency. We initialize the matrix with the lowest frequency data.
35 # Later, we can replace it using the tmatrix[...] = interp(freq) and s.update_tmatrices NOT YET; TODO
37 omega
= float(sys
.argv
[3]) * eV
/hbar
38 sv_threshold
= float(sys
.argv
[4])
40 # Now place the particles and set background index.
41 px
= 571*nm
; py
= 621*nm
46 orig_x
= (np
.arange(Nx
/2) + (0 if (Nx
% 2) else .5)) * px
47 orig_y
= (np
.arange(Ny
/2) + (0 if (Ny
% 2) else .5)) * py
49 orig_xy
= np
.stack(np
.meshgrid(orig_x
, orig_y
), axis
= -1)
51 #tmatrix = interp(omega)
52 tmatrix
= CTMatrix
.spherical_perm(bspec
, eqv_sph_radius
, omega
, mi(omega
), n
**2)
53 particles
= [Particle(orig_xy
[i
], tmatrix
) for i
in np
.ndindex(orig_xy
.shape
[:-1])]
56 ss
= ScatteringSystem(particles
, sym
)
62 for iri
in range(ss
.nirreps
):
63 destpath
= os
.path
.join(outputdatadir
, 'Nx%d_Ny%d_%geV_ir%d.npz'%(Nx
, Ny
, omega
/eV
*hbar
, iri
))
64 touchpath
= os
.path
.join(outputdatadir
, 'Nx%d_Ny%d_%geV_ir%d.done'%(Nx
, Ny
, omega
/eV
*hbar
, iri
))
65 if (os
.path
.isfile(destpath
) or os
.path
.isfile(touchpath
)) and not rewrite_output
:
66 print(destpath
, 'already exists, skipping')
68 mm_iri
= ss
.modeproblem_matrix_packed(k
, iri
)
69 U
, S
, Vh
= np
.linalg
.svd(mm_iri
)
71 print(iri
, ss
.irrep_names
[iri
], S
[-1])
72 starti
= max(0,len(S
) - np
.searchsorted(S
[::-1], sv_threshold
, side
='left')-1)
74 S
=S
[starti
:], omega
=omega
, Vh
= Vh
[starti
:], iri
=iri
, Nx
= Nx
, Ny
= Ny
)
77 Path(touchpath
).touch()
78 # Don't forget to conjugate Vh before transforming it to the full vector!