Coder Social home page Coder Social logo

michaelbosello / battery-rul-estimation Goto Github PK

View Code? Open in Web Editor NEW
150.0 3.0 34.0 8.83 MB

Remaining Useful Life (RUL) estimation of Lithium-ion batteries using deep LSTMs

License: Apache License 2.0

Python 0.11% Jupyter Notebook 99.89%
deep-neural-networks deep-learning time-series regression lstm bms rul battery-management-system lithium-ion remaining-useful-life

battery-rul-estimation's Introduction

Battery-state-estimation

Estimation of the Remaining Useful Life (RUL) of Lithium-ion batteries using Autoencoders + LSTMs and Autoencoders + CNNs.

Introduction

This repository provides the implementation of deep networks for RUL estimation. The experiments have been performed on two datasets: the NASA Randomized Battery Usage Data Set and the UNIBO Powertools Dataset.

Paper (Energies publication)

If you use this repo, please cite our paper:

To Charge or to Sell? EV Pack Useful Life Estimation via LSTMs, CNNs, and Autoencoders [URL]

@Article{en16062837,
    AUTHOR = {Bosello, Michael and Falcomer, Carlo and Rossi, Claudio and Pau, Giovanni},
    TITLE = {To Charge or to Sell? EV Pack Useful Life Estimation via LSTMs, CNNs, and Autoencoders},
    JOURNAL = {Energies},
    VOLUME = {16},
    YEAR = {2023},
    NUMBER = {6},
    ARTICLE-NUMBER = {2837},
    URL = {https://www.mdpi.com/1996-1073/16/6/2837},
    ISSN = {1996-1073},
    DOI = {10.3390/en16062837}
}

Source code structure

The package data_processing contains the scripts that load the data from the two sets. unibo_powertools_data.py loads the data from the UNIBO dataset and compute the derived columns like the SOC one, while model_data_handler.py prepare the time series. nasa_random_data.py both loads and prepares the data of the NASA Randomized set. prepare_rul_data.py is used for both datasets; it calculates the integral of the current to obtain the RUL based on Ah, and it format the time series for the neural network.

The experiments directory contains the Jupyter notebooks defining the various experiments and models used. The results directory shows the plots of the results and the measurements like RMSE, MAE, etc.

The trained models are available in the GitHub release section.

Quick start

1) Install requirements

Python packages

Tested with Tensorflow 2.7

pip install tensorflow
pip install pandas sklearn scipy
pip install plotly
pip install jupyter notebook ipykernel jupyterlab

2) Download the datasets

Download the NASA Randomized Battery Dataset and put its content in the directory battery-state-estimation/data/nasa-randomized/

Download the UNIBO dataset and put its content in the directory battery-state-estimation/data/unibo-powertools-dataset/

3) Run one of the notebooks

Run one of the notebooks in the experiments directory. You can switch between training a new model or loading an existing one by toggling the value of IS_TRAINING at the top of the notebook (just define the model file name in RESULT_NAME).

Check out the results directory if you want to see the results obtained by us (you can find the trained models in the release section of GitHub, you can run them by putting the files into the 'trained-model' directory).

If you want to run the notebook on Google Colab, load the repository in your Google Drive and set to True the variable IS_COLAB at the top of the notebook. This will allow the notebook to find the datasets and to save the results in your Drive.

battery-rul-estimation's People

Contributors

michaelbosello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

battery-rul-estimation's Issues

ZeroDivisionError: float division by zero

train_data_test_names = [
'000-DM-3.0-4019-S',
'001-DM-3.0-4019-S',
'002-DM-3.0-4019-S',
'006-EE-2.85-0820-S',
'007-EE-2.85-0820-S',
'018-DP-2.00-1320-S',
'019-DP-2.00-1320-S',
'036-DP-2.00-1720-S',
'037-DP-2.00-1720-S',
'038-DP-2.00-2420-S',
'040-DM-4.00-2320-S',
'042-EE-2.85-0820-S',
'045-BE-2.75-2019-S'
]

