From 14c74551a3ce7e054d8fcf9bd20bc98d2595e353 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Wed, 30 Oct 2024 15:20:50 -0400 Subject: [PATCH] BCs were not updated when only T was changing --- src/festim/boundary_conditions/dirichlet_bc.py | 4 +++- src/festim/problem_change_of_var.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/festim/boundary_conditions/dirichlet_bc.py b/src/festim/boundary_conditions/dirichlet_bc.py index a08384b26..306dc444e 100644 --- a/src/festim/boundary_conditions/dirichlet_bc.py +++ b/src/festim/boundary_conditions/dirichlet_bc.py @@ -127,7 +127,7 @@ def update(self, t: float): """Updates the boundary condition value Args: - t (float): the time + t: the time """ if callable(self.value): arguments = self.value.__code__.co_varnames @@ -135,6 +135,8 @@ def update(self, t: float): self.value_fenics.value = self.value(t=t) else: self.value_fenics.interpolate(self.bc_expr) + elif self.bc_expr is not None: + self.value_fenics.interpolate(self.bc_expr) class FixedConcentrationBC(DirichletBCBase): diff --git a/src/festim/problem_change_of_var.py b/src/festim/problem_change_of_var.py index 3bd4dca4c..6038ab08a 100644 --- a/src/festim/problem_change_of_var.py +++ b/src/festim/problem_change_of_var.py @@ -187,7 +187,9 @@ def create_dirichletbc_form(self, bc: festim.FixedConcentrationBC): function_space_value = bc.species.collapsed_function_space # create K_S function - Q0 = fem.functionspace(self.mesh.mesh, ("DG", 0)) + Q0 = fem.functionspace( + self.mesh.mesh, ("DG", 0) + ) # NOTE K_S0 and E_KS could be constants here and don't have to be defined on several materials K_S0 = fem.Function(Q0) E_KS = fem.Function(Q0) for subdomain in self.volume_subdomains: @@ -233,3 +235,11 @@ def create_dirichletbc_form(self, bc: festim.FixedConcentrationBC): ) return form + + def update_time_dependent_values(self): + super().update_time_dependent_values() + + if self.temperature_time_dependent: + for bc in self.boundary_conditions: + if isinstance(bc, boundary_conditions.FixedConcentrationBC): + bc.update(self.t)