-
-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plett OCP Hysteresis Model #3593
Merged
valentinsulzer
merged 58 commits into
pybamm-team:develop
from
mleot:plett-ocp-hysteresis
May 11, 2024
Merged
Changes from 54 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
01dc550
first tests passed
mleot 809af01
updated citations
mleot a9ce212
clean up ocp script
mleot 13875ce
might be step in wrong direction
mleot 80a03d6
now passes TestDFN unit test well posed
tanner-leo 7d2026c
now passes TestDFN unit test well posed
tanner-leo 551b023
passing MPM integration test
tanner-leo ab3f87d
nearly passing MPM + DFN tests
tanner-leo a9f09d0
Merge branch 'pr/mleot/3593' into pr/mleot/3593-1
tanner-leo fc91c08
Merge branch 'pybamm-team:develop' into plett-ocp-hysteresis
mleot 9388adf
style: pre-commit fixes
pre-commit-ci[bot] 7d4aa19
add citations
mleot 2463e2a
style: pre-commit fixes
pre-commit-ci[bot] 1bcb524
remove unessesary citation
mleot 3e89fb4
passes all unit tests
mleot 27e075f
style: pre-commit fixes
pre-commit-ci[bot] 2e7d81b
move Q from lithium ion function to submodel coupled variable
mleot 5ae648b
Merge branch 'plett-ocp-hysteresis' of https://github.com/mleot/pybam…
mleot e2fa1ed
clean up changes
mleot 9b0a4aa
style: pre-commit fixes
pre-commit-ci[bot] e37031c
Merge branch 'develop' into plett-ocp-hysteresis
mleot 2ed9dea
working example notebook and temporary revert to dQ as a function
mleot c4f96c6
style: pre-commit fixes
pre-commit-ci[bot] 5fd1555
revert to functional form of Q
mleot 957755e
renaming to dchs
mleot 3324f40
Merge branch 'develop' into plett-ocp-hysteresis
mleot d0be637
clean up
mleot c2825aa
update docs build script
mleot a16283a
update notebook
mleot cc64fb4
compatabilize composite model
mleot 7952dbd
add test
mleot 0ad1869
style: pre-commit fixes
pre-commit-ci[bot] 9e46865
remove unessesary statements
mleot 746f811
style: pre-commit fixes
pre-commit-ci[bot] e9dd55f
remove unused
mleot 4f8bbbc
Merge branch 'develop' into plett-ocp-hysteresis
mleot 69beb4e
Merge branch 'develop' into plett-ocp-hysteresis
mleot d379fb7
pre-compatibilize psd+composite electrode model
mleot 00a2e8e
style: pre-commit fixes
pre-commit-ci[bot] 8ad8214
update notebook name
mleot 2f947d9
rename to Wycisk from DCHS
mleot 9566f50
update parameters required & names
mleot 57240b8
Merge remote-tracking branch 'upstream/develop' into pr/mleot/3593
mleot ca414cb
Merge branch 'develop' into plett-ocp-hysteresis
mleot 668c5fe
Merge branch 'plett-ocp-hysteresis' of https://github.com/mleot/pybam…
mleot eb2fe95
change if statement for code cov
mleot 647be7b
add docs
mleot ec466f0
style: pre-commit fixes
pre-commit-ci[bot] 6cab440
Merge branch 'develop' into plett-ocp-hysteresis
mleot e72f799
update toctree
mleot f02551e
add to changelog
mleot 48fe678
Merge branch 'develop' into plett-ocp-hysteresis
mleot 31b7115
move functions inside submodel
mleot 66f0ef1
Merge branch 'develop' into plett-ocp-hysteresis
mleot 1a8268c
fix change requests
mleot 5c169e2
Merge branch 'develop' into plett-ocp-hysteresis
mleot f6fc3ad
getting rid of functional form Q
mleot d8f451e
Merge branch 'develop' into plett-ocp-hysteresis
mleot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ Open-circuit potential models | |
current_sigmoid_ocp | ||
single_ocp | ||
msmr_ocp | ||
wycisk_ocp |
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/interface/open_circuit_potential/wycisk_ocp.rst
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,5 @@ | ||
Wycisk Open Circuit Potential | ||
============================= | ||
|
||
.. autoclass:: pybamm.open_circuit_potential.WyciskOpenCircuitPotential | ||
:members: |
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
269 changes: 269 additions & 0 deletions
269
docs/source/examples/notebooks/models/differential-capacity-hysteresis-state.ipynb
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,269 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Differential Capacity Hysteresis State model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Note: you may need to restart the kernel to use updated packages.\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%pip install \"pybamm[plot,cite]\" -q # install PyBaMM if it is not installed\n", | ||
"import pybamm" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Model Equations\n", | ||
"\n", | ||
"Herein the model equations for the Differential Capacity Hysteresis State open-circuit potential model are outlined, as described in Wycisk (2022).\n", | ||
"\n", | ||
"### Hysteresis State Variable\n", | ||
"\n", | ||
"This approach utilizes a state variable to represent the degree of hysteresis at a given time and stoichiometry, $h(z,t)$. The hysteresis is treated separately from the open-circuit potential, where the potential of the electrode is written as\n", | ||
"\n", | ||
"$$ U = U_{avg}^0(z) + H(z) \\cdot h(z,t) - \\eta $$\n", | ||
"\n", | ||
"Where $H(z)$ is a function representing the hysteresis as a function of stoichiometry, $z$, and where $\\eta$ represents the sum of the overpotentials. $U_{avg}^0(z)$ is simply the average of the delithiation and lithiation open-circuit potential branches. $H(z)$ can be determined by finding the half-difference value between the lithiation and delithiation branches across the entire stoichiometry range. The state variable $h(z,t)$ is both stoichiometry and time-dependant, and spans between the range of -1 and 1. The hysteresis state variable $h(z,t)$ can be expressed in differential form with respect to time as\n", | ||
"\n", | ||
"$$ \\frac{dh(z,t)}{dt} = \\left(\\frac{k(z) \\cdot I(t)}{Q_{cell}}\\right)\\left(1-\\text{sgn}\\left(\\frac{dz(t)}{dt}\\right) h(z,t)\\right) $$\n", | ||
"\n", | ||
"where $ k(z) $ is expressed as \n", | ||
"\n", | ||
"$$ k(z) = K \\cdot \\frac{1}{\\left(C_{diff}\\left(z\\right)\\right)^{x}} $$\n", | ||
"\n", | ||
"And where $C_{diff}(z)$ is the differential capacity with respect to potential, expressed as \n", | ||
"\n", | ||
"$$ C_{diff}(z) = \\frac{dQ}{dU_{avg}^0(z)} $$\n", | ||
"\n", | ||
"Here, $Q$ is the capacity of the phase or active material experiencing the voltage hysteresis. The remaining parameters are $K$ and $x$ which are both fitting parameters that affect the response of the hysteresis state decay when passing charge in either direction.\n", | ||
"\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Comparing the DCHS and Current-Sigmoid model approaches\n", | ||
"\n", | ||
"The behavior of the DCHS model is different than the current-sigmoid model approach for open-circuit potential in systems with hysteresis. Where the current-sigmoid model switches between hysteresis states simply based on the instantaneous current, the DCHS model switches based on the amount of charge passed through the active material phase while also relying on the previous hysteresis state. To assess this differentiated performance, we will compare it to the current-sigmoid model by adapting the Chen2020_composite parameter set.\n", | ||
"\n", | ||
"First we generate the model, and specify the open-circuit potential methods for the negative and positive electrodes. To maintain consistency with the parameter set, two phases for the negative electrode will be defined." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model_DCHS = pybamm.lithium_ion.DFN(\n", | ||
" {\n", | ||
" \"open-circuit potential\": ((\"single\", \"Wycisk\"), \"single\"),\n", | ||
" \"particle phases\": (\"2\", \"1\"),\n", | ||
" }\n", | ||
")\n", | ||
"\n", | ||
"model_current_sigmoid = pybamm.lithium_ion.DFN(\n", | ||
" {\n", | ||
" \"open-circuit potential\": ((\"single\", \"current sigmoid\"), \"single\"),\n", | ||
" \"particle phases\": (\"2\", \"1\"),\n", | ||
" }\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Next, lets define the modifications to the parameter set" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters_DCHS = pybamm.ParameterValues(\"Chen2020_composite\")\n", | ||
"parameters_current_sigmoid = pybamm.ParameterValues(\"Chen2020_composite\")\n", | ||
"\n", | ||
"\n", | ||
"# get the lithiation and delithiation functions\n", | ||
"lithiation_ocp = parameters_DCHS[\"Secondary: Negative electrode lithiation OCP [V]\"]\n", | ||
"delithiation_ocp = parameters_DCHS[\"Secondary: Negative electrode delithiation OCP [V]\"]\n", | ||
"\n", | ||
"\n", | ||
"# define an additional OCP function\n", | ||
"def ocp_avg(sto):\n", | ||
" return (lithiation_ocp(sto) + delithiation_ocp(sto)) / 2\n", | ||
"\n", | ||
"\n", | ||
"# add additional parameters\n", | ||
"parameters_DCHS.update(\n", | ||
" {\n", | ||
" \"Secondary: Negative electrode OCP [V]\": ocp_avg,\n", | ||
" },\n", | ||
" check_already_exists=False,\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Next, we need to add the additional parameters required by the model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"parameters_DCHS.update(\n", | ||
" {\n", | ||
" \"Secondary: Negative particle hysteresis decay rate\": 0.005,\n", | ||
" \"Secondary: Negative particle hysteresis switching factor\": 10,\n", | ||
" },\n", | ||
" check_already_exists=False,\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"experiment = pybamm.Experiment(\n", | ||
" [\n", | ||
" (\"Discharge at 1 C for 1 hour or until 2.5 V\", \"Rest for 15 minutes\"),\n", | ||
" (\n", | ||
" \"Charge at 1C until 4.2 V\",\n", | ||
" \"Hold at 4.2 V until 0.05 C\",\n", | ||
" \"Rest for 15 minutes\",\n", | ||
" ),\n", | ||
" ]\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"simulation_dchs = pybamm.Simulation(\n", | ||
" model_DCHS, experiment=experiment, parameter_values=parameters_DCHS\n", | ||
")\n", | ||
"solution_dchs = simulation_dchs.solve(calc_esoh=False)\n", | ||
"\n", | ||
"simulation_current_sigmoid = pybamm.Simulation(\n", | ||
" model_current_sigmoid,\n", | ||
" experiment=experiment,\n", | ||
" parameter_values=parameters_current_sigmoid,\n", | ||
")\n", | ||
"\n", | ||
"solution_current_sigmoid = simulation_current_sigmoid.solve(calc_esoh=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now plotting the results and the hysteresis state " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "7fa481d981ff4f9da3b688120bdbf930", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"interactive(children=(FloatSlider(value=0.0, description='t', max=3.1492654802910014, step=0.03149265480291001…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"output_variables = [\n", | ||
" \"X-averaged negative electrode secondary hysteresis state\",\n", | ||
" \"Negative electrode secondary open-circuit potential [V]\",\n", | ||
" \"Negative electrode secondary stoichiometry\",\n", | ||
" \"Terminal voltage [V]\",\n", | ||
" \"X-averaged negative electrode secondary open-circuit potential [V]\",\n", | ||
"]\n", | ||
"\n", | ||
"pybamm.QuickPlot(solution_dchs, output_variables=output_variables).dynamic_plot()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "6745f5d4c7e64bbc8a57011b282bdf2e", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"interactive(children=(FloatSlider(value=0.0, description='t', max=3.1492654802910014, step=0.03149265480291001…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"output_variables = [\n", | ||
" \"Terminal voltage [V]\",\n", | ||
" \"Current [A]\",\n", | ||
" \"Negative electrode secondary open-circuit potential [V]\",\n", | ||
"]\n", | ||
"pybamm.QuickPlot(\n", | ||
" [solution_current_sigmoid, solution_dchs],\n", | ||
" labels=[\"Current sigmoid\", \"DCHS\"],\n", | ||
" output_variables=output_variables,\n", | ||
").dynamic_plot()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! this model is a great addition!