Skip to content

Commit

Permalink
Redefine LLI
Browse files Browse the repository at this point in the history
LLI given by (Inventory[fresh] - Inventory[aged])/Inventory[fresh]
  • Loading branch information
tomjholland committed May 21, 2024
1 parent d56eb4a commit 8b29c82
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
10 changes: 5 additions & 5 deletions pyprobe/methods/ocv_fitting/DMA.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def __init__(self, input_data: List[Result]) -> None:
self.cell_capacity = self.variable("Cell Capacity")
self.pe_capacity = self.variable("Cathode Capacity")
self.ne_capacity = self.variable("Anode Capacity")
self.offset = self.variable("Stoichiometry Offset")
self.li_inventory = self.variable("Li Inventory")
self.define_outputs(["SOH", "LAM_pe", "LAM_ne", "LLI"])
self.assign_outputs(
self.calculate_dma_parameters(
self.cell_capacity,
self.pe_capacity,
self.ne_capacity,
self.offset,
self.li_inventory,
)
)

Expand All @@ -35,7 +35,7 @@ def calculate_dma_parameters(
cell_capacity: NDArray[np.float64],
pe_capacity: NDArray[np.float64],
ne_capacity: NDArray[np.float64],
offset: NDArray[np.float64],
li_inventory: NDArray[np.float64],
) -> Tuple[
NDArray[np.float64],
NDArray[np.float64],
Expand All @@ -49,13 +49,13 @@ def calculate_dma_parameters(
ne_stoich_limits (NDArray[np.float64]): The anode stoichiometry limits.
pe_capacity (NDArray[np.float64]): The cathode capacity.
ne_capacity (NDArray[np.float64]): The anode capacity.
offset (NDArray[np.float64]): The stoichiometry offset.
li_inventory (NDArray[np.float64]): The lithium inventory.
Returns:
Tuple[float, float, float, float]: The SOH, LAM_pe, LAM_ne, and LLI.
"""
SOH = cell_capacity / cell_capacity[0]
LAM_pe = 1 - pe_capacity / pe_capacity[0]
LAM_ne = 1 - ne_capacity / ne_capacity[0]
LLI = (pe_capacity[0] - pe_capacity - (offset[0] - offset)) / cell_capacity[0]
LLI = 1 - li_inventory / li_inventory[0]
return SOH, LAM_pe, LAM_ne, LLI
17 changes: 8 additions & 9 deletions pyprobe/methods/ocv_fitting/Simple_OCV_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, rawdata: RawData, parameters: Dict[str, Any]):
"Cell Capacity",
"Cathode Capacity",
"Anode Capacity",
"Stoichiometry Offset",
"Li Inventory",
]
)
self.assign_outputs(
Expand Down Expand Up @@ -93,7 +93,7 @@ def fit_ocv(
- NDArray[np.float64]: The cell capacity.
- NDArray[np.float64]: The cathode capacity.
- NDArray[np.float64]: The anode capacity.
- NDArray[np.float64]: The stoichiometry offset.
- NDArray[np.float64]: The lithium inventory.
"""
cell_capacity = np.ptp(capacity)
SOC = capacity / cell_capacity
Expand Down Expand Up @@ -121,7 +121,7 @@ def objective_func(
x_ne_lo_out = x_out[0][2]
x_ne_hi_out = x_out[0][3]

pe_capacity, ne_capacity, stoich_offset = cls.calc_electrode_capacities(
pe_capacity, ne_capacity, li_inventory = cls.calc_electrode_capacities(
x_pe_lo_out, x_pe_hi_out, x_ne_lo_out, x_ne_hi_out, cell_capacity
)
return (
Expand All @@ -132,7 +132,7 @@ def objective_func(
np.array([cell_capacity]),
np.array([pe_capacity]),
np.array([ne_capacity]),
np.array([stoich_offset]),
np.array([li_inventory]),
)

@staticmethod
Expand All @@ -155,13 +155,12 @@ def calc_electrode_capacities(
Tuple[float, float, float]:
- NDArray: The cathode capacity.
- NDArray: The anode capacity.
- NDArray: The stoichiometry offset.
- NDArray: The lithium inventory.
"""
pe_capacity = cell_capacity / (x_pe_hi - x_pe_lo)
pe_capacity = cell_capacity / (x_pe_lo - x_pe_hi)
ne_capacity = cell_capacity / (x_ne_hi - x_ne_lo)
stoich_offset = ((1 - x_pe_hi) * pe_capacity) - (x_pe_lo * ne_capacity)

return pe_capacity, ne_capacity, stoich_offset
li_inventory = (pe_capacity * x_pe_lo) + (ne_capacity * x_ne_lo)
return pe_capacity, ne_capacity, li_inventory

@staticmethod
def calc_full_cell_OCV(
Expand Down
18 changes: 8 additions & 10 deletions tests/methods/ocv_fitting/test_DMA.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@ def eol_pe_limits_fixture():
def bol_capacity_fixture(bol_ne_limits_fixture, bol_pe_limits_fixture):
"""Return the cell and electrode capacities."""
cell_capacity = 5
pe_capacity, ne_capacity, stoich_offset = Simple_OCV_fit.calc_electrode_capacities(
pe_capacity, ne_capacity, li_inventory = Simple_OCV_fit.calc_electrode_capacities(
bol_pe_limits_fixture[0],
bol_pe_limits_fixture[1],
bol_ne_limits_fixture[0],
bol_ne_limits_fixture[1],
cell_capacity,
)
return [cell_capacity, pe_capacity, ne_capacity, stoich_offset]
return [cell_capacity, pe_capacity, ne_capacity, li_inventory]


@pytest.fixture
def eol_capacity_fixture(eol_ne_limits_fixture, eol_pe_limits_fixture):
"""Return the cell and electrode capacities."""
cell_capacity = 4.5
pe_capacity, ne_capacity, stoich_offset = Simple_OCV_fit.calc_electrode_capacities(
pe_capacity, ne_capacity, li_inventory = Simple_OCV_fit.calc_electrode_capacities(
eol_pe_limits_fixture[0],
eol_pe_limits_fixture[1],
eol_ne_limits_fixture[0],
eol_ne_limits_fixture[1],
cell_capacity,
)
return [cell_capacity, pe_capacity, ne_capacity, stoich_offset]
return [cell_capacity, pe_capacity, ne_capacity, li_inventory]


@pytest.fixture
Expand All @@ -69,7 +69,7 @@ def bol_result_fixture(bol_capacity_fixture):
"Cell Capacity": bol_capacity_fixture[0],
"Cathode Capacity": bol_capacity_fixture[1],
"Anode Capacity": bol_capacity_fixture[2],
"Stoichiometry Offset": bol_capacity_fixture[3],
"Li Inventory": bol_capacity_fixture[3],
}
),
info={},
Expand All @@ -85,7 +85,7 @@ def eol_result_fixture(eol_capacity_fixture):
"Cell Capacity": eol_capacity_fixture[0],
"Cathode Capacity": eol_capacity_fixture[1],
"Anode Capacity": eol_capacity_fixture[2],
"Stoichiometry Offset": eol_capacity_fixture[3],
"Li Inventory": eol_capacity_fixture[3],
}
),
info={},
Expand Down Expand Up @@ -118,10 +118,8 @@ def test_calculate_dma_parameters(
expected_LAM_pe = 1 - eol_capacity_fixture[1] / bol_capacity_fixture[1]
expected_LAM_ne = 1 - eol_capacity_fixture[2] / bol_capacity_fixture[2]
expected_LLI = (
bol_capacity_fixture[1]
- eol_capacity_fixture[1]
- (bol_capacity_fixture[3] - eol_capacity_fixture[3])
) / bol_capacity_fixture[0]
bol_capacity_fixture[3] - eol_capacity_fixture[3]
) / bol_capacity_fixture[3]

result = dma_fixture.result
assert result.data["SOH"].to_numpy()[1] == expected_SOH
Expand Down
4 changes: 2 additions & 2 deletions tests/methods/ocv_fitting/test_simple_ocv_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_init(
"Cell Capacity",
"Cathode Capacity",
"Anode Capacity",
"Stoichiometry Offset",
"Li Inventory",
]


Expand All @@ -157,5 +157,5 @@ def test_result(OCP_result_fixture, ocp_ne_fixture, ocp_pe_fixture):
"Cell Capacity",
"Cathode Capacity",
"Anode Capacity",
"Stoichiometry Offset",
"Li Inventory",
]

0 comments on commit 8b29c82

Please sign in to comment.