-
Notifications
You must be signed in to change notification settings - Fork 591
/
oblique-source.ctl
60 lines (49 loc) · 2.82 KB
/
oblique-source.ctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(set-param! resolution 50) ; pixels/μm
(set! geometry-lattice (make lattice (size 14 14 no-size)))
(set! pml-layers (list (make pml (thickness 2))))
; rotation angle (in degrees) of waveguide, counter clockwise (CCW) around z-axis
(define-param rot-angle 20)
(set! rot-angle (deg->rad rot-angle))
(set! geometry (list (make block
(center 0 0 0)
(size infinity 1 infinity)
(e1 (rotate-vector3 (vector3 0 0 1) rot-angle (vector3 1 0 0)))
(e2 (rotate-vector3 (vector3 0 0 1) rot-angle (vector3 0 1 0)))
(material (make medium (epsilon 12))))))
(define-param fsrc 0.15) ; frequency of eigenmode or constant-amplitude source
(define-param kx 0.4) ; initial guess for wavevector in x-direction of eigenmode
(define-param bnum 1) ; band number of eigenmode
(define kpoint (rotate-vector3 (vector3 0 0 1) rot-angle (vector3 kx 0 0)))
(define-param compute-flux? true) ; compute flux (true) or output the field profile (false)
(define-param eig-src? true) ; eigenmode (true) or constant-amplitude (false) source
(set! sources (list
(if eig-src?
(make eigenmode-source
(src (if compute-flux? (make gaussian-src (frequency fsrc) (fwidth (* 0.2 fsrc))) (make continuous-src (frequency fsrc))))
(center 0 0 0)
(size 0 14 0)
(direction (if (= rot-angle 0) AUTOMATIC NO-DIRECTION))
(eig-kpoint kpoint)
(eig-band bnum)
(eig-parity (if (= rot-angle 0) (+ EVEN-Y ODD-Z) ODD-Z))
(eig-match-freq? true))
(make source
(src (if compute-flux? (make gaussian-src (frequency fsrc) (fwidth (* 0.2 fsrc))) (make continuous-src (frequency fsrc))))
(center 0 0 0)
(size 0 2 0)
(component Ez)))))
(if (= rot-angle 0)
(set! symmetries (list (make mirror-sym (direction Y)))))
(if compute-flux?
(let ((tran (add-flux fsrc 0 1 (make flux-region (center 5 0 0) (size 0 14 0)))))
(run-sources+ 50)
(display-fluxes tran)
(let ((res (get-eigenmode-coefficients tran
(list 1)
#:eig-parity (if (= rot-angle 0) (+ ODD-Z EVEN-Y) ODD-Z)
#:direction NO-DIRECTION
#:kpoint-func (lambda (f n) kpoint))))
(print "mode-coeff-flux:, " (sqr (magnitude (array-ref (list-ref res 0) 0 0 0))) "\n")))
(run-until 100 (in-volume (volume (center 0 0 0) (size 10 10 0))
(at-beginning output-epsilon)
(at-end output-efield-z))))