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

add link_checker #1347

Merged
merged 9 commits into from
Feb 1, 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
32 changes: 32 additions & 0 deletions .github/workflows/url_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check URLs

on:
push:
schedule:
# Run everyday at 3 am UTC
- cron: 0 3 * * *

jobs:
urlchecks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: URLs-checker
uses: urlstechie/urlchecker-action@master
with:
# A comma-separated list of file types to cover in the URL checks
file_types: .rst,.md,.py,.ipynb

# Choose whether to include file with no URLs in the prints.
print_all: false

# Timeout in 10 seconds if url is not reached
timeout: 10

# How many times to retry a failed request (each is logged, defaults to 1)
retry_count: 3

# A comma separated patterns to exclude during URL checks
exclude_patterns: http://www.w3.org,http://purl.org/dc,http://127.0.0.1

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

## Optimizations

- Add URLs checker in workflows ([#1347](https://github.com/pybamm-team/PyBaMM/pull/1347))
- The `Solution` class now only creates the concatenated `y` when the user asks for it. This is an optimization step as the concatenation can be slow, especially with larger experiments ([#1331](https://github.com/pybamm-team/PyBaMM/pull/1331))
- If solver method `solve()` is passed a list of inputs as the `inputs` keyword argument, the resolution of the model for each input set is spread across several Python processes, usually running in parallel on different processors. The default number of processes is the number of processors available. `solve()` takes a new keyword argument `nproc` which can be used to set this number a manually.
- Variables are now post-processed using CasADi ([#1316](https://github.com/pybamm-team/PyBaMM/pull/1316))
Expand Down
2 changes: 1 addition & 1 deletion CMakeBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run(self):
"cmake configuration steps encountered errors, and the idaklu module"
" could not be built. Make sure dependencies are correctly "
"installed. See "
"https://github.com/pybamm-team/PyBaMM/blob/develop/"
"https://github.com/pybamm-team/PyBaMM/tree/develop"
"INSTALL-LINUX-MAC.md"
)
raise RuntimeError(msg)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You now have everything you need to start making changes!

### B. Writing your code

5. PyBaMM is developed in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)), and makes heavy use of [NumPy](https://en.wikipedia.org/wiki/NumPy) (see also [NumPy for MatLab users](https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.html) and [Python for R users](http://blog.hackerearth.com/how-can-r-users-learn-python-for-data-science)).
5. PyBaMM is developed in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)), and makes heavy use of [NumPy](https://en.wikipedia.org/wiki/NumPy) (see also [NumPy for MatLab users](https://numpy.org/doc/stable/user/numpy-for-matlab-users.html) and [Python for R users](http://blog.hackerearth.com/how-can-r-users-learn-python-for-data-science)).
6. Make sure to follow our [coding style guidelines](#coding-style-guidelines).
7. Commit your changes to your branch with [useful, descriptive commit messages](https://chris.beams.io/posts/git-commit/): Remember these are publicly visible and should still make sense a few months ahead in time. While developing, you can keep using the GitHub issue you're working on as a place for discussion. [Refer to your commits](https://stackoverflow.com/questions/8910271/how-can-i-reference-a-commit-in-an-issue-comment-on-github) when discussing specific lines of code.
8. If you want to add a dependency on another library, or re-use code you found somewhere else, have a look at [these guidelines](#dependencies-and-reusing-code).
Expand Down Expand Up @@ -300,7 +300,7 @@ And then visit the webpage served at http://127.0.0.1:8000. Each time a change t

Major PyBaMM features are showcased in [Jupyter notebooks](https://jupyter.org/) stored in the [examples directory](examples/notebooks). Which features are "major" is of course wholly subjective, so please discuss on GitHub first!

All example notebooks should be listed in [examples/README.md](https://github.com/pybamm-team/PyBaMM/examples/notebooks/README.md). Please follow the (naming and writing) style of existing notebooks where possible.
All example notebooks should be listed in [examples/README.md](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/README.md). Please follow the (naming and writing) style of existing notebooks where possible.

Where possible, notebooks are tested daily. A list of slow notebooks (which time-out and fail tests) is maintained in `.slow-books`, these notebooks will be excluded from daily testing.

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/add-model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Adding a Model
As with any contribution to PyBaMM, please follow the workflow in CONTRIBUTING.md_.
In particular, start by creating an issue to discuss what you want to do - this is a good way to avoid wasted coding hours!

We aim here to provide an overview of how a new model is entered into PyBaMM in a form which can be eventually merged into the master branch of the PyBaMM project. However, we recommend that you first read through the notebook: `create a model <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/create-model.ipynb>`_, which goes step-by-step through the procedure for creating a model. Once you understand that procedure, you can then formalise your model following the outline provided here.
We aim here to provide an overview of how a new model is entered into PyBaMM in a form which can be eventually merged into the master branch of the PyBaMM project. However, we recommend that you first read through the notebook: `create a model <https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/Creating%20Models>`_, which goes step-by-step through the procedure for creating a model. Once you understand that procedure, you can then formalise your model following the outline provided here.

The role of models
------------------

One of the main motivations for PyBaMM is to allow for new models of batteries to be easily be added, solved, tested, and compared without requiring a detailed knowledge of sophisticated numerical methods. It has therefore been our focus to make the process of adding a new model as simple as possible. To achieve this, all models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/expression-tree.ipynb>`_, which abstract away the details of computation.
One of the main motivations for PyBaMM is to allow for new models of batteries to be easily be added, solved, tested, and compared without requiring a detailed knowledge of sophisticated numerical methods. It has therefore been our focus to make the process of adding a new model as simple as possible. To achieve this, all models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb>`_, which abstract away the details of computation.

The fundamental building blocks of a PyBaMM expression tree are :class:`pybamm.Symbol`. There are different types of :class:`pybamm.Symbol`: :class:`pybamm.Variable`, :class:`pybamm.Parameter`, :class:`pybamm.Addition`, :class:`pybamm.Multiplication`, :class:`pybamm.Gradient` etc which have been created so that each component of a model written out in PyBaMM mirrors exactly the written mathematics. For example, the expression:

Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/add-parameter-values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In particular, start by creating an issue to discuss what you want to do - this
The role of parameter values
----------------------------

All models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/expression-tree.ipynb>`_.
All models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb>`_.
At the stage of creating a model, we use :class:`pybamm.Parameter` and :class:`pybamm.FunctionParameter` objects to represent parameters and functions respectively.

We then create a :class:`ParameterValues` class, using a specific set of parameters, to iterate through the model and replace any :class:`pybamm.Parameter` objects with a :class:`pybamm.Scalar` and any :class:`pybamm.FunctionParameter` objects with a :class:`pybamm.Function`.
Expand Down Expand Up @@ -154,13 +154,13 @@ or, equivalently in this case (since the only difference from the standard param
}
)

See the `"Getting Started" tutorial <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/Getting%20Started/Tutorial%202%20-%20Setting%20Parameter%20Values.ipynb>`_ for examples of setting parameters in action.
See the `"Getting Started" tutorial <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/Getting%20Started/Tutorial%204%20-%20Setting%20parameter%20values.ipynb>`_ for examples of setting parameters in action.

Unit tests for the new class
----------------------------

You might want to add some unit tests to show that the parameters combine as expected
(see e.g. `lithium-ion parameter tests <https://github.com/pybamm-team/PyBaMM/blob/master/tests/unit/test_parameters/test_dimensionless_parameter_values_lithium_ion.py>`_), but this is not crucial.
(see e.g. `lithium-ion parameter tests <https://github.com/pybamm-team/PyBaMM/blob/develop/tests/unit/test_parameters/test_lithium_ion_parameters.py>`_), but this is not crucial.

Test on the models
------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/add-solver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In particular, start by creating an issue to discuss what you want to do - this
The role of solvers
-------------------

All models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/expression-tree.ipynb>`_.
All models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb>`_.
After the model has been created, parameters have been set, and the model has been discretised, the model is now a linear algebra object with the following attributes:

model.concatenated_rhs
Expand Down Expand Up @@ -54,7 +54,7 @@ You can then start implementing the solver by adding the ``integrate`` function
For an example of an existing solver implementation, see the Scikits DAE solver
`API docs <https://pybamm.readthedocs.io/en/latest/source/solvers/scikits_solvers.html>`_
and
`notebook <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/solvers/scikits-dae-solver.ipynb>`_.
`notebook <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/solvers/dae-solver.ipynb>`_.

Unit tests for the new class
----------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/add-spatial-method.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In particular, start by creating an issue to discuss what you want to do - this
The role of spatial methods
---------------------------

All models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/expression-tree.ipynb>`_.
All models in PyBaMM are implemented as `expression trees <https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/expression_tree/expression-tree.ipynb>`_.
After it has been created and parameters have been set, the model is passed to the :class:`pybamm.Discretisation` class,
which converts it into a linear algebra form.
For example, the object:
Expand Down Expand Up @@ -74,7 +74,7 @@ Unit tests for the new class
----------------------------

For the new spatial method to be added to PyBaMM, you must add unit tests to demonstrate that it behaves as expected
(see, for example, the `Finite Volume unit tests <https://github.com/pybamm-team/PyBaMM/blob/master/tests/unit/test_spatial_methods/test_finite_volume.py>`_).
(see, for example, the `Finite Volume unit tests <https://github.com/pybamm-team/PyBaMM/blob/develop/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py>`_).
The best way to get started would be to create a file ``test_my_fast_method.py`` in ``tests/unit/test_spatial_methods/`` that performs at least the
following checks:

Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Once you are comfortable with the expression tree structure, a good starting poi

- [Full porous-electrode](https://pybamm.readthedocs.io/en/latest/source/models/lead_acid/full.html)
- [Leading-Order Quasi-Static](https://pybamm.readthedocs.io/en/latest/source/models/lead_acid/loqs.html)
- [Composite](https://pybamm.readthedocs.io/en/latest/source/models/lead_acid/composite.html)
- [Higher-Order](https://pybamm.readthedocs.io/en/latest/source/models/lead_acid/higher_order.html)

### Spatial Methods

Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/change-input-current.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Changing the input current when solving PyBaMM models\n",
"\n",
"This notebook shows you how to change the input current when solving PyBaMM models. It also explains how to load in current data from a file, and how to add a user-defined current function. For more examples of different drive cycles see [here](https://github.com/pybamm-team/PyBaMM/tree/master/results/drive_cycles).\n",
"This notebook shows you how to change the input current when solving PyBaMM models. It also explains how to load in current data from a file, and how to add a user-defined current function. For more examples of different drive cycles see [here](https://github.com/pybamm-team/PyBaMM/tree/develop/pybamm/input/drive_cycles).\n",
"\n",
"### Table of Contents\n",
"1. [Constant current](#constant)\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/change-settings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
"source": [
"## Changing the discretisation <a name=\"discretisation\"></a>\n",
"\n",
"The chosen spatial discretisation method to use for each domain is passed into the [`pybamm.Discretisation`](https://pybamm.readthedocs.io/en/latest/source/discretisations/discretisation.html) class as one of its arguments. The default spatial methods for the SPM class are given as:\n"
"The chosen spatial discretisation method to use for each domain is passed into the [`pybamm.Discretisation`](https://pybamm.readthedocs.io/en/latest/source/spatial_methods/discretisation.html) class as one of its arguments. The default spatial methods for the SPM class are given as:\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/compare-comsol-discharge-curve.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook we compare the discharge curves obtained by solving the DFN model both in PyBaMM and COMSOL. Results are presented for a range of C-rates, and we see an excellent agreement between the two implementations. If you would like to compare internal variables please see the script [compare_comsol_DFN](https://github.com/pybamm-team/PyBaMM/blob/comsol-voltage-compare/examples/scripts/compare_comsol/compare_comsol_DFN.py) which creates a slider plot comparing potentials and concentrations as functions of time and space for a given C-rate. For more information on the DFN model, see the [DFN notebook](https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/models/DFN.ipynb)."
"In this notebook we compare the discharge curves obtained by solving the DFN model both in PyBaMM and COMSOL. Results are presented for a range of C-rates, and we see an excellent agreement between the two implementations. If you would like to compare internal variables please see the script [compare_comsol_DFN](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/scripts/compare_comsol/compare_comsol_DFN.py) which creates a slider plot comparing potentials and concentrations as functions of time and space for a given C-rate. For more information on the DFN model, see the [DFN notebook](https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/models/DFN.ipynb)."
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/expression_tree/expression-tree.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"\n",
"1. The model is proposed, consisting of equations representing the right-hand-side of an ordinary differential equation (ODE), and/or algebraic equations for a differential algebraic equation (DAE), and also associated boundary condition equations\n",
"2. The parameters present in the model are replaced by actual scalar values from a parameter file, using the [`pybamm.ParamterValues`](https://pybamm.readthedocs.io/en/latest/source/parameters/parameter_values.html) class\n",
"3. The equations in the model are discretised onto a mesh, any spatial gradients are replaced with linear algebra expressions and the variables of the model are replaced with state vector slices. This is done using the [`pybamm.Discretisation`](https://pybamm.readthedocs.io/en/latest/source/discretisations/discretisation.html) class.\n",
"3. The equations in the model are discretised onto a mesh, any spatial gradients are replaced with linear algebra expressions and the variables of the model are replaced with state vector slices. This is done using the [`pybamm.Discretisation`](https://pybamm.readthedocs.io/en/latest/source/spatial_methods/discretisation.html) class.\n",
"\n",
"## Stage 1 - Symbolic Expression Trees\n",
"\n",
Expand Down Expand Up @@ -187,7 +187,7 @@
"\n",
"The third and final stage uses the `pybamm.Discretisation` class to discretise the spatial gradients and variables over a given mesh. After this stage the expression tree will encode a linear algebra expression that can be evaluated given the state vector $\\mathbf{y}$ and $t$.\n",
"\n",
"**Note:** for demonstration purposes, we use a dummy discretisation below. For a more complete description of the `pybamm.Discretisation` class, see the example notebook [here](https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/discretisations/finite-volumes.ipynb)."
"**Note:** for demonstration purposes, we use a dummy discretisation below. For a more complete description of the `pybamm.Discretisation` class, see the example notebook [here](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/notebooks/spatial_methods/finite-volumes.ipynb)."
]
},
{
Expand Down Expand Up @@ -221,7 +221,7 @@
"source": [
"![](expression_tree5.png)\n",
"\n",
"After the third stage, our expression tree is now able to be evaluated by one of the solver classes. Note that we have used a single equation above to illustrate the different types of expression trees in PyBaMM, but any given models will consist of many RHS or algebraic equations, along with boundary conditions. See [here](https://github.com/pybamm-team/PyBaMM/blob/master/examples/notebooks/add-model.ipynb) for more details of PyBaMM models."
"After the third stage, our expression tree is now able to be evaluated by one of the solver classes. Note that we have used a single equation above to illustrate the different types of expression trees in PyBaMM, but any given models will consist of many RHS or algebraic equations, along with boundary conditions. See [here](https://github.com/pybamm-team/PyBaMM/tree/develop/examples/notebooks/Creating%20Models) for more details of PyBaMM models."
]
},
{
Expand Down
Loading