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

Assign a spacial temperature vector as initial temperatrue field for DFN model #3131

Open
xyyrly opened this issue Jul 10, 2023 · 9 comments
Assignees
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours feature in-progress Assigned in the core dev monthly meeting priority: medium To be resolved if time allows

Comments

@xyyrly
Copy link

xyyrly commented Jul 10, 2023

Description

Hi team,
I try to set an initial temperature distribution in x dimension for DFN but now it looks only a scalar value can be set for the whole domain. Could it be fixed? Thanks!

Motivation

No response

Possible Implementation

No response

Additional context

No response

@xyyrly xyyrly added the feature label Jul 10, 2023
@valentinsulzer valentinsulzer added difficulty: easy A good issue for someone new. Can be done in a few hours priority: medium To be resolved if time allows labels Jul 10, 2023
@tommaull
Copy link
Contributor

I'll take this one

@xyyrly
Copy link
Author

xyyrly commented Jul 12, 2023

Thank you very much!

@tommaull
Copy link
Contributor

xyyrly - assuming you were using the xfull temperature model?

@xyyrly
Copy link
Author

xyyrly commented Jul 12, 2023

Hi tommaull,

I am using a new thermal model to calculate electrolyte temperature along x dimension and particle temperature along r dimension, kind of like DFN model.

@tommaull
Copy link
Contributor

Can you write out the steps to replicate with existing models?

@xyyrly
Copy link
Author

xyyrly commented Jul 12, 2023

Oh sorry I was confused. I think here what I hope to realize is to assign a spatical temperature distribution to DFN model without subthermal model. Is it possible?

@tommaull
Copy link
Contributor

tommaull commented Jul 12, 2023

I think a thermal model is required. @tinosulzer - what are your thoughts? My approach was going to be to add something like this to xfull:

def set_initial_conditions(self, variables):
T = variables["Cell temperature [K]"]

    if isinstance(self.param.T, (list, np.ndarray)):
        if len(self.param.T) == 3:
            # Get sizes of negative, separator, and positive domains
            sizes = {
                "negative electrode": self.mesh["negative electrode"].npts,
                "separator": self.mesh["separator"].npts,
                "positive electrode": self.mesh["positive electrode"].npts,
            }

            # Check if sizes match the length of T
            if all(size == len(T) for size in sizes.values()):
                self.initial_conditions = {
                    "negative electrode": self.param.T[
                        : sizes["negative electrode"]
                    ],
                    "separator": self.param.T[
                        sizes["negative electrode"] : sizes["negative electrode"]
                        + sizes["separator"]
                    ],
                    "positive electrode": self.param.T[
                        sizes["negative electrode"] + sizes["separator"] :
                    ],
                }
            else:
                raise ValueError("T vector size does not match domain sizes")
        else:
            raise ValueError("T should be a vector of length 3")
    else:
        self.initial_conditions = {T: np.full_like(T, self.param.T)}

@rtimms
Copy link
Contributor

rtimms commented Jul 12, 2023

@tommaull take a look at e.g. how we define initial concentration, which can depend on x and r, and then how it is used in the model.

You'll need to make initial temperature a FunctionParameter, then you can pass T(x) as an initial condition.

@tommaull
Copy link
Contributor

tommaull commented Jul 16, 2023

Put in a draft PR to show progress but having an issue I don't understand in the expression tree.

set T_init as a function in the x domain
#3151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours feature in-progress Assigned in the core dev monthly meeting priority: medium To be resolved if time allows
Projects
No open projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

7 participants