def test_curl_is_equal_to_curl_computed_with_grad_function(): N = 128 L = 2.0 kappa = 0.0 gamma = 1.0 v = np.random.random((2, N, N)) # print(np.shape(v)) st = ScalarTool(N, L) vt = VectorTool(N, L) v = vt.div_free_proj(v) v = vt.dealias(v) c = st.grad(v[1])[0] - st.grad(v[0])[1] assert np.allclose(c, vt.curl(v))
def test_l2norm_squared_of_curl_of_vector_is_spatial_integral_of_neg_vector_times_lap_vector( ): N = 128 L = 2.0 kappa = 0.0 gamma = 1.0 v = np.random.random((2, N, N)) # print(np.shape(v)) st = ScalarTool(N, L) vt = VectorTool(N, L) v = vt.div_free_proj(v) v = vt.dealias(v) curl = vt.curl(v) a = st.l2norm(curl)**2. b = st.sint(np.sum(-vt.lap(v) * v, 0)) assert np.allclose(a, b)