diff --git a/pybamm/expression_tree/symbol.py b/pybamm/expression_tree/symbol.py
index 6f6acfc6..99d5f617 100644
--- a/pybamm/expression_tree/symbol.py
+++ b/pybamm/expression_tree/symbol.py
@@ -9,6 +9,8 @@ import anytree
 import numbers
 import copy
 
+from anytree.exporter import DotExporter
+
 
 class Symbol(anytree.NodeMixin):
     """Base node class for the expression tree
@@ -89,6 +91,57 @@ class Symbol(anytree.NodeMixin):
         for pre, _, node in anytree.RenderTree(self):
             print("%s%s" % (pre, str(node)))
 
+    def visualise(self, filename, test=False):
+        """Produces a .png file of the tree (this node and its children) with the
+        name filename"""
+
+        new_node, counter = self.relabel_tree(self, 0)
+
+        # check that filename ends in .png.
+        filename = "view_tree/" + filename + ".png"
+
+        if test is False:
+            DotExporter(
+                new_node, nodeattrfunc=lambda node: 'label="{}"'.format(node.label)
+            ).to_picture(filename)
+
+    def relabel_tree(self, symbol, counter):
+        """ Finds all children of a symbol and assigns them a new id so that they can be
+                visualised properly using the graphviz output
+        """
+        name = symbol.name
+        if name == "div":
+            name = "&nabla;&sdot;"
+        elif name == "grad":
+            name = "&nabla;"
+        elif name == "/":
+            name = "&divide;"
+        elif name == "*":
+            name = "&times;"
+        elif name == "-":
+            name = "&minus;"
+        elif name == "+":
+            name = "&#43;"
+        elif name == "**":
+            name = "^"
+        elif name == "epsilon_s":
+            name = "&#603;"
+
+        new_node = anytree.Node(str(counter), label=name)
+        counter += 1
+
+        if isinstance(symbol, pybamm.BinaryOperator):
+            left, right = symbol.children
+            new_left, counter = self.relabel_tree(left, counter)
+            new_right, counter = self.relabel_tree(right, counter)
+            new_node.children = [new_left, new_right]
+
+        elif isinstance(symbol, pybamm.UnaryOperator):
+            new_child, counter = self.relabel_tree(symbol.children[0], counter)
+            new_node.children = [new_child]
+
+        return new_node, counter
+
     def pre_order(self):
         """returns an iterable that steps through the tree in pre-order
         fashion
diff --git a/pybamm/models/submodels/electrolyte.py b/pybamm/models/submodels/electrolyte.py
index b41b5e50..acad18a1 100644
--- a/pybamm/models/submodels/electrolyte.py
+++ b/pybamm/models/submodels/electrolyte.py
@@ -44,11 +44,9 @@ class StefanMaxwellDiffusion(pybamm.BaseModel):
 
         c_e = pybamm.Variable("c_e", domain=electrolyte_domain)
 
-        N_e = -(epsilon ** b) * pybamm.Gradient(c_e)
+        N_e = -(epsilon ** b) * pybamm.grad(c_e)
 
