From 0cdddd14ce43dd67d291c5553069225efd36f5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Mon, 12 Jun 2023 15:12:04 +0200 Subject: [PATCH 1/4] Update TerminalExpr.eval() Process argument of functions exp, sin, cos. TODO: process arguments of generic functions in SymPy. --- sympde/expr/evaluation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sympde/expr/evaluation.py b/sympde/expr/evaluation.py index 7cd02bbe..8b06f070 100644 --- a/sympde/expr/evaluation.py +++ b/sympde/expr/evaluation.py @@ -8,6 +8,7 @@ from sympy import Abs, S, cacheit from sympy import Indexed, Matrix, ImmutableDenseMatrix from sympy import expand +from sympy import exp, sin, cos from sympy.core import Basic, Symbol from sympy.core import Add, Mul, Pow from sympy.core.expr import AtomicExpr @@ -547,6 +548,10 @@ def eval(cls, expr, domain): exp = cls.eval(expr.exp, domain=domain) return base**exp + elif isinstance(expr, (exp, sin, cos)): # TODO [YG 12.06.2023]: use generic SymPy type + args = [cls.eval(a, domain=domain) for a in expr.args] + return type(expr)(*args) + elif isinstance(expr, JacobianSymbol): axis = expr.axis J = expr.mapping.jacobian_expr From 5f6044ca39dc98e97969b6c8891599f2382c0692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Mon, 12 Jun 2023 15:21:29 +0200 Subject: [PATCH 2/4] Do not use exp as a variable --- sympde/expr/evaluation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sympde/expr/evaluation.py b/sympde/expr/evaluation.py index 8b06f070..b5c3d8e8 100644 --- a/sympde/expr/evaluation.py +++ b/sympde/expr/evaluation.py @@ -544,9 +544,9 @@ def eval(cls, expr, domain): return Abs(cls.eval(expr.args[0], domain=domain)) elif isinstance(expr, Pow): - base = cls.eval(expr.base, domain=domain) - exp = cls.eval(expr.exp, domain=domain) - return base**exp + b = cls.eval(expr.base, domain=domain) + e = cls.eval(expr.exp , domain=domain) + return b ** e elif isinstance(expr, (exp, sin, cos)): # TODO [YG 12.06.2023]: use generic SymPy type args = [cls.eval(a, domain=domain) for a in expr.args] From 0a1e038b030f01af5eb8d4183090198ae31dac8a Mon Sep 17 00:00:00 2001 From: vcarlier Date: Thu, 22 Jun 2023 10:48:59 +0200 Subject: [PATCH 3/4] general trigonometric function -test --- sympde/expr/evaluation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sympde/expr/evaluation.py b/sympde/expr/evaluation.py index b5c3d8e8..5c58f8f6 100644 --- a/sympde/expr/evaluation.py +++ b/sympde/expr/evaluation.py @@ -14,6 +14,7 @@ from sympy.core.expr import AtomicExpr from sympy.core.containers import Tuple from sympy.simplify.simplify import simplify +from sympy.functions.elementary.trigonometric import TrigonometricFunction from sympde.core.basic import _coeffs_registery from sympde.core.basic import CalculusFunction @@ -549,6 +550,8 @@ def eval(cls, expr, domain): return b ** e elif isinstance(expr, (exp, sin, cos)): # TODO [YG 12.06.2023]: use generic SymPy type + #elif isinstance(expr, Function): # TODO [YG 12.06.2023]: use generic SymPy type + args = [cls.eval(a, domain=domain) for a in expr.args] return type(expr)(*args) From 51e6af47babb9f2df292a8f8c7865197864e3880 Mon Sep 17 00:00:00 2001 From: vcarlier Date: Thu, 22 Jun 2023 10:52:04 +0200 Subject: [PATCH 4/4] add generic hyperbolic or trigonometric function in eval --- sympde/expr/evaluation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sympde/expr/evaluation.py b/sympde/expr/evaluation.py index 5c58f8f6..b499aeec 100644 --- a/sympde/expr/evaluation.py +++ b/sympde/expr/evaluation.py @@ -15,6 +15,7 @@ from sympy.core.containers import Tuple from sympy.simplify.simplify import simplify from sympy.functions.elementary.trigonometric import TrigonometricFunction +from sympy.functions.elementary.hyperbolic import HyperbolicFunction from sympde.core.basic import _coeffs_registery from sympde.core.basic import CalculusFunction @@ -549,8 +550,7 @@ def eval(cls, expr, domain): e = cls.eval(expr.exp , domain=domain) return b ** e - elif isinstance(expr, (exp, sin, cos)): # TODO [YG 12.06.2023]: use generic SymPy type - #elif isinstance(expr, Function): # TODO [YG 12.06.2023]: use generic SymPy type + elif isinstance(expr, (TrigonometricFunction,HyperbolicFunction)): # TODO [YG 12.06.2023]: use generic SymPy type args = [cls.eval(a, domain=domain) for a in expr.args] return type(expr)(*args)