"vscode:/vscode.git/clone" did not exist on "6985e58938d40ad91ac07b0fddcfad8132e1447e"
friction_test.py 2.57 KB
Newer Older
mashun1's avatar
veros  
mashun1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from veros.core import friction
from veros.pyom_compat import get_random_state

from test_base import compare_state


TEST_SETTINGS = dict(
    nx=70,
    ny=60,
    nz=50,
    dt_tracer=3600,
    dt_mom=3600,
    enable_cyclic_x=True,
    enable_conserve_energy=True,
    enable_bottom_friction_var=True,
    enable_hor_friction_cos_scaling=True,
    enable_momentum_sources=True,
    r_ray=1,
    r_bot=1,
    r_quad_bot=1,
    A_h=1,
    A_hbi=1,
)


def test_explicit_vert_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.explicit_vert_friction(vs_state))
    pyom_obj.explicit_vert_friction()
    compare_state(vs_state, pyom_obj)


def test_implicit_vert_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.implicit_vert_friction(vs_state))
    pyom_obj.implicit_vert_friction()
    compare_state(vs_state, pyom_obj)


def test_rayleigh_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.rayleigh_friction(vs_state))
    pyom_obj.rayleigh_friction()
    compare_state(vs_state, pyom_obj)


def test_linear_bottom_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.linear_bottom_friction(vs_state))
    pyom_obj.linear_bottom_friction()
    compare_state(vs_state, pyom_obj)


def test_quadratic_bottom_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.quadratic_bottom_friction(vs_state))
    pyom_obj.quadratic_bottom_friction()
    compare_state(vs_state, pyom_obj)


def test_harmonic_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.harmonic_friction(vs_state))
    pyom_obj.harmonic_friction()
    compare_state(vs_state, pyom_obj)


def test_biharmonic_friction(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.biharmonic_friction(vs_state))
    pyom_obj.biharmonic_friction()
    compare_state(vs_state, pyom_obj)


def test_momentum_sources(pyom2_lib):
    vs_state, pyom_obj = get_random_state(pyom2_lib, extra_settings=TEST_SETTINGS)
    vs_state.variables.update(friction.momentum_sources(vs_state))
    pyom_obj.momentum_sources()
    compare_state(vs_state, pyom_obj)