On Feb 28, 2008, at 6:39 AM, fanguofang wrote:
> Dear Colleages:
>     I hope to use the loop,but it does not work,what is wrong with  
> it,thank you.
> Here is my loop:
>          (define (loop x)
>           (volume    (center   (/ (+ w  space) -2)  (- 2 (/ sy 2) )   
> (- (+ ( / wz1 2) (/ wz2 2) ) (+ (/ wz4 2)  (/ wz5 2))) )   (size w x  
> wz3 ) ))
>
>        (run-until 100
>        (at-time 100
>         (do ((x 0 (+ x 0.1))) ((> x 10))   (display-flux-in-box Y  
> (loop x)))))

This is very confused.  The arguments to run-until must be *functions*  
which, when called, do whatever you want to do.  You can't simply pass  
looping constructs, which is equivalent to passing the *result* of  
running the loop rather than passing a *function* which, when called,  
calls the loop.

This functional programming style (or what a C programmer would call  
"callback functions") makes Meep's interface powerful because you can  
pass arbitrary functions that modify the course of the simulation as  
it runs.  However, you really do have to understand Scheme programming  
a bit better to use it properly, which is where many people run into  
trouble.

Also, there is no function "display-flux-in-box".

What you want is something along the lines of:

(define (do-stuff)
     (print "my-flux:, "
               (flux-in-box Y (volume ....))
              "\n"))

(run-until 100 (at-end do-stuff))

Notice that I define a function do-stuff that, when called, will  
execute the commands you want (e.g. printing out the flux in some  
box).  Then, in run-until, you pass the *name* of the function...that  
is, you are passing the *function* as the argument, not the result (do- 
stuff) of *calling* the function.  This way, the run-until function  
can call the function itself at the appointed time(s).

Steven

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

Reply via email to