sol.save_data(***,to_format=“csv”) was worked at the previous version, but it is not work after updating to newer version. What am I gonna do?
Here is my code:
%pip install pybamm -q # install PyBaMM if it is not installed
import pybamm
import matplotlib.pyplot as plt
import numpy as np
parameter_values = pybamm.ParameterValues(“OKane2022”)
model = pybamm.lithium_ion.DFN({
“particle mechanics”: “swelling and cracking”,
“SEI”: “solvent-diffusion limited”,
“SEI on cracks”: “true”,
“lithium plating”: “partially reversible”,
})
experiment = pybamm.Experiment([
(f"Discharge at 0.3C until 2.75V",
“Rest for 10 min”,
f"Charge at 0.3C until 4.2V",
f"Hold at 4.2V until C/50")
] * 100,
termination=“80% capacity”
)
sim = pybamm.Simulation(model, experiment=experiment, parameter_values=parameter_values)
sol = sim.solve(save_at_cycles=10)
sol.save_data(“test.csv”, [“Time [h]”, “Current [A]”, “Terminal voltage [V]”], to_format=“csv”)
and the error is:
AttributeError Traceback (most recent call last)
/tmp/ipykernel_4605/3950115692.py in
----> 1 sol.save_data(“test.csv”, [“Time [h]”, “Current [A]”, “Terminal voltage [V]”], to_format=“csv”)
~/anaconda3/lib/python3.9/site-packages/pybamm/solvers/solution.py in save_data(self, filename, variables, to_format, short_names)
673 str if ‘csv’ or ‘json’ is chosen and filename is None, otherwise None
674 “”"
→ 675 data = self.get_data_dict(variables=variables, short_names=short_names)
676
677 if to_format == “pickle”:
~/anaconda3/lib/python3.9/site-packages/pybamm/solvers/solution.py in get_data_dict(self, variables, short_names, cycles_and_steps)
633 for i, cycle in enumerate(self.cycles):
634 data_short_names[“Cycle”] = np.concatenate(
→ 635 [data_short_names[“Cycle”], i * np.ones_like(cycle.t)]
636 )
637 for j, step in enumerate(cycle.steps):
AttributeError: ‘NoneType’ object has no attribute ‘t’