From 042afd9dd646d6fb014ad93be1cf9f685ded2267 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Tue, 16 Jul 2024 19:36:30 +0200 Subject: [PATCH 01/13] add test for NS terminal expressions --- sympde/expr/tests/test_expr.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index efca3a98..556b377d 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1890,6 +1890,40 @@ def test_interface_integral_4(): assert expr[0].expr[0,0] == u2[0]*v2[0] assert expr[0].expr[1,1] == u2[1]*v2[1] + +#============================================================================== +def test_terminal_expressions_for_navier_stokes(): + + domain = Square() + x, y = domain.coordinates + + mu = 1 + ux = cos(y*pi) + uy = x*(x-1) + ue = Matrix([[ux], [uy]]) + pe = sin(pi*y) + # ... + + # Verify that div(u) = 0 + assert (ux.diff(x) + uy.diff(y)).simplify() == 0 + + # ... Compute right-hand side + from sympde.calculus import laplace, grad + from sympde.expr import TerminalExpr + + a = TerminalExpr(-mu*laplace(ue), domain) + b = TerminalExpr( grad(ue), domain) + c = TerminalExpr( grad(pe), domain) + + f = (a + b.T*ue + c).simplify() + + fx = -mu*(ux.diff(x, 2) + ux.diff(y, 2)) + ux*ux.diff(x) + uy*ux.diff(y) + pe.diff(x) + fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) + + assert (f[0]-fx).simplify() == 0 + assert (f[1]-fy).simplify() == 0 + + # ... #============================================================================== # CLEAN UP SYMPY NAMESPACE From f33646b89e3c18c8deca82076926d3965b68a9aa Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Thu, 18 Jul 2024 15:45:57 +0200 Subject: [PATCH 02/13] add comment and print for failing test --- sympde/expr/tests/test_expr.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 556b377d..55236fe6 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1908,9 +1908,6 @@ def test_terminal_expressions_for_navier_stokes(): assert (ux.diff(x) + uy.diff(y)).simplify() == 0 # ... Compute right-hand side - from sympde.calculus import laplace, grad - from sympde.expr import TerminalExpr - a = TerminalExpr(-mu*laplace(ue), domain) b = TerminalExpr( grad(ue), domain) c = TerminalExpr( grad(pe), domain) @@ -1920,6 +1917,10 @@ def test_terminal_expressions_for_navier_stokes(): fx = -mu*(ux.diff(x, 2) + ux.diff(y, 2)) + ux*ux.diff(x) + uy*ux.diff(y) + pe.diff(x) fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) + # [MCP 18.07.2024] for now, this test fails here because f is essentially 0: this should be fixed + print(f'a = {a}') + print(f'b = {b}') + print(f'f = {f}') assert (f[0]-fx).simplify() == 0 assert (f[1]-fy).simplify() == 0 From 18036f321fd9635b47993185c012be7ae7a9c582 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Thu, 25 Jul 2024 09:33:31 +0200 Subject: [PATCH 03/13] add another test with div-free fields --- sympde/expr/tests/test_expr.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 55236fe6..a8cdc9f9 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1925,6 +1925,24 @@ def test_terminal_expressions_for_navier_stokes(): assert (f[1]-fy).simplify() == 0 +def test_terminal_expressions_with_div_free_fields(): + + domain = Square() + x, y = domain.coordinates + + ux = sin(pi * x) * cos(pi * y) + uy = -cos(pi * x) * sin(pi * y) + + # Verify that div(u) = 0 + assert (ux.diff(x) + uy.diff(y)).simplify() == 0 + + vx = x**2*(-x + 1)**2*(4*y**3 - 6*y**2 + 2*y) + vy =-y**2*(-y + 1)**2*(4*x**3 - 6*x**2 + 2*x) + + # Verify that div(v) = 0 + assert (vx.diff(x) + vy.diff(y)).simplify() == 0 + + # ... #============================================================================== # CLEAN UP SYMPY NAMESPACE From 9b25a7ed214fa95e32830cc107225f4b3d1deea2 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 11:27:16 +0100 Subject: [PATCH 04/13] run test by hand --- sympde/expr/tests/test_expr.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index a8cdc9f9..8427b8ec 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1892,6 +1892,7 @@ def test_interface_integral_4(): #============================================================================== +@pytest.mark.xfail def test_terminal_expressions_for_navier_stokes(): domain = Square() @@ -1918,9 +1919,15 @@ def test_terminal_expressions_for_navier_stokes(): fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) # [MCP 18.07.2024] for now, this test fails here because f is essentially 0: this should be fixed + print(20*" -- ") + print(20*" -- ") print(f'a = {a}') + print(20*" -- ") print(f'b = {b}') + print(20*" -- ") print(f'f = {f}') + print(20*" -- ") + print(20*" -- ") assert (f[0]-fx).simplify() == 0 assert (f[1]-fy).simplify() == 0 @@ -1955,3 +1962,5 @@ def teardown_module(): def teardown_function(): from sympy.core import cache cache.clear_cache() + +test_terminal_expressions_for_navier_stokes() \ No newline at end of file From b2fceb60cfbc26b5ddc5dfacc4eaf3da111e05ec Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 11:36:53 +0100 Subject: [PATCH 05/13] run test directly only if main --- sympde/expr/tests/test_expr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 8427b8ec..5d6d6219 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1963,4 +1963,5 @@ def teardown_function(): from sympy.core import cache cache.clear_cache() -test_terminal_expressions_for_navier_stokes() \ No newline at end of file +if __name__ == '__main__': + test_terminal_expressions_for_navier_stokes() \ No newline at end of file From e10a496ab58157a5acc5d5e18460d95316fdce4d Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 11:51:04 +0100 Subject: [PATCH 06/13] running NS expr test by hand --- sympde/expr/tests/test_expr.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 5d6d6219..0a4e0eff 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1892,7 +1892,6 @@ def test_interface_integral_4(): #============================================================================== -@pytest.mark.xfail def test_terminal_expressions_for_navier_stokes(): domain = Square() @@ -1919,15 +1918,9 @@ def test_terminal_expressions_for_navier_stokes(): fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) # [MCP 18.07.2024] for now, this test fails here because f is essentially 0: this should be fixed - print(20*" -- ") - print(20*" -- ") print(f'a = {a}') - print(20*" -- ") print(f'b = {b}') - print(20*" -- ") print(f'f = {f}') - print(20*" -- ") - print(20*" -- ") assert (f[0]-fx).simplify() == 0 assert (f[1]-fy).simplify() == 0 @@ -1947,8 +1940,9 @@ def test_terminal_expressions_with_div_free_fields(): vy =-y**2*(-y + 1)**2*(4*x**3 - 6*x**2 + 2*x) # Verify that div(v) = 0 + AA = (vx.diff(x) + vy.diff(y)).simplify() assert (vx.diff(x) + vy.diff(y)).simplify() == 0 - + print(f'test = {AA}') # ... #============================================================================== @@ -1964,4 +1958,5 @@ def teardown_function(): cache.clear_cache() if __name__ == '__main__': + # test_terminal_expressions_with_div_free_fields() test_terminal_expressions_for_navier_stokes() \ No newline at end of file From 4aeb88652597d40c6f24b642d3ec715f7b334fd0 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 11:59:28 +0100 Subject: [PATCH 07/13] put strange test in different file --- sympde/expr/tests/try_expr_test.py | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sympde/expr/tests/try_expr_test.py diff --git a/sympde/expr/tests/try_expr_test.py b/sympde/expr/tests/try_expr_test.py new file mode 100644 index 00000000..85f380ac --- /dev/null +++ b/sympde/expr/tests/try_expr_test.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +# TODO: - add assert to every test + +import pytest + +from sympy.core.containers import Tuple +from sympy import Function +from sympy import pi, cos, sin, exp +from sympy import ImmutableDenseMatrix as Matrix + +from sympde.core import Constant +from sympde.calculus import grad, dot, inner, rot, div +from sympde.calculus import laplace, bracket, convect +from sympde.calculus import jump, avg, Dn, minus, plus + +from sympde.topology import dx1, dx2, dx3 +from sympde.topology import dx, dy, dz +from sympde.topology import Mapping +from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace +from sympde.topology import element_of, elements_of +from sympde.topology import InteriorDomain, Union +from sympde.topology import Boundary, NormalVector +from sympde.topology import Domain +#from sympde.topology import trace_1 # TODO [YG, 27.01.2021]: fix trace +from sympde.topology import Square +from sympde.topology import ElementDomain +from sympde.topology import Area + +from sympde.expr.expr import LinearExpr +from sympde.expr.expr import LinearForm, BilinearForm +from sympde.expr.expr import integral +from sympde.expr.expr import Functional, Norm +from sympde.expr.expr import linearize +from sympde.expr.evaluation import TerminalExpr + +def try_terminal_expressions_for_navier_stokes(): + + print("try this in a different file") + + domain = Square() + x, y = domain.coordinates + + mu = 1 + ux = cos(y*pi) + uy = x*(x-1) + ue = Matrix([[ux], [uy]]) + pe = sin(pi*y) + # ... + + # ... Compute right-hand side + a = TerminalExpr(-mu*laplace(ue), domain) + b = TerminalExpr( grad(ue), domain) + c = TerminalExpr( grad(pe), domain) + + # Verify that div(u) = 0 + assert (ux.diff(x) + uy.diff(y)).simplify() == 0 + + d = TerminalExpr(div(ue), domain) + assert d.simplify() == 0 + + f = (a + b.T*ue + c).simplify() + + fx = -mu*(ux.diff(x, 2) + ux.diff(y, 2)) + ux*ux.diff(x) + uy*ux.diff(y) + pe.diff(x) + fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) + + # [MCP 18.07.2024] for now, this test fails here because f is essentially 0: this should be fixed + print(f'a = {a}') + print(f'b = {b}') + print(f'f = {f}') + assert (f[0]-fx).simplify() == 0 + assert (f[1]-fy).simplify() == 0 + + +if __name__ == '__main__': + + try_terminal_expressions_for_navier_stokes() \ No newline at end of file From 22c89c94b6ebac2ac1b0ba0454d76bbe1ace38a2 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 11:59:49 +0100 Subject: [PATCH 08/13] test also div terminal expr --- sympde/expr/tests/test_expr.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 0a4e0eff..eb90148a 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1904,14 +1904,17 @@ def test_terminal_expressions_for_navier_stokes(): pe = sin(pi*y) # ... - # Verify that div(u) = 0 - assert (ux.diff(x) + uy.diff(y)).simplify() == 0 - # ... Compute right-hand side a = TerminalExpr(-mu*laplace(ue), domain) b = TerminalExpr( grad(ue), domain) c = TerminalExpr( grad(pe), domain) - + + # Verify that div(u) = 0 + assert (ux.diff(x) + uy.diff(y)).simplify() == 0 + + d = TerminalExpr(div(ue), domain) + assert d.simplify() == 0 + f = (a + b.T*ue + c).simplify() fx = -mu*(ux.diff(x, 2) + ux.diff(y, 2)) + ux*ux.diff(x) + uy*ux.diff(y) + pe.diff(x) From a74562b69efc0be9a3550995916e7db67d8c8b7e Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 12:02:26 +0100 Subject: [PATCH 09/13] reduce imports in try file --- sympde/expr/tests/try_expr_test.py | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/sympde/expr/tests/try_expr_test.py b/sympde/expr/tests/try_expr_test.py index 85f380ac..f7d8c4f5 100644 --- a/sympde/expr/tests/try_expr_test.py +++ b/sympde/expr/tests/try_expr_test.py @@ -2,36 +2,36 @@ # TODO: - add assert to every test -import pytest +# import pytest -from sympy.core.containers import Tuple -from sympy import Function +# from sympy.core.containers import Tuple +# from sympy import Function from sympy import pi, cos, sin, exp from sympy import ImmutableDenseMatrix as Matrix -from sympde.core import Constant +# from sympde.core import Constant from sympde.calculus import grad, dot, inner, rot, div from sympde.calculus import laplace, bracket, convect -from sympde.calculus import jump, avg, Dn, minus, plus - -from sympde.topology import dx1, dx2, dx3 -from sympde.topology import dx, dy, dz -from sympde.topology import Mapping -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import element_of, elements_of -from sympde.topology import InteriorDomain, Union -from sympde.topology import Boundary, NormalVector -from sympde.topology import Domain -#from sympde.topology import trace_1 # TODO [YG, 27.01.2021]: fix trace +# from sympde.calculus import jump, avg, Dn, minus, plus + +# from sympde.topology import dx1, dx2, dx3 +# from sympde.topology import dx, dy, dz +# from sympde.topology import Mapping +# from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace +# from sympde.topology import element_of, elements_of +# from sympde.topology import InteriorDomain, Union +# from sympde.topology import Boundary, NormalVector +# from sympde.topology import Domain +# #from sympde.topology import trace_1 # TODO [YG, 27.01.2021]: fix trace from sympde.topology import Square -from sympde.topology import ElementDomain -from sympde.topology import Area - -from sympde.expr.expr import LinearExpr -from sympde.expr.expr import LinearForm, BilinearForm -from sympde.expr.expr import integral -from sympde.expr.expr import Functional, Norm -from sympde.expr.expr import linearize +# from sympde.topology import ElementDomain +# from sympde.topology import Area + +# from sympde.expr.expr import LinearExpr +# from sympde.expr.expr import LinearForm, BilinearForm +# from sympde.expr.expr import integral +# from sympde.expr.expr import Functional, Norm +# from sympde.expr.expr import linearize from sympde.expr.evaluation import TerminalExpr def try_terminal_expressions_for_navier_stokes(): From 29439e2fccab8c7b1d69cf86e34919ef66cc8081 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 26 Feb 2025 12:46:49 +0100 Subject: [PATCH 10/13] testing also div operator --- sympde/expr/tests/test_expr.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index eb90148a..0ba0e4ae 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1912,6 +1912,7 @@ def test_terminal_expressions_for_navier_stokes(): # Verify that div(u) = 0 assert (ux.diff(x) + uy.diff(y)).simplify() == 0 + # again, with div operator d = TerminalExpr(div(ue), domain) assert d.simplify() == 0 @@ -1935,17 +1936,25 @@ def test_terminal_expressions_with_div_free_fields(): ux = sin(pi * x) * cos(pi * y) uy = -cos(pi * x) * sin(pi * y) + u = Matrix([[ux], [uy]]) # Verify that div(u) = 0 assert (ux.diff(x) + uy.diff(y)).simplify() == 0 + # again, with div operator + du = TerminalExpr(div(u), domain) + assert du.simplify() == 0 + vx = x**2*(-x + 1)**2*(4*y**3 - 6*y**2 + 2*y) vy =-y**2*(-y + 1)**2*(4*x**3 - 6*x**2 + 2*x) + v = Matrix([[vx], [vy]]) # Verify that div(v) = 0 - AA = (vx.diff(x) + vy.diff(y)).simplify() assert (vx.diff(x) + vy.diff(y)).simplify() == 0 - print(f'test = {AA}') + + # again, with div operator + dv = TerminalExpr(div(v), domain) + assert dv.simplify() == 0 # ... #============================================================================== From e122e5756de10d821ad58b37cf3a0202da90e9ff Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Thu, 27 Feb 2025 11:05:40 +0100 Subject: [PATCH 11/13] some cleaning --- sympde/expr/tests/test_expr.py | 12 ++--- sympde/expr/tests/try_expr_test.py | 77 ------------------------------ 2 files changed, 4 insertions(+), 85 deletions(-) delete mode 100644 sympde/expr/tests/try_expr_test.py diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 0ba0e4ae..bced37e0 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1912,7 +1912,7 @@ def test_terminal_expressions_for_navier_stokes(): # Verify that div(u) = 0 assert (ux.diff(x) + uy.diff(y)).simplify() == 0 - # again, with div operator + # and again with div operator d = TerminalExpr(div(ue), domain) assert d.simplify() == 0 @@ -1921,10 +1921,6 @@ def test_terminal_expressions_for_navier_stokes(): fx = -mu*(ux.diff(x, 2) + ux.diff(y, 2)) + ux*ux.diff(x) + uy*ux.diff(y) + pe.diff(x) fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) - # [MCP 18.07.2024] for now, this test fails here because f is essentially 0: this should be fixed - print(f'a = {a}') - print(f'b = {b}') - print(f'f = {f}') assert (f[0]-fx).simplify() == 0 assert (f[1]-fy).simplify() == 0 @@ -1941,7 +1937,7 @@ def test_terminal_expressions_with_div_free_fields(): # Verify that div(u) = 0 assert (ux.diff(x) + uy.diff(y)).simplify() == 0 - # again, with div operator + # and again with div operator du = TerminalExpr(div(u), domain) assert du.simplify() == 0 @@ -1952,7 +1948,7 @@ def test_terminal_expressions_with_div_free_fields(): # Verify that div(v) = 0 assert (vx.diff(x) + vy.diff(y)).simplify() == 0 - # again, with div operator + # and again with div operator dv = TerminalExpr(div(v), domain) assert dv.simplify() == 0 @@ -1969,6 +1965,6 @@ def teardown_function(): from sympy.core import cache cache.clear_cache() +# for running some tests with a direct call to file if __name__ == '__main__': - # test_terminal_expressions_with_div_free_fields() test_terminal_expressions_for_navier_stokes() \ No newline at end of file diff --git a/sympde/expr/tests/try_expr_test.py b/sympde/expr/tests/try_expr_test.py deleted file mode 100644 index f7d8c4f5..00000000 --- a/sympde/expr/tests/try_expr_test.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding: utf-8 - -# TODO: - add assert to every test - -# import pytest - -# from sympy.core.containers import Tuple -# from sympy import Function -from sympy import pi, cos, sin, exp -from sympy import ImmutableDenseMatrix as Matrix - -# from sympde.core import Constant -from sympde.calculus import grad, dot, inner, rot, div -from sympde.calculus import laplace, bracket, convect -# from sympde.calculus import jump, avg, Dn, minus, plus - -# from sympde.topology import dx1, dx2, dx3 -# from sympde.topology import dx, dy, dz -# from sympde.topology import Mapping -# from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -# from sympde.topology import element_of, elements_of -# from sympde.topology import InteriorDomain, Union -# from sympde.topology import Boundary, NormalVector -# from sympde.topology import Domain -# #from sympde.topology import trace_1 # TODO [YG, 27.01.2021]: fix trace -from sympde.topology import Square -# from sympde.topology import ElementDomain -# from sympde.topology import Area - -# from sympde.expr.expr import LinearExpr -# from sympde.expr.expr import LinearForm, BilinearForm -# from sympde.expr.expr import integral -# from sympde.expr.expr import Functional, Norm -# from sympde.expr.expr import linearize -from sympde.expr.evaluation import TerminalExpr - -def try_terminal_expressions_for_navier_stokes(): - - print("try this in a different file") - - domain = Square() - x, y = domain.coordinates - - mu = 1 - ux = cos(y*pi) - uy = x*(x-1) - ue = Matrix([[ux], [uy]]) - pe = sin(pi*y) - # ... - - # ... Compute right-hand side - a = TerminalExpr(-mu*laplace(ue), domain) - b = TerminalExpr( grad(ue), domain) - c = TerminalExpr( grad(pe), domain) - - # Verify that div(u) = 0 - assert (ux.diff(x) + uy.diff(y)).simplify() == 0 - - d = TerminalExpr(div(ue), domain) - assert d.simplify() == 0 - - f = (a + b.T*ue + c).simplify() - - fx = -mu*(ux.diff(x, 2) + ux.diff(y, 2)) + ux*ux.diff(x) + uy*ux.diff(y) + pe.diff(x) - fy = -mu*(uy.diff(x, 2) + uy.diff(y, 2)) + ux*uy.diff(x) + uy*uy.diff(y) + pe.diff(y) - - # [MCP 18.07.2024] for now, this test fails here because f is essentially 0: this should be fixed - print(f'a = {a}') - print(f'b = {b}') - print(f'f = {f}') - assert (f[0]-fx).simplify() == 0 - assert (f[1]-fy).simplify() == 0 - - -if __name__ == '__main__': - - try_terminal_expressions_for_navier_stokes() \ No newline at end of file From 1241286314cbb8f58f084b66b9455326ca8f5623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Thu, 27 Feb 2025 17:36:06 +0100 Subject: [PATCH 12/13] Improve script usage in test_expr.py: Provide simple mechanism to run multiple tests with a clear output --- sympde/expr/tests/test_expr.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index bced37e0..58cb262d 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1951,8 +1951,8 @@ def test_terminal_expressions_with_div_free_fields(): # and again with div operator dv = TerminalExpr(div(v), domain) assert dv.simplify() == 0 + assert False - # ... #============================================================================== # CLEAN UP SYMPY NAMESPACE #============================================================================== @@ -1965,6 +1965,24 @@ def teardown_function(): from sympy.core import cache cache.clear_cache() -# for running some tests with a direct call to file +#============================================================================== +# DIRECT CALL TO FILE (allows to run some tests directly) +#============================================================================== + if __name__ == '__main__': - test_terminal_expressions_for_navier_stokes() \ No newline at end of file + + # Tests that should be run (with no arguments) + tests = ( + test_terminal_expressions_for_navier_stokes, + test_terminal_expressions_with_div_free_fields + ) + + for test in tests: + try: + print(f"Running: {test.__name__}... ", end='') + test() + except: + print("FAIL") + raise + else: + print("PASS") From 83ea6632cb518c278f3286d1d764801e0a82ffb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Thu, 27 Feb 2025 17:42:22 +0100 Subject: [PATCH 13/13] Remove failing assert from test_expr.py --- sympde/expr/tests/test_expr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sympde/expr/tests/test_expr.py b/sympde/expr/tests/test_expr.py index 58cb262d..ebcfb19b 100644 --- a/sympde/expr/tests/test_expr.py +++ b/sympde/expr/tests/test_expr.py @@ -1951,7 +1951,6 @@ def test_terminal_expressions_with_div_free_fields(): # and again with div operator dv = TerminalExpr(div(v), domain) assert dv.simplify() == 0 - assert False #============================================================================== # CLEAN UP SYMPY NAMESPACE