-        self.rhs = {
-            c_e: -pybamm.Divergence(N_e) / delta / epsilon + nu * (1 - t_plus) * G
-        }
+        self.rhs = {c_e: -pybamm.div(N_e) / delta / epsilon + nu * (1 - t_plus) * G}
         self.initial_conditions = {c_e: ce0}
         self.boundary_conditions = {
             N_e: {"left": pybamm.Scalar(0), "right": pybamm.Scalar(0)}

Improve tree visualisation
**Summary**
Add a method to visualize the tree within an svg file. 

**Reason** 
Is useful for demonstrating what the code is doing and for a user to make manual checks on inputted models.

diff --git a/tests/test_base_model.py b/tests/test_base_model.py
new file mode 100644
index 00000000..94dddd06
--- /dev/null
+++ b/tests/test_base_model.py
@@ -0,0 +1,73 @@
+#
+# Tests for the base model class
+#
+import pybamm
+
+import unittest
+
+
+class TestBaseModel(unittest.TestCase):
+    def test_rhs_set_get(self):
+        model = pybamm.BaseModel()
+        rhs = {
+            pybamm.Symbol("c"): pybamm.Symbol("alpha"),
+            pybamm.Symbol("d"): pybamm.Symbol("beta"),
+        }
+        model.rhs = rhs
+        self.assertEqual(rhs, model.rhs)
+        # test domains
+        rhs = {
+            pybamm.Symbol("c", domain=["negative electrode"]): pybamm.Symbol(
+                "alpha", domain=["negative electrode"]
+            ),
+            pybamm.Symbol("d", domain=["positive electrode"]): pybamm.Symbol(
+                "beta", domain=["positive electrode"]
+            ),
+        }
+        model.rhs = rhs
+        self.assertEqual(rhs, model.rhs)
+        # non-matching domains should fail
+        with self.assertRaises(pybamm.DomainError):
+            model.rhs = {
+                pybamm.Symbol("c", domain=["positive electrode"]): pybamm.Symbol(
+                    "alpha", domain=["negative electrode"]
+                )
+            }
+
+    def test_initial_conditions_set_get(self):
+        model = pybamm.BaseModel()
+        initial_conditions = {
+            pybamm.Symbol("c0"): pybamm.Symbol("gamma"),
+            pybamm.Symbol("d0"): pybamm.Symbol("delta"),
+        }
+        model.initial_conditions = initial_conditions
+        self.assertEqual(initial_conditions, model.initial_conditions)
+
+    def test_boundary_conditions_set_get(self):
+        model = pybamm.BaseModel()
+        boundary_conditions = {"c_left": "epsilon", "c_right": "eta"}
+        model.boundary_conditions = boundary_conditions
+        self.assertEqual(boundary_conditions, model.boundary_conditions)
+
+    def test_variables_set_get(self):
+        model = pybamm.BaseModel()
+        variables = {"c": "alpha", "d": "beta"}
+        model.variables = variables
+        self.assertEqual(variables, model.variables)
+
+    def test_model_dict_behaviour(self):
+        model = pybamm.BaseModel()
+        key = pybamm.Symbol("c")
+        rhs = {key: pybamm.Symbol("alpha")}
+        model.rhs = rhs
+        self.assertEqual(model[key], rhs[key])
+        self.assertEqual(model[key], model.rhs[key])
+
+
+if __name__ == "__main__":
+    print("Add -v for more debug output")
+    import sys
+
+    if "-v" in sys.argv:
+        debug = True
+    unittest.main()
diff --git a/tests/test_expression_tree/test_symbol.py b/tests/test_expression_tree/test_symbol.py
index b787d7f7..147a8477 100644
--- a/tests/test_expression_tree/test_symbol.py
+++ b/tests/test_expression_tree/test_symbol.py
@@ -136,6 +136,13 @@ class TestSymbol(unittest.TestCase):
             r"Symbol\(" + hex_regex + ", a, grad\(a\)\)",
         )
 
+    def test_symbol_visualise(self):
+        G = pybamm.Symbol("G")
+        model = pybamm.electrolyte.StefanMaxwellDiffusion(G)
+        c_e = list(model.rhs.keys())[0]
+        rhs = model.rhs[c_e]
+        rhs.visualise("StefanMaxwell_test", test=True)
+
 
 if __name__ == "__main__":
     print("Add -v for more debug output")

pip install -e .[dev,docs]
parse_log_pytest
requirements.txt
flake8 pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
anyio==3.6.2
anytree==2.8.0
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
async-generator==1.10
attrs==22.2.0
Babel==2.11.0
backcall==0.2.0
bleach==4.1.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
comm==0.1.4
contextvars==2.4
cycler==0.11.0
dataclasses==0.8
decorator==5.1.1
defusedxml==0.7.1
docutils==0.17.1
entrypoints==0.4
flake8==5.0.4
idna==3.10
imagesize==1.4.1
immutables==0.19
importlib-metadata==4.2.0
iniconfig==1.1.1
ipykernel==5.5.6
ipython==7.16.3
ipython-genutils==0.2.0
ipywidgets==7.8.5
jedi==0.17.2
Jinja2==3.0.3
json5==0.9.16
jsonschema==3.2.0
jupyter==1.1.1
jupyter-client==7.1.2
jupyter-console==6.4.3
jupyter-core==4.9.2
jupyter-server==1.13.1
jupyterlab==3.2.9
jupyterlab-pygments==0.1.2
jupyterlab-server==2.10.3
jupyterlab_widgets==1.1.11
kiwisolver==1.3.1
MarkupSafe==2.0.1
matplotlib==3.3.4
mccabe==0.7.0
mistune==0.8.4
nbclassic==0.3.5
nbclient==0.5.9
nbconvert==6.0.7
nbformat==5.1.3
nest-asyncio==1.6.0
notebook==6.4.10
numpy==1.19.5
packaging==21.3
pandas==1.1.5
pandocfilters==1.5.1
parso==0.7.1
pexpect==4.9.0
pickleshare==0.7.5
Pillow==8.4.0
pluggy==1.0.0
prometheus-client==0.17.1
prompt-toolkit==3.0.36
ptyprocess==0.7.0
py==1.11.0
-e git+https://github.com/tinosulzer/PyBaMM.git@0d54ab4c834bce7ca0f068904f5f9561fca4bba1#egg=pybamm
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.14.0
pyparsing==3.1.4
pyrsistent==0.18.0
pytest==7.0.1
python-dateutil==2.9.0.post0
pytz==2025.2
pyzmq==25.1.2
requests==2.27.1
scipy==1.5.4
Send2Trash==1.8.3
six==1.17.0
sniffio==1.2.0
snowballstemmer==2.2.0
Sphinx==4.3.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
terminado==0.12.1
testpath==0.6.0
tomli==1.2.3
tornado==6.1
traitlets==4.3.3
typing_extensions==4.1.1
urllib3==1.26.20
wcwidth==0.2.13
webencodings==0.5.1
websocket-client==1.3.1
widgetsnbextension==3.6.10
zipp==3.6.0

