Hi,
I haven't studied your code too closely so I am not sure what geometry
you are trying to make, but it looks to me like you are trying to create
two loops, one nested within the other to set your geometry. Here is an
example of one I have done to create a surface grating which seems to
work (all the variables are parameters set elsewhere in the ctl file).
Note the all important "apply append" bit which unifies all the lists
returned by the lambda functions into one big list. I am no Scheme
master and unsure of myself when it comes to defining functions so I
prefer this more intuitive way of nesting loops. There is a good
explanation on the Meep tutorial page somewhere.
(set! geometry
(apply append
(map (lambda (x)
(map (lambda (z)
(make block
(center (+ xmin (- (* x a) (/ a 2))) (+ ysurf (/
d 2)) (+ zmin (- (* z a) (/ a 2))))
(size (* F a) d (* F a))
(material (make dielectric (epsilon 1)))))
(arith-sequence 1 1 (inexact->exact Nz))))
(arith-sequence 1 1 (inexact->exact Nx)))))
Hope this helps and apologies if this is nothing like what you want to do!
Ian
[EMAIL PROTECTED] wrote:
> Send meep-discuss mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
> or, via email, send a message with subject or body 'help' to
> [EMAIL PROTECTED]
>
> You can reach the person managing the list at
> [EMAIL PROTECTED]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of meep-discuss digest..."
>
>
> Today's Topics:
>
> 1. h5 file size (Szymon Lis)
> 2. A program error when I use meep (Yan Liu)
> 3. Materials in meep - changes on the web page (Artem)
> 4. Materials in Meep - Changes on the web page (Artem)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 02 Oct 2008 19:08:19 +0100
> From: Szymon Lis <[EMAIL PROTECTED]>
> Subject: [Meep-discuss] h5 file size
> To: meep discuss <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=us-ascii
>
> Hi,
>
> I'm trying 3d modeling. And my h5 file is quite huge. (50GB or more). So I
> don't have enough disk space for it. Is some method to make this files
> smaller? I also wandering that maybe I have some mistake in my code. Has
> anyone similar problem?
>
> Thank you.
> Szymon
>
>
> ___________
> Szymon Lis
> Photonics Group
> Faculty of Microsystem Electronics and Photonics
> Wroclaw University of Technology
> ul. Janiszewskiego 11/17, 50-372 Wroclaw, POLAND
>
> Tel. +48 (71) 320 3735
> Fax. +48 (71) 328 3504
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 3 Oct 2008 10:27:23 +0800
> From: "Yan Liu" <[EMAIL PROTECTED]>
> Subject: [Meep-discuss] A program error when I use meep
> To: [email protected]
> Message-ID:
> <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Dear Dr. Johnson and every meep user:
> I am sorry that I am not very familiar with Scheme Programming. I have tried
> to make the change as you described but the loop would not return a list of
> materials.
>
> There is some other explanations on the using of "map" on mailing list. But
> that seems different with my 2D data reading case.
>
> I know that scheme is based on lisp(list processing). But I feel confused
> with my problem.
>
> I think my program is still with the questions you mentioned before.
>
> I have tried two ways:
> 1)
>
> (define loopinside
> (lambda(y ymax x)
> (if (< y ymax)
> (begin (set! geometry(make block (center (+ 0.5 x) (+ 0.5 y)) (size 1 1
> infinity)
> (material (make dielectric(epsilon 12)))))
> (set! y(+ y 1))
> (loopinside y ymax x)))))
>
> (define loopoutside
> (lambda (x xmax y ymax)
> (if (< x xmax)
> (begin (loopinside y ymax x)
> (set! x (+ x 1))
> (loopoutside x xmax y ymax)))))
>
> when I use (loopoutside -110 110 -65 65)
> the it seems there is still nothing returns
>
> Backtrace:
> In current input:
> 46: 0* [run-until 200 #<procedure #f (to-do)> #<procedure #f (to-do)>]
> ?: 1* (if (null? fields) (init-fields))
> ?: 2 [init-fields]
> ?: 3* (if (null? structure) (init-structure k-point))
> ?: 4 [init-structure #f]
> ...
> ?: 5 (set! structure (make-structure (infer-dimensions k) s ...))
> ?: 6* [make-structure 2 #(222 132 1.0e-20) #(0 0 0) 1 #t 1.0e-4 100000 #f
> ...]
>
> I have tried to use map, same problem occurs
> <unnamed port>: In procedure vector-ref in expression (make-structure
> (infer-dimensions k) s ...):
> <unnamed port>: Wrong type argument in position 1: #f
> ABORT: (wrong-type-arg)
>
> I am not very clear on how to use 'cons and set!' or 'map' to finish my 2D
> data reading task in meep
> Would you please describe it more clearly?
>
> Thanks very much!
> Best Regards!
> 2008/10/2 Steven G. Johnson <[EMAIL PROTECTED]>
>
>
>> On Oct 1, 2008, at 8:22 AM, Yan Liu wrote:
>>
>>
>>> (define loopinside
>>> (lambda(y ymax x)
>>> (if (< y ymax)
>>> (begin (make block (center (+ 0.5 x) (+ 0.5 y)) (size 1 1 infinity)
>>> (material (make dielectric (epsilon (read i)))))
>>> (set! y(+ y 1))
>>>
>> This does not return a list of materials. In fact, it does not return
>> anything useful. The problem is that your loop body doesn't *do*
>> anything with the block it creates.
>>
>> Let me make an analogy. Suppose you wanted to sum n numbers i=1 to n,
>> in a C program. The analogue of your loop above would be to write:
>> for (i = 1; i <= n; ++i)
>> i;
>> This is a perfectly valid C program, but it doesn't compute the sum.
>> The command "i;" just evaluates i but doesn't do anything with the
>> result. Your code has the same problem.
>>
>> If you want to do it in a traditional, imperative style (which is what
>> the "do" loop construct is for), then you need to have some variable
>> that will hold your list of objects, and then on each iteration of the
>> loop add your object to the list with "cons" and "set!"
>>
>> A more natural style (for Scheme) is to use "map":
>>
>> (map (lambda (y) (make block ....))
>> (arith-sequence y-min y-step num-y))
>>
>> "map" returns a list and is a basic tool in Scheme to create one list
>> from another.
>>
>> Steven
>>
>> _______________________________________________
>> meep-discuss mailing list
>> [email protected]
>> http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
>>
>>
>
>
>
>
--
Research PhD Student
Photonics Group
Dept. of Electrical & Electronic Engineering
University of Bristol
Rm 2.11 Queen's Building,
University Walk,
Bristol, BS8 1TR
email: [EMAIL PROTECTED]
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss