On Aug 24, 2012, at 3:28 PM, Simon Huskier wrote:
> Dear all,
> 
> I have two questions in a plane wave generating CTL code source by matt and 
> Steven. The source code is pasted after the message. I use the latest 
> released version MEEP 1.2.1 on Debian Squeeze.
> 
> 1. For Bloch-periodic boundary condition, the usual way is setting the 
> k-point and ensure-periodicity as following.
>             (set! k-point (vector3 0 0 0))
>             (set! ensure-periodicity true)
>    But in the code, they set the k-point to (kx 0 0).
>             (set! k-point (vector3 kx 0 0))
>    If I change the above kx to zero, then I will get a wrong picture of plane 
> wave.

I can't replicate your problem; with your code if I set theta=0 (hence kx=0) 
then the output looks fine.
> 
> 2. The usual way to set the amp-func is like following. (Written by Steven in 
> the discussion list)
>          ; pw-amp is a function that returns the amplitude exp(ik(x+x0)) at a
>          ; given point x.  (We need the x0 because current amplitude functions
>          ; in Meep are defined relative to the center of the current source,
>          ; whereas we want a fixed origin.)  Actually, it is a function of k
>          ; and x0 that returns a function of x ...
>         (define ((pw-amp k x0) x)
>              (exp (* 0+1i (vector3-dot k (vector3+ x x0)))))

Note that this is equivalent to:

        (define (pw-amp k x0)
             (lambda (x)
                ......))

That is, it constructs a anonymous function of x and returns it.  
(http://en.wikipedia.org/wiki/Anonymous_function)

> 
>         To call the function, we need to provide two parameters: k and x0.
>          (amp-func (pw-amp k (vector3 (* -0.5 s) 0)))
> 
>    But in the code, the way to set the amp-func is as following
>          (define (my-amp-func p) (exp (* 0+2i pi kx (vector3-x p))))
>          
>          To call it, they provide no parameter at all.
>          (amp-func my-amp-func)
> 
> I don't understand the way they use amp-func in the code, but it does give 
> the desired plane wave.

The first and second versions only differ by a phase factor.   In both cases 
the amp-func is a function of position x.  They differ in a few ways:

        1) in the first case, parameters like k are passed to pw-amp as 
parameters and then an anonymous function is returned.  In the second case the 
parameter kx is passed as a global variable

        2) In the first case a vector k, which includes the 2*pi factor, is 
passed. In the second case only one component kx, which doesn't include the 
2*pi factor, is passed.

        3) When the amp-func is called, the x parameter has an origin at the 
center of the source volume.  In the first case this is explicitly shifted to 
some desired origin x0, whereas the second case corresponds to x0=0.   This is 
only a phase shift in the source.

Steven


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

Reply via email to