-
Notifications
You must be signed in to change notification settings - Fork 591
/
antenna-radiation.ctl
63 lines (51 loc) · 2.74 KB
/
antenna-radiation.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
61
62
63
(set-param! resolution 50) ; pixels/μm
(define-param sxy 4)
(define-param dpml 1)
(set! geometry-lattice (make lattice (size (+ sxy (* 2 dpml)) (+ sxy (* 2 dpml)) no-size)))
(set! pml-layers (list (make pml (thickness dpml))))
(define-param fcen 1.0)
(define-param df 0.4)
(define-param src-cmpt Ez)
(set! sources (list (make source
(src (make gaussian-src (frequency fcen) (fwidth df)))
(center 0)
(component src-cmpt))))
(if (= src-cmpt Ex)
(set! symmetries (list (make mirror-sym (direction X) (phase -1))
(make mirror-sym (direction Y) (phase +1)))))
(if (= src-cmpt Ey)
(set! symmetries (list (make mirror-sym (direction X) (phase +1))
(make mirror-sym (direction Y) (phase -1)))))
(if (= src-cmpt Ez)
(set! symmetries (list (make mirror-sym (direction X) (phase +1))
(make mirror-sym (direction Y) (phase +1)))))
(define nearfield-box
(add-near2far fcen 0 1
(make near2far-region (center 0 (* 0.5 sxy)) (size sxy 0))
(make near2far-region (center 0 (* -0.5 sxy)) (size sxy 0) (weight -1))
(make near2far-region (center (* 0.5 sxy) 0) (size 0 sxy))
(make near2far-region (center (* -0.5 sxy) 0) (size 0 sxy) (weight -1))))
(define flux-box
(add-flux fcen 0 1
(make flux-region (center 0 (* 0.5 sxy)) (size sxy 0))
(make flux-region (center 0 (* -0.5 sxy)) (size sxy 0) (weight -1))
(make flux-region (center (* 0.5 sxy) 0) (size 0 sxy))
(make flux-region (center (* -0.5 sxy) 0) (size 0 sxy) (weight -1))))
(run-sources+ (stop-when-fields-decayed 50 src-cmpt (vector3 0 0) 1e-8))
(print "near-flux:, " (list-ref (get-fluxes flux-box) 0) "\n")
(define-param r (/ 1000 fcen)) ; half side length of far-field square box OR radius of far-field circle
(define-param res-ff 1) ; resolution of far fields (points/μm)
(define far-flux (+ (list-ref (flux nearfield-box Y (volume (center 0 r 0) (size (* 2 r) 0 0)) res-ff) 0)
(- (list-ref (flux nearfield-box Y (volume (center 0 (- r) 0) (size (* 2 r) 0 0)) res-ff) 0))
(list-ref (flux nearfield-box X (volume (center r 0 0) (size 0 (* 2 r) 0)) res-ff) 0)
(- (list-ref (flux nearfield-box X (volume (center (- r) 0 0) (size 0 (* 2 r) 0)) res-ff) 0))))
(print "far-flux-box:, " far-flux "\n")
(define-param npts 100) ; number of points in [0,2*pi) range of angles
(map (lambda (n)
(let ((ff (get-farfield nearfield-box (vector3 (* r (cos (* 2 pi (/ n npts)))) (* r (sin (* 2 pi (/ n npts)))) 0))))
(print "farfield:, " n ", " (* 2 pi (/ n npts)))
(map (lambda (m)
(print ", " (list-ref ff m)))
(arith-sequence 0 1 6))
(print "\n")))
(arith-sequence 0 1 npts))