-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add first go at grouped SPMe * Update thicknesses * Update overpotentials * Add double-layer * Update example * Remove factors of length * Fix domain parameters * Update series resistance and etas * Set constant conductivity * Remove factor of 3 * Add parameter conversion function * Combine plots * Update model options * Rename variables * Add conductivities and init_soc * Update averaging * Move timescales * Rescale electrolyte source * Assume high conductivities * Add electrolyte flux * Add transfer coefficient * Update grouped_SPMe * Revert to sto_e, make double layer optional * Add target continuity conditions * Simplify ocv_init setting * Remove concatenations * Switch from theoretical to measured capacity * Move example into subfolder * Fix electrolyte scaling * Add potentials to quick plot * Update option setting * Grouped SPMe edit (#577) * Add Battery voltage to the variables list * Create grouped_SPMe_experiment.py * Move set_initial_state to base models * Remove testing script * Add tests on GroupedSPMe * Test differential surface form * Fix option setting * Update README.md * Add test_grouped_SPMe * Increase coverage * Update name and option setting * Remove comments * Combine if statements * Update CHANGELOG.md --------- Co-authored-by: Noël Hallemans <[email protected]>
- Loading branch information
1 parent
0b6ae29
commit 23aa9dd
Showing
12 changed files
with
938 additions
and
36 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
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,113 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
import pybop | ||
from pybop.models.lithium_ion.basic_SPMe import convert_physical_to_grouped_parameters | ||
|
||
# Prepare figure | ||
layout_options = dict( | ||
xaxis_title="Time / s", | ||
yaxis_title="Voltage / V", | ||
) | ||
plot_dict = pybop.plot.StandardPlot(layout_options=layout_options) | ||
|
||
# Unpack parameter values from Chen2020 | ||
parameter_set = pybop.ParameterSet.pybamm("Chen2020") | ||
|
||
# Fix the electrolyte diffusivity and conductivity | ||
ce0 = parameter_set["Initial concentration in electrolyte [mol.m-3]"] | ||
T = parameter_set["Ambient temperature [K]"] | ||
parameter_set["Electrolyte diffusivity [m2.s-1]"] = parameter_set[ | ||
"Electrolyte diffusivity [m2.s-1]" | ||
](ce0, T) | ||
parameter_set["Electrolyte conductivity [S.m-1]"] = parameter_set[ | ||
"Electrolyte conductivity [S.m-1]" | ||
](ce0, T) | ||
|
||
# Define a test protocol | ||
initial_state = {"Initial SoC": 0.9} | ||
experiment = pybop.Experiment( | ||
[ | ||
"Discharge at 1C until 2.5 V (5 seconds period)", | ||
"Rest for 30 minutes (5 seconds period)", | ||
# "Charge at 2C until 4.1 V (5 seconds period)", | ||
# "Rest for 30 minutes (5 seconds period)", | ||
], | ||
) | ||
|
||
# Run an example SPMe simulation | ||
model_options = {"surface form": "differential", "contact resistance": "true"} | ||
time_domain_SPMe = pybop.lithium_ion.SPMe( | ||
parameter_set=parameter_set, | ||
options=model_options, | ||
) | ||
simulation = time_domain_SPMe.predict( | ||
initial_state=initial_state, experiment=experiment | ||
) | ||
dataset = pybop.Dataset( | ||
{ | ||
"Time [s]": simulation["Time [s]"].data, | ||
"Current function [A]": simulation["Current [A]"].data, | ||
"Voltage [V]": simulation["Voltage [V]"].data, | ||
} | ||
) | ||
plot_dict.add_traces(dataset["Time [s]"], dataset["Voltage [V]"]) | ||
|
||
# Test model in the time domain | ||
grouped_parameter_set = convert_physical_to_grouped_parameters(parameter_set) | ||
time_domain_grouped = pybop.lithium_ion.GroupedSPMe( | ||
parameter_set=grouped_parameter_set, | ||
options=model_options, | ||
build=True, | ||
) | ||
time_domain_grouped.set_initial_state(initial_state) | ||
time_domain_grouped.set_current_function(dataset) | ||
simulation = time_domain_grouped.predict(t_eval=dataset["Time [s]"]) | ||
dataset = pybop.Dataset( | ||
{ | ||
"Time [s]": simulation["Time [s]"].data, | ||
"Current function [A]": simulation["Current [A]"].data, | ||
"Voltage [V]": simulation["Voltage [V]"].data, | ||
} | ||
) | ||
plot_dict.add_traces(dataset["Time [s]"], dataset["Voltage [V]"], line_dash="dash") | ||
plot_dict() | ||
|
||
# Set up figure | ||
fig, ax = plt.subplots() | ||
ax.grid() | ||
|
||
# Compare models in the frequency domain | ||
freq_domain_SPMe = pybop.lithium_ion.SPMe( | ||
parameter_set=parameter_set, options=model_options, eis=True | ||
) | ||
freq_domain_grouped = pybop.lithium_ion.GroupedSPMe( | ||
parameter_set=grouped_parameter_set, | ||
options=model_options, | ||
eis=True, | ||
build=True, | ||
) | ||
|
||
for i, model in enumerate([freq_domain_SPMe, freq_domain_grouped]): | ||
NSOC = 11 | ||
Nfreq = 60 | ||
fmin = 4e-4 | ||
fmax = 1e3 | ||
SOCs = np.linspace(0, 1, NSOC) | ||
frequencies = np.logspace(np.log10(fmin), np.log10(fmax), Nfreq) | ||
|
||
impedances = 1j * np.zeros((Nfreq, NSOC)) | ||
for ii, SOC in enumerate(SOCs): | ||
model.set_initial_state({"Initial SoC": SOC}) | ||
simulation = model.simulateEIS(inputs=None, f_eval=frequencies) | ||
impedances[:, ii] = simulation["Impedance"] | ||
|
||
if i == 0: | ||
ax.plot(np.real(impedances[:, ii]), -np.imag(impedances[:, ii]), "b") | ||
if i == 1: | ||
ax.plot(np.real(impedances[:, ii]), -np.imag(impedances[:, ii]), "r--") | ||
|
||
# Show figure | ||
ax.set(xlabel=r"$Z_r(\omega)$ [$\Omega$]", ylabel=r"$-Z_j(\omega)$ [$\Omega$]") | ||
ax.set_aspect("equal", "box") | ||
plt.show() |
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.