Skip to content

Commit

Permalink
#1100 merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Aug 4, 2020
2 parents 1872abf + dd37a7f commit df8bcea
Show file tree
Hide file tree
Showing 141 changed files with 2,617 additions and 1,919 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Features

- Added "R-averaged particle concentration" variables` ([#1118](https://github.com/pybamm-team/PyBaMM/pull/1118))
- Automatically compute surface area per unit volume based on particle shape for li-ion models ([#1120])(https://github.com/pybamm-team/PyBaMM/pull/1120)
- Added "R-averaged particle concentration" variables ([#1118](https://github.com/pybamm-team/PyBaMM/pull/1118))
- Added support for sensitivity calculations to the casadi solver ([#1109](https://github.com/pybamm-team/PyBaMM/pull/1109))
- Added support for index 1 semi-explicit dae equations and sensitivity calculations to JAX BDF solver ([#1107](https://github.com/pybamm-team/PyBaMM/pull/1107))
- Allowed keyword arguments to be passed to `Simulation.plot()` ([#1099](https://github.com/pybamm-team/PyBaMM/pull/1099))
Expand All @@ -19,8 +20,9 @@
## Breaking changes

- Changed sensitivity API. Removed `ProcessedSymbolicVariable`, all sensitivity now handled within the solvers and `ProcessedVariable` ()
- Renamed `quick_plot_vars` to `output_variables` in `Simulation` to be consistent with `QuickPlot`. Passing `quick_plot_vars` to `Simulation.plot()` has been deprecated and `output_variables` should be passed instead ([#1099](https://github.com/pybamm-team/PyBaMM/pull/1099))

- The modules containing standard parameters are now classes so they can take options
(e.g. `standard_parameters_lithium_ion` is now `LithiumIonParameters`) ([#1120])(https://github.com/pybamm-team/PyBaMM/pull/1120)
- Renamed `quick_plot_vars` to `output_variables` in `Simulation` to be consistent with `QuickPlot`. Passing `quick_plot_vars` to `Simulation.plot()` has been deprecated and `output_variables` should be passed instead ([#1099](https://github.com/pybamm-team/PyBaMM/pull/1099))

# [v0.2.3](https://github.com/pybamm-team/PyBaMM/tree/v0.2.3) - 2020-07-01

Expand Down
2 changes: 1 addition & 1 deletion docs/source/parameters/electrical_parameters.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Electrical Parameters
=====================

.. automodule:: pybamm.parameters.electrical_parameters
.. autoclass:: pybamm.ElectricalParameters
3 changes: 1 addition & 2 deletions docs/source/parameters/geometric_parameters.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Geometric Parameters
====================

.. automodule:: pybamm.parameters.geometric_parameters

.. autoclass:: pybamm.GeometricParameters
6 changes: 3 additions & 3 deletions docs/source/parameters/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Parameters
geometric_parameters
electrical_parameters
thermal_parameters
standard_parameters_lithium_ion
standard_parameters_lead_acid
parameter_sets
lithium_ion_parameters
lead_acid_parameters
parameter_sets
4 changes: 4 additions & 0 deletions docs/source/parameters/lead_acid_parameters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Lead-Acid Parameters
====================

.. autoclass:: pybamm.LeadAcidParameters
4 changes: 4 additions & 0 deletions docs/source/parameters/lithium_ion_parameters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Lithium-ion Parameters
======================

.. autoclass:: pybamm.LithiumIonParameters
4 changes: 2 additions & 2 deletions docs/source/parameters/parameter_values.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Base Parameter Values
=====================
Parameter Values
================

.. autoclass:: pybamm.ParameterValues
:members:
4 changes: 0 additions & 4 deletions docs/source/parameters/standard_parameters_lead_acid.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/source/parameters/standard_parameters_lithium_ion.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/parameters/thermal_parameters.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Thermal Parameters
=====================
==================

.. automodule:: pybamm.parameters.thermal_parameters
.. autoclass:: pybamm.ThermalParameters
5 changes: 3 additions & 2 deletions docs/tutorials/add-model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ The inbuilt models in PyBaMM do not add all the model attributes within their ow
In addition to calling submodels, common sets of variables and parameters found in
lithium-ion and lead acid batteries are provided in
`standard_variables.py`,
`standard_parameters_lithium_ion.py`,
`standard_parameters_lead_acid.py`,
`lithium_ion_parameters.py`,
`lead_acid_parameters.py`,
`electrical_parameters.py`,
`geometric_parameters.py`,
`thermal_parameters.py`,
and `standard_spatial_vars.py`
which we encourage use of to save redefining the same parameters and variables in
every model and submodel.
Expand Down
25 changes: 8 additions & 17 deletions examples/notebooks/change-input-current.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: You are using pip version 20.1.1; however, version 20.2 is available.\n",
"You should consider upgrading via the '/home/ferranbrosa/PyBaMM/env/bin/python -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 @@ -77,7 +75,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "55b83465a9ea4937bfd3444fa7198460",
"model_id": "0b6d24762adc49bb95efa892bed183da",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -126,7 +124,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b827d913896b418caf161f6d8ee9df92",
"model_id": "9cdb5f149490457796917576b3d5eb13",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -164,7 +162,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "64e6f94728be4ef5bfec800bc26f0768",
"model_id": "a43ac5cc2f204becbb8263f606f7fe94",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -270,7 +268,7 @@
"param = model.default_parameter_values\n",
"\n",
"# set user defined current function\n",
"A = pybamm.electrical_parameters.I_typ\n",
"A = model.param.I_typ\n",
"omega = 0.1\n",
"param[\"Current function [A]\"] = my_fun(A,omega)\n",
"\n",
Expand All @@ -294,7 +292,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c2a1fdc7aa5246aaa9543650d96894ca",
"model_id": "373a98b202d54b958d2a1bc8c5653aba",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -326,20 +324,13 @@
"quick_plot = pybamm.QuickPlot(solution, output_variables, label)\n",
"quick_plot.dynamic_plot();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "PyBaMM development (env)",
"display_name": "Python 3",
"language": "python",
"name": "pybamm-dev"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -351,7 +342,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
30 changes: 22 additions & 8 deletions examples/notebooks/compare-comsol-discharge-curve.ipynb

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions examples/notebooks/compare-ecker-data.ipynb

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions examples/notebooks/models/pouch-cell-model.ipynb

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions examples/scripts/SPMe_SOC.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import numpy as np
import matplotlib.pyplot as plt

plt.close("all")
pybamm.set_logging_level(30)

factor = 6.38
capacities = []
specific_capacities = []
Expand Down Expand Up @@ -56,8 +53,6 @@
"Maximum concentration in positive electrode [mol.m-3]": 50000,
"Initial concentration in negative electrode [mol.m-3]": 12500,
"Initial concentration in positive electrode [mol.m-3]": 25000,
"Negative electrode surface area to volume ratio [m-1]": 180000.0,
"Positive electrode surface area to volume ratio [m-1]": 150000.0,
"Current function [A]": I_app,
}
)
Expand Down Expand Up @@ -133,3 +128,4 @@
ax1.set_ylabel("Capacity [mAh]")
ax2.set_ylabel("Specific Capacity [mAh.cm-3]")
ax2.set_xlabel("Anode : Cathode thickness")
plt.show()
15 changes: 11 additions & 4 deletions examples/scripts/compare_comsol/compare_comsol_DFN.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@

# load parameters and process model and geometry
param = pybamm_model.default_parameter_values
param["Electrode width [m]"] = 1
param["Electrode height [m]"] = 1
param["Current function [A]"] = 24 * C_rates[C_rate]
param.update(
{
"Electrode width [m]": 1,
"Electrode height [m]": 1,
"Negative electrode conductivity [S.m-1]": 126,
"Positive electrode conductivity [S.m-1]": 16.6,
"Current function [A]": 24 * C_rates[C_rate],
}
)

param.process_model(pybamm_model)
param.process_geometry(geometry)

Expand All @@ -55,7 +62,7 @@
# Make Comsol 'model' for comparison
whole_cell = ["negative electrode", "separator", "positive electrode"]
comsol_t = comsol_variables["time"]
L_x = param.evaluate(pybamm.standard_parameters_lithium_ion.L_x)
L_x = param.evaluate(pybamm_model.param.L_x)


def get_interp_fun(variable_name, domain):
Expand Down
12 changes: 9 additions & 3 deletions examples/scripts/compare_comsol/discharge_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@

# load parameters and process model and geometry
param = model.default_parameter_values
param["Electrode width [m]"] = 1
param["Electrode height [m]"] = 1
param["Current function [A]"] = "[input]"
param.update(
{
"Electrode width [m]": 1,
"Electrode height [m]": 1,
"Negative electrode conductivity [S.m-1]": 126,
"Positive electrode conductivity [S.m-1]": 16.6,
"Current function [A]": "[input]",
}
)
param.process_model(model)
param.process_geometry(geometry)

Expand Down
56 changes: 14 additions & 42 deletions examples/scripts/compare_lithium_ion_particle_distribution.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,40 @@
#
# Compare lithium-ion battery models
# Compare lithium-ion battery models with and without particle size distibution
#
import argparse
import numpy as np
import pybamm

parser = argparse.ArgumentParser()
parser.add_argument(
"--debug", action="store_true", help="Set logging level to 'DEBUG'."
)
args = parser.parse_args()
if args.debug:
pybamm.set_logging_level("DEBUG")
else:
pybamm.set_logging_level("INFO")
pybamm.set_logging_level("INFO")

# load models
options = {"thermal": "isothermal"}
models = [
pybamm.lithium_ion.DFN(options, name="standard DFN"),
pybamm.lithium_ion.DFN(options, name="particle DFN"),
pybamm.lithium_ion.DFN(name="standard DFN"),
pybamm.lithium_ion.DFN(name="particle DFN"),
]


# load parameter values and process models and geometry
# load parameter values
params = [models[0].default_parameter_values, models[1].default_parameter_values]
params[0]["Typical current [A]"] = 1.0
params[0].process_model(models[0])


params[1]["Typical current [A]"] = 1.0


def negative_distribution(x):
return 1 + x
return 1 + 2 * x / models[1].param.l_n


def positive_distribution(x):
return 1 + (x - (1 - models[1].param.l_p))
return 1 + 2 * (1 - x) / models[1].param.l_p


params[1]["Negative particle distribution in x"] = negative_distribution
params[1]["Positive particle distribution in x"] = positive_distribution
params[1].process_model(models[1])

# set mesh
var = pybamm.standard_spatial_vars
var_pts = {var.x_n: 10, var.x_s: 10, var.x_p: 10, var.r_n: 5, var.r_p: 5}

# discretise models
for param, model in zip(params, models):
# create geometry
geometry = model.default_geometry
param.process_geometry(geometry)
mesh = pybamm.Mesh(geometry, models[-1].default_submesh_types, var_pts)
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
disc.process_model(model)

# solve model
solutions = [None] * len(models)
# set up and solve simulations
t_eval = np.linspace(0, 3600, 100)
for i, model in enumerate(models):
solutions[i] = pybamm.CasadiSolver().solve(model, t_eval)

sols = []
for model, param in zip(models, params):
sim = pybamm.Simulation(model, parameter_values=param)
sol = sim.solve(t_eval)
sols.append(sol)

output_variables = [
"Negative particle surface concentration",
Expand All @@ -78,5 +50,5 @@ def positive_distribution(x):
]

# plot
plot = pybamm.QuickPlot(solutions, output_variables=output_variables)
plot = pybamm.QuickPlot(sols, output_variables=output_variables)
plot.dynamic_plot()
53 changes: 53 additions & 0 deletions examples/scripts/compare_particle_shape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Example showing how to prescribe the surface area per unit volume independent of
# the assumed particle shape. Setting the "particle shape" option to "user" returns
# a model which solves a spherical diffusion problem in the particles, but passes
# a user supplied surface area per unit volume
#

import pybamm
import numpy as np

pybamm.set_logging_level("INFO")

models = [
pybamm.lithium_ion.DFN({"particle shape": "spherical"}, name="spherical"),
pybamm.lithium_ion.DFN({"particle shape": "user"}, name="user"),
]
params = [models[0].default_parameter_values, models[0].default_parameter_values]

# set up and solve simulations
solutions = []
t_eval = np.linspace(0, 3600, 100)

for model, param in zip(models, params):
if model.name == "user":
# add the user supplied parameters
param.update(
{
"Negative electrode surface area to volume ratio [m-1]": 170000,
"Positive electrode surface area to volume ratio [m-1]": 200000,
"Negative surface area per unit volume distribution in x": 1,
"Positive surface area per unit volume distribution in x": 1,
},
check_already_exists=False,
)

sim = pybamm.Simulation(model, parameter_values=param)
solution = sim.solve(t_eval)
solutions.append(solution)

# plot solutions
pybamm.dynamic_plot(
solutions,
[
"Negative particle surface concentration [mol.m-3]",
"Positive particle surface concentration [mol.m-3]",
"Negative electrode interfacial current density [A.m-2]",
"Positive electrode interfacial current density [A.m-2]",
"Negative electrode potential [V]",
"Electrolyte potential [V]",
"Positive electrode potential [V]",
"Terminal voltage [V]",
],
)
Loading

0 comments on commit df8bcea

Please sign in to comment.