Skip to content

Commit

Permalink
Merge branch 'develop' into issue-3115-shell-domains
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Aug 9, 2023
2 parents dba86bf + b6d4f3f commit 67dcb1c
Show file tree
Hide file tree
Showing 27 changed files with 152 additions and 119 deletions.
3 changes: 2 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@
"profile": "https://www.aboutenergy.io/",
"contributions": [
"code",
"bug"
"bug",
"ideas"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lychee_url_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
--exclude-loopback
--exclude https://twitter.com/pybamm_
--exclude "https://doi\.org|www.sciencedirect\.com/*"
--exclude https://www.rse.ox.ac.uk
--accept 200,429
--exclude-path ./CHANGELOG.md
--exclude-path ./scripts/update_version.py
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/need_reply_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
if: |
github.event.comment.author_association != 'OWNER' &&
github.event.comment.author_association != 'COLLABORATOR' &&
github.repository-owner == 'pybamm-team'
github.repository_owner == 'pybamm-team'
steps:
- name: Remove needs-reply label
uses: octokit/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/needs_reply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: github.repository-owner == 'pybamm-team'
if: github.repository_owner == 'pybamm-team'
steps:
- name: Close old issues that need reply
uses: dwieeb/needs-reply@v2
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.281"
rev: "v0.0.282"
hooks:
- id: ruff
args: [--fix, --ignore=E741, --exclude=__init__.py]
Expand Down
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ sphinx:
fail_on_warning: false

formats:
- pdf
- epub
- htmlzip

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chenzhao-py"><img src="https://avatars.githubusercontent.com/u/75906533?v=4?s=100" width="100px;" alt="CHEN ZHAO"/><br /><sub><b>CHEN ZHAO</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Achenzhao-py" title="Bug reports">🐛</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://www.aboutenergy.io/"><img src="https://avatars.githubusercontent.com/u/91731499?v=4?s=100" width="100px;" alt="darryl-ad"/><br /><sub><b>darryl-ad</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=darryl-ad" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Adarryl-ad" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.aboutenergy.io/"><img src="https://avatars.githubusercontent.com/u/91731499?v=4?s=100" width="100px;" alt="darryl-ad"/><br /><sub><b>darryl-ad</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=darryl-ad" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Adarryl-ad" title="Bug reports">🐛</a> <a href="#ideas-darryl-ad" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/julian-evers"><img src="https://avatars.githubusercontent.com/u/133691040?v=4?s=100" width="100px;" alt="julian-evers"/><br /><sub><b>julian-evers</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=julian-evers" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://batterycontrolgroup.engin.umich.edu/"><img src="https://avatars.githubusercontent.com/u/633873?v=4?s=100" width="100px;" alt="Jason Siegel"/><br /><sub><b>Jason Siegel</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=js1tr3" title="Code">💻</a> <a href="#ideas-js1tr3" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tommaull"><img src="https://avatars.githubusercontent.com/u/101814207?v=4?s=100" width="100px;" alt="Tom Maull"/><br /><sub><b>Tom Maull</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=tommaull" title="Code">💻</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=tommaull" title="Tests">⚠️</a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
"outputs": [],
"source": [
"comsol_model = pybamm.BaseModel()\n",
"comsol_model.geometry = pybamm.battery_geometry(options={\"dimensionality\": 1})\n",
"comsol_model._geometry = pybamm.battery_geometry(options={\"dimensionality\": 1})\n",
"comsol_model.variables = {\n",
" \"Voltage [V]\": comsol_voltage,\n",
" \"Negative current collector potential [V]\": comsol_phi_s_cn,\n",
Expand Down
9 changes: 7 additions & 2 deletions docs/source/examples/notebooks/models/thermal-models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "dev",
"language": "python",
"name": "python3"
},
Expand All @@ -533,7 +533,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.9.16"
},
"toc": {
"base_numbering": 1,
Expand All @@ -547,6 +547,11 @@
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
},
"vscode": {
"interpreter": {
"hash": "bca2b99bfac80e18288b793d52fa0653ab9b5fe5d22e7b211c44eb982a41c00c"
}
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/compare_comsol/compare_comsol_DFN.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_interp_fun(variable_name, domain):

# Create comsol model with dictionary of Matrix variables
comsol_model = pybamm.lithium_ion.BaseModel()
comsol_model.geometry = pybamm_model.default_geometry
comsol_model._geometry = pybamm_model.default_geometry
comsol_model.variables = {
"Negative particle surface concentration [mol.m-3]": comsol_c_n_surf,
"Electrolyte concentration [mol.m-3]": comsol_c_e,
Expand Down
66 changes: 21 additions & 45 deletions examples/scripts/thermal_lithium_ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,35 @@
#

import pybamm
import numpy as np

# load model
pybamm.set_logging_level("INFO")

options = {"thermal": "x-full"}
full_thermal_model = pybamm.lithium_ion.SPMe(options)

options = {"thermal": "x-lumped"}
lumped_thermal_model = pybamm.lithium_ion.SPMe(options)

models = [full_thermal_model, lumped_thermal_model]

# load parameter values and process models and geometry
param = models[0].default_parameter_values
# load models
models = [
pybamm.lithium_ion.SPMe({"thermal": "x-full"}),
pybamm.lithium_ion.SPMe({"thermal": "x-lumped"}),
]

# for x-full, cooling is only implemented on the surfaces
# so set other forms of cooling to zero for comparison.
param.update(
# load parameter values and update cooling coefficients
parameter_values = pybamm.ParameterValues("Marquis2019")
parameter_values.update(
{
"Negative current collector"
+ " surface heat transfer coefficient [W.m-2.K-1]": 5,
"Positive current collector"
+ " surface heat transfer coefficient [W.m-2.K-1]": 5,
"Negative tab heat transfer coefficient [W.m-2.K-1]": 0,
"Positive tab heat transfer coefficient [W.m-2.K-1]": 0,
"Edge heat transfer coefficient [W.m-2.K-1]": 0,
"Negative current collector surface heat transfer coefficient [W.m-2.K-1]"
"": 5,
"Positive current collector surface heat transfer coefficient [W.m-2.K-1]"
"": 5,
"Negative tab heat transfer coefficient [W.m-2.K-1]": 10,
"Positive tab heat transfer coefficient [W.m-2.K-1]": 10,
"Edge heat transfer coefficient [W.m-2.K-1]": 5,
}
)

# create and solve simulations
sols = []
for model in models:
param.process_model(model)

# set mesh
var_pts = {"x_n": 10, "x_s": 10, "x_p": 10, "r_n": 10, "r_p": 10}

# discretise models
for model in 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)
t_eval = np.linspace(0, 3600, 100)
for i, model in enumerate(models):
solver = pybamm.ScipySolver(atol=1e-8, rtol=1e-8)
solution = solver.solve(model, t_eval)
solutions[i] = solution
sim = pybamm.Simulation(model, parameter_values=parameter_values)
sol = sim.solve([0, 3600])
sols.append(sol)

# plot
output_variables = [
Expand All @@ -63,5 +40,4 @@
"Cell temperature [K]",
]
labels = ["Full thermal model", "Lumped thermal model"]
plot = pybamm.QuickPlot(solutions, output_variables, labels)
plot.dynamic_plot()
pybamm.dynamic_plot(sols, output_variables, labels=labels)
2 changes: 1 addition & 1 deletion pybamm/discretisations/discretisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def process_model(

# Save geometry
pybamm.logger.verbose("Save geometry for {}".format(model.name))
model_disc.geometry = getattr(self.mesh, "_geometry", None)
model_disc._geometry = getattr(self.mesh, "_geometry", None)

# Check that resulting model makes sense
if check_model:
Expand Down
4 changes: 0 additions & 4 deletions pybamm/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ def length_scales(self, values):
def geometry(self):
return self._geometry

@geometry.setter
def geometry(self, geometry):
self._geometry = geometry

@property
def default_var_pts(self):
return {}
Expand Down
6 changes: 3 additions & 3 deletions pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class BatteryModelOptions(pybamm.FuzzyDict):
"true" or "false". "false" is the default, since calculating discharge
energy can be computationally expensive for simple models like SPM.
* "cell geometry" : str
Sets the geometry of the cell. Can be "pouch" (default) or
"arbitrary". The arbitrary geometry option solves a 1D electrochemical
Sets the geometry of the cell. Can be "arbitrary" (default) or
"pouch". The arbitrary geometry option solves a 1D electrochemical
model with prescribed cell volume and cross-sectional area, and
(if thermal effects are included) solves a lumped thermal model
with prescribed surface area for cooling.
Expand Down Expand Up @@ -283,9 +283,9 @@ def __init__(self, extra_options):
default_options = {
name: options[0] for name, options in self.possible_options.items()
}
extra_options = extra_options or {}

# Change the default for cell geometry based on which thermal option is provided
extra_options = extra_options or {}
# return "none" if option not given
thermal_option = extra_options.get("thermal", "none")
if thermal_option in ["none", "isothermal", "lumped"]:
Expand Down
2 changes: 2 additions & 0 deletions pybamm/models/submodels/thermal/base_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def _get_standard_coupled_variables(self, variables):
"Total heating [W.m-3]": Q,
"X-averaged total heating [W.m-3]": Q_av,
"Volume-averaged total heating [W.m-3]": Q_vol_av,
"Negative current collector Ohmic heating [W.m-3]": Q_ohm_s_cn,
"Positive current collector Ohmic heating [W.m-3]": Q_ohm_s_cp,
}
)
return variables
Expand Down
1 change: 0 additions & 1 deletion pybamm/models/submodels/thermal/lumped.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def set_rhs(self, variables):
T_amb = variables["Ambient temperature [K]"]

# Account for surface area to volume ratio in cooling coefficient
# The factor 1/delta^2 comes from the choice of non-dimensionalisation.
if self.options["cell geometry"] == "pouch":
cell_volume = self.param.L * self.param.L_y * self.param.L_z

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def set_rhs(self, variables):
T_amb = variables["Ambient temperature [K]"]

# Account for surface area to volume ratio of pouch cell in cooling
# coefficient. Note: the factor 1/delta^2 comes from the choice of
# non-dimensionalisation
# coefficient.
yz_surface_area = self.param.L_y * self.param.L_z
cell_volume = self.param.L * self.param.L_y * self.param.L_z
yz_surface_cooling_coefficient = (
Expand Down
Loading

0 comments on commit 67dcb1c

Please sign in to comment.