Skip to content

Commit

Permalink
#1230 merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Nov 15, 2020
2 parents 3a33d92 + 53f46fa commit 4fe6879
Show file tree
Hide file tree
Showing 56 changed files with 703 additions and 386 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

## Breaking changes

- The parameters "Positive/Negative particle distribution in x" and "Positive/Negative surface area per unit volume distribution in x" have been deprecated. Instead, users can provide "Positive/Negative particle radius [m]" and "Positive/Negative surface area per unit volume [m-1]" directly as functions of through-cell position (x [m]) ([#1237](https://github.com/pybamm-team/PyBaMM/pull/1237))

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

Expand Down
11 changes: 2 additions & 9 deletions examples/notebooks/compare-ecker-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
" var.x_n: int(parameter_values.evaluate(model.param.L_n / 1e-6)),\n",
" var.x_s: int(parameter_values.evaluate(model.param.L_s / 1e-6)),\n",
" var.x_p: int(parameter_values.evaluate(model.param.L_p / 1e-6)),\n",
" var.r_n: int(parameter_values.evaluate(model.param.R_n / 1e-7)),\n",
" var.r_p: int(parameter_values.evaluate(model.param.R_p / 1e-7)),\n",
" var.r_n: int(parameter_values.evaluate(model.param.R_n_typ / 1e-7)),\n",
" var.r_p: int(parameter_values.evaluate(model.param.R_p_typ / 1e-7)),\n",
"}"
]
},
Expand Down Expand Up @@ -221,13 +221,6 @@
"\n",
"[2] Richardson, Giles, et. al. \"Generalised single particle models for high-rate operation of graded lithium-ion electrodes: Systematic derivation and validation.\" Electrochemica Acta 339 (2020): 135862"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/models/DFN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"\n",
"#### Concentration in the electrode active material:\n",
"\\begin{gather}\n",
"N_{\\text{s,k}}\\big|_{r_{\\text{k}}=0} = 0, \\quad \\text{k} \\in \\text{n, p}, \\quad \\ \\ - \\frac{a_{\\text{k}}\\gamma_{\\text{k}}}{\\mathcal{C}_{\\text{k}}} N_{\\text{s,k}}\\big|_{r_{\\text{k}}=1} = j_{\\text{k}}, \\quad \\text{k} \\in \\text{n, p}.\n",
"N_{\\text{s,k}}\\big|_{r_{\\text{k}}=0} = 0, \\quad \\text{k} \\in \\text{n, p}, \\quad \\ \\ - \\frac{a_{R, \\text{k}}\\gamma_{\\text{k}}}{\\mathcal{C}_{\\text{k}}} N_{\\text{s,k}}\\big|_{r_{\\text{k}}=1} = j_{\\text{k}}, \\quad \\text{k} \\in \\text{n, p}.\n",
"\\end{gather}\n",
"\n",
"#### Reference potential:\n",
Expand Down Expand Up @@ -203,7 +203,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b72126bb294743c38f4aa5069787b9b6",
"model_id": "eceebcfd564d4b53bf56bda5abf066ff",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -240,7 +240,7 @@
"|$\\mathcal{C}_{\\text{k}}$ | $\\tau_{\\text{k}}^*/\\tau_{\\text{d}}^*$ | Ratio of solid diffusion and discharge timescales |\n",
"|$\\mathcal{C}_{\\text{e}}$ |$\\tau_{\\text{e}}^*/\\tau_{\\text{d}}^*$ |Ratio of electrolyte transport and discharge timescales|\n",
"|$\\mathcal{C}_{\\text{r,k}}$ |$\\tau_{\\text{r,k}}^*/\\tau_{\\text{d}}^*$ |Ratio of reaction and discharge timescales|\n",
"|$a_{\\text{k}}$ |$a_{\\text{k}}^* R_{\\text{k}}^*$ | Product of particle radius and surface area to volume ratio|\n",
"|$a_{R, \\text{k}}$ |$a_{\\text{k}}^* R_{\\text{k}}^*$ | Product of particle radius and surface area to volume ratio|\n",
"|$\\gamma_{\\text{k}}$ |$c_{\\text{k,max}}^*/c_{\\text{n,max}}^*$ |Ratio of maximum lithium concentrations in solid|\n",
"|$\\gamma_{\\text{e}}$ |$c_{\\text{e,typ}}^*/c_{\\text{n,max}}^*$ |Ratio of maximum lithium concentration in the negative electrode solid and typical electrolyte concentration|\n",
"\n",
Expand Down
97 changes: 83 additions & 14 deletions examples/notebooks/models/SPM.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions examples/notebooks/models/SPMe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"\\mathcal{C}_{\\text{k}} \\frac{\\partial c_{\\text{s,k}}}{\\partial t} &= -\\frac{1}{r_{\\text{k}}^2} \\frac{\\partial}{\\partial r_{\\text{k}}} \\left(r_{\\text{k}}^2 N_{\\text{s,k}}\\right), \\\\\n",
"N_{\\text{s,k}} &= -D_{\\text{s,k}}(c_{\\text{s,k}}) \\frac{\\partial c_{\\text{s,k}}}{\\partial r_{\\text{k}}}, \\quad \\text{k} \\in \\text{n, p}, \\end{align}\n",
"$$\n",
"N_{\\text{s,k}}\\big|_{r_{\\text{k}}=0} = 0, \\quad \\text{k} \\in \\text{n, p}, \\quad \\ \\ - \\frac{a_{\\text{k}}\\gamma_{\\text{k}}}{\\mathcal{C}_{\\text{k}}} N_{\\text{s,k}}\\big|_{r_{\\text{k}}=1} = \n",
"N_{\\text{s,k}}\\big|_{r_{\\text{k}}=0} = 0, \\quad \\text{k} \\in \\text{n, p}, \\quad \\ \\ - \\frac{a_{R, \\text{k}}\\gamma_{\\text{k}}}{\\mathcal{C}_{\\text{k}}} N_{\\text{s,k}}\\big|_{r_{\\text{k}}=1} = \n",
"\\begin{cases}\n",
"\t\t \\frac{I}{L_{\\text{n}}}, \\quad &\\text{k}=\\text{n}, \\\\ \n",
"\t\t -\\frac{I}{L_{\\text{p}}}, \\quad &\\text{k}=\\text{p}, \n",
Expand Down Expand Up @@ -155,7 +155,7 @@
{
"data": {
"text/plain": [
"<pybamm.solvers.solution.Solution at 0x7f69f08dd2e8>"
"<pybamm.solvers.solution.Solution at 0x7f5cd829b4a8>"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -183,7 +183,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "47ee8d1901bd4bdd87fba1d347da16ec",
"model_id": "5f19fdea006d4f22ae77a584c87d5eb3",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -218,7 +218,7 @@
"|$\\mathcal{C}_{\\text{k}}$ | $\\tau_{\\text{k}}^*/\\tau_{\\text{d}}^*$ | Ratio of solid diffusion and discharge timescales |\n",
"|$\\mathcal{C}_{\\text{e}}$ |$\\tau_{\\text{e}}^*/\\tau_{\\text{d}}^*$ |Ratio of electrolyte transport and discharge timescales|\n",
"|$\\mathcal{C}_{\\text{r,k}}$ |$\\tau_{\\text{r,k}}^*/\\tau_{\\text{d}}^*$ |Ratio of reaction and discharge timescales|\n",
"|$a_{\\text{k}}$ |$a_{\\text{k}}^* R_{\\text{k}}^*$ | Product of particle radius and surface area to volume ratio|\n",
"|$a_{R, \\text{k}}$ |$a_{\\text{k}}^* R_{\\text{k}}^*$ | Product of particle radius and surface area to volume ratio|\n",
"|$\\gamma_{\\text{k}}$ |$c_{\\text{k,max}}^*/c_{\\text{n,max}}^*$ |Ratio of maximum lithium concentrations in solid|\n",
"|$\\gamma_{\\text{e}}$ |$c_{\\text{e,typ}}^*/c_{\\text{n,max}}^*$ |Ratio of maximum lithium concentration in the negative electrode solid and typical electrolyte concentration|\n",
"\n",
Expand Down
26 changes: 17 additions & 9 deletions examples/notebooks/models/compare-lithium-ion.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/notebooks/models/pouch-cell-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/user/Documents/PyBaMM/pybamm/models/full_battery_models/base_battery_model.py:361: UserWarning: 1+1D Thermal models are only valid if both tabs are placed at the top of the cell.\n",
"/home/user/Documents/PyBaMM/pybamm/models/full_battery_models/base_battery_model.py:375: UserWarning: 1+1D Thermal models are only valid if both tabs are placed at the top of the cell.\n",
" \"1+1D Thermal models are only valid if both tabs are \"\n"
]
}
Expand Down Expand Up @@ -339,7 +339,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We then add the solution object from the 1+1D model. This is just so that PyBaMM uses the same times behind the scenes when dealing with COMSOL model and the reduced-order models: the variables in `comsol_model.variables` are functions of time only that return the (interpolated in space) COMSOL solution."
"We then add the solution object from the 1+1D model. This is just so that PyBaMM uses the same (dimensionless) times behind the scenes when dealing with COMSOL model and the reduced-order models: the variables in `comsol_model.variables` are functions of time only that return the (interpolated in space) COMSOL solution. We also need to update the time and length scales for the COMSOL model so that any dimensionless variables are scaled correctly. "
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/compare_comsol/compare_comsol_DFN.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def myinterp(t):
# Make new solution with same t and y
comsol_solution = pybamm.Solution(pybamm_solution.t, pybamm_solution.y)
# Update solution scales to match the pybamm model
comsol_solution.timescale_eval = pybamm_model.timescale_eval
comsol_solution.length_scales_eval = pybamm_model.length_scales_eval
comsol_model.timescale_eval = pybamm_model.timescale_eval
comsol_model.length_scales_eval = pybamm_model.length_scales_eval
comsol_solution.model = comsol_model

# plot
Expand Down
23 changes: 14 additions & 9 deletions examples/scripts/compare_lithium_ion_particle_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@
params = [models[0].default_parameter_values, models[1].default_parameter_values]


def negative_distribution(x):
return 1 + 2 * x / models[1].param.l_n
def negative_radius(x):
"Negative particle radius as a function of through-cell position (x_n [m])"
R_n_0 = params[0]["Negative particle radius [m]"]
grading = 1 + 2 * x / models[1].param.L_n
return grading * R_n_0


def positive_distribution(x):
return 1 + 2 * (1 - x) / models[1].param.l_p
def positive_radius(x):
"Positive particle radius as a function of through-cell position (x_p [m])"
R_p_0 = params[0]["Positive particle radius [m]"]
grading = 1 + 2 * (models[1].param.L_x - x) / models[1].param.L_p
return grading * R_p_0


params[1]["Negative particle distribution in x"] = negative_distribution
params[1]["Positive particle distribution in x"] = positive_distribution

params[1]["Negative particle radius [m]"] = negative_radius
params[1]["Positive particle radius [m]"] = positive_radius

# set up and solve simulations
t_eval = np.linspace(0, 3600, 100)
Expand All @@ -45,8 +50,8 @@ def positive_distribution(x):
"Electrolyte potential [V]",
"Positive electrode potential [V]",
"Terminal voltage [V]",
"Negative particle distribution in x",
"Positive particle distribution in x",
"Negative particle radius",
"Positive particle radius",
]

# plot
Expand Down
2 changes: 0 additions & 2 deletions examples/scripts/compare_particle_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
{
"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,
)
Expand Down
1 change: 1 addition & 0 deletions pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def version(formatted=False):

if system() != "Windows":
from .expression_tree.operations.evaluate import EvaluatorJax
from .expression_tree.operations.evaluate import JaxCooMatrix

from .expression_tree.operations.jacobian import Jacobian
from .expression_tree.operations.convert_to_casadi import CasadiConverter
Expand Down
Loading

0 comments on commit 4fe6879

Please sign in to comment.