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

Warn when Temperature is mixed with BCs, sources, etc. #787

Closed
RemDelaporteMathurin opened this issue Jun 18, 2024 · 5 comments · Fixed by #812
Closed

Warn when Temperature is mixed with BCs, sources, etc. #787

RemDelaporteMathurin opened this issue Jun 18, 2024 · 5 comments · Fixed by #812
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@RemDelaporteMathurin
Copy link
Collaborator

Currently users can setup temperature boundary conditions, sources, etc while setting up a F.Temperature() object.

When this happens, the BCs and sources are ignored.

It would be nice to either raise an error or at least a warning that F.Temperature() and F.DirichletBC(field="T", ....) should not be used together.

@RemDelaporteMathurin RemDelaporteMathurin added the enhancement New feature or request label Jun 18, 2024
@RemDelaporteMathurin RemDelaporteMathurin added the good first issue Good for newcomers label Jun 26, 2024
@JonathanGSDUFOUR
Copy link
Contributor

I'll start working on this issue, should not take too long if I understand well the code

@RemDelaporteMathurin
Copy link
Collaborator Author

I'll start working on this issue, should not take too long if I understand well the code

Sounds good! I assigned you to it.

@RemDelaporteMathurin
Copy link
Collaborator Author

@JonathanGSDUFOUR I think there has been a confusion in what exactly we need to fix.

Here's an example:

import festim as F
import numpy as np

my_model = F.Simulation()


# Here, we define boundary conditions for heat transfer
# and at the same time we prescribe a temperature field which overwrites everything!

my_model.T = F.Temperature(873)

my_model.boundary_conditions = [
    F.DirichletBC(field="T", value=1200, surfaces=1),
    F.DirichletBC(field="T", value=373, surfaces=2),
]

my_model.materials = F.Material(1, 1, 0)

my_model.mesh = F.MeshFromVertices(np.linspace(0, 1))

my_model.settings = F.Settings(
    absolute_tolerance=1e-10, relative_tolerance=1e-10, transient=False
)

my_model.initialise()
my_model.run()

In this model, we set the temperature to 873 K but also set boundary conditions. This should not be possible as it is not compatible.

However in the current state of FESTIM, the code above runs without any issue.

It should return an error saying: can't use boundary conditions with Temperature(), use HeatTransferProblem() instead.

Does that make sense?

@JonathanGSDUFOUR
Copy link
Contributor

Okay I understand where is the issue !
So I should reset what I did also right ? If it wasn't a real issue

@RemDelaporteMathurin
Copy link
Collaborator Author

I think you can close the PR you opened and open a new PR.

I advise you to start by writing a test. Basically the test would be running the code I sent above and checking that an error is raised.

Then once you check that this test catches the bug you can implement a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants