Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased](https://github.com/NREL/BATMODS-lite/)

### New Features
- Check bounds of intercalation fraction before calculating exchange current density ([#19](https://github.com/NREL/BATMODS-lite/pull/19))
- Update `materials` module with new LFP properties, from ICI ([#18](https://github.com/NREL/BATMODS-lite/pull/18))
- Use `CubicSpline` interpolations for LFP properties ([#15](https://github.com/NREL/BATMODS-lite/pull/15))
- Add degradation parameters for the electrolyte (applies to P2D only) ([#14](https://github.com/NREL/BATMODS-lite/pull/14))
Expand Down
8 changes: 4 additions & 4 deletions images/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/bmlite/materials/_graphite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from numbers import Real

import numpy as np


Expand Down Expand Up @@ -93,6 +95,15 @@ def get_i0(self, x: float | np.ndarray, C_Li: float | np.ndarray,

c = Constants()

# Avoid floating point errors
if isinstance(x, Real):
if (x < 0 and self.alpha_c < 1) or (x > 1 and self.alpha_a < 1):
raise ValueError('x is out of [0, 1] during i0 calculation')
elif isinstance(x, np.ndarray):
if ((any(x.flatten() < 0) and self.alpha_c < 1)
or (any(x.flatten() > 1) and self.alpha_a < 1)):
raise ValueError('x is out of [0, 1] during i0 calculation')

i0 = 2.5 * 0.27 * np.exp(-30e6 / c.R * (1 / T - 1 / 303.15)) \
* C_Li**self.alpha_a * (self.Li_max * x)**self.alpha_c \
* (self.Li_max - self.Li_max * x)**self.alpha_a
Expand Down
11 changes: 11 additions & 0 deletions src/bmlite/materials/_lfp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from numbers import Real

import numpy as np


Expand Down Expand Up @@ -101,6 +103,15 @@ def get_i0(self, x: float | np.ndarray, C_Li: float | np.ndarray,

c = Constants()

# Avoid floating point errors
if isinstance(x, Real):
if (x < 0 and self.alpha_c < 1) or (x > 1 and self.alpha_a < 1):
raise ValueError('x is out of [0, 1] during i0 calculation')
elif isinstance(x, np.ndarray):
if ((any(x.flatten() < 0) and self.alpha_c < 1)
or (any(x.flatten() > 1) and self.alpha_a < 1)):
raise ValueError('x is out of [0, 1] during i0 calculation')

i0 = 0.27 * np.exp(-30e6 / c.R * (1 / T - 1 / 303.15)) \
* C_Li**self.alpha_a * (self.Li_max * x)**self.alpha_c \
* (self.Li_max - self.Li_max * x)**self.alpha_a
Expand Down