-
-
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.
Merge pull request #1121 from ferranbrosa/issue-983-half-cell
Issue 983 half cell
- Loading branch information
Showing
19 changed files
with
922 additions
and
9 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,65 @@ | ||
# | ||
# Example showing how to load and solve the DFN for the half cell | ||
# | ||
|
||
import pybamm | ||
import numpy as np | ||
|
||
pybamm.set_logging_level("INFO") | ||
|
||
# load model | ||
options = {"working electrode": "positive"} | ||
model = pybamm.lithium_ion.BasicDFNHalfCell(options=options) | ||
|
||
# create geometry | ||
geometry = model.default_geometry | ||
|
||
# load parameter values | ||
chemistry = pybamm.parameter_sets.Chen2020 | ||
param = pybamm.ParameterValues(chemistry=chemistry) | ||
|
||
# add lithium counter electrode parameter values | ||
param.update( | ||
{ | ||
"Lithium counter electrode exchange-current density [A.m-2]": 12.6, | ||
"Lithium counter electrode conductivity [S.m-1]": 1.0776e7, | ||
"Lithium counter electrode thickness [m]": 250e-6, | ||
}, | ||
check_already_exists=False, | ||
) | ||
|
||
# process model and geometry | ||
param.process_model(model) | ||
param.process_geometry(geometry) | ||
|
||
# set mesh | ||
var = pybamm.standard_spatial_vars | ||
var_pts = {var.x_n: 30, var.x_s: 30, var.x_p: 30, var.r_n: 10, var.r_p: 10} | ||
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts) | ||
|
||
# discretise model | ||
disc = pybamm.Discretisation(mesh, model.default_spatial_methods) | ||
disc.process_model(model) | ||
|
||
# solve model | ||
t_eval = np.linspace(0, 3800, 1000) | ||
solver = pybamm.CasadiSolver(mode="fast", atol=1e-6, rtol=1e-3) | ||
solution = solver.solve(model, t_eval) | ||
|
||
# plot | ||
plot = pybamm.QuickPlot( | ||
solution, | ||
[ | ||
"Negative particle surface concentration [mol.m-3]", | ||
"Electrolyte concentration [mol.m-3]", | ||
"Positive particle surface concentration [mol.m-3]", | ||
"Current [A]", | ||
"Negative electrode potential [V]", | ||
"Electrolyte potential [V]", | ||
"Positive electrode potential [V]", | ||
"Terminal voltage [V]", | ||
], | ||
time_unit="seconds", | ||
spatial_unit="um", | ||
) | ||
plot.dynamic_plot() |
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.