-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Save simulation output #145
Conversation
Codecov Report
@@ Coverage Diff @@
## main #145 +/- ##
==========================================
+ Coverage 97.12% 97.18% +0.05%
==========================================
Files 11 11
Lines 1184 1206 +22
==========================================
+ Hits 1150 1172 +22
Misses 34 34 |
@wigging thanks looks good but can you add tests? |
Sure, but how do you make a unit test for a function that creates a folder and writes to files? |
You can use os.path.isfile() to assert that a file is created |
Sir @TomTranter, I uploaded some tests. Let me know what else is needed. Regarding the online documentation, will the function docstrings be used to update the docs or do I need to manually update the documentation? |
If this pull request is not useful for liionpack then please close the request. Otherwise, let me know what else needs to be done before accepting the request. |
@wigging sorry I haven't got round to looking at the code yet. Will try to asap. |
This is a good start and I'm happy to merge. Some thoughts would be we should add headers and a time column to the csv. Think about using hdf5 as well. Also we should add some options to do journaling for the solve process but this may be better to save the simulation objects themselves rather than output variables. Worth thinking about some more |
The csv function saves each output item to its own csv file into a For saving to csv, I guess it would be better to save everything into one csv file instead of separate files. For the NumPy formats, I think I'll just use the npz format and remove the ability to save to npy. I don't see any benefits to use npy instead of npz. Supporting hdf5 output would add another dependency to the project. Liionpack already uses NumPy so not a big deal to save output in a NumPy format. |
It's been awhile since I ran the code in this pull request. Disregard my comment about saving to a single csv file. The csv function saves to multiple files because some of the outputs are 2D arrays. So it's not feasible to save all the output into a single csv file. |
Added some utility functions to save the simulation output to CSV, NumPy
.npy
, and compressed NumPy.npz
files. Also added an example of using the save functions.I did a comparison of the disk usage for these different file formats (see below). The compressed
.npz
format can save a lot of storage space for large pack simulations. There are other file formats such as Feather and Parquet but using those formats would introduce more dependencies to liionpack.Below are disk storage results for a 16p2s single charge/discharge simulation. Simulation outputs written to file are time, terminal voltage, pack terminal voltage, pack current, open circuit voltage, cell resistance, and cell current.
Below are disk storage results for a 400p125s single charge/discharge simulation. Simulation outputs written to file are time, terminal voltage, pack terminal voltage, pack current, open circuit voltage, cell resistance, and cell current.