|
1 | 1 | import numpy as np
|
2 | 2 | from numpy.testing import assert_array_almost_equal_nulp
|
3 | 3 |
|
4 |
| -from ppmpy.euler import Euler |
5 |
| -from ppmpy.initial_conditions import sod |
| 4 | +from ppmpy.euler import Euler, FluidVars |
| 5 | +from ppmpy.initial_conditions import sod, acoustic_pulse |
6 | 6 |
|
7 | 7 |
|
8 |
| -class TestGrid: |
| 8 | +class TestFluidVars: |
| 9 | + |
| 10 | + @classmethod |
| 11 | + def setup_class(cls): |
| 12 | + """ this is run once for each class before any tests """ |
| 13 | + |
| 14 | + @classmethod |
| 15 | + def teardown_class(cls): |
| 16 | + """ this is run once for each class after all tests """ |
| 17 | + |
| 18 | + def setup_method(self): |
| 19 | + """ this is run before each test """ |
| 20 | + |
| 21 | + self.v = FluidVars() |
| 22 | + |
| 23 | + def teardown_method(self): |
| 24 | + """ this is run after each test """ |
| 25 | + |
| 26 | + def test_indices(self): |
| 27 | + assert self.v.urho == self.v.qrho |
| 28 | + assert self.v.umx == self.v.qu |
| 29 | + assert self.v.uener == self.v.qp |
| 30 | + |
| 31 | + |
| 32 | +class TestEuler: |
9 | 33 |
|
10 | 34 | @classmethod
|
11 | 35 | def setup_class(cls):
|
@@ -47,7 +71,7 @@ def test_cons_to_prim(self):
|
47 | 71 | assert q[-1, v.qu] == u_r
|
48 | 72 | assert q[-1, v.qp] == p_r
|
49 | 73 |
|
50 |
| - def test_properties(self): |
| 74 | + def test_estimate_dt(self): |
51 | 75 |
|
52 | 76 | # for sod, there is only a left and right state. No initial velocity
|
53 | 77 | # so we can just get the soundspeed
|
@@ -80,3 +104,57 @@ def test_result(self):
|
80 | 104 | 0.125001080305388, 0.1250000106083176])
|
81 | 105 |
|
82 | 106 | assert_array_almost_equal_nulp(self.euler.U[self.euler.grid.lo:self.euler.grid.hi+1, 0], answer, nulp=9)
|
| 107 | + |
| 108 | + |
| 109 | +class TestEulerReconstruction: |
| 110 | + |
| 111 | + @classmethod |
| 112 | + def setup_class(cls): |
| 113 | + """ this is run once for each class before any tests """ |
| 114 | + |
| 115 | + @classmethod |
| 116 | + def teardown_class(cls): |
| 117 | + """ this is run once for each class after all tests """ |
| 118 | + |
| 119 | + def setup_method(self): |
| 120 | + """ this is run before each test """ |
| 121 | + |
| 122 | + self.euler = Euler(16, 0.5, init_cond=acoustic_pulse) |
| 123 | + self.euler.estimate_dt() |
| 124 | + |
| 125 | + def teardown_method(self): |
| 126 | + """ this is run after each test """ |
| 127 | + |
| 128 | + def test_construct_parabola(self): |
| 129 | + |
| 130 | + self.euler.construct_parabola() |
| 131 | + |
| 132 | + ans = np.array([0.0000000000000000e+00, 0.0000000000000000e+00, |
| 133 | + 0.0000000000000000e+00, 0.0000000000000000e+00, |
| 134 | + 0.0000000000000000e+00, -1.4925725604797435e-05, |
| 135 | + -5.5892314022898404e-04, -3.1886159900746947e-03, |
| 136 | + -1.1509891420676155e-02, -1.5395301015125540e-02, |
| 137 | + -7.3670928260867186e-03, 0.0000000000000000e+00, |
| 138 | + 0.0000000000000000e+00, -7.3670928260867186e-03, |
| 139 | + -1.5395301015125540e-02, -1.1509891420676155e-02, |
| 140 | + -3.1886159900746947e-03, -5.5892314022898404e-04, |
| 141 | + -1.4925725604797435e-05, 0.0000000000000000e+00, |
| 142 | + 0.0000000000000000e+00, 0.0000000000000000e+00, |
| 143 | + 0.0000000000000000e+00, 0.0000000000000000e+00]) |
| 144 | + |
| 145 | + assert_array_almost_equal_nulp(self.euler.q_parabola[0].a6, ans) |
| 146 | + |
| 147 | + ans2 = np.array([0.0000000000000000e+00, 0.0000000000000000e+00, |
| 148 | + -8.8817841970012523e-16, 0.0000000000000000e+00, |
| 149 | + -8.8817841970012523e-16, -1.4925738349269579e-05, |
| 150 | + -5.5894233322995035e-04, -3.1567942491133039e-03, |
| 151 | + -1.1552096619801056e-02, -1.5947978794340401e-02, |
| 152 | + -8.1712935823112787e-03, 0.0000000000000000e+00, |
| 153 | + 0.0000000000000000e+00, -8.1712935823112787e-03, |
| 154 | + -1.5947978794340401e-02, -1.1552096619801056e-02, |
| 155 | + -3.1567942491133039e-03, -5.5894233322995035e-04, |
| 156 | + -1.4925738349269579e-05, -8.8817841970012523e-16, |
| 157 | + 0.0000000000000000e+00, -8.8817841970012523e-16, |
| 158 | + 0.0000000000000000e+00, 0.0000000000000000e+00]) |
| 159 | + |
| 160 | + assert_array_almost_equal_nulp(self.euler.q_parabola[2].a6, ans2) |
0 commit comments