name: PyBaMM
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - anyio==3.6.2
      - anytree==2.8.0
      - argon2-cffi==21.3.0
      - argon2-cffi-bindings==21.2.0
      - async-generator==1.10
      - attrs==22.2.0
      - babel==2.11.0
      - backcall==0.2.0
      - bleach==4.1.0
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - comm==0.1.4
      - contextvars==2.4
      - cycler==0.11.0
      - dataclasses==0.8
      - decorator==5.1.1
      - defusedxml==0.7.1
      - docutils==0.17.1
      - entrypoints==0.4
      - flake8==5.0.4
      - idna==3.10
      - imagesize==1.4.1
      - immutables==0.19
      - importlib-metadata==4.2.0
      - iniconfig==1.1.1
      - ipykernel==5.5.6
      - ipython==7.16.3
      - ipython-genutils==0.2.0
      - ipywidgets==7.8.5
      - jedi==0.17.2
      - jinja2==3.0.3
      - json5==0.9.16
      - jsonschema==3.2.0
      - jupyter==1.1.1
      - jupyter-client==7.1.2
      - jupyter-console==6.4.3
      - jupyter-core==4.9.2
      - jupyter-server==1.13.1
      - jupyterlab==3.2.9
      - jupyterlab-pygments==0.1.2
      - jupyterlab-server==2.10.3
      - jupyterlab-widgets==1.1.11
      - kiwisolver==1.3.1
      - markupsafe==2.0.1
      - matplotlib==3.3.4
      - mccabe==0.7.0
      - mistune==0.8.4
      - nbclassic==0.3.5
      - nbclient==0.5.9
      - nbconvert==6.0.7
      - nbformat==5.1.3
      - nest-asyncio==1.6.0
      - notebook==6.4.10
      - numpy==1.19.5
      - packaging==21.3
      - pandas==1.1.5
      - pandocfilters==1.5.1
      - parso==0.7.1
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pillow==8.4.0
      - pluggy==1.0.0
      - prometheus-client==0.17.1
      - prompt-toolkit==3.0.36
      - ptyprocess==0.7.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pyrsistent==0.18.0
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyzmq==25.1.2
      - requests==2.27.1
      - scipy==1.5.4
      - send2trash==1.8.3
      - six==1.17.0
      - sniffio==1.2.0
      - snowballstemmer==2.2.0
      - sphinx==4.3.2
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - terminado==0.12.1
      - testpath==0.6.0
      - tomli==1.2.3
      - tornado==6.1
      - traitlets==4.3.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - websocket-client==1.3.1
      - widgetsnbextension==3.6.10
      - zipp==3.6.0
prefix: /opt/conda/envs/PyBaMM

tests/test_expression_tree/test_symbol.py::TestSymbol::test_symbol_visualise
tests/test_base_model.py::TestBaseModel::test_boundary_conditions_set_get tests/test_base_model.py::TestBaseModel::test_initial_conditions_set_get tests/test_base_model.py::TestBaseModel::test_model_dict_behaviour tests/test_base_model.py::TestBaseModel::test_rhs_set_get tests/test_base_model.py::TestBaseModel::test_variables_set_get tests/test_expression_tree/test_symbol.py::TestSymbol::test_multiple_symbols tests/test_expression_tree/test_symbol.py::TestSymbol::test_symbol_evaluation tests/test_expression_tree/test_symbol.py::TestSymbol::test_symbol_init tests/test_expression_tree/test_symbol.py::TestSymbol::test_symbol_methods tests/test_expression_tree/test_symbol.py::TestSymbol::test_symbol_repr
pybamm/expression_tree/symbol.py pybamm/models/submodels/electrolyte.py
pybamm/expression_tree/symbol.py pybamm/models/submodels/electrolyte.py