The way I do stuff like this would be:

(define (structure r-local)
                (append
                        (list (make block (center 0) (size sx sy h)
                                (material (make dielectric (index n)))))
                        (geometric-objects-lattice-duplicates
                                (list
                                (make cylinder (center 0) (radius r-local) 
(height h)
                                (material air))))))

(do ((r rstart (+ r rstep))) ((> r rstop))

                        (set! geometry (structure r))

                        (run-until 200 (at-beginning output-epsilon)))

However from the look of your error message, I would consider using the 
functions restart-fields, and change-sources! within the loop.

>From: "F.S.F. Brossard" <[EMAIL PROTECTED]>
>To: meep-discuss <[email protected]>
>Subject: [Meep-discuss] Error new-meep-fields
>Date: 09 Aug 2007 13:00:29 +0100
>
>Hi Steven and Meep users,
>
>I would like to implement a loop in Meep in order to calculate the Q, 
>frequency, etc of a cavity for different values of hole radius for example. 
>In MPB, I first define the structure in a function such as
>(define (structure r) (set! geometry...)) then  create a (do loop for 
>different values of r) in which I call the function (structure r) and call 
>(run-te) within the loop and it works fine. However in Meep an error is 
>returned:
>In procedure new-meep-fields:
>No matching method for generic function 'new_meep_fields'
>It seems that in meep we can't define the geometry within a function in the 
>same way as in MPB, so what is the correct procedure?
>
>Below is an example in meep which fails, the run function is just a test 
>(no source).
>
>Thanks for your help,
>
>Fred
>
>; square lattice
>
>; define cell size
>
>(define-param sx 8)
>(define-param sy 6)
>(define-param sz 3)
>(define-param res 20) ; resolution
>
>(define-param h 0.75) ; thickness of waveguide
>(define-param r 0.2) ; radius of holes
>(define-param n 3.46) ; index of waveguide
>
>(define rstart 0.2)
>(define rstep 0.05)
>(define rstop 0.3)
>
>(set! eps-averaging? false)
>
>(set! geometry-lattice (make lattice (size sx sy sz)))
>
>; define periodic array
>
>(define (structure r)
>
>       (set! geometry
>               (append
>                       (list (make block (center 0) (size sx sy h)
>                               (material (make dielectric (index n)))))
>                       (geometric-objects-lattice-duplicates
>                               (list
>                               (make cylinder (center 0) (radius r) (height h)
>                               (material air)))))))
>
>
>
>(set! k-point (vector3 0))
>
>(set-param! resolution 20)
>
>; set-up symmetry
>
>(set! symmetries (list (make mirror-sym (direction Y) (phase -1))
>                                       (make mirror-sym (direction X) (phase 
> -1))))
>
>(do ((r rstart (+ r rstep))) ((> r rstop))
>
>                       (structure r)
>
>                       (run-until 200 (at-beginning output-epsilon)))
>
>
>--
>Frederic Brossard
>Hitachi Cambridge Laboratory
>Cavendish Laboratory
>J J Thomson Avenue
>Cambridge CB3 0HE
>
>
>_______________________________________________
>meep-discuss mailing list
>[email protected]
>http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

_________________________________________________________________
Booking a flight? Know when to buy with airfare predictions on MSN Travel. 
http://travel.msn.com/Articles/aboutfarecast.aspx&ocid=T001MSN25A07001


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

Reply via email to