Skip to content

Commit

Permalink
#2418 debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Dec 13, 2022
1 parent 01b810d commit 8714c0f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
29 changes: 20 additions & 9 deletions examples/scripts/compare_lithium_ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,46 @@
import pybamm

pybamm.set_logging_level("INFO")
options = {"interface utilisation": "constant"}
# load models
models = [
pybamm.lithium_ion.SPM(),
pybamm.lithium_ion.SPMe(),
pybamm.lithium_ion.DFN(),
# pybamm.lithium_ion.SPM(options),
# pybamm.lithium_ion.SPMe(options),
# pybamm.lithium_ion.DFN(options),
# pybamm.lithium_ion.NewmanTobias(),
]


parameter_values = pybamm.ParameterValues("Marquis2019")
parameter_values.update(
{
"Current function [A]": 0,
}
"Initial negative electrode interface utilisation": 0.9,
"Initial positive electrode interface utilisation": 0.8,
},
check_already_exists=False,
)
sims = []
for model in models:
sim = pybamm.Simulation(model, parameter_values=parameter_values)
sim.solve([0, 3600])
sim.solver.atol = 1e-8
sim.solver.rtol = 1e-8
sol = sim.solve([0, 3600])
sims.append(sim)
# print(sol.y[:, -1])
print(sim.built_model.concatenated_rhs.evaluate(y=sol.y[:, -1].full()))

# plot
pybamm.dynamic_plot(
sims,
[
"Total lithium in particles [mol]",
"X-averaged negative particle concentration [mol.m-3]",
"Negative electrode interfacial current density [A.m-2]",
"Current collector current density [A.m-2]",
"Electrolyte current density [A.m-2]",
# "X-averaged negative particle concentration [mol.m-3]",
# "X-averaged positive particle concentration [mol.m-3]",
# "Negative electrode filling fraction",
# "Positive electrode filling fraction",
# "Negative electrode interfacial current density [A.m-2]",
# "Current collector current density [A.m-2]",
# "Electrolyte current density [A.m-2]",
],
)
16 changes: 8 additions & 8 deletions examples/scripts/experimental_protocols/cccv.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
(
"Discharge at C/5 for 10 hours or until 3.3 V",
"Rest for 1 hour",
# "Charge at 1 A until 4.1 V",
# "Hold at 4.1 V until 10 mA",
# "Rest for 1 hour",
"Charge at 1 A until 4.1 V",
"Hold at 4.1 V until 10 mA",
"Rest for 1 hour",
),
]
# * 3
* 10
)
model = pybamm.lithium_ion.SPM()
model = pybamm.lithium_ion.SPM({"SEI": "ec reaction limited"})

sim = pybamm.Simulation(
model, experiment=experiment, solver=pybamm.CasadiSolver("fast with events")
)
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
sim.solve()

sim.plot(["Total lithium in particles [mol]"])

# Plot voltages from the discharge segments only
fig, ax = plt.subplots()
for i in range(3):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_models/standard_output_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def test_conservation(self):
elif self.model.options["surface form"] == "differential":
np.testing.assert_array_almost_equal(diff, 0, decimal=10)
else:
np.testing.assert_array_almost_equal(diff, 0, decimal=15)
np.testing.assert_array_almost_equal(diff, 0, decimal=14)

def test_concentration_profile(self):
"""Test that the concentration in the centre of the negative particles is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def run_basic_processing_test(self, options, **kwargs):

def test_basic_processing(self):
options = {}
# use Ecker parameters for nonlinear diffusion
param = pybamm.ParameterValues("Ecker2015")
self.run_basic_processing_test(options, parameter_values=param)
self.run_basic_processing_test(options)

def test_sensitivities(self):
model = self.model()
Expand Down

0 comments on commit 8714c0f

Please sign in to comment.