Пример #1
0
 def test_no_forward_injection_in_2D(self):
     """ Test no forward injection in 2D with mode source in vacuum. """
     self.fom = ModeMatch(monitor_name = 'figure_of_merit',
                          mode_number = 2, # evanescent mode
                          direction = 'Forward',
                          multi_freq_src = False,
                          target_T_fwd = lambda wl: np.ones(wl.size),
                          norm_p = 1)
     Optimization.set_source_wavelength(self.sim, 'source', self.fom.multi_freq_src, len(self.wavelengths))
     self.sim.fdtd.setnamed('FDTD','dimension','2D')
     self.fom.add_to_sim(self.sim)
     self.sim.run(name = 'modematch_no_forward_injection_in_2D', iter = 3)
     FOM = self.fom.get_fom(self.sim)
     self.assertAlmostEqual(FOM, 0.0, 5)
 def test_forward_injection_in_2D(self):
     """ Test forward injection in 2D with mode source in vacuum. """
     self.fom = ModeMatch(monitor_name='figure_of_merit',
                          mode_number=1,
                          direction='Forward',
                          multi_freq_src=True,
                          target_T_fwd=lambda wl: np.ones(wl.size),
                          norm_p=1)
     Optimization.set_source_wavelength(self.sim, 'source',
                                        self.fom.multi_freq_src,
                                        len(self.wavelengths))
     self.sim.fdtd.setnamed('FDTD', 'dimension', '2D')
     self.fom.initialize(self.sim)
     self.fom.make_forward_sim(self.sim)
     self.sim.run(name='modematch_forward_injection_in_2D', iter=2)
     FOM = self.fom.get_fom(self.sim)
     self.assertAlmostEqual(FOM, self.ref_fom, 4)
Пример #3
0
 def test_backward_injection_in_3D(self):
     """ Test backward injection in 3D with mode source in dielectric region. """
     self.fom = ModeMatch(monitor_name = 'figure_of_merit',
                          mode_number = 1,
                          direction = 'Backward',
                          multi_freq_src = True,
                          target_T_fwd = lambda wl: np.ones(wl.size),
                          norm_p = 1)
     Optimization.set_source_wavelength(self.sim, 'source', self.fom.multi_freq_src, len(self.wavelengths))
     self.sim.fdtd.setnamed('FDTD','dimension','3D')
     self.sim.fdtd.setnamed('source', 'x', -self.sim.fdtd.getnamed('source','x'))
     self.sim.fdtd.setnamed('source','direction','Backward')
     self.sim.fdtd.setnamed('figure_of_merit','x', -self.sim.fdtd.getnamed('figure_of_merit','x'))
     self.fom.add_to_sim(self.sim)
     self.sim.run(name = 'modematch_backward_injection_in_3D', iter = 1)
     FOM = self.fom.get_fom(self.sim)
     self.assertAlmostEqual(FOM, self.ref_fom, 5)