Skip to content

Commit

Permalink
add unit test for normal_dot_vec (PaddlePaddle#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatV authored Jun 17, 2023
1 parent 20ee40d commit 7ed7c1e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/equation/test_normal_dot_vec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import paddle
import pytest

from ppsci import equation


def compute_func(x: tuple, y: tuple):
z_i = paddle.zeros_like(x[0])
for x_i, y_i in zip(x, y):
z_i += x_i * y_i
return z_i


def test_normal_dot_vel():
batch_size = 13
u = paddle.randn([batch_size, 1])
v = paddle.randn([batch_size, 1])
w = paddle.randn([batch_size, 1])

normal_x = paddle.randn([batch_size, 1])
normal_y = paddle.randn([batch_size, 1])
normal_z = paddle.randn([batch_size, 1])

pde = equation.NormalDotVec(("u", "v", "w"))
out = {
"u": u,
"v": v,
"w": w,
"normal_x": normal_x,
"normal_y": normal_y,
"normal_z": normal_z,
}

expected_result = compute_func((u, v, w), (normal_x, normal_y, normal_z))
assert paddle.allclose(pde.equations["normal_dot_vel"](out), expected_result)


if __name__ == "__main__":
pytest.main()

0 comments on commit 7ed7c1e

Please sign in to comment.