On Mon, 2 Apr 2007, #YIP CHAN HOE# wrote:
I am rather weak in Scheme programming and couldn't figure out after
working a few days on this.
I wanted to run Harminv on several k-points in my structure. So I wrote
a loop to automate the task.
How to write a loop in Scheme is the first thing new Scheme programmers
usually get confused about, since the looping constructs are fairly
different from those in familiar imperative languages like C. So, I
wrote a brief introduction in the manual that gives several ways to do it:
http://ab-initio.mit.edu/wiki/index.php/Guile_and_Scheme_links
Can anyone kindly help me on the harminv loop ? Thank you.
.........................
(define k-points (list (vector3 1 0 0)
(vector3 0 1 0)
))
(set! k-points (interpolate 10 k-points))
(run-until 500 (at-beginning output-epsilon)
(after-sources (map (lambda (k1) (harminv Hz k1 fcen df)) k-points))
))
This isn't going to work for several reasons.
First, you need to put your k-point loop *outside* the run function, so as
to do a separate run for each k-point. And you need to set! k-point
somewhere.
Second, "map" takes a list and a function and produces a new list. Here,
you are therefore creating a list of results from calling harminv (each
call of which returns a step function) and passing it to after-sources,
which doesn't work because after-source doesn't take a list of step
functions as arguments.
Third, you are passing the k-point as the second argument of harminv,
which is probably not what you want. The second argument of harminv is
the *position vector* at which the fields will be observed in order to
extract the frequencies. By "k-point", I assume that you mean the Bloch
wavevector which determines the boundary conditions, and has nothing to do
with position vectors.
Assuming that what you want is to run for a set of k points, you could do
something like:
(map (lambda (k1)
(set! k-point k1)
(run-until 500 (at-beginning output-epsilon)
(after-sources (harminv Hz pt fcen df))))
k-points)
which corrects the above errors. Here "pt" should be some position vector
of the location at which you are interested in looking at Hz, e.g.
(define pt (vector3 0.1 0.2 0.3))
Steven
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss