Skip to content

Commit c0d394e

Browse files
Merge pull request #2777 from abillscmu/batt-carnot
Method to calculate theoretical efficiency
2 parents 124efe5 + 0fa49e2 commit c0d394e

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- 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))
3030
- 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)).
3131
- Added temperature control to experiment class. ([#2518](https://github.com/pybamm-team/PyBaMM/pull/2518))
32+
- Added method to calculate maximum theoretical energy. ([#2777](https://github.com/pybamm-team/PyBaMM/pull/2777))
3233

3334
## Bug fixes
3435

pybamm/models/full_battery_models/lithium_ion/electrode_soh.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,3 +557,47 @@ def get_min_max_stoichiometries(
557557
"""
558558
esoh_solver = ElectrodeSOHSolver(parameter_values, param, known_value)
559559
return esoh_solver.get_min_max_stoichiometries()
560+
561+
562+
def calculate_theoretical_energy(
563+
parameter_values, initial_soc=1.0, final_soc=0.0, points=100
564+
):
565+
"""
566+
Calculate maximum energy possible from a cell given OCV, initial soc, and final soc
567+
given voltage limits, open-circuit potentials, etc defined by parameter_values
568+
569+
Parameters
570+
----------
571+
parameter_values : :class:`pybamm.ParameterValues`
572+
The parameter values class that will be used for the simulation.
573+
initial_soc : float
574+
The soc at begining of discharge, default 1.0
575+
final_soc : float
576+
The soc at end of discharge, default 1.0
577+
points : int
578+
The number of points at which to calculate voltage.
579+
580+
Returns
581+
-------
582+
E
583+
The total energy of the cell in Wh
584+
"""
585+
# Get initial and final stoichiometric values.
586+
n_i, p_i = get_initial_stoichiometries(initial_soc, parameter_values)
587+
n_f, p_f = get_initial_stoichiometries(final_soc, parameter_values)
588+
n_vals = np.linspace(n_i, n_f, num=points)
589+
p_vals = np.linspace(p_i, p_f, num=points)
590+
# Calculate OCV at each stoichiometry
591+
param = pybamm.LithiumIonParameters()
592+
T = param.T_amb(0)
593+
Vs = np.empty(n_vals.shape)
594+
for i in range(n_vals.size):
595+
Vs[i] = parameter_values.evaluate(
596+
param.p.prim.U(p_vals[i], T)
597+
) - parameter_values.evaluate(param.n.prim.U(n_vals[i], T))
598+
# Calculate dQ
599+
Q_p = parameter_values.evaluate(param.p.prim.Q_init) * (p_f - p_i)
600+
dQ = Q_p / (points - 1)
601+
# Integrate and convert to W-h
602+
E = np.trapz(Vs, dx=dQ)
603+
return E

tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,25 @@ def test_known_solution(self):
143143
self.assertAlmostEqual(sol["Uw(x_0)"].data[0], V_min, places=5)
144144

145145

146+
class TestCalculateTheoreticalEnergy(unittest.TestCase):
147+
def test_efficiency(self):
148+
model = pybamm.lithium_ion.DFN(options={"calculate discharge energy": "true"})
149+
parameter_values = pybamm.ParameterValues("Chen2020")
150+
sim = pybamm.Simulation(model, parameter_values=parameter_values)
151+
sol = sim.solve([0, 3600], initial_soc=1.0)
152+
discharge_energy = sol["Discharge energy [W.h]"].entries[-1]
153+
theoretical_energy = (
154+
pybamm.lithium_ion.electrode_soh.calculate_theoretical_energy(
155+
parameter_values
156+
)
157+
)
158+
# Real energy should be less than discharge energy,
159+
# and both should be greater than 0
160+
self.assertLess(discharge_energy, theoretical_energy)
161+
self.assertLess(0, discharge_energy)
162+
self.assertLess(0, theoretical_energy)
163+
164+
146165
class TestGetInitialSOC(unittest.TestCase):
147166
def test_initial_soc(self):
148167
param = pybamm.LithiumIonParameters()

0 commit comments

Comments
 (0)