Repository: pybamm-team/PyBaMM (python)

Issue:
[Bug]: incorrect error message for multiple input params
### PyBaMM Version

develop

### Python Version

3.10

### Describe the bug

Say you want to create an input parameter but forget to pass the updated params to the simulation class:

```python
import pybamm
import numpy as np

model = pybamm.lithium_ion.SPM()
params = model.default_parameter_values
params.update({
    "Current function [A]": "[input]",
})
solver = pybamm.IDAKLUSolver()
sim = pybamm.Simulation(pybamm.lithium_ion.SPM(), solver=solver)
sol = sim.solve([0, 3600], inputs=[{"Current function [A]": 1}, {"Current function [A]": 2}])
```

This produces the following error:

```
Traceback (most recent call last):
  File "/home/mrobins/git/PyBaMM/test.py", line 11, in <module>
    sol = sim.solve([0, 3600], inputs=[{"Current function [A]": 1}, {"Current function [A]": 2}])
  File "/home/mrobins/git/PyBaMM/env/lib/python3.10/site-packages/pybamm/simulation.py", line 542, in solve
    self._solution = solver.solve(
  File "/home/mrobins/git/PyBaMM/env/lib/python3.10/site-packages/pybamm/solvers/base_solver.py", line 824, in solve
    raise pybamm.SolverError(
pybamm.expression_tree.exceptions.SolverError: Input parameters cannot appear in expression for initial conditions.
```

Which is incorrect. The correct response should be to not error and carry on the simulation, as the solver has all the input parameters it needs (since there are none in the model)

### Steps to Reproduce

see above

### Relevant log output

```shell

```

Pull request:
bug: fix case where multiple inputs are passed, but no inputs in model
# Description

Fixes #4864

## Type of change

Please add a line in the relevant section of [CHANGELOG.md](https://github.com/pybamm-team/PyBaMM/blob/develop/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

- [x] Bug fix (non-breaking change which fixes an issue)

# Key checklist:

- [x] No style issues: `$ pre-commit run` (or `$ nox -s pre-commit`) (see [CONTRIBUTING.md](https://github.com/pybamm-team/PyBaMM/blob/develop/CONTRIBUTING.md#installing-and-using-pre-commit) for how to set this up to run automatically when committing locally, in just two lines of code)
- [x] All tests pass: `$ python -m pytest` (or `$ nox -s tests`)
- [x] The documentation builds: `$ python -m pytest --doctest-plus src` (or `$ nox -s doctests`)

You can run integration tests, unit tests, and doctests together at once, using `$ nox -s quick`.

## Further checks:

- [x] Code is commented, particularly in hard-to-understand areas
- [x] Tests added that prove fix is effective or that feature works


Patch:
diff --git a/src/pybamm/solvers/base_solver.py b/src/pybamm/solvers/base_solver.py
index 9b19f0a8a..49e9b928a 100644
--- a/src/pybamm/solvers/base_solver.py
+++ b/src/pybamm/solvers/base_solver.py
@@ -809,20 +809,24 @@ class BaseSolver:
         # when len(inputs_list) > 1, only `model_inputs_list[0]`
         # is passed to `_set_consistent_initialization`.
         # See https://github.com/pybamm-team/PyBaMM/pull/1261
-        if len(inputs_list) > 1:
+        if len(model_inputs_list) > 1:
             all_inputs_names = set(
                 itertools.chain.from_iterable(
                     [model_inputs.keys() for model_inputs in model_inputs_list]
                 )
             )
-            initial_conditions_node_names = set(
-                [it.name for it in model.concatenated_initial_conditions.pre_order()]
-            )
-            if all_inputs_names.issubset(initial_conditions_node_names):
-                raise pybamm.SolverError(
-                    "Input parameters cannot appear in expression "
-                    "for initial conditions."
+            if all_inputs_names:
+                initial_conditions_node_names = set(
+                    [
+                        it.name
+                        for it in model.concatenated_initial_conditions.pre_order()
+                    ]
                 )
+                if all_inputs_names.issubset(initial_conditions_node_names):
+                    raise pybamm.SolverError(
+                        "Input parameters cannot appear in expression "
+                        "for initial conditions."
+                    )
 
         # if any setup configuration has changed, we need to re-set up
         if sensitivities_have_changed:
diff --git a/src/pybamm/solvers/idaklu_solver.py b/src/pybamm/solvers/idaklu_solver.py
index d23e4fdb4..86ff83839 100644
--- a/src/pybamm/solvers/idaklu_solver.py
+++ b/src/pybamm/solvers/idaklu_solver.py
@@ -765,7 +765,7 @@ class IDAKLUSolver(pybamm.BaseSolver):
                 ]
             )
         else:
-            inputs = np.array([[]])
+            inputs = np.array([[]] * len(inputs_list))
 
         # stack y0full and ydot0full so they are a 2D array of shape (number_of_inputs, number_of_states + number_of_parameters * number_of_states)
         # note that y0full and ydot0full are currently 1D arrays (i.e. independent of inputs), but in the future we will support


Test patch:
diff --git a/tests/unit/test_solvers/test_base_solver.py b/tests/unit/test_solvers/test_base_solver.py
index 513a9e3e9..f67248ade 100644
--- a/tests/unit/test_solvers/test_base_solver.py
+++ b/tests/unit/test_solvers/test_base_solver.py
@@ -38,6 +38,20 @@ class TestBaseSolver:
         ):
             pybamm.BaseSolver(root_method=pybamm.ScipySolver())
 
+    def test_additional_inputs_provided(self):
+        # if additional inputs are provided that are not in the model, this should run as normal
+        sim = pybamm.Simulation(pybamm.lithium_ion.SPM(), solver=pybamm.IDAKLUSolver())
+        sol1 = sim.solve([0, 3600])["Voltage [V]"].entries
+        sol2 = sim.solve([0, 3600], inputs={"Current function [A]": 1})[
+            "Voltage [V]"
+        ].entries
+        sol3 = sim.solve(
+            [0, 3600], inputs=[{"Current function [A]": 1}, {"Current function [A]": 2}]
+        )[0]["Voltage [V]"].entries
+        # check that the solutions are the same
+        np.testing.assert_array_almost_equal(sol1, sol2)
+        np.testing.assert_array_almost_equal(sol2, sol3)
+
     def test_step_or_solve_empty_model(self):
         model = pybamm.BaseModel()
         solver = pybamm.BaseSolver()