Skip to content

Commit

Permalink
Merge pull request #1822 from pybamm-team/issue-1810-shortcuts
Browse files Browse the repository at this point in the history
Issue 1810 shortcuts
  • Loading branch information
valentinsulzer authored Nov 25, 2021
2 parents 6eab5e4 + cc21e58 commit 0ab7c34
Show file tree
Hide file tree
Showing 112 changed files with 1,618 additions and 1,945 deletions.
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

- The name of a parameter set can be passed to `ParameterValues` as a string, e.g. `ParameterValues("Chen2020")`
- Reformatted SEI growth models into a single submodel with conditionals ([#1808](https://github.com/pybamm-team/PyBaMM/pull/1808))
- Stress-induced diffusion is now a separate model option instead of being automatically included when using the particle mechanics submodels ([#1797](https://github.com/pybamm-team/PyBaMM/pull/1797))
- `Experiment`s with drive cycles can be solved ([#1793](https://github.com/pybamm-team/PyBaMM/pull/1793))
Expand All @@ -18,6 +19,7 @@

## Breaking changes

- The `chemistry` keyword argument in `ParameterValues` has been deprecated. Use `ParameterValues(chem)` instead of `ParameterValues(chemistry=chem)`
- Raise error when trying to convert an `Interpolant` with the "pchip" interpolator to CasADI ([#1791](https://github.com/pybamm-team/PyBaMM/pull/1791))
- Raise error if `Concatenation` is used directly with `Variable` objects (`concatenation` should be used instead) ([#1789](https://github.com/pybamm-team/PyBaMM/pull/1789))
- Made jax, jaxlib and the PyBaMM JaxSolver optional ([#1767](https://github.com/pybamm-team/PyBaMM/pull/1767))
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/time_setup_models_and_sims.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def compute_discretisation(model, param):

class TimeBuildSPM:
def __init__(self):
self.param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.param = pybamm.ParameterValues("Marquis2019")

def time_setup_SPM(self):
self.model = pybamm.lithium_ion.SPM()
Expand All @@ -29,7 +29,7 @@ def time_setup_SPM(self):

class TimeBuildSPMe:
def __init__(self):
self.param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.param = pybamm.ParameterValues("Marquis2019")

def time_setup_SPMe(self):
self.model = pybamm.lithium_ion.SPMe()
Expand All @@ -39,7 +39,7 @@ def time_setup_SPMe(self):

class TimeBuildDFN:
def __init__(self):
self.param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.param = pybamm.ParameterValues("Marquis2019")

def time_setup_DFN(self):
self.model = pybamm.lithium_ion.DFN()
Expand All @@ -52,7 +52,7 @@ class TimeBuildSPMSimulation:
params = [False, True]

def __init__(self):
self.param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.param = pybamm.ParameterValues("Marquis2019")

def time_setup_SPM_simulation(self, with_experiment):
self.model = pybamm.lithium_ion.SPM()
Expand All @@ -72,7 +72,7 @@ class TimeBuildSPMeSimulation:
params = [False, True]

def __init__(self):
self.param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.param = pybamm.ParameterValues("Marquis2019")

def time_setup_SPMe_simulation(self, with_experiment):
self.model = pybamm.lithium_ion.SPMe()
Expand All @@ -92,7 +92,7 @@ class TimeBuildDFNSimulation:
params = [False, True]

def __init__(self):
self.param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.param = pybamm.ParameterValues("Marquis2019")

def time_setup_DFN_simulation(self, with_experiment):
self.model = pybamm.lithium_ion.DFN()
Expand Down
14 changes: 2 additions & 12 deletions benchmarks/time_solve_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,12 @@ def prepare_model(model):
geometry = model.default_geometry

# load parameter values and process model and geometry
chemistry = pybamm.parameter_sets.Marquis2019
param = pybamm.ParameterValues(chemistry=chemistry)
param = pybamm.ParameterValues("Marquis2019")
param.process_model(model)
param.process_geometry(geometry)

# set mesh
var = pybamm.standard_spatial_vars
var_pts = {
var.x_n: 20,
var.x_s: 20,
var.x_p: 20,
var.r_n: 30,
var.r_p: 30,
var.y: 10,
var.z: 10,
}
var_pts = {"x_n": 20, "x_s": 20, "x_p": 20, "r_n": 30, "r_p": 30, "y": 10, "z": 10}
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts)

# discretise model
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/add-parameter-values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Then, to use these new parameters, use:

.. code-block:: python
param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.AuthorYear)
param = pybamm.ParameterValues("AuthorYear")
Note that you can re-use existing parameter subsets instead of creating new ones (for example, you could just replace "experiment": "new_experiment_AuthorYear" with "experiment": "1C_discharge_from_full_Marquis2019" in the above dictionary).

Expand Down Expand Up @@ -173,7 +173,7 @@ To test this, add something like the following test to one of the model test fil
def test_my_new_parameters(self):
model = pybamm.lithium_ion.DFN()
parameter_values = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.AuthorYear)
parameter_values = pybamm.ParameterValues("AuthorYear")
modeltest = tests.StandardModelTest(model, parameter_values=parameter_values)
modeltest.test_all()
Expand Down
27 changes: 20 additions & 7 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 @@ -52,8 +52,6 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: You are using pip version 21.0.1; however, version 21.1.2 is available.\n",
"You should consider upgrading via the '/home/user/Documents/PyBaMM/env/bin/python3.8 -m pip install --upgrade pip' command.\u001b[0m\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
Expand Down Expand Up @@ -251,7 +249,7 @@
"outputs": [],
"source": [
"# mesh\n",
"submesh_types = {\"negative particle\": pybamm.MeshGenerator(pybamm.Uniform1DSubMesh)}\n",
"submesh_types = {\"negative particle\": pybamm.Uniform1DSubMesh}\n",
"var_pts = {r: 20}\n",
"mesh = pybamm.Mesh(geometry, submesh_types, var_pts)\n",
"\n",
Expand Down Expand Up @@ -294,14 +292,14 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2021-05-27 10:31:08,618 - [WARNING] processed_variable.get_spatial_scale(471): No length scale set for negative particle. Using default of 1 [m].\n",
"2021-05-27 10:31:08,729 - [WARNING] processed_variable.get_spatial_scale(471): No length scale set for negative particle. Using default of 1 [m].\n"
"2021-11-19 15:29:38,512 - [WARNING] processed_variable.get_spatial_scale(520): No length scale set for negative particle. Using default of 1 [m].\n",
"2021-11-19 15:29:38,541 - [WARNING] processed_variable.get_spatial_scale(520): No length scale set for negative particle. Using default of 1 [m].\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "28d9f238e5364c4588a39b0984631dee",
"model_id": "c7ec6d3f5bf14206a6ec219f10583c46",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -397,7 +395,7 @@
"text": [
"[1] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, and Moritz Diehl. CasADi – A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019. doi:10.1007/s12532-018-0139-4.\n",
"[2] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.\n",
"[3] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). ECSarXiv. February, 2020. doi:10.1149/osf.io/67ckj.\n",
"[3] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). Journal of Open Research Software, 9(1):14, 2021. doi:10.5334/jors.309.\n",
"[4] Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, and others. SciPy 1.0: fundamental algorithms for scientific computing in Python. Nature Methods, 17(3):261–272, 2020. doi:10.1038/s41592-019-0686-2.\n",
"\n"
]
Expand All @@ -410,7 +408,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -424,7 +422,20 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.8.12"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 0ab7c34

Please sign in to comment.