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

Issue 1029 reformat geometry #1032

Merged
merged 4 commits into from
Jun 1, 2020
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- Reformatted `Geometry` and `Mesh` classes ([#1032](https://github.com/pybamm-team/PyBaMM/pull/1032))
- Added arbitrary geometry to the lumped thermal model ([#718](https://github.com/pybamm-team/PyBaMM/issues/718))
- Allowed `ProcessedVariable` to handle cases where `len(solution.t)=1` ([#1020](https://github.com/pybamm-team/PyBaMM/pull/1020))
- Added `BackwardIndefiniteIntegral` symbol ([#1014](https://github.com/pybamm-team/PyBaMM/pull/1014))
Expand Down Expand Up @@ -45,6 +46,7 @@

## Breaking changes

- Geometry should no longer be given keys 'primary' or 'secondary' ([#1032](https://github.com/pybamm-team/PyBaMM/pull/1032))
- Calls to `ProcessedVariable` objects are now made using dimensional time and space ([#1028](https://github.com/pybamm-team/PyBaMM/pull/1028))
- For variables discretised using finite elements the result returned by calling `ProcessedVariable` is now transposed ([#1020](https://github.com/pybamm-team/PyBaMM/pull/1020))
- Renamed "surface area density" to "surface area to volume ratio" ([#975](https://github.com/pybamm-team/PyBaMM/pull/975))
Expand Down
4 changes: 4 additions & 0 deletions docs/source/geometry/battery_geometry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Battery Geometry
================

.. autofunction:: pybamm.battery_geometry
24 changes: 0 additions & 24 deletions docs/source/geometry/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,3 @@ Geometry

.. autoclass:: pybamm.Geometry
:members:

.. autoclass:: pybamm.Geometry1DMacro
:members:

.. autoclass:: pybamm.Geometry3DMacro
:members:

.. autoclass:: pybamm.Geometry1DMicro
:members:

.. autoclass:: pybamm.Geometry1p1DMicro
:members:

.. autoclass:: pybamm.Geometryxp1DMacro
:members:

.. autoclass:: pybamm.Geometryxp0p1DMicro
:members:

.. autoclass:: pybamm.Geometryxp1p1DMicro
:members:

.. autoclass:: pybamm.Geometry2DCurrentCollector
:members:
1 change: 1 addition & 0 deletions docs/source/geometry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Geometry
.. toctree::

geometry
battery_geometry

2 changes: 1 addition & 1 deletion docs/tutorials/add-model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Events will stop the solver whenever they return 0.

Setting defaults
~~~~~~~~~~~~~~~~
It can be useful for testing, and quickly running a model to have a default setup. Each of the defaults listed above should adhere to the API requirements but in short, we require ``self.default_geometry`` to be an instance of :class:`pybamm.Geometry`, ``self.default_solver`` to be an instance of :class:`pybamm.BaseSolver`, and
It can be useful for testing, and quickly running a model to have a default setup. Each of the defaults listed above should adhere to the API requirements but in short, we require ``self.default_geometry`` to be a dictionary of the right format (see :meth:`pybamm.battery_geometry`), ``self.default_solver`` to be an instance of :class:`pybamm.BaseSolver`, and
``self.default_parameter_values`` to be an instance of :class:`pybamm.ParameterValues`. We also require that ``self.default_submesh_types`` is a dictionary with keys which are strings corresponding to the regions of the battery (e.g. "negative electrode") and values which are an instance of :class:`pybamm.SubMesh1D`. The ``self.default_spatial_methods`` attribute is also required to be a dictionary with keys corresponding to the regions of the battery but with values which are an instance of
:class:`pybamm.SpatialMethod`. Finally, ``self.default_var_pts`` is required to be a dictionary with keys which are an instance of :class:`pybamm.SpatialVariable` and values which are integers.

Expand Down
19 changes: 11 additions & 8 deletions examples/notebooks/Creating Models/2-a-pde-model.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"source": [
"# geometry\n",
"r = pybamm.SpatialVariable(\"r\", domain=[\"negative particle\"], coord_sys=\"spherical polar\")\n",
"geometry = {\"negative particle\": {\"primary\": {r: {\"min\": pybamm.Scalar(0), \"max\": R}}}}\n",
"geometry = {\"negative particle\": {r: {\"min\": pybamm.Scalar(0), \"max\": R}}}\n",
"param.process_geometry(geometry)\n",
"\n",
"# models\n",
Expand Down Expand Up @@ -279,10 +279,18 @@
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2020-05-30 11:14:09,214 - [WARNING] processed_variable.get_spatial_scale(497): No scale set for spatial variable r_n. Using default of 1 [m].\n",
"2020-05-30 11:14:09,244 - [WARNING] processed_variable.get_spatial_scale(497): No scale set for spatial variable r_n. Using default of 1 [m].\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a020dc7cd8574e698ef0e06d4392e689",
"model_id": "c043c0f27ffc46f88fe69b0cbdf14d46",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -312,7 +320,7 @@
"c_av_reduced = solutions[1][\"Average concentration [mol.m-3]\"]\n",
"\n",
"# plot\n",
"r = mesh[\"negative particle\"][0].nodes # radial position\n",
"r = mesh[\"negative particle\"].nodes # radial position\n",
"\n",
"def plot(t):\n",
" fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(13, 4))\n",
Expand Down Expand Up @@ -382,7 +390,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
19 changes: 14 additions & 5 deletions examples/notebooks/Creating Models/5-a-simple-SEI-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,20 @@
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2020-05-30 11:30:30,931 - [WARNING] processed_variable.get_spatial_scale(497): No scale set for spatial variable x. Using default of 1 [m].\n"
]
}
],
"source": [
"# define geometry\n",
"geometry = pybamm.Geometry()\n",
"geometry.add_domain(\"SEI layer\", {\"primary\": {x: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}}})\n",
"geometry = pybamm.Geometry(\n",
" {\"SEI layer\": {x: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}}}\n",
")\n",
"\n",
"def Diffusivity(cc):\n",
" return cc * 10**(-5)\n",
Expand Down Expand Up @@ -591,7 +600,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8d9c98b030934135908c6ddd5c92699b",
"model_id": "03d0d8fd63324d16858941bfcbe513be",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -660,7 +669,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
7 changes: 3 additions & 4 deletions examples/notebooks/expression_tree/broadcasts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
"source": [
"var = pybamm.standard_spatial_vars\n",
"geometry = {\n",
" \"negative electrode\": {\"primary\": {var.x_n: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}}},\n",
" \"negative particle\": {\"primary\": {var.r_n: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}}},\n",
"\n",
" \"negative electrode\": {var.x_n: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}},\n",
" \"negative particle\": {var.r_n: {\"min\": pybamm.Scalar(0), \"max\": pybamm.Scalar(1)}},\n",
"}\n",
"\n",
"submesh_types = {\n",
Expand Down Expand Up @@ -261,7 +260,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
42 changes: 21 additions & 21 deletions examples/notebooks/models/SPM.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/notebooks/models/pouch-cell-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
"# set up space\n",
"mesh = simulations[\"1+1D DFN\"].mesh\n",
"L_z = param.evaluate(pybamm.standard_parameters_lithium_ion.L_z)\n",
"pybamm_z = mesh[\"current collector\"][0].nodes\n",
"pybamm_z = mesh[\"current collector\"].nodes\n",
"z_interp = pybamm_z * L_z\n",
"\n",
" \n",
Expand Down
20 changes: 10 additions & 10 deletions examples/notebooks/spatial_methods/finite-volumes.ipynb

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions examples/notebooks/unsteady_heat_equation.ipynb

Large diffs are not rendered by default.

Loading