Skip to content

Commit

Permalink
Merge pull request #1628 from partben/issue-1623-function-docs
Browse files Browse the repository at this point in the history
Reorganised functions.py and updated functions.rst
  • Loading branch information
valentinsulzer authored Aug 26, 2021
2 parents 79681e9 + c3105e3 commit b924eca
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ example notebook ([#1602](https://github.com/pybamm-team/PyBaMM/pull/1602))

## Bug fixes

- Updated documentation to include some previously missing functions, such as `erf` and `tanh` ([#1628](https://github.com/pybamm-team/PyBaMM/pull/1628))
- Fixed reading citation file without closing ([#1620](https://github.com/pybamm-team/PyBaMM/pull/1620))
- Porosity variation for SEI and plating models is calculated from the film thickness rather than from a separate ODE ([#1617](https://github.com/pybamm-team/PyBaMM/pull/1617))
- Fixed a bug where the order of the indexing for the entries of variables discretised using FEM was incorrect ([#1556](https://github.com/pybamm-team/PyBaMM/pull/1556))
Expand Down
37 changes: 37 additions & 0 deletions docs/source/expression_tree/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ Functions
.. autoclass:: pybamm.SpecificFunction
:members:

.. autoclass:: pybamm.Arcsinh
:members:

.. autofunction:: pybamm.arcsinh

.. autoclass:: pybamm.Arctan
:members:

.. autofunction:: pybamm.arctan

.. autoclass:: pybamm.Cos
:members:

Expand All @@ -17,6 +27,13 @@ Functions

.. autofunction:: pybamm.cosh

.. autoclass:: pybamm.Erf
:members:

.. autofunction:: pybamm.erf

.. autofunction:: pybamm.erfc

.. autoclass:: pybamm.Exponential
:members:

Expand All @@ -27,10 +44,20 @@ Functions

.. autofunction:: pybamm.log

.. autofunction:: pybamm.log10

.. autoclass:: pybamm.Max
:members:

.. autofunction:: pybamm.max

.. autoclass:: pybamm.Min
:members:

.. autofunction:: pybamm.min

.. autofunction:: pybamm.sech

.. autoclass:: pybamm.Sin
:members:

Expand All @@ -40,3 +67,13 @@ Functions
:members:

.. autofunction:: pybamm.sinh

.. autoclass:: pybamm.Sqrt
:members:

.. autofunction:: pybamm.sqrt

.. autoclass:: pybamm.Tanh
:members:

.. autofunction:: pybamm.tanh
74 changes: 37 additions & 37 deletions pybamm/expression_tree/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,22 @@ def arcsinh(child):
return simplified_function(Arcsinh, child)


class Arctan(SpecificFunction):
"""Arctan function."""

def __init__(self, child):
super().__init__(np.arctan, child)

def _function_diff(self, children, idx):
"""See :meth:`pybamm.Function._function_diff()`."""
return 1 / (children[0] ** 2 + 1)


def arctan(child):
"""Returns hyperbolic tan function of child."""
return simplified_function(Arctan, child)


class Cos(SpecificFunction):
"""Cosine function."""

Expand Down Expand Up @@ -343,6 +359,27 @@ def cosh(child):
return simplified_function(Cosh, child)


class Erf(SpecificFunction):
"""Error function."""

def __init__(self, child):
super().__init__(special.erf, child)

def _function_diff(self, children, idx):
"""See :meth:`pybamm.Function._function_diff()`."""
return 2 / np.sqrt(np.pi) * Exponential(-children[0] ** 2)


def erf(child):
"""Returns error function of child."""
return simplified_function(Erf, child)


def erfc(child):
"""Returns complementary error function of child."""
return 1 - simplified_function(Erf, child)


class Exponential(SpecificFunction):
"""Exponential function."""

Expand Down Expand Up @@ -491,40 +528,3 @@ def _function_diff(self, children, idx):
def tanh(child):
"""Returns hyperbolic tan function of child."""
return simplified_function(Tanh, child)


class Arctan(SpecificFunction):
"""Arctan function."""

def __init__(self, child):
super().__init__(np.arctan, child)

def _function_diff(self, children, idx):
"""See :meth:`pybamm.Function._function_diff()`."""
return 1 / (children[0] ** 2 + 1)


def arctan(child):
"""Returns hyperbolic tan function of child."""
return simplified_function(Arctan, child)


class Erf(SpecificFunction):
"""Error function."""

def __init__(self, child):
super().__init__(special.erf, child)

def _function_diff(self, children, idx):
"""See :meth:`pybamm.Function._function_diff()`."""
return 2 / np.sqrt(np.pi) * Exponential(-children[0] ** 2)


def erf(child):
"""Returns error function of child."""
return simplified_function(Erf, child)


def erfc(child):
"""Returns complementary error function of child."""
return 1 - simplified_function(Erf, child)

0 comments on commit b924eca

Please sign in to comment.