-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

wlx schrieb:
> Hi
> 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 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 ???
> How can I output the results?? It seems that "output-field-function" is not 
> applicable. Can anyone give me a sample code???
> Thank you !!!
>

You are not calculating |Ez|^2/(|E|^2). Your code calculates the square
root of each electric field component, not the absolute squares ( (sqrt)
means square root, not square). That should read:

(define (do-Ez-sum)
  (set! Ezsum (+ Ezsum
          (integrate-field-function (list Ez Ex Ey)
            (lambda (ez ex ey)
              (/
               (* ez (conj ez))
               (+
                (* ex (conj ex))
                (* ey (conj ey))
                (* ez (conj ez)))))))))

That calculates (Ez * Ez^)/(Ex*Ex^ + Ey*Ey^ + Ez*Ez^) where A^ means the
complex conjugate of A.

(after-time) tells (run-until) that it should start executing the
function only after the said time. The line should read:

(run-until 500 (after-time 300 do-Ez-sum))

To output Ezsum you could do something like:

(print Ezsum "\n")

This prints out Ezsum on a line of its own.

Hope that helps,

Ulrich Dobramysl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4DLsvlTvENIKkvMRAnOyAJ9/340cnIEFBjtYpoRURhDH9bs7LQCaA1dX
U1F1RlsrXAKDNAuRz5cc/DM=
=6mX+
-----END PGP SIGNATURE-----

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

Reply via email to