Dear all meep users,
 
        I got a question about the flux calculation. Now, I want to obtain the 
transmittance spectra of 2d photonic crystals. As we know, we could use the 
(add-flux (....)) to achieve it. However, I want to calculate it at every 
single frequency. I wrote a ctl file about this. In this program, I wrote a 
loop to upgrade the frequency of the gaussian source. I encountered some 
problems. 
      Firstly, the calculating would cost a lot of time, what is wrong?
      Secondly, if I substitute the (run-resources+ number) for (run-resources 
+ (stop-when...) ), the program only calculates the first frequency, what is 
wrong?
      What is wrong with my program? Can anybody tell me?

################
(set! resolution 10)
(define-param N1 5)
(define-param N2 8)
(define-param N3 5)
(define-param M 30)
(define-param dpml 2)
(define-param pad 5)
(define-param d1 1.485)
(define-param d2 2.310)
(define-param r 0.33)
(define-param sx (* 2 (+ N2 N3  d2 pad dpml -2))  )
(define-param sy  (+ (- M 1) (* 2 dpml)) )
(define-param sl (/ sy 4) )
(define mat (make dielectric (index 1.8725)))
(set! geometry-lattice (make lattice (size sx sy no-size)) )
(set!  geometry
   (append
       (geometric-object-duplicates  (vector3 1 0 0) 0 (-  N1 1)
                    (make cylinder (center (- 1 N1 d1)  (/ (- M 1) 2) ) (height 
infinity) (radius r) (material air) )
       ) 
      
       (geometric-object-duplicates  (vector3 1 0 0) 0 (-  N2 1)
                   (make cylinder (center 0  (/ (- M 1) 2) ) (height infinity) 
(radius r) (material air) )
       )
       (geometric-object-duplicates  (vector3 1 0 0) 0 (-  N3 1)
                    (make cylinder (center (+ N2 d2 -1)  (/ (- M 1) 2) ) 
(height infinity) (radius r) (material air) )
       )
   
   ) 
)
(set! geometry
       (append
                 
            (list (make block (center 0 0 0) (size infinity infinity) (material 
mat) ) )
            (geometric-objects-duplicates  (vector3 0 -1 0) 0 (-  M 1)  
geometry )
       )
)
(set! pml-layers  (list (make pml (thickness dpml)) ))
;(use-output-directory)
(define-param amp 1)
(define-param fcen 0.3)
(define-param df (/ fcen 5))
(define trans 0)
(define (doit x x-max dx)
   (if (<= x x-max) 
     (begin
       (set!  sources
     
             (list
                  (make source  (src (make gaussian-src (frequency x) (fwidth 
df) ) ) (component Ey) (center (+ dpml 0.5 (/ sx -2)) 0 0 )
                               (size 0  sl) (amplitude amp)
                  )
             )
       )
   
 (set! trans (add-flux  fcen 0 1  (make flux-region (center (- (* 0.5 sx) dpml 
0.5 ) 0 0) (size 0 sl) ) ) )
 (run-sources+ 
(stop-when-fields-decayed 50 Ey (vector3 0 0 (- (* 0.5 sx) dpml 0.5) )  1e-3) 
)
 (print "flux:" " "  amp " "  x " " (first (get-fluxes trans)) "\n")
 (doit (+ x dx) x-max dx) ) ) )
(doit 0.25 0.45 0.001)
 
 
                                                           Sincerely 
yours,          
                                                           Jiaxiang Zhang 


      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to