Skip to content

Commit b924eca

Browse files
Merge pull request #1628 from partben/issue-1623-function-docs
Reorganised functions.py and updated functions.rst
2 parents 79681e9 + c3105e3 commit b924eca

File tree

3 files changed

+75
-37
lines changed

3 files changed

+75
-37
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ example notebook ([#1602](https://github.com/pybamm-team/PyBaMM/pull/1602))
3939

4040
## Bug fixes
4141

42+
- Updated documentation to include some previously missing functions, such as `erf` and `tanh` ([#1628](https://github.com/pybamm-team/PyBaMM/pull/1628))
4243
- Fixed reading citation file without closing ([#1620](https://github.com/pybamm-team/PyBaMM/pull/1620))
4344
- 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))
4445
- 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))

docs/source/expression_tree/functions.rst

+37
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ Functions
77
.. autoclass:: pybamm.SpecificFunction
88
:members:
99

10+
.. autoclass:: pybamm.Arcsinh
11+
:members:
12+
13+
.. autofunction:: pybamm.arcsinh
14+
15+
.. autoclass:: pybamm.Arctan
16+
:members:
17+
18+
.. autofunction:: pybamm.arctan
19+
1020
.. autoclass:: pybamm.Cos
1121
:members:
1222

@@ -17,6 +27,13 @@ Functions
1727

1828
.. autofunction:: pybamm.cosh
1929

30+
.. autoclass:: pybamm.Erf
31+
:members:
32+
33+
.. autofunction:: pybamm.erf
34+
35+
.. autofunction:: pybamm.erfc
36+
2037
.. autoclass:: pybamm.Exponential
2138
:members:
2239

@@ -27,10 +44,20 @@ Functions
2744

2845
.. autofunction:: pybamm.log
2946

47+
.. autofunction:: pybamm.log10
48+
49+
.. autoclass:: pybamm.Max
50+
:members:
51+
3052
.. autofunction:: pybamm.max
3153

54+
.. autoclass:: pybamm.Min
55+
:members:
56+
3257
.. autofunction:: pybamm.min
3358

59+
.. autofunction:: pybamm.sech
60+
3461
.. autoclass:: pybamm.Sin
3562
:members:
3663

@@ -40,3 +67,13 @@ Functions
4067
:members:
4168

4269
.. autofunction:: pybamm.sinh
70+
71+
.. autoclass:: pybamm.Sqrt
72+
:members:
73+
74+
.. autofunction:: pybamm.sqrt
75+
76+
.. autoclass:: pybamm.Tanh
77+
:members:
78+
79+
.. autofunction:: pybamm.tanh

pybamm/expression_tree/functions.py

+37-37
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,22 @@ def arcsinh(child):
311311
return simplified_function(Arcsinh, child)
312312

313313

314+
class Arctan(SpecificFunction):
315+
"""Arctan function."""
316+
317+
def __init__(self, child):
318+
super().__init__(np.arctan, child)
319+
320+
def _function_diff(self, children, idx):
321+
"""See :meth:`pybamm.Function._function_diff()`."""
322+
return 1 / (children[0] ** 2 + 1)
323+
324+
325+
def arctan(child):
326+
"""Returns hyperbolic tan function of child."""
327+
return simplified_function(Arctan, child)
328+
329+
314330
class Cos(SpecificFunction):
315331
"""Cosine function."""
316332

@@ -343,6 +359,27 @@ def cosh(child):
343359
return simplified_function(Cosh, child)
344360

345361

362+
class Erf(SpecificFunction):
363+
"""Error function."""
364+
365+
def __init__(self, child):
366+
super().__init__(special.erf, child)
367+
368+
def _function_diff(self, children, idx):
369+
"""See :meth:`pybamm.Function._function_diff()`."""
370+
return 2 / np.sqrt(np.pi) * Exponential(-children[0] ** 2)
371+
372+
373+
def erf(child):
374+
"""Returns error function of child."""
375+
return simplified_function(Erf, child)
376+
377+
378+
def erfc(child):
379+
"""Returns complementary error function of child."""
380+
return 1 - simplified_function(Erf, child)
381+
382+
346383
class Exponential(SpecificFunction):
347384
"""Exponential function."""
348385

@@ -491,40 +528,3 @@ def _function_diff(self, children, idx):
491528
def tanh(child):
492529
"""Returns hyperbolic tan function of child."""
493530
return simplified_function(Tanh, child)
494-
495-
496-
class Arctan(SpecificFunction):
497-
"""Arctan function."""
498-
499-
def __init__(self, child):
500-
super().__init__(np.arctan, child)
501-
502-
def _function_diff(self, children, idx):
503-
"""See :meth:`pybamm.Function._function_diff()`."""
504-
return 1 / (children[0] ** 2 + 1)
505-
506-
507-
def arctan(child):
508-
"""Returns hyperbolic tan function of child."""
509-
return simplified_function(Arctan, child)
510-
511-
512-
class Erf(SpecificFunction):
513-
"""Error function."""
514-
515-
def __init__(self, child):
516-
super().__init__(special.erf, child)
517-
518-
def _function_diff(self, children, idx):
519-
"""See :meth:`pybamm.Function._function_diff()`."""
520-
return 2 / np.sqrt(np.pi) * Exponential(-children[0] ** 2)
521-
522-
523-
def erf(child):
524-
"""Returns error function of child."""
525-
return simplified_function(Erf, child)
526-
527-
528-
def erfc(child):
529-
"""Returns complementary error function of child."""
530-
return 1 - simplified_function(Erf, child)

0 commit comments

Comments
 (0)