def setUpClass(cls): Yb_number_density = 3e25 core_r = 5e-6 background_loss = 0 length = 3 pump_cladding_r = 50e-6 core_to_cladding_ratio = core_r / pump_cladding_r core_NA = 0.12 npoints = 20 tolerance = 1e-5 cls.input_signal_power = 0.4 cls.input_pump_power = 47.2 fiber = YbDopedDoubleCladFiber(length, core_r, Yb_number_density, background_loss, core_NA, core_to_cladding_ratio) simulation = SteadyStateSimulation() simulation.fiber = fiber simulation.add_cw_signal(wl=1030e-9, power=cls.input_signal_power, mode_shape_parameters={ 'functional_form': 'gaussian', 'mode_diameter': 2 * 4.8e-6 }) simulation.add_backward_pump(wl=914e-9, power=cls.input_pump_power) simulation.set_number_of_nodes(npoints) cls.result = simulation.run(tol=tolerance)
def setUpClass(cls): yb_number_density = 3e25 core_r = 5e-6 background_loss = 0 length = 3 pump_cladding_r = 50e-6 core_to_cladding_ratio = core_r / pump_cladding_r core_na = 0.12 tolerance = 1e-5 cls.input_signal_power = 0.4 cls.input_pump_power = 47.2 fiber = YbDopedDoubleCladFiber(length, core_r, yb_number_density, background_loss, core_na, core_to_cladding_ratio) pump_wavelengths = np.linspace(910, 950, 11) * 1e-9 cls.gains = [] init_guess_array = None for pump_wl in pump_wavelengths: simulation = SteadyStateSimulation(fiber) simulation.add_forward_signal(wl=1030e-9, input_power=cls.input_signal_power, mode=GaussianMode( mfd=2 * 4.8e-6, core_radius=fiber.core_radius), channel_id='signal') simulation.add_backward_pump(wl=pump_wl, input_power=cls.input_pump_power) if init_guess_array is not None: simulation.set_guess_array(init_guess_array) result = simulation.run(tol=tolerance) init_guess_array = result.powers result_dict = result.make_result_dict() signal_gain = result_dict['signal']['gain'] cls.gains.append(signal_gain)
def setUpClass(cls): yb_number_density = 3e25 core_r = 5e-6 background_loss = 0 length = 3 pump_cladding_r = 50e-6 core_to_cladding_ratio = core_r / pump_cladding_r core_na = 0.12 npoints = 20 tolerance = 1e-5 cls.input_signal_power = 0.4 cls.input_pump_power = 47.2 fiber = YbDopedDoubleCladFiber(length, core_r, yb_number_density, background_loss, core_na, core_to_cladding_ratio) simulation = SteadyStateSimulation(fiber) simulation.add_forward_signal(wl=1030e-9, input_power=cls.input_signal_power, mode=GaussianMode( mfd=2 * 4.8e-6, core_radius=fiber.core_radius)) simulation.add_backward_pump(wl=914e-9, input_power=cls.input_pump_power) simulation.set_number_of_nodes(npoints) cls.result = simulation.run(tol=tolerance)
def test_steady_state(self): steady_state_simulation = SteadyStateSimulation(self.fiber) steady_state_simulation.add_forward_signal( wl=self.signal_wl, input_power=self.signal_power, loss=self.signal_loss) steady_state_simulation.add_forward_pump(wl=self.pump_wl, input_power=self.pump_power) steady_state_simulation.add_backward_pump(wl=self.pump_wl, input_power=self.pump_power, loss=self.bw_pump_loss) steady_state_result = steady_state_simulation.run(tol=1e-5) ss_losses = steady_state_result.powers_at_fiber_end() / np.array( [self.signal_power, self.pump_power, self.pump_power]) self.assertTrue( np.allclose(to_db(ss_losses), self.expected_losses, atol=1e-3, rtol=1e-5))
def setUpClass(cls): Yb_number_density = 3e25 core_r = 5e-6 background_loss = 0 length = 3 pump_cladding_r = 50e-6 core_to_cladding_ratio = core_r / pump_cladding_r core_NA = 0.12 tolerance = 1e-5 cls.input_signal_power = 0.4 cls.input_pump_power = 47.2 fiber = YbDopedDoubleCladFiber(length, core_r, Yb_number_density, background_loss, core_NA, core_to_cladding_ratio) pump_wavelengths = np.linspace(910, 950, 11) * 1e-9 cls.gains = [] init_guess_array = None for pump_wl in pump_wavelengths: simulation = SteadyStateSimulation() simulation.fiber = fiber simulation.add_cw_signal(wl=1030e-9, power=cls.input_signal_power, mode_shape_parameters={ 'functional_form': 'gaussian', 'mode_diameter': 2 * 4.8e-6 }) simulation.add_backward_pump(wl=pump_wl, power=cls.input_pump_power) if init_guess_array is not None: simulation.set_guess_array(init_guess_array) result = simulation.run(tol=tolerance) init_guess_array = result.powers result_dict = result.make_result_dict() signal_gain = result_dict['forward_signal']['gain'][0] cls.gains.append(signal_gain)
def test_steady_state_python_and_cpp_single_ring(self): steady_state_simulation = SteadyStateSimulation(self.fiber) steady_state_simulation.add_forward_signal(wl=self.signal_wl, input_power=self.signal_power) steady_state_simulation.add_backward_pump(wl=self.pump_wl, input_power=self.pump_power / 2) steady_state_simulation.add_forward_pump(wl=self.pump_wl, input_power=self.pump_power / 2) steady_state_simulation.add_ase(wl_start=1020e-9, wl_end=1040e-9, n_bins=3) steady_state_result = steady_state_simulation.run(tol=1e-5) dynamic_simulation = DynamicSimulation(self.time_steps, self.fiber) dynamic_simulation.add_forward_signal(wl=self.signal_wl, input_power=self.signal_power) dynamic_simulation.add_backward_pump(wl=self.pump_wl, input_power=self.pump_power / 2) dynamic_simulation.add_forward_pump(wl=self.pump_wl, input_power=self.pump_power / 2) dynamic_simulation.add_ase(wl_start=1020e-9, wl_end=1040e-9, n_bins=3) dynamic_simulation.use_cpp_backend() cpp_result = dynamic_simulation.run(z_nodes=self.z_nodes, dt=self.steady_state_dt, stop_at_steady_state=True) dynamic_simulation.use_python_backend() python_result = dynamic_simulation.run(z_nodes=self.z_nodes, dt=self.steady_state_dt, stop_at_steady_state=True) dynamic_simulation.use_pythran_backend() pythran_result = dynamic_simulation.run(z_nodes=self.z_nodes, dt=self.steady_state_dt, stop_at_steady_state=True) dynamic_simulation.use_numba_backend() numba_result = dynamic_simulation.run(z_nodes=self.z_nodes, dt=self.steady_state_dt, stop_at_steady_state=True) steady_state_output_powers = steady_state_result.powers_at_fiber_end() cpp_output_powers = cpp_result.powers_at_fiber_end() python_output_powers = python_result.powers_at_fiber_end() pythran_output_powers = pythran_result.powers_at_fiber_end() numba_output_powers = numba_result.powers_at_fiber_end() self.assertTrue(np.allclose(steady_state_output_powers, cpp_output_powers, rtol=1e-3)) self.assertTrue(np.allclose(cpp_output_powers, python_output_powers, rtol=1e-6)) self.assertTrue(np.allclose(pythran_output_powers, python_output_powers, rtol=1e-6)) self.assertTrue(np.allclose(numba_output_powers, python_output_powers, rtol=1e-6))