-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9d57e7
commit 50980b5
Showing
9 changed files
with
130 additions
and
12 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
61 changes: 61 additions & 0 deletions
61
...integration/test_models/test_full_battery_models/test_lithium_ion/test_compare_outputs.py
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,61 @@ | ||
# | ||
# Tests for the surface formulation | ||
# | ||
import pybamm | ||
import numpy as np | ||
import unittest | ||
from tests import StandardOutputComparison | ||
|
||
|
||
class TestCompareOutputs(unittest.TestCase): | ||
def test_compare_outputs_surface_form(self): | ||
# load models | ||
options = [ | ||
{"surface form": cap} for cap in [False, "differential", "algebraic"] | ||
] | ||
model_combos = [ | ||
# ([pybamm.lithium_ion.SPM(opt) for opt in options]), | ||
([pybamm.lithium_ion.DFN(opt) for opt in options]) | ||
] | ||
|
||
for models in model_combos: | ||
# load parameter values (same for all models) | ||
param = models[0].default_parameter_values | ||
param.update({"Typical current [A]": 1}) | ||
for model in models: | ||
param.process_model(model) | ||
|
||
# set mesh | ||
var = pybamm.standard_spatial_vars | ||
var_pts = {var.x_n: 5, var.x_s: 5, var.x_p: 5, var.r_n: 5, var.r_p: 5} | ||
|
||
# discretise models | ||
discs = {} | ||
for model in models: | ||
geometry = model.default_geometry | ||
param.process_geometry(geometry) | ||
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts) | ||
disc = pybamm.Discretisation(mesh, model.default_spatial_methods) | ||
disc.process_model(model) | ||
discs[model] = disc | ||
|
||
# solve model | ||
solutions = {} | ||
t_eval = np.linspace(0, 0.2, 100) | ||
for i, model in enumerate(models): | ||
solution = model.default_solver.solve(model, t_eval) | ||
solutions[model] = solution | ||
|
||
# compare outputs | ||
comparison = StandardOutputComparison(models, discs, solutions) | ||
comparison.test_all(skip_first_timestep=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
print("Add -v for more debug output") | ||
import sys | ||
|
||
if "-v" in sys.argv: | ||
debug = True | ||
pybamm.set_logging_level("DEBUG") | ||
unittest.main() |
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