Repository: pybamm-team/PyBaMM

Issue:
[Bug]: "electrode diffusivity" -> "particle diffusivity" is still breaking change on `develop` when using pre-24.5 pybamm.ParameterValues
### PyBaMM Version

develop

### Python Version

3.9.13

### Describe the bug

Since #4072 re-inverted the logic fix in #3871, the release candidate on `develop` causes the rename of "electrode diffusivity" -> "particle diffusivity" to be a breaking change. Parameter sets using the old key names do not simulate in the 24.5 RC.

### Steps to Reproduce

```python
import pybamm

parameter_values = pybamm.ParameterValues("Chen2020")

# Dummy a pybamm.ParameterValues object with a legacy parameter name
parameter_values.update(
    {
        "Negative electrode diffusivity [m2.s-1]": parameter_values["Negative particle diffusivity [m2.s-1]"],
    },
    check_already_exists=False,
)
del parameter_values["Negative particle diffusivity [m2.s-1]"]

# Try to run a simulation with the old-style parameter set
model = pybamm.lithium_ion.DFN()
experiment = pybamm.Experiment(
    [
        "Discharge at 1C until 3 V",
    ]
)
sim = pybamm.Simulation(
    model,
    parameter_values=parameter_values,
    experiment=experiment,
)

# KeyError provoked here on call into pybamm.ParameterValues with new key name
sol = sim.solve()
```

### Relevant log output

_No response_

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pybamm-team/PyBaMM/pull/4267?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 99.56%. Comparing base [(`ab7348f`)](https://app.codecov.io/gh/pybamm-team/PyBaMM/commit/ab7348fe05a42510e3e0fe3be0a606eae7f5364e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team) to head [(`ded1844`)](https://app.codecov.io/gh/pybamm-team/PyBaMM/commit/ded1844af500ed8c092b6ce06f515b20056cf0d4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team).
> Report is 2 commits behind head on develop.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##           develop    #4267    +/-   ##
=========================================
  Coverage    99.55%   99.56%            
=========================================
  Files          288      288            
  Lines        21897    22089   +192     
=========================================
+ Hits         21800    21992   +192     
  Misses          97       97            
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/pybamm-team/PyBaMM/pull/4267?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team).


Patch:
diff --git a/pybamm/util.py b/pybamm/util.py
index 0fe02c835..130cb5ba4 100644
--- a/pybamm/util.py
+++ b/pybamm/util.py
@@ -57,14 +57,22 @@ class FuzzyDict(dict):
         try:
             return super().__getitem__(key)
         except KeyError as error:
-            if "particle diffusivity" in key:
-                warn(
-                    f"The parameter '{key.replace('particle', 'electrode')}' "
-                    f"has been renamed to '{key}'",
-                    DeprecationWarning,
-                    stacklevel=2,
+            if "electrode diffusivity" in key or "particle diffusivity" in key:
+                old_term, new_term = (
+                    ("electrode", "particle")
+                    if "electrode diffusivity" in key
+                    else ("particle", "electrode")
                 )
-                return super().__getitem__(key.replace("particle", "electrode"))
+                alternative_key = key.replace(old_term, new_term)
+
+                if old_term == "electrode":
+                    warn(
+                        f"The parameter '{alternative_key}' has been renamed to '{key}' and will be removed in a future release. Using '{key}'",
+                        DeprecationWarning,
+                        stacklevel=2,
+                    )
+
+                return super().__getitem__(alternative_key)
             if key in ["Negative electrode SOC", "Positive electrode SOC"]:
                 domain = key.split(" ")[0]
                 raise KeyError(


Test patch:
diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
index 21673a44f..abcdb4dca 100644
--- a/tests/unit/test_util.py
+++ b/tests/unit/test_util.py
@@ -34,6 +34,11 @@ class TestUtil:
                 "SEI current": 3,
                 "Lithium plating current": 4,
                 "A dimensional variable [m]": 5,
+                "Positive particle diffusivity [m2.s-1]": 6,
+            }
+        )
+        d2 = pybamm.FuzzyDict(
+            {
                 "Positive electrode diffusivity [m2.s-1]": 6,
             }
         )
@@ -56,6 +61,16 @@ class TestUtil:
         with pytest.raises(KeyError, match="Upper voltage"):
             d.__getitem__("Open-circuit voltage at 100% SOC [V]")
 
+        assert (
+            d2["Positive particle diffusivity [m2.s-1]"]
+            == d["Positive particle diffusivity [m2.s-1]"]
+        )
+
+        assert (
+            d2["Positive electrode diffusivity [m2.s-1]"]
+            == d["Positive electrode diffusivity [m2.s-1]"]
+        )
+
         with pytest.warns(DeprecationWarning):
             assert (
                 d["Positive electrode diffusivity [m2.s-1]"]