Added "use lumped thermal capacity" option in lumped thermal model. - #4968
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4968 +/- ##
========================================
Coverage 98.64% 98.64%
========================================
Files 304 304
Lines 23742 23750 +8
========================================
+ Hits 23421 23429 +8
Misses 321 321 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
aabills
left a comment
There was a problem hiding this comment.
Thanks @Rishab87 !
Overall it looks really great, there are just a few small issues.
I'd also like to see an integration test where we ensure that the equation is doing what it is supposed to be doing, maybe by back calculating the lumped capacity and comparing it with the standard thermal model.
| "Initial concentration in negative electrode [mol.m-3]": 24108.0, | ||
| "Initial concentration in positive electrode [mol.m-3]": 21725.0, | ||
| "Initial temperature [K]": 298.15, | ||
| "Cell heat capacity [J.K-1.m-3]": 2.5e6, |
There was a problem hiding this comment.
In general, we try not to add parameters that were not in the original paper to the parameter sets, so could you delete this from all the parameter sets?
| "voltage as a state": ["false", "true"], | ||
| "working electrode": ["both", "positive"], | ||
| "x-average side reactions": ["false", "true"], | ||
| "use lumped capacity": ["false", "true"], |
There was a problem hiding this comment.
Let's rename this to "use lumped thermal capacity" for clarity, given that batteries also have an charge capacity.
| y_eval = np.zeros((sim._built_model.len_rhs, 1)) | ||
| heat_capacity_eval = var.evaluate(t_eval, y_eval) | ||
|
|
||
| assert abs(heat_capacity_eval - lumped_value) < lumped_value * 1e-10 |
There was a problem hiding this comment.
I'm not sure that this is a great test. What is this trying to test exactly?
There was a problem hiding this comment.
Also you can use np.assert_almost_equal
There was a problem hiding this comment.
I've changed this unit test a bit, it checks whether the heat capacity parameter is being used correctly when the option is enabled.
| self.h_total = self.therm.h_total | ||
| self.rho_c_p_eff = self.therm.rho_c_p_eff | ||
| self.lambda_eff = self.therm.lambda_eff | ||
| self.cell_heat_capacity = self.therm.cell_heat_capacity |
There was a problem hiding this comment.
This is the same thing as rho_c_p_eff right? So why make a new parameter for it?
There was a problem hiding this comment.
I think rho_c_p_eff calculates the effective volumetric heat capacity of the entire battery cell by combining the heat capacities of each component but cell_heat_capacity is the lumped heat capacity of the whole cell, we can define this parameter directly in lumped.py too but I made it like this for consistency of the codebase
There was a problem hiding this comment.
yeah I think it makes sense to keep it separate after further consideration.
…/PyBaMM into properly-lumped-thermal
|
@aabills thanks for the review! |
| @@ -224,6 +224,10 @@ class BatteryModelOptions(pybamm.FuzzyDict): | |||
| the respective porosity change) over the x-axis in Single Particle | |||
| Models, can be "false" or "true". Default is "false" for SPMe and | |||
| "true" for SPM. | |||
There was a problem hiding this comment.
Can you add a check that raises an OptionError for incompatible options? There are some examples of this further down in this file.
There was a problem hiding this comment.
ohh right, missed that, adding
| Q_cr_W = pybamm.Scalar(0) | ||
| Q_cr_vol_av = Q_cr_W | ||
|
|
||
| # Add lumped heat capacity if option is enabled |
There was a problem hiding this comment.
It might be cleaner to have this option check in the base class rather than overwriting the variable for the lumped model.
|
Hey @Rishab87 I'll re-review once you've implemented Rob's changes |
aabills
left a comment
There was a problem hiding this comment.
Ok at this point it looks great substantively. The only thing is, the testing in unit/ doesn't really match what we did for the other models. Could you please add it to unit/test_models/test_full_battery_models/base_lithium_ion_tests.py and base_lithium_ion_half_cell_tests.py? You should be able to do both the option error and the check well posedness there. And then move the parameter test from unittests to test_thermal_parameters, which is in test_lithium_ion_parameters.py
Thanks so much!
| self.h_total = self.therm.h_total | ||
| self.rho_c_p_eff = self.therm.rho_c_p_eff | ||
| self.lambda_eff = self.therm.lambda_eff | ||
| self.cell_heat_capacity = self.therm.cell_heat_capacity |
There was a problem hiding this comment.
yeah I think it makes sense to keep it separate after further consideration.
|
@aabills, shifted those tests and changed them accordingly |
aabills
left a comment
There was a problem hiding this comment.
Looks awesome, thanks a lot!!
Description
Added "use lumped thermal capacity" option in lumped thermal model so that we can simulate properly for those who do not have detailed thermal characterization of each component of the cell.
Fixes #4612
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)
Important checks:
Please confirm the following before marking the PR as ready for review:
nox -s pre-commitnox -s testsnox -s doctests