def before_sim(self, sim: FdfdSimProp) -> None: beam_center = self._params.beam_center if beam_center is None: beam_center = self._params.center eps_grid = copy.deepcopy(sim.grid) eps_grid.grids = sim.eps source, _ = fdfd_tools.free_space_sources.build_gaussian_source( omega=2 * np.pi / sim.wlen, eps_grid=eps_grid, mu=None, axis=gridlock.axisvec2axis(self._params.normal), polarity=gridlock.axisvec2polarity(self._params.normal), slices=simspace.create_region_slices(sim.grid.exyz, self._params.center, self._params.extents), theta=self._params.theta, psi=self._params.psi, polarization_angle=self._params.polarization_angle, w0=self._params.w0, center=beam_center, power=self._params.power) if self._params.normalize_by_sim: source = fdfd_tools.free_space_sources.normalize_source_by_sim( omega=2 * np.pi / sim.wlen, source=source, eps=sim.eps, dxes=sim.dxes, pml_layers=sim.pml_layers, solver=sim.solver, power=self._params.power) sim.source += source
def before_sim(self, sim: FdfdSimProp) -> None: if self._wg_mode is None: self._wg_mode = fdfd_solvers.waveguide_mode.build_waveguide_source( omega=2 * np.pi / sim.wlen, dxes=sim.dxes, eps=sim.eps, mu=None, mode_num=self._src.mode_num, waveguide_slice=simspace.create_region_slices( sim.grid.exyz, self._src.center, self._src.extents), axis=gridlock.axisvec2axis(self._src.normal), polarity=gridlock.axisvec2polarity(self._src.normal), power=self._src.power) sim.source += self._wg_mode
def before_sim(self, sim: FdfdSimProp) -> None: # Calculate the eigenmode if we have not already. if self._wg_overlap is None: self._wg_overlap = fdfd_solvers.waveguide_mode.build_overlap( omega=2 * np.pi / sim.wlen, dxes=sim.dxes, eps=sim.eps, mu=None, mode_num=self._overlap.mode_num, waveguide_slice=simspace.create_region_slices( sim.grid.exyz, self._overlap.center, self._overlap.extents), axis=gridlock.axisvec2axis(self._overlap.normal), polarity=gridlock.axisvec2polarity(self._overlap.normal), power=self._overlap.power) self._wg_overlap = np.stack(self._wg_overlap, axis=0)