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

CV capacity summary statistic #552

Merged
merged 4 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions beep/conversion_schemas/structured_dtypes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ summary:
paused: 'int32'
CV_time: 'float32'
CV_current: 'float32'
CV_capacity: 'float32'

diagnostic_summary:
discharge_capacity: 'float64'
Expand All @@ -46,6 +47,7 @@ diagnostic_summary:
cycle_type: 'category'
CV_time: 'float32'
CV_current: 'float32'
CV_capacity: 'float32'

diagnostic_interpolated:
voltage: 'float32'
Expand Down
28 changes: 25 additions & 3 deletions beep/structure/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,17 +877,20 @@ def summarize_cycles(
summary["paused"] = self.raw_data.groupby("cycle_index").apply(
get_max_paused_over_threshold)

# Add CV_time and CV_current summary stats
# Add CV_time, CV_current, CV_capacity summary stats
CV_time = []
CV_current = []
CV_capacity = []
for cycle in summary.cycle_index:
raw_cycle = self.raw_data.loc[self.raw_data.cycle_index == cycle]
charge = raw_cycle.loc[raw_cycle.current > 0]
CV = get_CV_segment_from_charge(charge)
CV_time.append(get_CV_time(CV))
CV_current.append(get_CV_current(CV))
CV_capacity.append(get_CV_capacity(CV))
summary["CV_time"] = CV_time
summary["CV_current"] = CV_current
summary["CV_capacity"] = CV_capacity

summary = self._cast_dtypes(summary, "summary")

Expand Down Expand Up @@ -1093,9 +1096,10 @@ def summarize_diagnostic(self, diagnostic_available):
diagnostic_available["cycle_type"] * len(starts_at)
)

# Add CV_time and CV_current summary stats
# Add CV_time, CV_current, and CV_capacity summary stats
CV_time = []
CV_current = []
CV_capacity = []
for cycle in diag_summary.cycle_index:
raw_cycle = self.raw_data.loc[self.raw_data.cycle_index == cycle]

Expand All @@ -1104,9 +1108,11 @@ def summarize_diagnostic(self, diagnostic_available):
CV = get_CV_segment_from_charge(CCCV)
CV_time.append(get_CV_time(CV))
CV_current.append(get_CV_current(CV))
CV_capacity.append(get_CV_capacity(CV))

diag_summary["CV_time"] = CV_time
diag_summary["CV_current"] = CV_current
diag_summary["CV_capacity"] = CV_capacity

diag_summary = self._cast_dtypes(diag_summary, "diagnostic_summary")

Expand Down Expand Up @@ -1530,7 +1536,7 @@ def get_CV_segment_from_charge(charge, dt_tol=1, dVdt_tol=1e-5, dIdt_tol=1e-4):

# Find the first index where the CV segment begins
i = 0
while i < len(dV) and not (dt[i] > dt_tol and abs(dV[i]/dt[i]) < dVdt_tol and abs(dI[i]/dt[i]) > dIdt_tol):
while i < len(dV) and (dt[i] < dt_tol or abs(dV[i]/dt[i]) > dVdt_tol or abs(dI[i]/dt[i]) < dIdt_tol):
i = i+1

# Filter for CV phase
Expand Down Expand Up @@ -1568,3 +1574,19 @@ def get_CV_current(CV):
if isinstance(CV, pd.DataFrame):
if len(CV):
return(CV.current.iat[-1])


def get_CV_capacity(CV):
"""
Helper function to compute CV capacity.

Args:
CV (pd.DataFrame): CV segement of charge

Returns:
(float): charge capacity during the CV segment

"""
if isinstance(CV, pd.DataFrame):
ardunn marked this conversation as resolved.
Show resolved Hide resolved
if len(CV):
ardunn marked this conversation as resolved.
Show resolved Hide resolved
return(CV.charge_capacity.iat[-1] - CV.charge_capacity.iat[0])
3 changes: 3 additions & 0 deletions beep/structure/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def test_summarize_cycles(self):
"energy_efficiency",
"CV_time",
"CV_current",
"CV_capacity"
},
set(summary_diag.columns),
)
Expand All @@ -354,6 +355,7 @@ def test_summarize_cycles(self):
self.assertEqual(summary_diag["paused"].max(), 0)
self.assertEqual(summary_diag["CV_time"][1], np.float32(160111.796875))
self.assertEqual(summary_diag["CV_current"][1], np.float32(0.4699016))
self.assertEqual(summary_diag["CV_capacity"][1], np.float32(94.090355))
self.run_dtypes_check(summary_diag)

# incorporates test_get_energy and get_charge_throughput
Expand Down Expand Up @@ -432,6 +434,7 @@ def test_summarize_diagnostic(self):
self.assertEqual(diag_summary["paused"].max(), 0)
self.assertEqual(diag_summary["CV_time"][0], np.float32(125502.578125))
self.assertEqual(diag_summary["CV_current"][0], np.float32(2.3499656))
self.assertEqual(diag_summary["CV_capacity"][0], np.float32(84.70442))

# based on RCRT.test_determine_paused
def test_paused_intervals(self):
Expand Down