Repository: pybamm-team/PyBaMM

Issue:
Simplify `GetConstantCurrent`
Allow `GetConstantCurrent` function to be simplified to just be a `pybamm.Scalar`

Discussion:

Patch:
diff --git a/pybamm/expression_tree/functions.py b/pybamm/expression_tree/functions.py
index efc634fa6..d6b7525bd 100644
--- a/pybamm/expression_tree/functions.py
+++ b/pybamm/expression_tree/functions.py
@@ -182,8 +182,11 @@ class Function(pybamm.Symbol):
          :: pybamm.Function if there are children
         """
         if self.takes_no_params is True:
-            # If self.func() takes no parameters then we can always simplify it
+            # If self.function() takes no parameters then we can always simplify it
             return pybamm.Scalar(self.function())
+        elif isinstance(self.function, pybamm.GetConstantCurrent):
+            # If self.function() is a constant current then simplify to scalar
+            return pybamm.Scalar(self.function.parameters_eval["Current [A]"])
         else:
             return pybamm.Function(self.function, *simplified_children)
 


Test patch:
diff --git a/tests/unit/test_parameters/test_current_functions.py b/tests/unit/test_parameters/test_current_functions.py
index f2b800323..927205cbf 100644
--- a/tests/unit/test_parameters/test_current_functions.py
+++ b/tests/unit/test_parameters/test_current_functions.py
@@ -14,6 +14,18 @@ class TestCurrentFunctions(unittest.TestCase):
         assert isinstance(function(np.zeros(3)), numbers.Number)
         assert isinstance(function(np.zeros([3, 3])), numbers.Number)
 
+        # test simplify
+        current = pybamm.electrical_parameters.current_with_time
+        parameter_values = pybamm.ParameterValues(
+            {
+                "Typical current [A]": 2,
+                "Typical timescale [s]": 1,
+                "Current function": pybamm.GetConstantCurrent(),
+            }
+        )
+        processed_current = parameter_values.process_symbol(current)
+        self.assertIsInstance(processed_current.simplify(), pybamm.Scalar)
+
     def test_get_current_data(self):
         # test units
         function_list = [