Repository: pybamm-team/PyBaMM

Issue:
Default Solver Casadi
Make casadi the default solver

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d7bb2309..fc47c4c40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 
 ## Optimizations
 
+-   Changed default solver for DAE models to `CasadiSolver` ([#978](https://github.com/pybamm-team/PyBaMM/pull/978))
 -   Added some extra simplifications to the expression tree ([#971](https://github.com/pybamm-team/PyBaMM/pull/971))
 -   Changed the behaviour of "safe" mode in `CasadiSolver` ([#956](https://github.com/pybamm-team/PyBaMM/pull/956))
 -   Sped up model building ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))
diff --git a/pybamm/models/base_model.py b/pybamm/models/base_model.py
index 2a16c024a..44f5cf29e 100644
--- a/pybamm/models/base_model.py
+++ b/pybamm/models/base_model.py
@@ -651,9 +651,6 @@ class BaseModel(object):
         "Return default solver based on whether model is ODE model or DAE model"
         if len(self.algebraic) == 0:
             return pybamm.ScipySolver()
-        elif pybamm.have_idaklu() and self.use_jacobian is True:
-            # KLU solver requires jacobian to be provided
-            return pybamm.IDAKLUSolver()
         else:
             return pybamm.CasadiSolver(mode="safe")
 
@@ -677,11 +674,7 @@ def find_symbol_in_dict(dic, name):
 
 
 def find_symbol_in_model(model, name):
-    dics = [
-        model.rhs,
-        model.algebraic,
-        model.variables,
-    ]
+    dics = [model.rhs, model.algebraic, model.variables]
     for dic in dics:
         dic_return = find_symbol_in_dict(dic, name)
         if dic_return:
diff --git a/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py b/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py
index bbf97bf0d..990434414 100644
--- a/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py
+++ b/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py
@@ -42,17 +42,6 @@ class BaseModel(pybamm.BaseBatteryModel):
         var = pybamm.standard_spatial_vars
         return {var.x_n: 25, var.x_s: 41, var.x_p: 34, var.y: 10, var.z: 10}
 
-    @property
-    def default_solver(self):
-        """
-        Return default solver based on whether model is ODE model or DAE model.
-        There are bugs with KLU on the lead-acid models.
-        """
-        if len(self.algebraic) == 0:
-            return pybamm.ScipySolver()
-        else:
-            return pybamm.CasadiSolver(mode="safe")
-
     def set_soc_variables(self):
         "Set variables relating to the state of charge."
         # State of Charge defined as function of dimensionless electrolyte concentration
diff --git a/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py b/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py
index 26819f11f..e74fe39cb 100644
--- a/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py
+++ b/pybamm/models/submodels/current_collector/effective_resistance_current_collector.py
@@ -217,4 +217,4 @@ class EffectiveResistance2D(pybamm.BaseModel):
 
     @property
     def default_solver(self):
-        return pybamm.AlgebraicSolver()
+        return pybamm.CasadiAlgebraicSolver()


Test patch:
diff --git a/tests/unit/test_models/test_submodels/test_current_collector/test_effective_current_collector.py b/tests/unit/test_models/test_submodels/test_current_collector/test_effective_current_collector.py
index 352d6a726..66a17b5a1 100644
--- a/tests/unit/test_models/test_submodels/test_current_collector/test_effective_current_collector.py
+++ b/tests/unit/test_models/test_submodels/test_current_collector/test_effective_current_collector.py
@@ -19,7 +19,7 @@ class TestEffectiveResistance2D(unittest.TestCase):
 
     def test_default_solver(self):
         model = pybamm.current_collector.EffectiveResistance2D()
-        self.assertIsInstance(model.default_solver, pybamm.AlgebraicSolver)
+        self.assertIsInstance(model.default_solver, pybamm.CasadiAlgebraicSolver)
 
     def test_get_processed_potentials(self):
         # solve cheap SPM to test processed potentials (think of an alternative test?)