Skip to content

Commit a0c0ab2

Browse files
committed
add energy to summary vars
1 parent b483d9c commit a0c0ab2

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

pybamm/models/full_battery_models/lithium_ion/electrode_soh.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,7 @@ def get_min_max_stoichiometries(
559559
return esoh_solver.get_min_max_stoichiometries()
560560

561561

562-
def calculate_theoretical_energy(
563-
parameter_values, initial_soc=1.0, final_soc=0.0, points=100
564-
):
562+
def theoretical_energy_integral(parameter_values, n_i, n_f, p_i, p_f, points=100):
565563
"""
566564
Calculate maximum energy possible from a cell given OCV, initial soc, and final soc
567565
given voltage limits, open-circuit potentials, etc defined by parameter_values
@@ -570,10 +568,9 @@ def calculate_theoretical_energy(
570568
----------
571569
parameter_values : :class:`pybamm.ParameterValues`
572570
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
571+
n_i, n_f, p_i, p_f : float
572+
initial and final stoichiometries for the positive and negative
573+
electrodes, respectively
577574
points : int
578575
The number of points at which to calculate voltage.
579576
@@ -582,9 +579,6 @@ def calculate_theoretical_energy(
582579
E
583580
The total energy of the cell in Wh
584581
"""
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)
588582
n_vals = np.linspace(n_i, n_f, num=points)
589583
p_vals = np.linspace(p_i, p_f, num=points)
590584
# Calculate OCV at each stoichiometry
@@ -601,3 +595,33 @@ def calculate_theoretical_energy(
601595
# Integrate and convert to W-h
602596
E = np.trapz(Vs, dx=dQ)
603597
return E
598+
599+
600+
def calculate_theoretical_energy(
601+
parameter_values, initial_soc=1.0, final_soc=0.0, points=100, initial_stoichs=None
602+
):
603+
"""
604+
Calculate maximum energy possible from a cell given OCV, initial soc, and final soc
605+
given voltage limits, open-circuit potentials, etc defined by parameter_values
606+
607+
Parameters
608+
----------
609+
parameter_values : :class:`pybamm.ParameterValues`
610+
The parameter values class that will be used for the simulation.
611+
initial_soc : float
612+
The soc at begining of discharge, default 1.0
613+
final_soc : float
614+
The soc at end of discharge, default 1.0
615+
points : int
616+
The number of points at which to calculate voltage.
617+
618+
Returns
619+
-------
620+
E
621+
The total energy of the cell in Wh
622+
"""
623+
# Get initial and final stoichiometric values.
624+
n_i, p_i = get_initial_stoichiometries(initial_soc, parameter_values)
625+
n_f, p_f = get_initial_stoichiometries(final_soc, parameter_values)
626+
E = theoretical_energy_integral(parameter_values, n_i, n_f, p_i, p_f, points=points)
627+
return E

pybamm/solvers/solution.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,4 +880,14 @@ def _get_cycle_summary_variables(cycle_solution, esoh_solver):
880880
for var in esoh_sol.all_models[0].variables:
881881
cycle_summary_variables[var] = esoh_sol[var].data[0]
882882

883+
# Calculate theoretical energy
884+
n_i = cycle_summary_variables["x_0"]
885+
p_i = cycle_summary_variables["y_0"]
886+
n_f = n_i + cycle_summary_variables["x_100 - x_0"]
887+
p_f = p_i - cycle_summary_variables["y_0 - y_100"]
888+
energy = pybamm.lithium_ion.electrode_soh.theoretical_energy_integral(
889+
esoh_solver.parameter_values, n_i, n_f, p_i, p_f
890+
)
891+
cycle_summary_variables["Maximum theoretical energy [W.h]"] = energy
892+
883893
return cycle_summary_variables

0 commit comments

Comments
 (0)