test_data_test_names = [
'003-DM-3.0-4019-S',
'008-EE-2.85-0820-S',
'039-DP-2.00-2420-S',
'041-DM-4.00-2320-S',
]

dataset.prepare_data(train_data_test_names, test_data_test_names)

Error:

2022/06/28 14:03:12 [DEBUG]: Start preparing data for training: ['000-DM-3.0-4019-S', '001-DM-3.0-4019-S', '002-DM-3.0-4019-S', '006-EE-2.85-0820-S', '007-EE-2.85-0820-S', '018-DP-2.00-1320-S', '019-DP-2.00-1320-S', '036-DP-2.00-1720-S', '037-DP-2.00-1720-S', '038-DP-2.00-2420-S', '040-DM-4.00-2320-S', '042-EE-2.85-0820-S', '045-BE-2.75-2019-S'] and testing: ['003-DM-3.0-4019-S', '008-EE-2.85-0820-S', '039-DP-2.00-2420-S', '041-DM-4.00-2320-S']...
/content/drive/My Drive/battery-state-estimation/battery-state-estimation/data_processing/unibo_powertools_data.py:273: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
cyc_data = np.array(cyc_data)
2022/06/28 14:03:36 [DEBUG]: Finish getting training and testing charge data.
2022/06/28 14:03:48 [DEBUG]: Finish getting training and testing discharge data.
2022/06/28 14:03:48 [DEBUG]: Finish cleaning training and testing charge data.
2022/06/28 14:03:48 [DEBUG]: Finish cleaning training and testing discharge data.

ZeroDivisionError Traceback (most recent call last)
in ()
22 ]
23
---> 24 dataset.prepare_data(train_data_test_names, test_data_test_names)

1 frames
/content/drive/My Drive/battery-state-estimation/battery-state-estimation/data_processing/unibo_powertools_data.py in prepare_data(self, train_names, test_names)
218
219 self.train_discharge_cyc = self.__add_discharge_soc_pars(
--> 220 self.train_discharge_cyc, self.train_charge_cap
221 )
222 self.test_discharge_cyc = self.__add_discharge_soc_pars(

/content/drive/My Drive/battery-state-estimation/battery-state-estimation/data_processing/unibo_powertools_data.py in __add_discharge_soc_pars(self, discharge_cyc, charge_cap)
311 np.zeros(discharge_cyc[i].shape[0])]
312 discharge_cyc[i][:, -1] = (charge_cap[i][CapacityCols.CHARGING_CAPACITY] - discharge_cyc[i]
--> 313 [:, CycleCols.DISCHARGING_CAPACITY]) / charge_cap[i][CapacityCols.CHARGING_CAPACITY]
314
315 # Time remaining to cycle end: (Time of last row in cycle - current time)

ZeroDivisionError: float division by zero

base path in unibo rul estimation

dataset = UniboPowertoolsData(
test_types=[],
chunk_size=1000000,
lines=[37, 40],
charge_line=37,
discharge_line=40,
base_path="data/unibo-powertools-dataset/unibo-powertools-dataset/test_result.csv"
)

error:
FileNotFoundError Traceback (most recent call last)
Input In [13], in <cell line: 1>()
----> 1 dataset = UniboPowertoolsData(
2 test_types=[],
3 chunk_size=1000000,
4 lines=[37, 40],
5 charge_line=37,
6 discharge_line=40,
7 base_path="Desktop/battery unibo/battery-rul-estimation-main/battery-rul-estimation/data/unibo-powertools-dataset/unibo-powertools-dataset/test_result.csv"
8 )

File ~\Desktop\battery unibo\battery-rul-estimation-main\battery-rul-estimation\experiments\unibo-powertools../..\data_processing\unibo_powertools_data.py:79, in UniboPowertoolsData.init(self, test_types, chunk_size, lines, charge_line, discharge_line, base_path)
76 self.cyc_path = base_path + TEST_RESULT_DATA_PATH
77 self.cap_path = base_path + TEST_RESULT_TRIAL_END_DATA_PATH
---> 79 self.__load_raw_data()

