Repository: pybamm-team/PyBaMM (python)

Issue:
[Bug]: skip_step option should return termination condition
### PyBaMM Version

v25.4.0

### Python Version

3.12.7

### Describe the bug

It would be helpful if the new `skip_step` option (#4839) could return empty solutions with the correct `termination` condition.

### Steps to Reproduce

Here is an example of an experiment with two steps. The second step cannot be initialized because the current constraint is violated. However, the termination returned is "final time" from the first step.
```
import pybamm
parameter_values = pybamm.ParameterValues("Chen2020")
model = pybamm.lithium_ion.SPMe()
experiment = pybamm.Experiment(
    [
        "Rest for 10 min",
        "Hold at 3.8V for 1h until > 5A",
    ]
)
sim = pybamm.Simulation(
    model,
    experiment=experiment,
    parameter_values=parameter_values,
)
solution = sim.solve()
print(f"Termination: {solution.termination}")
```

### Relevant log output

```shell

```

Pull request:
Update the termination state when skip_ok is enabled
# Description

Update the termination state when `skip_ok` is enabled. The termination state is now updated when a step fails to initialize because of a constraint.

Fixes #4961 

## 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 #)

# Important checks:

Please confirm the following before marking the PR as ready for review:
- No style issues: `nox -s pre-commit`
- All tests pass: `nox -s tests`
- The documentation builds: `nox -s doctests`
- Code is commented for hard-to-understand areas
- Tests added that prove fix is effective or that feature works


Patch:
diff --git a/src/pybamm/simulation.py b/src/pybamm/simulation.py
index 14b9a193e..e776255d8 100644
--- a/src/pybamm/simulation.py
+++ b/src/pybamm/simulation.py
@@ -871,6 +871,9 @@ class Simulation:
                                 pybamm.logger.warning(
                                     f"Step '{step_str}' is infeasible at initial conditions, but skip_ok is True. Skipping step."
                                 )
+
+                                # Update the termination and continue
+                                self._solution.termination = step_solution.termination
                                 continue
                             else:
                                 raise pybamm.SolverError(


Test patch:
diff --git a/tests/unit/test_experiments/test_simulation_with_experiment.py b/tests/unit/test_experiments/test_simulation_with_experiment.py
index 9468aa3e0..d2ec75eeb 100644
--- a/tests/unit/test_experiments/test_simulation_with_experiment.py
+++ b/tests/unit/test_experiments/test_simulation_with_experiment.py
@@ -187,6 +187,16 @@ class TestSimulationExperiment:
         with pytest.raises(pybamm.SolverError, match="skip_ok is True for all steps"):
             sim.solve()
 
+        # Check termination after a skipped step
+        steps = [
+            pybamm.step.Current(2, duration=100.0, skip_ok=False),
+            cc_charge_skip_ok,
+        ]
+        experiment = pybamm.Experiment(steps)
+        sim = pybamm.Simulation(model, experiment=experiment, parameter_values=param)
+        sol = sim.solve()
+        assert sol.termination == "Event exceeded in initial conditions"
+
     def test_all_empty_solution_errors(self):
         model = pybamm.lithium_ion.SPM()
         parameter_values = pybamm.ParameterValues("Chen2020")