MCPcopy Create free account
hub / github.com/NanoComp/meep / FluxRegion

Class FluxRegion

python/simulation.py:510–564  ·  view source on GitHub ↗

A `FluxRegion` object is used with [`add_flux`](#flux-spectra) to specify a region in which Meep should accumulate the appropriate Fourier-transformed fields in order to compute a flux spectrum. It represents a region (volume, plane, line, or point) in which to compute the integral

Source from the content-addressed store, hash-verified

508
509
510class FluxRegion:
511 """
512 A `FluxRegion` object is used with [`add_flux`](#flux-spectra) to specify a region in
513 which Meep should accumulate the appropriate Fourier-transformed fields in order to
514 compute a flux spectrum. It represents a region (volume, plane, line, or point) in
515 which to compute the integral of the Poynting vector of the Fourier-transformed
516 fields. `ModeRegion` is an alias for `FluxRegion` for use with `add_mode_monitor`.
517
518 Note that the flux is always computed in the *positive* coordinate direction, although
519 this can effectively be flipped by using a `weight` of -1.0. This is useful, for
520 example, if you want to compute the outward flux through a box, so that the sides of
521 the box add instead of subtract.
522 """
523
524 def __init__(
525 self,
526 center: Vector3Type = None,
527 size: Vector3Type = Vector3(),
528 direction: int = mp.AUTOMATIC,
529 weight: float = 1.0,
530 volume: Optional[Volume] = None,
531 ):
532 """
533 Construct a `FluxRegion` object.
534
535 + **`center` [ `Vector3` ]** — The center of the flux region (no default).
536
537 + **`size` [ `Vector3` ]** — The size of the flux region along each of the coordinate
538 axes. Default is `(0,0,0)`; a single point.
539
540 + **`direction` [ `direction` constant ]** — The direction in which to compute the
541 flux (e.g. `mp.X`, `mp.Y`, etcetera). Default is `AUTOMATIC`, in which the
542 direction is determined by taking the normal direction if the flux region is a
543 plane (or a line, in 2d). If the normal direction is ambiguous (e.g. for a point
544 or volume), then you *must* specify the `direction` explicitly (not doing so
545 will lead to an error).
546
547 + **`weight` [ `complex` ]** — A weight factor to multiply the flux by when it is
548 computed. Default is 1.0.
549
550 + **`volume` [ `Volume` ]** — A `meep.Volume` can be used to specify the flux region
551 instead of a `center` and a `size`.
552 """
553 if center is None and volume is None:
554 raise ValueError("Either center or volume required")
555
556 if volume:
557 self.center = volume.center
558 self.size = volume.size
559 else:
560 self.center = Vector3(*center)
561 self.size = Vector3(*size)
562
563 self.direction = direction
564 self.weight = complex(weight)
565
566
567ModeRegion = FluxRegion

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected