示例#1
0
文件: test_tools.py 项目: wdachub/lit
def test_that_l2norm_of_sinx_on_domain_with_L_of_2pi_equals_sqrt_of_half_of_Lsq(
):
    L = 2.0 * np.pi
    N = 128
    st = ScalarTool(N, L)
    X = np.mgrid[:N, :N].astype(float) * (L / N)
    th = np.sin(2.0 * np.pi * X[0] / L)
    assert math.isclose(st.l2norm(th), (0.5 * L**2)**0.5)
示例#2
0
文件: test_tools.py 项目: wdachub/lit
def test_l2norm_of_a_scalar_should_be_nearly_invariant_of_discretization():
    L = 10.0
    Narray = np.array([64, 128, 256, 512]).astype('int')
    l2norm = np.zeros(len(Narray))
    for i, N in enumerate(Narray):
        st = ScalarTool(N, L)
        X = np.mgrid[:N, :N].astype(float) * (L / N)
        th = np.sin(2.0 * np.pi * X[0] / L)
        l2norm[i] = st.l2norm(th)
    assert np.allclose(l2norm[-1], l2norm)
示例#3
0
文件: test_tools.py 项目: wdachub/lit
def test_that_sinx_on_domain_with_L_of_2pi_has_equal_norms():
    L = 2.0 * np.pi
    N = 128
    st = ScalarTool(N, L)
    X = np.mgrid[:N, :N].astype(float) * (L / N)
    th = np.sin(2.0 * np.pi * X[0] / L)
    l2norm = st.l2norm(th)
    h1norm = st.h1norm(th)
    hm1norm = st.hm1norm(th)
    print(l2norm)
    print(h1norm)
    print(hm1norm)
    assert (math.isclose(l2norm, h1norm) and math.isclose(l2norm, hm1norm))
示例#4
0
文件: test_tools.py 项目: wdachub/lit
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)