I discovered that this approach is incompatible with meep-mpi as-is. 
The h5math and file deletion needs to be run serially.  I just output 
the files I need and use h5math from the command line, but that would 
require either a long h5math expression "d1*d1 + d2*d2 + ...", or a bash 
script which operates on two h5 files at a time.

I tried putting a (= 0 (meep-my-rank)) in the step function to 
serialize this, but then meep-mpi deadlocked as warned in the 
documentation.





On Wed, 18 Jun 2008, matt wrote:

>
>
>
>
> Neat, thanks!
>
> For the time average amplitude of a complex field, I changed the
> convert-h5 function as shown below.  It's very hokey because the field
> component is hard-coded into the function, but it works.  Also, it's not
> really an average but rather a sum, which is okay if you just want a
> pretty picture.
>
>
> (define (convert-complex-h5 rm? convert-cmd . step-funcs)
>   (define (convert fname)
>     (if (and rm? (zero? (system (string-append convert-cmd " \"" fname 
> ":hz.i\" \"" fname ":hz.r\""))))
>     (system (string-append "rm \"" fname "\""))))
>   (lambda (to-do)
>     (let ((hooksave output-h5-hook))
>       (set! output-h5-hook convert)
>       (map (lambda (f) (eval-step-func f to-do)) step-funcs)
>       (set! output-h5-hook hooksave))))
>
>
> (define (complex-time-avg 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-complex-h5 true
>                                      (string-append "h5math -e \"sqrt(d1*d1 + 
> d2*d2)\" " fname "")
>                                      step-func) to-do))
>       ;; otherwise, add the output file to fname
>       ((convert-complex-h5 true
>                              (string-append "h5math -e \"d1 + sqrt(d2*d2 + 
> d3*d3)\" " fname " " fname "")
>                              step-func) to-do)))))
>
>
>
>
> On Tue, 17 Jun 2008, Steven G. Johnson wrote:
>
>> On Jun 17, 2008, at 5:37 AM, matt wrote:
>>> I want meep to output the amplitude of the complex time-average
>>> magnetic
>>> field over the computation domain, as an h5 file.
>>
>>
>> See e.g.
>>
>> http://thread.gmane.org/gmane.comp.science.electromagnetism.meep.general/1456
>>
>>> but I'm not looking for for the instantaneous magnetic field.  I'm
>>> also
>>> not interested in the time-average flux or energy, which I could with
>>> flux-in-box or field-energy-in-box.
>>
>> Those two only give you time averages if you have time-harmonic
>> complex fields (i.e. a CW source, with force-complex-fields?=true, and
>> have waited for transients to disappear).
>>
>> But in the case of a time-harmonic source, the time-average field is
>> simply zero.
>>
>> Steven
>>
>> _______________________________________________
>> meep-discuss mailing list
>> [email protected]
>> http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
>>
>
> _______________________________________________
> meep-discuss mailing list
> [email protected]
> http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
>

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

Reply via email to