def test_variables(self): solver, finit = self.case_solver(50, 50, xn.extrapol2d1(), 'centered') assert not finit.isnan() data = 2 * finit.phydata('kinetic-energy') - finit.phydata( 'density') * (finit.phydata('velocity_x')**2 + finit.phydata('velocity_y')**2) error = np.sum(np.abs(data)) assert error < 1.e-12
def test_O1_hlle(self): solver, finit = self.case_solver(50, 50, xn.extrapol2d1(), 'hlle') endtime = 5. cfl = 1.6 fsol = solver.solve(finit, cfl, [endtime]) assert not fsol[-1].isnan() rhoavg, rhovar = fsol[-1].stats("density") assert rhoavg == pytest.approx(1.408796) # mass conservation assert rhovar == pytest.approx(5.12e-6, rel=.01)
def test_centered(self): solver, finit = self.case_solver(50, 50, xn.extrapol2d1(), 'centered') endtime = 5. cfl = 2.5 fsol = solver.solve(finit, cfl, [endtime]) assert not fsol[-1].isnan() rhoavg, rhovar = fsol[-1].stats("density") assert rhoavg == pytest.approx(1.408796) # mass conservation assert rhovar == pytest.approx(.00115, rel=.01)
def test_flow_sup(self): endtime = 100. cfl = 1.5 bcL = {'type': 'insup', 'ptot': 2.8, 'rttot': 1., 'p': 1.} bcR = {'type': 'outsup'} solver, finit = self.case_solver(20, 5, xn.extrapol2d1(), 'hlle', bcL, bcR) fsol = solver.solve(finit, cfl, [endtime]) assert not fsol[-1].isnan() mach_th = np.sqrt(((bcL['ptot'] / bcL['p'])**(1. / 3.5) - 1.) / .2) error = np.sqrt( np.sum((fsol[-1].phydata('mach') - mach_th)**2) / fsol[-1].nelem) / mach_th assert error < 1.e-8