@@ -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
0 commit comments