Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to calculate theoretical efficiency #2777

Merged
merged 6 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Added an option for using a banded jacobian and sundials banded solvers for the IDAKLU solve ([#2677](https://github.com/pybamm-team/PyBaMM/pull/2677))
- The "particle size" option can now be a tuple to allow different behaviour in each electrode ([#2672](https://github.com/pybamm-team/PyBaMM/pull/2672)).
- Added temperature control to experiment class. ([#2518](https://github.com/pybamm-team/PyBaMM/pull/2518))
- Added method to calculate maximum theoretical energy. ([#2777](https://github.com/pybamm-team/PyBaMM/pull/2777))

## Bug fixes

Expand Down
51 changes: 51 additions & 0 deletions pybamm/models/full_battery_models/lithium_ion/electrode_soh.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,54 @@ def get_min_max_stoichiometries(
"""
esoh_solver = ElectrodeSOHSolver(parameter_values, param, known_value)
return esoh_solver.get_min_max_stoichiometries()


def calculate_theoretical_energy(
parameter_values, initial_soc=1.0, final_soc=0.0, points=100
):
"""
Calculate maximum energy possible from a cell given OCV, initial soc, and final soc
given voltage limits, open-circuit potentials, etc defined by parameter_values

Parameters
----------
parameter_values : :class:`pybamm.ParameterValues`
The parameter values class that will be used for the simulation.
initial_soc : float
The soc at begining of discharge, default 1.0
final_soc : float
The soc at end of discharge, default 1.0
points : int
The number of points at which to calculate voltage.

Returns
-------
E
The total energy of the cell in Wh
"""
# Get initial and final stoichiometric values.
n_i, p_i = get_initial_stoichiometries(initial_soc, parameter_values)
n_f, p_f = get_initial_stoichiometries(final_soc, parameter_values)
n_vals = np.linspace(n_i, n_f, num=points)
p_vals = np.linspace(p_i, p_f, num=points)
# Calculate OCV at each stoichiometry
Vs = np.empty(n_vals.shape)
for i in range(n_vals.size):
V_pos = parameter_values["Positive electrode OCP [V]"](p_vals[i]).value
V_neg = parameter_values["Negative electrode OCP [V]"](n_vals[i]).value
Vs[i] = V_pos - V_neg
aabills marked this conversation as resolved.
Show resolved Hide resolved
Q_max_pos = parameter_values[
"Maximum concentration in positive electrode [mol.m-3]"
]
# Get electrode properties to convert stoich range to moles Li
W = parameter_values["Electrode width [m]"]
H = parameter_values["Electrode height [m]"]
T_pos = parameter_values["Positive electrode thickness [m]"]
eps_s_pos = parameter_values["Positive electrode active material volume fraction"]
vol_pos = W * H * T_pos * eps_s_pos
aabills marked this conversation as resolved.
Show resolved Hide resolved
# Calculate dQ
Q_p = vol_pos * Q_max_pos * (p_f - p_i)
dQ = Q_p / (points - 1)
# Integrate and convert to W-h
E = np.trapz(Vs, dx=dQ) * 26.8
aabills marked this conversation as resolved.
Show resolved Hide resolved
return E
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ def test_known_solution(self):
self.assertAlmostEqual(sol["Uw(x_0)"].data[0], V_min, places=5)


class TestCalculateTheoreticalEnergy(unittest.TestCase):
def test_efficiency(self):
model = pybamm.lithium_ion.DFN(options={"calculate discharge energy": "true"})
parameter_values = pybamm.ParameterValues("Chen2020")
sim = pybamm.Simulation(model, parameter_values=parameter_values)
sol = sim.solve([0, 3600], initial_soc=1.0)
discharge_energy = sol["Discharge energy [W.h]"].entries[-1]
theoretical_energy = (
pybamm.lithium_ion.electrode_soh.calculate_theoretical_energy(
parameter_values
)
)
# Real energy should be less than discharge energy,
# and both should be greater than 0
self.assertLess(discharge_energy, theoretical_energy)
self.assertLess(0, discharge_energy)
self.assertLess(0, theoretical_energy)


class TestGetInitialSOC(unittest.TestCase):
def test_initial_soc(self):
param = pybamm.LithiumIonParameters()
Expand Down