def _test_perfect_overlap(params): (ly, lt, lr, rr, ns), geom, lx = params kwargs = {'geom': geom, 'logt': lt, 'logy': ly, 'logx': lx, 'nstencil': ns, 'lrefl': lr, 'rrefl': rr} # zero offset (offset = 0.0) tout, Cout, info, rd = integrate_rd(D=1e-5, N=64, offset=0, sigma_q=13, **kwargs) assert info['success'] delta_C = Cout[:, :, 0] - Cout[:, :, 1] # test that the species do not deviate (weak test) assert np.all(np.abs(delta_C) < 1e-3)
def _test_pair_centered_at_x0_different_sigma(params): (ly, lt, lr, rr, ns), geom, lx = params kwargs = {'geom': geom, 'logt': lt, 'logy': ly, 'logx': lx, 'nstencil': ns, 'lrefl': lr, 'rrefl': rr} # separated gaussians (offset = 0.25) N = 64*(8 if ly else 1)*(4 if ns > 3 else 1) tout, Cout, info, rd = integrate_rd( D=-3e-8, t0=1e-6, tend=7, x0=1e-6, xend=1.0, N=N, base=0, offset=0, nt=25, sigma_q=101, sigma_skew=0.1, **kwargs) assert info['success'] mass_consv = np.array([ [rd.integrated_conc(Cout[j, :, i]) for i in range(rd.n)] for j in range(tout.size) ]) assert np.all(np.abs(mass_consv - mass_consv[[0], :]) < 1e-4)
def _test_mass_conservation(params): (ly, lt, lr, rr, ns), geom, lx = params kwargs = {'geom': geom, 'logt': lt, 'logy': ly, 'logx': lx, 'nstencil': ns, 'lrefl': lr, 'rrefl': rr} # separated gaussians (offset = 0.25) N = 64*(4 if ly else 1)*(8 if ns > 3 else 1) tout, Cout, info, rd = integrate_rd( D=-3e-8, t0=1e-6, tend=7, x0=0.1, xend=1.0, N=N, offset=.25, nt=25, sigma_q=101, **kwargs) assert info['success'] mass_consv = np.array([ [rd.integrated_conc(Cout[j, :, i]) for i in range(rd.n)] for j in range(tout.size) ]) print(mass_consv - mass_consv[[0], :]) assert np.all(np.abs(mass_consv - mass_consv[[0], :]) < 1e-5) # For current parameters gaussians are well separated at end # of simulation, hence we expect maximum Efield to have same # value as in the beginning of simulation efield_i = rd.calc_efield(Cout[0, :, :].flatten()) efield_f = rd.calc_efield(Cout[-1, :, :].flatten()) assert abs(np.max(np.abs(efield_i)) - np.max(np.abs(efield_f))) < 1e-6