Example #1
0
    def test_euler_jacobian(self):
        S, J = euler_operator(self.sbp, self.state)

        for i, grad in enumerate(J):
            f = lambda x: euler_operator(self.sbp, x)[0][i]
            grad_approx = approx_fprime(self.state, f, 1e-8)
            grad_exact = J[i, :]
            err = np.linalg.norm(grad_approx - grad_exact, ord=np.inf)
            print("Euler OP, Gradient error = {:.2e}".format(err))
            self.assertTrue(err < 1e-5)
Example #2
0
    def spatial_op(state):
        S,J = euler_operator(sbp, state) + \
              wall_operator(sbp, state, 0, 'w') + \
              outflow_operator(sbp, state, 0, 'e') + \
              wall_operator(sbp, state, 0, 's') + \
              wall_operator(sbp, state, 0, 'n')

        return S, J
Example #3
0
    def spatial_op(state):
        S,J = euler_operator(sbp, state) + \
              inflow_operator(sbp, state, 0, 'w', -1, 0) + \
              pressure_operator(sbp, state, 0, 'e') + \
              wall_operator(sbp, state, 0, 's') + \
              wall_operator(sbp, state, 0, 'n')

        return S, J