Subject: Error in running some loop in set! geometry

From: Partha Saha <[email-masked]>
Date: Fri, 13 May 2016 10:34:28 +0000 (UTC)

Dear Prof. Steve and all the meep users

I am new to meep and Scheme coding and I think I have a problem making a
loop in Scheme but I don't know what I have done wrong.

I am trying to make a 1D slotted nanobeam slab but finding some error in
running the loop. My ctl file is as follows:

; Some parameters to describe the geometry:                                     
(define-param eps 12) ; dielectric constant of waveguide                        
(define-param w 1.1627906977) ; width of waveguide                         
             
(define-param r_center 0.4203935599) ; radius of holes at the center
(define-param r_end 0.3631484794) ; radius of holes at the end
(define-param h 0.3935599284) ; height of slab  
(define-param w_slot 0.0894454383) ; width of slot                         
            
;(define-param d 1.4) ; defect spacing (ordinary spacing = 1) but in my case
no defect hence disabled                   
(define-param N 30) ; number of holes on either side of defect      
(define-param i-max 20) ; number of holes on either side of tapered region  
(define-param di 1); change in i   
(define-param dmirr 1); change in mirr  
(define-param mirr-max 10) ; number of holes on either side of mirror holes
region 

; The cell dimensions                                                           
(define-param sy 6) ; size of cell in y direction (perpendicular to wvg.)    
(define-param sz 3) ; size of cell in z direction (perpendicular to wvg.)     
(define-param pad 2) ; padding between last hole and PML edge                   
(define-param dpml 1) ; PML thickness 

(define sx (* 2 (+ pad dpml N))) ; size of cell in x direction

(set! geometry-lattice (make lattice (size sx sy sz)))

(set! geometry   
(append geometry; combine lists of objects  
   (list (make block (center 0 0 0) (size infinity w h)
               (material (make dielectric (epsilon eps))))

          (make block (center 0 0 0) (size (+ (* 2 N) 2) w_slot infinity)
(material air)) ; air slot in the waveguide

          (do ((i 1 (+ i di))) ((>= i i-max))  (make cylinder (center (+ 0.5
(* (+ i -1) 1)) 0 0) (radius (+ r_center (/ (* (* (+ i -1) (+ i -1)) (-
r_end r_center)) (* (+ i-max -1) (+ i-max -1))))) (height infinity)
(material air)))

          (do ((i 1 (+ i di))) ((>= i i-max))  (make cylinder (center (+
-0.5 (* (+ i -1) -1)) 0 0) (radius (+ r_center (/ (* (* (+ i -1) (+ i -1))
(- r_end r_center)) (* (+ i-max -1) (+ i-max -1))))) (height infinity)
(material air)))

          (do ((mirr 1 (+ mirr dmirr))) ((>= mirr mirr-max)) (make cylinder
(center (+ i-max mirr -0.5) 0 0) (radius r_end) (height infinity) (material
air)))

          (do ((mirr 1 (+ mirr dmirr))) ((>= mirr mirr-max)) (make cylinder
(center (- 0.5 i-max mirr) 0 0) (radius r_end) (height infinity) (material
air)))

);end of list
);end of append
);end of geometry

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

(set-param! resolution 20)

(define-param fcen 0.3653594) ; pulse center frequency
(define-param df 0.2)  ; pulse width (in frequency)
(define-param nfreq 500) ; number of frequencies at which to compute flux

(set! sources (list
               (make source
                 (src (make gaussian-src (frequency fcen) (fwidth df)))
                 (component Ey)
                 (center (+ dpml (* -0.5 sx)) 0 0)
                 (size 0 w 0))))

(set! symmetries (list (make mirror-sym (direction Y) (phase -1))))

(run-sources+ 300
              (at-beginning output-epsilon)
              (after-sources (harminv Ez (vector3 (+ N 0.2) 0 0) fcen df)))

The error message is
ERROR: In procedure cdr:
ERROR: In procedure cdr: Wrong type (expecting pair): #<unspecified>

The full error is
Backtrace:
In ice-9/boot-9.scm:
 157: 11 [catch #t #<catch-closure 249aa60> ...]
In unknown file:
   ?: 10 [apply-smob/1 #<catch-closure 249aa60>]
In ice-9/eval.scm:
 432: 9 [eval # #]
 432: 8 [eval # #]
In unknown file:
   ?: 7 [primitive-load "nanobeam_edited_with_do_loop.ctl"]
In ice-9/eval.scm:
 387: 6 [eval # ()]
 432: 5 [eval # #]
 432: 4 [eval # #]
 467: 3 [eval # #]
In unknown file:
   ?: 2 [make-structure 3 #(66.0 6.0 3.0) #(0.0 0.0 0.0) 20 #t 1.0e-4 100000
#f ...]
In ice-9/eval.scm:
 387: 1 [eval # #]
In unknown file:
   ?: 0 [cdr #<unspecified>]

ERROR: In procedure cdr:
ERROR: In procedure cdr: Wrong type (expecting pair): #<unspecified>

Can anyone help me in finding the error?