diff --git a/CHANGELOG.md b/CHANGELOG.md index 73d03dc9f1..a60c8c50f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# [Unreleased](https://github.com/pybamm-team/PyBaMM/) + +## Bug fixes + +- Fixed `sympy` operators for `Arctan` and `Exponential` ([#1786](https://github.com/pybamm-team/PyBaMM/pull/1786)) + # [v21.10](https://github.com/pybamm-team/PyBaMM/tree/v21.9) - 2021-10-31 ## Features diff --git a/pybamm/expression_tree/functions.py b/pybamm/expression_tree/functions.py index ebe2cfd356..59b05b5170 100644 --- a/pybamm/expression_tree/functions.py +++ b/pybamm/expression_tree/functions.py @@ -321,6 +321,10 @@ def _function_diff(self, children, idx): """See :meth:`pybamm.Function._function_diff()`.""" return 1 / (children[0] ** 2 + 1) + def _sympy_operator(self, child): + """Override :meth:`pybamm.Function._sympy_operator`""" + return sympy.atan(child) + def arctan(child): """Returns hyperbolic tan function of child.""" @@ -390,6 +394,10 @@ def _function_diff(self, children, idx): """See :meth:`pybamm.Function._function_diff()`.""" return Exponential(children[0]) + def _sympy_operator(self, child): + """Override :meth:`pybamm.Function._sympy_operator`""" + return sympy.exp(child) + def exp(child): """Returns exponential function of child.""" diff --git a/tests/unit/test_expression_tree/test_functions.py b/tests/unit/test_expression_tree/test_functions.py index ffbe514f20..5c7f5bba95 100644 --- a/tests/unit/test_expression_tree/test_functions.py +++ b/tests/unit/test_expression_tree/test_functions.py @@ -140,6 +140,12 @@ def test_to_equation(self): # Test Arcsinh self.assertEqual(pybamm.Arcsinh(a).to_equation(), sympy.asinh(a)) + # Test Arctan + self.assertEqual(pybamm.Arctan(a).to_equation(), sympy.atan(a)) + + # Test Exponential + self.assertEqual(pybamm.Exponential(a).to_equation(), sympy.exp(a)) + # Test log self.assertEqual(pybamm.Log(54.0).to_equation(), sympy.log(54.0))