-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
set T_init as a function in the x domain #3151
Conversation
Lots of test errors, opening PR for visibility only. |
So I'm getting an error that I don't fully understand within the symbol.py, called through the equation tree. There appears to be math operation where two different domains are being subtracted. (Current collector and particle). |
My guess is that the errors are caused because now |
You'll also need to make sure that you set |
OK, so got some more stuff working, but now it seems like there's some confusion around the domain variable between the submodels and the base model. Error trace: File c:\users\tom.maull\desktop\pybammdev\pybamm\pybamm\models\submodels\thermal\lumped.py:24, in Lumped.init(self, param, domain, options) File c:\users\tom.maull\desktop\pybammdev\pybamm\pybamm\models\submodels\thermal\base_thermal.py:23, in BaseThermal.init(self, param, domain, options) File c:\users\tom.maull\desktop\pybammdev\pybamm\pybamm\models\submodels\base_submodel.py:123, in BaseSubModel.domain(self, domain) |
Hey is anyone able to take a look at this one? |
x = pybamm.SpatialVariable( | ||
f"x_{domain[0]}", | ||
domain=[f"{domain} electrode"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue with the tests is here as the domain is inherited from the for loop and it is not a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be the "whole cell" x, i.e.
whole_cell = ["negative electrode", "separator", "positive electrode"]
x = pybamm.SpatialVariable(
"x",
domain=whole_cell,
auxiliary_domains={"secondary": "current collector"},
coord_sys="cartesian",
)
or, even better, just do pybamm.standard_spatial_vars.x
which will fetch the same defn from standard_spatial_vars.py
Hi @tommaull! Let me know if you have any questions about the comments above (not sure I was very clear haha). |
Hi @brosaplanella and @rtimms, here's the latest. I've definitely bitten off more than I should have here. Appreciate your help. |
for domain in self.domain_params.values(): | ||
domain._set_parameters() | ||
for domain, params in self.domain_params.items(): | ||
params._domain = domain # Set _domain attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed, since T
is defined across all domains, not by component
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
# Domain parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now this can go, for the same reasons as above
# ) | ||
|
||
self.T_init = pybamm.FunctionParameter( | ||
f"{domain}Initial temperature in {domain} electrode [mol.m-3]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just call it "Initial temperature [K]"
@@ -67,4 +67,4 @@ def set_rhs(self, variables): | |||
|
|||
def set_initial_conditions(self, variables): | |||
T_vol_av = variables["Volume-averaged cell temperature [K]"] | |||
self.initial_conditions = {T_vol_av: self.param.T_init} | |||
self.initial_conditions = {T_vol_av: pybamm.x_average(self.param.T_init)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will also need to do this in the "x-lumped" models for pouch cell (in the folder submodels/thermal/pouch_cell/
)
thanks @tommaull it's getting there - just some confusion around the cell temperature being set on the "whole cell" domain instead of separately for negative electrode/separator/positive electrode |
@@ -28,17 +31,39 @@ def __init__(self): | |||
|
|||
def _set_parameters(self): | |||
"""Defines the dimensional parameters""" | |||
for domain in self.domain_params.values(): | |||
domain._set_parameters() | |||
for domain, params in self.domain_params.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should just be
for domain in self.domain_params.values():
domain._set_parameters()
For the x-full model you need to update the boundary conditions to be def set_initial_conditions(self, variables):
T = variables["Cell temperature [K]"]
T_cn = variables["Negative current collector temperature [K]"]
T_cp = variables["Positive current collector temperature [K]"]
T_init = self.param.T_init
self.initial_conditions = {
T_cn: pybamm.boundary_value(T_init, "left"),
T: T_init,
T_cp: pybamm.boundary_value(T_init, "right"),
} so that the current collector initial temperatures are It looks like you'll also need to update the |
If you want a variable with primary domains matching the original variable, you can re-broadcast pybamm.PrimaryBroadcast(T_av, ["negative electrode", "separator", "positive electrode"]) |
Description
Changed T_init to functional parameter in the x domain
Fixes #3131
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.
Key checklist:
$ pre-commit run
(see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python run-tests.py --all
$ python run-tests.py --doctest
You can run unit and doctests together at once, using
$ python run-tests.py --quick
.Further checks: