07 Visualizing larger packs¶
In this example we will demonstrate another method for visualizing the data from a simulation that may be more convenient for larger packs.
In [1]:
Copied!
try:
import liionpack as lp
except:
!pip install -q git+https://github.com/pybamm-team/liionpack.git@main
import liionpack as lp
import numpy as np
import os
import pybamm
nproc = os.cpu_count()
try:
import liionpack as lp
except:
!pip install -q git+https://github.com/pybamm-team/liionpack.git@main
import liionpack as lp
import numpy as np
import os
import pybamm
nproc = os.cpu_count()
Set up and run a simulation with 5000 cells. Plotting the information for all the cells using lp.plot_cells
would take a long time to render and also would not contain any spatial information about regions of the pack experiencing different conditions.
In [2]:
Copied!
Np = 100
Ns = 50
Nspm = Np * Ns
# Generate the netlist
netlist = lp.setup_circuit(Np=Np, Ns=Ns, Rb=1e-5, Ri=3e-2)
# Define additional output variables
output_variables = [
"Volume-averaged cell temperature [K]",
]
# Define a cycling experiment using PyBaMM
experiment = pybamm.Experiment(
[
"Discharge at 100 A for 10 minutes",
],
period="1 minute",
)
# Define the PyBaMM parameters
parameter_values = pybamm.ParameterValues("Chen2020")
parameter_values.update(
{"Total heat transfer coefficient [W.m-2.K-1]": "[input]"}
)
htc = np.random.random(Nspm) * 50.0
inputs = {"Total heat transfer coefficient [W.m-2.K-1]": htc}
# Solve the pack
output = lp.solve(
netlist=netlist,
sim_func=lp.thermal_simulation,
parameter_values=parameter_values,
experiment=experiment,
output_variables=output_variables,
inputs=inputs,
initial_soc=0.5,
nproc=nproc
)
Np = 100
Ns = 50
Nspm = Np * Ns
# Generate the netlist
netlist = lp.setup_circuit(Np=Np, Ns=Ns, Rb=1e-5, Ri=3e-2)
# Define additional output variables
output_variables = [
"Volume-averaged cell temperature [K]",
]
# Define a cycling experiment using PyBaMM
experiment = pybamm.Experiment(
[
"Discharge at 100 A for 10 minutes",
],
period="1 minute",
)
# Define the PyBaMM parameters
parameter_values = pybamm.ParameterValues("Chen2020")
parameter_values.update(
{"Total heat transfer coefficient [W.m-2.K-1]": "[input]"}
)
htc = np.random.random(Nspm) * 50.0
inputs = {"Total heat transfer coefficient [W.m-2.K-1]": htc}
# Solve the pack
output = lp.solve(
netlist=netlist,
sim_func=lp.thermal_simulation,
parameter_values=parameter_values,
experiment=experiment,
output_variables=output_variables,
inputs=inputs,
initial_soc=0.5,
nproc=nproc
)
Stepping simulation: 100%|█████████████████████████████████████████████████████████████| 11/11 [13:15<00:00, 72.32s/it]
We can use plot_cell_data_image
to produce a snapshot of the system in image format which has the same dimensions as the number of cells in parallel and series.
In [3]:
Copied!
data = output["Volume-averaged cell temperature [K]"][-1, :]
lp.plot_cell_data_image(netlist, data, tick_labels=False, figsize=(15, 6))
data = output["Volume-averaged cell temperature [K]"][-1, :]
lp.plot_cell_data_image(netlist, data, tick_labels=False, figsize=(15, 6))
In [4]:
Copied!
data = output["Terminal voltage [V]"][-1, :]
lp.plot_cell_data_image(netlist, data, tick_labels=False, figsize=(15, 6))
data = output["Terminal voltage [V]"][-1, :]
lp.plot_cell_data_image(netlist, data, tick_labels=False, figsize=(15, 6))