Hi,

 

Time ago (February) I asked about a way to add-up all the h5 files that
result from outputting the energy maps. Steven wrote a code, I would swear
the code worked fine then, but when I run it now I get a weird-looking image
that looks like several patches put together. I don't think it has to do
with the new version of MEEP, but nothing else has changed. If you add
manually the energy-density h5 files everything looks good. Any idea if
there is something wrong with the code (see below) or how the newest version
of MEEP reads it?

 

Also, I tried to look for information about the function (convert-h5 .) but
I could not find any. Where should I look for it?

 

Thanks,

                Floren

 

----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------

(define-param sx 13) ; the size of the computational cell, not including PML

(define-param sy 10)

(define-param dpml 1) ; thickness of PML layers

 

(set! geometry-lattice (make lattice (size (+ sx (* 2 dpml)) sy no-size)))

 

 

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

(set-param! resolution 20)

(set-param! k-point (vector3 0))

 

(define-param fcen 0.5) ; source frequency

(define frame (/ 1 fcen 10)) ; A period divided in 10 frames

 

; ---------- beginning of function suggested by SGJ

; we define function sum-h5  with two arguments:

; the name of the output file (fname) and the step-function that will be
added

 

(define (sum-h5 fname step-func)

   (let ((first-step? true))

     (lambda (to-do)

       (if first-step?

           

            (begin ; just copy the output file to fname

                  (set! first-step? false)

                  ((convert-h5 true

                        (string-append "h5math -e \"d1\" " fname "")

                        step-func) to-do))

           ; otherwise, add the output file to fname

            ((convert-h5 true

                  (string-append "h5math -e \"d1 + d2\" " fname " " fname
"")

                  step-func) to-do)

))))

; ---------- end of function suggested by SGJ

 

(set! sources 

      (list

       (make source

         (src (make continuous-src (frequency fcen)))

         (component Ez) (center (* -0.5 sx) 0) (size 0 sy)

      )))

 

(run-until (/ 100 fcen) ; the calculation runs for 100 periods

      (after-time (/ 99 fcen) ; the output data begins to be collected after
99 periods

            (at-every frame (sum-h5 "dpwr-sum.h5" output-dpwr))

            (at-every frame output-dpwr))); this line is just for getting
the fields that are added by the function

----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------------------------ 

 

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

Reply via email to