From f2ba663b2bcd14f44e0ceda863946aeffbf9618e Mon Sep 17 00:00:00 2001 From: JDUFOUR Date: Tue, 23 Jul 2024 10:44:16 +0200 Subject: [PATCH] added corrections --- festim/generic_simulation.py | 10 ++++------ test/system/test_misc.py | 11 +++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/festim/generic_simulation.py b/festim/generic_simulation.py index 5f7cb2eba..ff1607fd2 100644 --- a/festim/generic_simulation.py +++ b/festim/generic_simulation.py @@ -207,9 +207,9 @@ def attribute_source_terms(self): # set sources for source in self.sources: if source.field == "T" and not isinstance( - self.T, festim.temperature.temperature_solver.HeatTransferProblem + self.T, festim.HeatTransferProblem ): # check that there is not a source defined in T as the same time as a festim.Temperature - raise ValueError( + raise TypeError( "Heat transfer sources can only be used with HeatTransferProblem" ) if isinstance(source, festim.RadioactiveDecay) and source.field == "all": @@ -249,10 +249,8 @@ def check_boundary_conditions(self): raise ValueError("SurfaceKinetics can only be used in 1D simulations") # check that there is not a Temperature defined at the same time as a boundary condition in T - if bc.field == "T" and not isinstance( - self.T, festim.temperature.temperature_solver.HeatTransferProblem - ): - raise ValueError( + if bc.field == "T" and not isinstance(self.T, festim.HeatTransferProblem): + raise TypeError( "Heat transfer boundary conditions can only be used with HeatTransferProblem" ) diff --git a/test/system/test_misc.py b/test/system/test_misc.py index 493a721e9..4fb0c5d87 100644 --- a/test/system/test_misc.py +++ b/test/system/test_misc.py @@ -169,7 +169,7 @@ def test_error_DirichletBC_on_same_surface(field, surfaces): field == "T" ): # with festim.Temperature already defined there is another error given with pytest.raises( - ValueError, + TypeError, match="Heat transfer boundary conditions can only be used with HeatTransferProblem", ): sim.initialise() @@ -197,11 +197,8 @@ def test_BC_on_T_with_Temp(bc): sim.settings = F.Settings( transient=False, absolute_tolerance=1e8, relative_tolerance=1e-8 ) - sim.sources = [] - sim.dt = None - sim.exports = [] with pytest.raises( - ValueError, + TypeError, match="Heat transfer boundary conditions can only be used with HeatTransferProblem", ): sim.initialise() @@ -222,10 +219,8 @@ def test_source_on_T_with_Temp(): transient=False, absolute_tolerance=1e8, relative_tolerance=1e-8 ) sim.sources = [F.Source(value=1, volume=1, field="T")] - sim.dt = None - sim.exports = [] with pytest.raises( - ValueError, + TypeError, match="Heat transfer sources can only be used with HeatTransferProblem", ): sim.initialise()