Repository: pybamm-team/PyBaMM (python)

Issue:
Increase default r_pts
I think we should increase the default r_pts from 10. E.g.
```python3
import pybamm
import numpy as np

model = pybamm.lithium_ion.DFN()

chemistry = pybamm.parameter_sets.Ecker2015
parameter_values = pybamm.ParameterValues(chemistry=chemistry)

var = pybamm.standard_spatial_vars
npts = [10, 20, 25, 30, 40, 50]

solver = pybamm.CasadiSolver(mode="fast")
t_eval = np.linspace(0, 3800, 200)

sols = []
for N in npts:
    var_pts = {var.x_n: 20, var.x_s: 20, var.x_p: 20, var.r_n: N, var.r_p: N}
    sim = pybamm.Simulation(
        model, solver=solver, parameter_values=parameter_values, var_pts=var_pts
    )
    sol = sim.solve(t_eval=t_eval)
    print("N={}: {} s".format(N, sol.solve_time))
    sols.append(sol)

pybamm.dynamic_plot(sols, ["Terminal voltage [V]"], time_unit="seconds", labels=npts)
```

gives 

N=10: 0.15861007800413063 s
N=20: 0.235911022995424 s
N=25: 0.29073380999761866 s
N=30: 0.31032642299396684 s
N=40: 0.4951283990012598 s
N=50: 0.5220356229983736 s


![Figure_2](https://user-images.githubusercontent.com/43040151/85523692-37762900-b5ff-11ea-9139-933e013cc036.png)

My vote would be somewhere between 20 and 30 


Pull request description:
#1075 update default var pts
# Description
Update the default variable points

Fixes #1075 

## Type of change

Please add a line in the relevant section of [CHANGELOG.md](https://github.com/pybamm-team/PyBaMM/blob/master/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

- [ ] New feature (non-breaking change which adds functionality)
- [ ] Optimization (back-end change that speeds up the code)
- [ ] Bug fix (non-breaking change which fixes an issue)


# Key checklist:

- [ ] No style issues: `$ flake8`
- [ ] All tests pass: `$ python run-tests.py --unit`
- [ ] The documentation builds: `$ cd docs` and then `$ make clean; make html`

You can run all three at once, using `$ python run-tests.py --quick`.

## Further checks:

- [ ] Code is commented, particularly in hard-to-understand areas
- [ ] Tests added that prove fix is effective or that feature works


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14b1d7798..427d2673d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
 
 ## Bug fixes
 
+-   Update the default variable points to better capture behaviour in the solid particles in li-ion models ([#1081](https://github.com/pybamm-team/PyBaMM/pull/1081))
 -   Fix `QuickPlot` to display variables discretised by FEM (in y-z) properly ([#1078](https://github.com/pybamm-team/PyBaMM/pull/1078))
 -   Add length scales to `EffectiveResistance` models ([#1071](https://github.com/pybamm-team/PyBaMM/pull/1071))
 -   Allowed for pybamm functions exp, sin, cos, sqrt to be used in expression trees that
diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py
index d499d08d2..fef75e178 100644
--- a/pybamm/models/full_battery_models/base_battery_model.py
+++ b/pybamm/models/full_battery_models/base_battery_model.py
@@ -113,15 +113,19 @@ class BaseBatteryModel(pybamm.BaseModel):
     @property
     def default_var_pts(self):
         var = pybamm.standard_spatial_vars
-        return {
+        base_var_pts = {
             var.x_n: 20,
             var.x_s: 20,
             var.x_p: 20,
-            var.r_n: 10,
-            var.r_p: 10,
+            var.r_n: 30,
+            var.r_p: 30,
             var.y: 10,
             var.z: 10,
         }
+        # Reduce the default points for 2D current collectors
+        if self.options["dimensionality"] == 2:
+            base_var_pts.update({var.x_n: 10, var.x_s: 10, var.x_p: 10})
+        return base_var_pts
 
     @property
     def default_submesh_types(self):


Test patch:
diff --git a/tests/integration/test_solvers/test_solution.py b/tests/integration/test_solvers/test_solution.py
index 487f8016f..c764feb05 100644
--- a/tests/integration/test_solvers/test_solution.py
+++ b/tests/integration/test_solvers/test_solution.py
@@ -84,8 +84,11 @@ class TestSolution(unittest.TestCase):
         # solve model
         solver = model.default_solver
 
+        var = pybamm.standard_spatial_vars
+        Nr = model.default_var_pts[var.r_n]
+
         T_av = 0
-        c_s_n_av = np.ones((10, 1)) * 0.6
+        c_s_n_av = np.ones((Nr, 1)) * 0.6
         external_variables = {
             "Volume-averaged cell temperature": T_av,
             "X-averaged negative particle concentration": c_s_n_av,
@@ -111,7 +114,7 @@ class TestSolution(unittest.TestCase):
         t_eval = np.linspace(0, 3600)
         sol = solver.solve(model, t_eval, external_variables=external_variables)
         np.testing.assert_array_equal(
-            sol.inputs["Volume-averaged cell temperature"], np.zeros((1, len(sol.t))),
+            sol.inputs["Volume-averaged cell temperature"], np.zeros((1, len(sol.t)))
         )
         np.testing.assert_array_equal(
             sol.inputs["X-averaged negative particle concentration"],
diff --git a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py
index 635ccc04f..d7d90e0cd 100644
--- a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py
+++ b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py
@@ -76,6 +76,24 @@ class TestBaseBatteryModel(unittest.TestCase):
             )
         )
 
+    def test_default_var_pts(self):
+        var = pybamm.standard_spatial_vars
+        var_pts = {
+            var.x_n: 20,
+            var.x_s: 20,
+            var.x_p: 20,
+            var.r_n: 30,
+            var.r_p: 30,
+            var.y: 10,
+            var.z: 10,
+        }
+        model = pybamm.BaseBatteryModel({"dimensionality": 0})
+        self.assertDictEqual(var_pts, model.default_var_pts)
+
+        var_pts.update({var.x_n: 10, var.x_s: 10, var.x_p: 10})
+        model = pybamm.BaseBatteryModel({"dimensionality": 2})
+        self.assertDictEqual(var_pts, model.default_var_pts)
+
     def test_default_spatial_methods(self):
         model = pybamm.BaseBatteryModel({"dimensionality": 0})
         self.assertTrue(
diff --git a/tests/unit/test_simulation.py b/tests/unit/test_simulation.py
index 3222383c7..896decf8b 100644
--- a/tests/unit/test_simulation.py
+++ b/tests/unit/test_simulation.py
@@ -244,8 +244,11 @@ class TestSimulation(unittest.TestCase):
         model = pybamm.lithium_ion.SPMe(model_options)
         sim = pybamm.Simulation(model)
 
+        var = pybamm.standard_spatial_vars
+        Nr = model.default_var_pts[var.r_n]
+
         T_av = 0
-        c_s_n_av = np.ones((10, 1)) * 0.5
+        c_s_n_av = np.ones((Nr, 1)) * 0.5
         external_variables = {
             "Volume-averaged cell temperature": T_av,
             "X-averaged negative particle concentration": c_s_n_av,