Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'simplification' and other associated tests #1362 #1369

Merged
merged 19 commits into from
Feb 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@

## Breaking changes

- Removed `Simplification` class and `.simplify()` function ([#1369](https://github.com/pybamm-team/PyBaMM/pull/1369))
- All example notebooks in PyBaMM's GitHub repository must now include the command `pybamm.print_citations()`, otherwise the tests will fail. This is to encourage people to use this command to cite the relevant papers ([#1340](https://github.com/pybamm-team/PyBaMM/pull/1340))
- Notation has been homogenised to use positive and negative electrode (instead of cathode and anode). This applies to the parameter folders (now called `'positive_electrodes'` and `'negative_electrodes'`) and the options of `active_material` and `particle_cracking` submodels (now called `'positive'` and `'negative'`) ([#1337](https://github.com/pybamm-team/PyBaMM/pull/1337))
- `Interpolant` now takes `x` and `y` instead of a single `data` entry ([#1312](https://github.com/pybamm-team/PyBaMM/pull/1312))
1 change: 0 additions & 1 deletion docs/source/expression_tree/operations/index.rst
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ Classes and functions that operate on the expression tree

.. toctree::

simplify
evaluate
jacobian
convert_to_casadi
11 changes: 0 additions & 11 deletions docs/source/expression_tree/operations/simplify.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/source/expression_tree/symbol.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Symbol
======
.. autofunction:: pybamm.simplify_if_constant

.. autoclass:: pybamm.Symbol
:special-members:
4 changes: 2 additions & 2 deletions examples/notebooks/expression_tree/expression-tree.ipynb
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@
"metadata": {},
"outputs": [],
"source": [
"diff_wrt_equation = equation.diff(t).simplify()\n",
"diff_wrt_equation = equation.diff(t)\n",
"diff_wrt_equation.visualise('expression_tree2.png')"
]
},
@@ -274,4 +274,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
7 changes: 0 additions & 7 deletions pybamm/__init__.py
Original file line number Diff line number Diff line change
@@ -96,13 +96,6 @@ def version(formatted=False):
from .expression_tree.exceptions import *

# Operations
from .expression_tree.operations.simplify import (
Simplification,
simplify_if_constant,
simplify_addition_subtraction,
simplify_multiplication_division,
)

from .expression_tree.operations.evaluate import (
find_symbols,
id_to_python_variable,
36 changes: 0 additions & 36 deletions pybamm/expression_tree/binary_operators.py
Original file line number Diff line number Diff line change
@@ -162,12 +162,6 @@ def _binary_jac(self, left_jac, right_jac):
""" Calculate the jacobian of a binary operator. """
raise NotImplementedError

def _binary_simplify(self, new_left, new_right):
""" Simplify a binary operator """
return pybamm.simplify_if_constant(
self._binary_new_copy(new_left, new_right), clear_domains=False
)

def _binary_evaluate(self, left, right):
""" Perform binary operation on nodes 'left' and 'right'. """
raise NotImplementedError
@@ -226,10 +220,6 @@ def _binary_evaluate(self, left, right):
with np.errstate(invalid="ignore"):
return left ** right

def _binary_simplify(self, new_left, new_right):
""" See :meth:`pybamm.BinaryOperator._binary_simplify()`. """
return pybamm.simplified_power(new_left, new_right)


class Addition(BinaryOperator):
"""A node in the expression tree representing an addition operator
@@ -253,10 +243,6 @@ def _binary_evaluate(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_evaluate()`. """
return left + right

def _binary_simplify(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_simplify()`. """
return pybamm.simplify_addition_subtraction(self.__class__, left, right)


class Subtraction(BinaryOperator):
"""A node in the expression tree representing a subtraction operator
@@ -281,12 +267,6 @@ def _binary_evaluate(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_evaluate()`. """
return left - right

def _binary_simplify(self, left, right):
"""
See :meth:`pybamm.BinaryOperator._binary_simplify()`.
"""
return pybamm.simplify_addition_subtraction(self.__class__, left, right)


class Multiplication(BinaryOperator):
"""
@@ -332,10 +312,6 @@ def _binary_evaluate(self, left, right):
else:
return left * right

def _binary_simplify(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_simplify()`. """
return pybamm.simplify_multiplication_division(self.__class__, left, right)


class MatrixMultiplication(BinaryOperator):
"""A node in the expression tree representing a matrix multiplication operator
@@ -378,10 +354,6 @@ def _binary_evaluate(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_evaluate()`. """
return left @ right

def _binary_simplify(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_simplify()`. """
return pybamm.simplify_multiplication_division(self.__class__, left, right)


class Division(BinaryOperator):
"""A node in the expression tree representing a division operator
@@ -425,10 +397,6 @@ def _binary_evaluate(self, left, right):
else:
return left / right

def _binary_simplify(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_simplify()`. """
return pybamm.simplify_multiplication_division(self.__class__, left, right)


class Inner(BinaryOperator):
"""
@@ -486,10 +454,6 @@ def _binary_new_copy(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_new_copy()`. """
return pybamm.inner(left, right)

def _binary_simplify(self, left, right):
""" See :meth:`pybamm.BinaryOperator._binary_simplify()`. """
return pybamm.simplify_multiplication_division(self.__class__, left, right)

def _evaluates_on_edges(self, dimension):
""" See :meth:`pybamm.Symbol._evaluates_on_edges()`. """
return False
23 changes: 0 additions & 23 deletions pybamm/expression_tree/concatenations.py
Original file line number Diff line number Diff line change
@@ -94,12 +94,6 @@ def _concatenation_jac(self, children_jacs):
""" Calculate the jacobian of a concatenation """
return NotImplementedError

def _concatenation_simplify(self, children):
""" See :meth:`pybamm.Symbol.simplify()`. """
new_symbol = self.__class__(*children)
new_symbol.clear_domains()
return new_symbol

def _evaluate_for_shape(self):
""" See :meth:`pybamm.Symbol.evaluate_for_shape` """
if len(self.children) == 0:
@@ -155,12 +149,6 @@ def _concatenation_jac(self, children_jacs):
else:
return SparseStack(*children_jacs)

def _concatenation_simplify(self, children):
""" See :meth:`pybamm.Concatenation._concatenation_simplify()`. """
new_symbol = simplified_numpy_concatenation(*children)
new_symbol.clear_domains()
return new_symbol


class DomainConcatenation(Concatenation):
"""A node in the expression tree representing a concatenation of symbols, being
@@ -308,17 +296,6 @@ def _concatenation_new_copy(self, children):
)
return new_symbol

def _concatenation_simplify(self, children):
""" See :meth:`pybamm.Concatenation._concatenation_simplify()`. """
new_symbol = simplified_domain_concatenation(
children, self.full_mesh, copy_this=self
)
# TODO: this should not be needed, but somehow we are still getting domains in
# the simplified children
new_symbol.clear_domains()

return new_symbol


class SparseStack(Concatenation):
"""A node in the expression tree representing a concatenation of sparse
Loading