On Fri, 7 Sep 2007, wlx wrote: > I'm doing a 3D simulation. I want to calculate the integral of > |Ez|^2/(|E|^2) over 200 time steps at the end of the sumulation time. I
This doesn't seem well-defined. What if |E| = 0? > need to calculate the whole field. I have looked through the > meep-discuss but have no idea. I write the function like: > > (define Ezsum 0) > (define (do-Ez-sum) > (set! Ezsum (+ Ezsum > (integrate-field-function (list Ez Ex Ey) > (lambda (ez ex ey) (/ (sqrt ez) (+ (sqrt ex) (sqrt ey) (sqrt > ez)))))))) > > (after-time 300 (run-until 500 do-Ez-sum)) > > Is there anything wrong ??? I can spot at least two errors. First, you should have (lambda r ez ex ey) ...), since integrate-field-function alwasy passes the position as the first argument. See: http://ab-initio.mit.edu/wiki/index.php/Meep_field-function_examples Second, after-time should go inside the run statement, i.e. (run-until 500 (after-time 300 do-Ez-sum)) > How can I output the results?? It seems that "output-field-function" is > not applicable. Can anyone give me a sample code??? (print "Ezsum = " Ezsum "\n") will do it, since you just want to output a single number. output-field-function is to output HDF5 files. Regards, Steven G. Johnson _______________________________________________ meep-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

