-
-
Notifications
You must be signed in to change notification settings - Fork 606
/
Copy pathDFN.py
39 lines (30 loc) · 908 Bytes
/
DFN.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
# Example showing how to load and solve the DFN
#
import pybamm
import numpy as np
pybamm.set_logging_level("INFO")
# load model
model = pybamm.lithium_ion.DFN()
# create geometry
geometry = model.default_geometry
# load parameter values and process model and geometry
param = model.default_parameter_values
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, 0.2, 100)
solver = model.default_solver
solver.rtol = 1e-3
solver.atol = 1e-6
solution = solver.solve(model, t_eval)
# plot
plot = pybamm.QuickPlot(model, mesh, solution)
plot.dynamic_plot()