Hi:
Perhaps this can be done by simply defining the flux objects after I
first do run-sources so that the fields are only accumulated after the
source is off?
(run-sources)
(define totflux
(add-flux fcen df nfreq
(make flux-region (center SourceX (+ SourceY (* BoxSizeY
-1))) (size (* BoxSizeX 2) 0 ) (weight -1)) ; -y
)
)
(define radflux
(add-flux fcen df nfreq
(make flux-region (center 0 (- (/ StripSizeY -2) (* D 2)))
(size (+ StripSizeX D D D D) 0) (weight -1)) ; -y
)
)
(define nradflux
(add-flux fcen df nfreq
(make flux-region (center 0 (- (/ StripSizeY -2) (/ D 2)))
(size (+ StripSizeX D) 0) (weight -1)) ; -y
)
)
(run-until (stop-when-fields-decayed (/ 15 fcen) Ex (vector3 SourceX (+
SourceX (* BoxSizeX -1))) 1e-3)
)
(display-fluxes totflux radflux nradflux)
Regards,
Kevin Chih-Yao Huang
On Thu, Aug 27, 2009 at 5:54 PM, Kevin Huang <[email protected]> wrote:
> Hi:
>
> I'd like to start the field accumulation for the flux spectra after the
> source has been turned off, therefore the add-flux function has to be called
> within run.
> I first define a function to display the fluxes, FluxDisplay.
> Then in run-sources+ I use "let" to initialize the respective flux regions
> after the source is off.
> However, I think this will give me a problem because the initialized
> add-flux variables, totflux, radflux and nradflux are local variables.
> I'm not sure what the scope of these variables are, if I define the
> function FluxDisplay outside run-sources, in principle this will not display
> the local variables?
>
> How can I initialize the add-flux variables inside run-sources while
> defining a function to display them outside run?
>
> (define (FluxDisplay) (display-fluxes totflux radflux nradflux))
>
> (run-sources+ num_step
> (after-sources (let ( (totflux (add-flux fcen df nfreq
> (make flux-region (center SourceX (+
> SourceY (* BoxSizeY -1))) (size (* BoxSizeX 2) 0 ) (weight -1)) ; -y
> (make flux-region (center SourceX (+
> SourceY (* BoxSizeY 1))) (size (* BoxSizeX 2) 0 ) ) ; +y
> (make flux-region (center (+ SourceX (*
> BoxSizeX -1)) SourceY) (size 0 (* BoxSizeY 2) ) (weight -1)) ; -x
> (make flux-region (center (+ SourceX (*
> BoxSizeX 1)) SourceY) (size 0 (* BoxSizeY 2) ) ) ; +x
> ))
> (radflux (add-flux fcen df nfreq
> (make flux-region (center 0 (- (/
> StripSizeY -2) (* D 2))) (size (+ StripSizeX D D D D) 0) (weight -1)) ;
> -y
> (make flux-region (center 0 (+ (/
> StripSizeY 2) (* D 2))) (size (+ StripSizeX D D D D) 0) ) ;
> +y
> (make flux-region (center (- (/ StripSizeX
> -2) (* D 2)) 0) (size 0 (+ StripSizeY D D D D)) (weight -1)) ; -x
> (make flux-region (center (+ (/ StripSizeX
> 2) (* D 2)) 0) (size 0 (+ StripSizeY D D D D)) ) ; +x
> ))
> (nradflux (add-flux fcen df nfreq
> (make flux-region (center 0 (- (/
> StripSizeY -2) (/ D 2))) (size (+ StripSizeX D) 0) (weight -1)) ; -y
> (make flux-region (center 0 (+ (/
> StripSizeY 2) (/ D 2))) (size (+ StripSizeX D) 0) ) ; +y
> (make flux-region (center (- (/ StripSizeX
> -2) (/ D 2)) 0) (size 0 (+ StripSizeY D)) (weight -1)) ; -x
> (make flux-region (center (+ (/ StripSizeX
> 2) (/ D 2)) 0) (size 0 (+ StripSizeY D)) ) ; +x
> ))
> )
> )
> )
> (at-end FluxDisplay)
> )
>
>
> Thank you.
>
> Regards.
> Kevin Chih-Yao Huang
>
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss