(define-param d (/ (sqrt 3) 2))
(define-param N 17)
(define-param sy (* N d)) ; the (odd) number of lateral supercell periods
(define-param dpml 1)
(define-param pad 1)
(define-param sx (+ (* (+ pad dpml) 2) N))
(define-param eps 12) ; the dielectric constant of the rods
(define-param r 0.45) ; the rod radius in the bulk crystal
(define-param rc 0.21)
(define-param s 3)
(set! geometry-lattice (make lattice (size sx sy no-size)))
(set! geometry
(append
(list (make block (center 0 (* 0.5 d))
(size sx (* 2 d) infinity)
(material (make dielectric (epsilon eps)))))
(geometric-object-duplicates (vector3 1 0) 0 (/ (- N 1) 2)
(make cylinder (center 0 0) (radius r) (height infinity)
(material air)))
(geometric-object-duplicates (vector3 -1 0) 0 (/ (- N 1) 2)
(make cylinder (center 0 0) (radius r) (height infinity)
(material air)))
(geometric-object-duplicates (vector3 1 0) 0 (/ (- N 1) 2)
(make cylinder (center 0.5 (* 1 d)) (radius r) (height infinity)
(material air)))
(geometric-object-duplicates (vector3 -1 0) 0 (/ (- N 1) 2)
(make cylinder (center -0.5 (* 1 d)) (radius r) (height infinity)
(material air)))))
(set! geometry (geometric-objects-lattice-duplicates geometry infinity (* 2 d) infinity))
(set! geometry (append geometry
(geometric-object-duplicates (vector3 1 0) 0 (/ (- N 1) 2)
(make cylinder (center 0 0) (radius r) (height infinity)
(material (make dielectric (epsilon eps)))))
(geometric-object-duplicates (vector3 -1 0) 0 (/ (- N 1) 2)
(make cylinder (center 0 0) (radius r) (height infinity)
(material (make dielectric (epsilon eps)))))
(geometric-object-duplicates (vector3 1 0) 0 (- s 1)
(make cylinder (center 1 0) (radius rc) (height infinity)
(material air)))
(geometric-object-duplicates (vector3 -1 0) 0 (- s 1)
(make cylinder (center -1 0) (radius rc) (height infinity)
(material air)))
))
(set! pml-layers (list (make pml (thickness dpml))))
(set-param! resolution 20)
(define-param fcen 0.3629) ; pulse center frequency
(define-param df 0.2) ; pulse width (in frequency)
(define-param nfreq 500) ; number of frequencies at which to compute flux
; false = transmission spectrum, true = resonant modes:
(define-param compute-mode? false)
(if compute-mode?
(begin
(set! sources (list
(make source
(src (make gaussian-src (frequency fcen) (fwidth df)))
(component Hz) (center 0 0))))
(run-sources+ 400
(at-beginning output-epsilon)
(after-sources (harminv Hz (vector3 0) fcen df)))
(run-until (/ 1 fcen) (at-every (/ 1 fcen 20) output-hfield-z))
)
(begin
(set! sources (list
(make source
(src (make gaussian-src (frequency fcen) (fwidth df)))
(component Ey)
(center (+ (* -0.5 sx) dpml pad) 0)
(size 0 (* 1 d)))))
(define trans ; transmitted flux
(add-flux fcen df nfreq
(make flux-region
(center (- (* 0.5 sx) dpml pad) 0) (size 0 (* 2 d)))))
(run-sources+ 500
(at-beginning output-epsilon))
(display-fluxes trans) ; print out the flux spectrum
))
评论1