-
-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix * fix exception * added a Newfile * pseudo * #1778 add heat of mixing option * #1778 fixed indentation * #1778 fixed test * #1778 fixed test * #1788 added heat of mixing tests * First commit * #1778 fixed test * First iteration * #1788 try to fix diff of U * first push from mac * Fixed full broadcast * Fixed domain in the integral * #1778 fix parameter values example * Added children[0].children[0] * Added half cell * style: pre-commit fixes * #1788 revert some unrelated changes * change ocv hack * Revert "change ocv hack" This reverts commit 3ad0c75. * #1778 fix heat of mixing * #1839 fix thermal submodels to take x_average * #1778 add example heat of mixing * ruff * style: pre-commit fixes * #1778 fix lead acid models * fix SPM with the right broadcast of temperature * #1778 refactor heat of mixing * style: pre-commit fixes * Add Richardson2021 citation for heat of mixing * Fixed heat of mixing sign * Rewritten heat of mixing example, added comparison plot to compare with the paper * Fixed ruff formatting errors in the heat of mixing example script * #1778 fix x-full * #1778 fix tests * #1778 improve coverage * style: pre-commit fixes * #1778 Valentin's suggestion to remove the dUdsto function and compute the derivative in the model directly instead * #1778 fix failing test * #1778 add heat of mixing to CHANGELOG --------- Co-authored-by: Alec Bills <48105066+abillscmu@users.noreply.github.com> Co-authored-by: smitasahu2 <smitasahuiitd@gmail.com> Co-authored-by: Afgr1087 <andres.galvis@fem.unicamp.br> Co-authored-by: Ferran Brosa Planella <Ferran.Brosa-Planella@warwick.ac.uk> Co-authored-by: Ivan Korotkin <i.korotkin@soton.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
23bebd0
commit 241e4cc
Showing
14 changed files
with
327 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# | ||
# Compare SPMe model with and without heat of mixing | ||
# | ||
import pybamm | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
pybamm.set_logging_level("INFO") | ||
|
||
# load models | ||
models = [ | ||
pybamm.lithium_ion.SPMe( | ||
{"heat of mixing": "true", "thermal": "lumped"}, name="SPMe with heat of mixing" | ||
), | ||
pybamm.lithium_ion.SPMe({"thermal": "lumped"}, name="SPMe without heat of mixing"), | ||
] | ||
|
||
# set parametrisation (Ecker et al., 2015) | ||
parameter_values = pybamm.ParameterValues("Ecker2015") | ||
|
||
# set mesh | ||
# (increased number of points in particles to avoid oscillations for high C-rates) | ||
var_pts = {"x_n": 16, "x_s": 8, "x_p": 16, "r_n": 128, "r_p": 128} | ||
|
||
# set the constant current discharge C-rate | ||
C_rate = 5 | ||
|
||
# set the simulation time and increase the number of points | ||
# for better integration in time | ||
t_eval = np.linspace(0, 720, 360) | ||
|
||
# set up an extra plot with the heat of mixing vs time in each electrode and | ||
# the integrated heat of mixing vs time in each electrode to compare with | ||
# Figure 6(a) from Richardson et al. (2021) | ||
fig, axs = plt.subplots(2, len(models), figsize=(12, 7)) | ||
|
||
# extract some of the parameters | ||
L_n = parameter_values["Negative electrode thickness [m]"] | ||
L_p = parameter_values["Positive electrode thickness [m]"] | ||
A = parameter_values["Electrode width [m]"] * parameter_values["Electrode height [m]"] | ||
|
||
# create and run simulations | ||
sims = [] | ||
for m, model in enumerate(models): | ||
sim = pybamm.Simulation( | ||
model, parameter_values=parameter_values, var_pts=var_pts, C_rate=C_rate | ||
) | ||
sim.solve(t_eval) | ||
sims.append(sim) | ||
|
||
# extract solution for plotting | ||
sol = sim.solution | ||
|
||
# extract variables from the solution | ||
time = sol["Time [h]"].entries | ||
Q_mix = sol["Heat of mixing [W.m-3]"].entries | ||
|
||
# heat of mixing in negative and positive electrodes multiplied by the electrode | ||
# width, represents the integral of heat of mixing term across each of the | ||
# electrodes (W.m-2) | ||
Q_mix_n = Q_mix[0, :] * L_n | ||
Q_mix_p = Q_mix[-1, :] * L_p | ||
|
||
# heat of mixing integrals (J.m-2) | ||
Q_mix_n_int = 0.0 | ||
Q_mix_p_int = 0.0 | ||
|
||
# data for plotting | ||
Q_mix_n_plt = [] | ||
Q_mix_p_plt = [] | ||
|
||
# performs integration in time | ||
for i, t in enumerate(time[1:]): | ||
dt = (t - time[i]) * 3600 # seconds | ||
Q_mix_n_avg = (Q_mix_n[i] + Q_mix_n[i + 1]) * 0.5 | ||
Q_mix_p_avg = (Q_mix_p[i] + Q_mix_p[i + 1]) * 0.5 | ||
# convert J to kJ and divide the integral by the electrode area A to compare | ||
# with Figure 6(a) from Richardson et al. (2021) | ||
Q_mix_n_int += Q_mix_n_avg * dt / 1000 / A | ||
Q_mix_p_int += Q_mix_p_avg * dt / 1000 / A | ||
Q_mix_n_plt.append(Q_mix_n_int) | ||
Q_mix_p_plt.append(Q_mix_p_int) | ||
|
||
# plots heat of mixing in each electrode vs time in minutes | ||
axs[0, m].plot(time * 60, Q_mix_n, ls="-", label="Negative electrode") | ||
axs[0, m].plot(time * 60, Q_mix_p, ls="--", label="Positive electrode") | ||
axs[0, m].set_title(f"{model.name}") | ||
axs[0, m].set_xlabel("Time [min]") | ||
axs[0, m].set_ylabel("Heat of mixing [W.m-2]") | ||
axs[0, m].grid(True) | ||
axs[0, m].legend() | ||
|
||
# plots integrated heat of mixing in each electrode vs time in minutes | ||
axs[1, m].plot(time[1:] * 60, Q_mix_n_plt, ls="-", label="Negative electrode") | ||
axs[1, m].plot(time[1:] * 60, Q_mix_p_plt, ls="--", label="Positive electrode") | ||
axs[1, m].set_xlabel("Time [min]") | ||
axs[1, m].set_ylabel("Integrated heat of mixing [kJ.m-2]") | ||
axs[1, m].grid(True) | ||
axs[1, m].legend() | ||
|
||
# plot | ||
pybamm.dynamic_plot( | ||
sims, | ||
output_variables=[ | ||
"X-averaged cell temperature [K]", | ||
"X-averaged heat of mixing [W.m-3]", | ||
"X-averaged total heating [W.m-3]", | ||
"Heat of mixing [W.m-3]", | ||
"Voltage [V]", | ||
"Current [A]", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.