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

Method add_energy

python/simulation.py:3122–3146  ·  view source on GitHub ↗

`add_energy(fcen, df, nfreq, freq, EnergyRegions, decimation_factor=0)` ##sig Add a bunch of `EnergyRegion`s to the current simulation (initializing the fields if they have not yet been initialized), telling Meep to accumulate the appropriate field Fourier transfor

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

3120 )
3121
3122 def add_energy(self, *args, **kwargs):
3123 """
3124 `add_energy(fcen, df, nfreq, freq, EnergyRegions, decimation_factor=0)` ##sig
3125
3126 Add a bunch of `EnergyRegion`s to the current simulation (initializing the fields
3127 if they have not yet been initialized), telling Meep to accumulate the appropriate
3128 field Fourier transforms for `nfreq` equally spaced frequencies covering the
3129 frequency range `fcen-df/2` to `fcen+df/2` or an array/list `freq` for arbitrarily
3130 spaced frequencies. Return an *energy object*, which you can pass to the functions
3131 below to get the energy spectrum, etcetera. To reduce the memory-bandwidth burden of
3132 accumulating DFT fields, an integer `decimation_factor` can be specified for updating the DFT
3133 fields at every `decimation_factor` timesteps. If `decimation_factor` is 0 (the default),
3134 this value is automatically determined from the
3135 [Nyquist rate](https://en.wikipedia.org/wiki/Nyquist_rate) of the bandwidth-limited
3136 sources and this DFT monitor. It can be turned off by setting it to 1. Use this feature
3137 with care, as the decimated timeseries may be corrupted by
3138 [aliasing](https://en.wikipedia.org/wiki/Aliasing) of high frequencies.
3139 """
3140 args = fix_dft_args(args, 0)
3141 freq = args[0]
3142 energys = args[1:]
3143 decimation_factor = kwargs.get("decimation_factor", 0)
3144 en = DftEnergy(self._add_energy, [freq, energys, decimation_factor])
3145 self.dft_objects.append(en)
3146 return en
3147
3148 def _add_energy(self, freq, energys, decimation_factor):
3149 if self.fields is None:

Callers 1

test_dft_energyMethod · 0.95

Calls 3

fix_dft_argsFunction · 0.85
DftEnergyClass · 0.85
getMethod · 0.80

Tested by 1

test_dft_energyMethod · 0.76