Dear Steven and meep users,

I'mi trying using meep in order to solve a diffraction problem: in the code
I allegue I try to simulate the following

1) Source: Plane wave approaching from the bottom of the panel, skewly
traveling upwards at a certain angle

2) Grating: Reflection on a highly conductive medium (epsilon 30) whose
surface is sinusoidal. The idea that I followd to realize a sinusoidal
boundary is ideally to superpose a sin function area (y = A * sin (q*x))
over a flat block, both with the same reflection index.

To do it numerically:

a) I approximate a unique period of the sin function by superposing
rectangles whose height is fixed to be Dy = A/m (where m is the number of
slices I want to cut the sin function into), i-th width is Dx(i) = (1/q)
asin(i*Dy/A) and centered in xc(i)=0, yc(i)=(i-1/2)*Dy.

b) I superimpose the m rectangles with a loop and I duplicate what I find
over the whole simulation box

Here is the code:

(define-param L 2) ;Period of the sinusoidal boundary
(define-param q (/ (* 2 pi) L)) ;Wave vector of the sinusoidal boundary
(define-param A 1) ;Amplitude of the " "
(define-param N 5) ;Number of single period repetions to right and left of
central period

(define-param s (* (+ (* N 2) 1) L)) ;Box basic dimensions
(define-param dpml 2)
(define-param svert (+ s (* 2 dpml))) ;Box dimensions
(define-param frec 1)
(define-param m 10) ;number of slices I need to create boundary
(define-param Dy (/ A m)) ;rectangles' height

(define-param theta (/ pi 4))

(define kx (* frec (sin theta)))
(define (my-amp-func p)(exp (* 0+2i pi kx (vector3-x p))))

(set! k-point (vector3 kx 0 0)) ;periodic boundary condition along direction
without mirror (kx cons.)
(set! geometry-lattice (make lattice (size s svert no-size)))

(define-param block_list (list)) ;creation of list of superimposed
rectangles, THIS DOESN'T WORK
(do
    ((  i 1;
      (+ i 1)
    ))
    ((< m))

    (set! block_list
        (append block_list
             (make block
                 (center 0 (* Dy (- i (/ 1 2))))
                 (size (- L (* (/ 2 q) asin ((* i (/ Dy A))) )) Dy)
                 (material (make dielectric (epsilon 30)))
             )
        )
    )
)

(set! geometry             ; I don't know if this works...
      (append
           (list
               (make block (center 0 (/ s 2) ) (size s (/ s 4)
infinity)(material (make dielectric (epsilon 30))))

               (geometric-object-duplicates (vector3 L 0) 0  N  block_list )

               (geometric-object-duplicates (vector3 -L 0) 0  N  block_list
)
           )
      )
) ; creation of geometric domain

(set! sources (list
             (make source
              (src (make continuous-src (frequency frec)))
              (component Ez)
              (center 0 (/ s -2))
              (size s 0)
              (amp-func my-amp-func))))

(set! pml-layers (list (make pml (thickness dpml) (direction Y))))

(set! resolution 40)

(run-until 100
             (at-beginning output-epsilon)
             ;(at-end output-efield-z)
             (at-end (output-png Ez "-Zc dkbluered")))


I don't know where's the error (or errors), I'd never used Scheme before,
and by the way, if there is a faster, better, and cleaner method to create
this kind of boundaries I'd really like to know them!!!

Thanks to all who'll read this kilometric mail,

Good job everyone,

Mattia
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to