def test_energy_conserve_s0_cw(self): u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b = \ formulate_GNLSE(self.int_fwm, self.N_g, self.z, self.dz_less, self.fp, self.df, self.F, self.lamp, self.lamda_c, self.P_p,self.P_s, self.P_i, cw) ss = 0 u_out_b, U_out_b, temp1, temp2, temp3 = pulse_propagation_adaptive( u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b.dAdzmm) E1 = np.linalg.norm(u_b, 2, axis=-1) E2 = np.linalg.norm(u_out_b, 2, axis=-1) assert_allclose(E1, E2)
def test_energy_conserve_s1_pulse(self): u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b = \ formulate_GNLSE(self.int_fwm, self.N_g, self.z.end, self.dz_less, self.fp, self.df, self.F, self.lamp, self.lamda_c, self.P_p,self.P_s, self.P_i, pulse) ss = 1 u_out_b, U_out_b, temp1, temp2, temp3 = pulse_propagation_constant( u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b.dAdzmm, self.z) E1 = np.linalg.norm(u_b, 2, axis=-1) E2 = np.linalg.norm(u_out_b, 2, axis=-1) assert_allclose(E1, E2, atol=1e-2)
def test_energy_conserve_s0_pulse(self): u_g, U_g, int_fwm_g, sim_wind_g, Dop_g, non_integrand_g = \ formulate_GNLSE(self.int_fwm, self.N_g, self.z, self.dz_less, self.fp, self.df, self.F, self.lamp, self.lamda_c, self.P_p, self.P_s,self.P_i, pulse) ss = 0 #u_out_b, U_out_b = self.pulse_propagation( # u_g, U_g, int_fwm_g, sim_wind_g, Dop_g, non_integrand_g.dAdzmm, self.z) u_out_g, U_out_g, temp1, temp2, temp3 = pulse_propagation_adaptive( u_g, U_g, int_fwm_g, sim_wind_g, Dop_g, non_integrand_g.dAdzmm, self.z) E1 = np.linalg.norm(u_g, 2, axis=-1) E2 = np.linalg.norm(u_out_g, 2, axis=-1) assert_allclose(E1, E2, atol=1e-3)
class Test_energy_conserve_constant(): "---------------constants---------------" ss = 1 n2 = 2.5e-20 gama = 10e-3 lamda_c = 1051.85e-9 dz_less = 100 betas = np.array([0, 0, 0, 6.756e-2, # propagation constants [ps^n/m] -1.002e-4, 3.671e-7]) * 1e-3 maxerr = 1e-13 fr = 0.18 "----------Combined parameters-----------" alphadB = 0 z = 1 dz = 0.01 z = float_range(0, z, dz) df = 0.01 # frequency step in [Thz] lamp = 1048e-9 P_p = 20 P_s = 1 P_i = 1 T0 = 10 # [ps] "----------------------------------------" "------------BNLSE parameters------------" N_b = 10 Df_band = df * 2**N_b "------------GNLSE parameters------------" N_g = 14 "----------------------------------------" M = overlap(n2, lamda_c, gama) F, fp = dF_sidebands(betas, lamp, lamda_c, n2, M, P_p) sim_wind_g = \ formulate_GNLSE(int_fwm, N_g, z.end, dz_less, fp, df, F, lamp, lamda_c, P_p, P_s,P_i, pulse_GNLSE)[3] def test_energy_conserve_s0_pulse(self): u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b = \ formulate_BNLSE(int_fwm, self.N_b, self.z.end, self.dz_less, self.fp, self.df, self.F, self.Df_band, self.lamp, self.lamda_c, self.P_p,self.P_s, self.P_i, pulse, self.sim_wind_g.fv, self.sim_wind_g) ss = 0 u_out_b, U_out_b, temp1,temp2,temp3 = pulse_propagation_constant( u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b.dAdzmm, self.z) E1 = np.sum(np.linalg.norm(u_b, 2, axis=-1)**2) E2 = np.sum(np.linalg.norm(u_out_b, 2, axis=-1)**2) assert_allclose(E1, E2) def test_energy_conserve_s1_pulse(self): u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b = \ formulate_BNLSE(int_fwm, self.N_b, self.z.end, self.dz_less, self.fp, self.df, self.F, self.Df_band, self.lamp, self.lamda_c, self.P_p,self.P_s, self.P_i, pulse, self.sim_wind_g.fv, self.sim_wind_g) ss = 1 u_out_b, U_out_b, temp1,temp2,temp3 = pulse_propagation_constant( u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b.dAdzmm, self.z) E1 = np.sum(np.linalg.norm(u_b, 2, axis=-1)**2) E2 = np.sum(np.linalg.norm(u_out_b, 2, axis=-1)**2) assert_allclose(E1, E2) def test_energy_conserve_s0_cw(self): u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b = \ formulate_BNLSE(int_fwm, self.N_b, self.z.end, self.dz_less, self.fp, self.df, self.F, self.Df_band, self.lamp, self.lamda_c, self.P_p,self.P_s, self.P_i, cw, self.sim_wind_g.fv, self.sim_wind_g) ss = 0 u_out_b, U_out_b, temp1,temp2,temp3 = pulse_propagation_constant( u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b.dAdzmm, self.z) E1 = np.sum(np.linalg.norm(u_b, 2, axis=-1)**2) E2 = np.sum(np.linalg.norm(u_out_b, 2, axis=-1)**2) assert_allclose(E1, E2) def test_energy_conserve_s1_cw(self): u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b = \ formulate_BNLSE(int_fwm, self.N_b, self.z.end, self.dz_less, self.fp, self.df, self.F, self.Df_band, self.lamp, self.lamda_c, self.P_p,self.P_s, self.P_i, cw, self.sim_wind_g.fv, self.sim_wind_g) ss = 1 u_out_b, U_out_b, temp1,temp2,temp3 = pulse_propagation_constant( u_b, U_b, int_fwm_b, sim_wind_b, Dop_b, non_integrand_b.dAdzmm, self.z) E1 = np.sum(np.linalg.norm(u_b, 2, axis=-1)**2) E2 = np.sum(np.linalg.norm(u_out_b, 2, axis=-1)**2) assert_allclose(E1, E2)