File ~\Desktop\battery unibo\battery-rul-estimation-main\battery-rul-estimation\experiments\unibo-powertools../..\data_processing\unibo_powertools_data.py:82, in UniboPowertoolsData.__load_raw_data(self)
81 def __load_raw_data(self):
---> 82 self.__load_csv_to_raw()
83 self.__clean_cycle_raw()
84 self.__clean_capacity_raw()

File ~\Desktop\battery unibo\battery-rul-estimation-main\battery-rul-estimation\experiments\unibo-powertools../..\data_processing\unibo_powertools_data.py:92, in UniboPowertoolsData.__load_csv_to_raw(self)
88 def __load_csv_to_raw(self):
89 self.logger.debug("Start loading data with lines: %s, types: %s and chunksize: %s..." %
90 (self.lines, self.test_types, self.chunksize))
---> 92 iter_cyc = pd.read_csv(
93 self.cyc_path, chunksize=self.chunksize, iterator=True)
94 self.cycle_raw = pd.concat(self.__filter_raw_chunk(iter_cyc))
96 iter_cap = pd.read_csv(
97 self.cap_path, chunksize=self.chunksize, iterator=True)

File ~\anaconda3\lib\site-packages\pandas\util_decorators.py:311, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, **kwargs)
305 if len(args) > num_allow_args:
306 warnings.warn(
307 msg.format(arguments=arguments),
308 FutureWarning,
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:680, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
665 kwds_defaults = _refine_defaults_read(
666 dialect,
667 delimiter,
(...)
676 defaults={"delimiter": ","},
677 )
678 kwds.update(kwds_defaults)
--> 680 return _read(filepath_or_buffer, kwds)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:575, in _read(filepath_or_buffer, kwds)
572 _validate_names(kwds.get("names", None))
574 # Create the parser.
--> 575 parser = TextFileReader(filepath_or_buffer, **kwds)
577 if chunksize or iterator:
578 return parser

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:933, in TextFileReader.init(self, f, engine, **kwds)
930 self.options["has_index_names"] = kwds["has_index_names"]
932 self.handles: IOHandles | None = None
--> 933 self._engine = self._make_engine(f, self.engine)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:1217, in TextFileReader._make_engine(self, f, engine)
1213 mode = "rb"
1214 # error: No overload variant of "get_handle" matches argument types
1215 # "Union[str, PathLike[str], ReadCsvBuffer[bytes], ReadCsvBuffer[str]]"
1216 # , "str", "bool", "Any", "Any", "Any", "Any", "Any"
-> 1217 self.handles = get_handle( # type: ignore[call-overload]
1218 f,
1219 mode,
1220 encoding=self.options.get("encoding", None),
1221 compression=self.options.get("compression", None),
1222 memory_map=self.options.get("memory_map", False),
1223 is_text=is_text,
1224 errors=self.options.get("encoding_errors", "strict"),
1225 storage_options=self.options.get("storage_options", None),
1226 )
1227 assert self.handles is not None
1228 f = self.handles.handle

File ~\anaconda3\lib\site-packages\pandas\io\common.py:789, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
784 elif isinstance(handle, str):
785 # Check whether the filename is to be opened in binary mode.
786 # Binary mode does not support 'encoding' and 'newline'.
787 if ioargs.encoding and "b" not in ioargs.mode:
788 # Encoding
--> 789 handle = open(
790 handle,
791 ioargs.mode,
792 encoding=ioargs.encoding,
793 errors=errors,
794 newline="",
795 )
796 else:
797 # Binary mode
798 handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: 'Desktop/battery unibo/battery-rul-estimation-main/battery-rul-estimation/data/unibo-powertools-dataset/unibo-powertools-dataset/test_result.csvdata/unibo-powertools-dataset/unibo-powertools-dataset/test_result.csv'
git

what is the version of tensorflow in this code?

Hi, thanks for sharing this great work. The paper and code have inspired me a lot.
I want to reproduce your result, so i would like to ask what version of tensorflow you used in this code? thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.