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

Method __init__

python/adjoint/objective.py:160–214  ·  view source on GitHub ↗

Initialize an instance of a differentiable frequency-dependent eigenmode coefficient. Args: sim: the Meep simulation object of the problem. volume: the volume over which the eigenmode coefficient is calculated. mode: the eigenmode number. forw

(
        self,
        sim: mp.Simulation,
        volume: mp.Volume,
        mode: int,
        forward: Optional[bool] = True,
        kpoint_func: Optional[Callable] = None,
        kpoint_func_overlap_idx: Optional[int] = 0,
        decimation_factor: Optional[int] = 0,
        subtracted_dft_fields: Optional[FluxData] = None,
        **kwargs
    )

Source from the content-addressed store, hash-verified

158 """A differentiable frequency-dependent eigenmode coefficient."""
159
160 def __init__(
161 self,
162 sim: mp.Simulation,
163 volume: mp.Volume,
164 mode: int,
165 forward: Optional[bool] = True,
166 kpoint_func: Optional[Callable] = None,
167 kpoint_func_overlap_idx: Optional[int] = 0,
168 decimation_factor: Optional[int] = 0,
169 subtracted_dft_fields: Optional[FluxData] = None,
170 **kwargs
171 ):
172 """Initialize an instance of a differentiable frequency-dependent
173 eigenmode coefficient.
174
175 Args:
176 sim: the Meep simulation object of the problem.
177 volume: the volume over which the eigenmode coefficient is calculated.
178 mode: the eigenmode number.
179 forward: whether the forward or backward mode coefficient is returned
180 as the result of the evaluation. Default is True.
181 kpoint_func: an optional k-point function to use when evaluating the
182 eigenmode coefficient. When specified, this overrides the effect
183 of `forward`.
184 kpoint_func_overlap_idx: the index of the mode coefficient to return
185 when specifying `kpoint_func`. When specified, this overrides the
186 effect of `forward` and should have a value of either 0 or 1.
187 decimation_factor: An integer used to specify the number of timesteps
188 between updates of the DFT fields. The default is 0, at which the
189 value is automatically determined from the Nyquist rate of the
190 bandwidth-limited sources and the DFT monitor. It can be turned
191 off by setting it to 1.
192 subtracted_dft_fields: the DFT fields obtained using `get_flux_data`
193 from a previous normalization run. This is subtracted from the
194 DFT fields of this mode monitor in order to improve the accuracy
195 of the reflectance measurement (i.e., the $S_{11}$ scattering
196 parameter). Default is None.
197 eigenmode_kwargs: additional keyword arguments for EigenModeSource.
198 """
199 super().__init__(sim)
200 if kpoint_func_overlap_idx not in [0, 1]:
201 raise ValueError(
202 "`kpoint_func_overlap_idx` should be either 0 or 1, but got %d"
203 % (kpoint_func_overlap_idx,)
204 )
205 self.volume = volume
206 self.mode = mode
207 self.forward = forward
208 self.kpoint_func = kpoint_func
209 self.kpoint_func_overlap_idx = kpoint_func_overlap_idx
210 self.eigenmode_kwargs = kwargs
211 self._monitor = None
212 self._cscale = None
213 self.decimation_factor = decimation_factor
214 self.subtracted_dft_fields = subtracted_dft_fields
215
216 def register_monitors(self, frequencies):
217 self._frequencies = np.asarray(frequencies)

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected