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

Surface temperature model #4203

Merged
merged 19 commits into from
Aug 27, 2024
Merged

Surface temperature model #4203

merged 19 commits into from
Aug 27, 2024

Conversation

valentinsulzer
Copy link
Member

Description

From Lin et al 2014 (kudos @js1tr3 et al)
image
image

Fixes #4022

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@valentinsulzer valentinsulzer marked this pull request as draft June 20, 2024 13:40
@valentinsulzer
Copy link
Member Author

Still need to add tests and update examples

@TomTranter
Copy link
Contributor

I am happy to review this when ready

@valentinsulzer valentinsulzer marked this pull request as ready for review June 21, 2024 03:46
@valentinsulzer
Copy link
Member Author

@TomTranter ready for review

Copy link

codecov bot commented Jun 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (8057c16) to head (a33ecb9).
Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4203      +/-   ##
===========================================
- Coverage    99.46%   99.42%   -0.05%     
===========================================
  Files          289      292       +3     
  Lines        22200    22215      +15     
===========================================
+ Hits         22081    22087       +6     
- Misses         119      128       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kratman
Copy link
Contributor

kratman commented Jun 21, 2024

Looks like the examples are failing here:

            for phase in self.options.phases[domain]:
                if particle == "Fickian diffusion":
                    submod = pybamm.particle.FickianDiffusion(
                        self.param, domain, self.options, phase=phase, x_average=True
                    )
                elif particle in [
                    "uniform profile",
                    "quadratic profile",
                    "quartic profile",
                ]:
                    submod = pybamm.particle.XAveragedPolynomialProfile(
                        self.param, domain, self.options, phase=phase
                    )
                elif particle == "MSMR":
                    submod = pybamm.particle.MSMRDiffusion(
                        self.param, domain, self.options, phase=phase, x_average=True
                    )
                    # also set the submodel for calculating stoichiometry from
                    # potential
                    self.submodels[f"{domain} {phase} stoichiometry"] = (
                        pybamm.particle.MSMRStoichiometryVariables(
                            self.param,
                            domain,
                            self.options,
                            phase=phase,
                            x_average=True,
                        )
                    )
                self.submodels[f"{domain} {phase} particle"] = submod

The variable submod does not get defined before assignment. PyCharm identifies that the variable may be undefined. We should probably make sure our inspection tools flag this

@TomTranter
Copy link
Contributor

The model seems to be working but I am not sure about some of the numbers or what the constants in the equation represent. It would make more sense to me to have 3 nodes representing the core, casing and environment. I also would prefer the equations to be consistent with the other heat capacities and specify the thermal conductivity and specific heat capacity. The paper quotes these values for the parameters in the model
image
The thermal resistance seems ok but capacity seems a bit high unless my assumed casing thickness is a bit low.

# Assuming a 21700 cylindrical cell with Al casing

rho_Al = 2710.00  # [kg/m^3]
h_casing = 70.0e-3  # [m] height of casing
t_casing = 1.0e-3  # [m] casing thickness
r_casing = 10.50e-3  # [m] casing radius

# Volume of the cylindrical side
vol_casing_side = np.pi * ((r_casing + t_casing)**2 - r_casing**2) * h_casing  # [m^3]

# Volume of the end caps
vol_casing_caps = 2 * np.pi * r_casing**2 * t_casing  # [m^3]

# Total volume of the casing
vol_casing = vol_casing_side + vol_casing_caps

Cp_Al = 890.0  # [J/kg.K]
C_Al = rho_Al * vol_casing * Cp_Al

print("Casing heat capacity [J/K]:", C_Al)


k_Al = 237 # W.m-1K-1
R_casing = 1 / (k_Al * t_casing)

print("Environment thermal resistance [K/W]:", R_casing)

parameter_values = pybamm.ParameterValues("Chen2020")
parameter_values.update(
    {
        "Casing heat capacity [J.K-1]": C_Al,
        "Environment thermal resistance [K.W-1]": R_casing,
    },
    check_already_exists=False,
)

Gives
Casing heat capacity [J/K]: 13.33
Environment thermal resistance [K/W]: 4.21

Could we see what adding another equation does to the model to go from casing to cooling channel centre through air. It seems like the fitted parameters for this model might be doing some averaging of properties which is not that obvious to the user

@valentinsulzer
Copy link
Member Author

I'd like to stick as closely as possible to what is implemented in the referred paper, so that we can say "this is the model from this paper" rather than having to justify choices of equations and parameters. Especially as this model already gives good fit to some data I've been looking at

Copy link
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @valentinsulzer ! looks good to me once the conflicts are fixed

class Lumped(pybamm.BaseSubModel):
"""
Class for the lumped surface temperature submodel, which adds an ODE for the
surface temperature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth putting the citation in the docs

@kratman kratman merged commit ac6c450 into develop Aug 27, 2024
25 of 26 checks passed
@kratman kratman deleted the issue-4022-surface branch August 27, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Surface temperature" submodel
4 participants