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

Reorganised functions.py and updated functions.rst #1628

Merged
merged 5 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
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
Expand Up @@ -36,6 +36,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)