From f728b4e014fc19aadb02a20bb64b864b88ba0245 Mon Sep 17 00:00:00 2001 From: gabriele-ferrero Date: Fri, 6 Oct 2023 18:44:40 -0400 Subject: [PATCH 1/6] Added parametric test for Flux BC initialise --- test/unit/test_boundary_conditions.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index b00d2810d..bdc26e754 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -543,15 +543,23 @@ def test_string_for_field_in_dirichletbc(): bc.create_dirichletbc(V, fenics.Constant(1), surface_marker) -def test_dissociation_flux_solve(): - """Test to catch bug DissociationFlux see #581""" +@pytest.mark.parametrize( + "boundary", + [ + (festim.DissociationFlux(surfaces=[1], Kd_0=1, E_Kd=0, P=1e4)), + (festim.ConvectiveFlux(h_coeff=1, T_ext=1, surfaces=1)), + (festim.FluxBC(surfaces=1, value=1, field=0)), + (festim.MassFlux(h_coeff=1, c_ext=1, surfaces=1)), + (festim.RecombinationFlux(Kr_0=1e-20, E_Kr=0, order=2, surfaces=1)), + ], +) +def test_flux_BC_initialise(boundary): + """Test to catch bug Flux BCs see #581""" sim = festim.Simulation() sim.mesh = festim.MeshFromVertices([0, 1, 2, 3]) sim.materials = festim.Material(id=1, D_0=1, E_D=0) sim.T = festim.Temperature(value=500) - sim.boundary_conditions = [ - festim.DissociationFlux(surfaces=[1], Kd_0=1, E_Kd=0, P=1e4) - ] + sim.boundary_conditions = [boundary] sim.settings = festim.Settings( transient=False, absolute_tolerance=1e8, relative_tolerance=1e-8 ) From 0e7af5caf24e842c493770e3596ff634915d3c23 Mon Sep 17 00:00:00 2001 From: Gabriele Ferrero <116028237+gabriele-ferrero@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:08:17 -0400 Subject: [PATCH 2/6] Update test/unit/test_boundary_conditions.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> --- test/unit/test_boundary_conditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index bdc26e754..278a0cbbb 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -544,7 +544,7 @@ def test_string_for_field_in_dirichletbc(): @pytest.mark.parametrize( - "boundary", + "bc", [ (festim.DissociationFlux(surfaces=[1], Kd_0=1, E_Kd=0, P=1e4)), (festim.ConvectiveFlux(h_coeff=1, T_ext=1, surfaces=1)), From 881cfa35fed0509f47e3fdeffd9be9551ca74535 Mon Sep 17 00:00:00 2001 From: Gabriele Ferrero <116028237+gabriele-ferrero@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:08:24 -0400 Subject: [PATCH 3/6] Update test/unit/test_boundary_conditions.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> --- test/unit/test_boundary_conditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index 278a0cbbb..eda6b4741 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -553,7 +553,7 @@ def test_string_for_field_in_dirichletbc(): (festim.RecombinationFlux(Kr_0=1e-20, E_Kr=0, order=2, surfaces=1)), ], ) -def test_flux_BC_initialise(boundary): +def test_flux_BC_initialise(bc): """Test to catch bug Flux BCs see #581""" sim = festim.Simulation() sim.mesh = festim.MeshFromVertices([0, 1, 2, 3]) From e3a0e5212feb4da392fe0d563effe3479afcfe19 Mon Sep 17 00:00:00 2001 From: Gabriele Ferrero <116028237+gabriele-ferrero@users.noreply.github.com> Date: Fri, 6 Oct 2023 19:08:29 -0400 Subject: [PATCH 4/6] Update test/unit/test_boundary_conditions.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> --- test/unit/test_boundary_conditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index eda6b4741..1366be2cf 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -559,7 +559,7 @@ def test_flux_BC_initialise(bc): sim.mesh = festim.MeshFromVertices([0, 1, 2, 3]) sim.materials = festim.Material(id=1, D_0=1, E_D=0) sim.T = festim.Temperature(value=500) - sim.boundary_conditions = [boundary] + sim.boundary_conditions = [bc] sim.settings = festim.Settings( transient=False, absolute_tolerance=1e8, relative_tolerance=1e-8 ) From 5e26a484d00cf000b526b66f2f5de1fca7f4f0fa Mon Sep 17 00:00:00 2001 From: gabriele-ferrero Date: Fri, 6 Oct 2023 19:16:44 -0400 Subject: [PATCH 5/6] Added Dirichlet BC --- test/unit/test_boundary_conditions.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index 1366be2cf..83f385cc7 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -551,6 +551,23 @@ def test_string_for_field_in_dirichletbc(): (festim.FluxBC(surfaces=1, value=1, field=0)), (festim.MassFlux(h_coeff=1, c_ext=1, surfaces=1)), (festim.RecombinationFlux(Kr_0=1e-20, E_Kr=0, order=2, surfaces=1)), + ( + festim.ImplantationDirichlet( + surfaces=1, + phi=1e18, + R_p=1e-9, + D_0=1, + E_D=0, + Kr_0=None, + E_Kr=None, + Kd_0=None, + E_Kd=None, + P=None, + ) + ), + (festim.DirichletBC(surfaces=1, value=1, field=0)), + (festim.HenrysBC(surfaces=1, H_0=1, E_H=0, pressure=1e3)), + (festim.SievertsBC(surfaces=1, S_0=1, E_S=0, pressure=1e3)), ], ) def test_flux_BC_initialise(bc): From e6008a2c961086582799023e53b70f9588ff7039 Mon Sep 17 00:00:00 2001 From: gabriele-ferrero Date: Sat, 7 Oct 2023 10:02:48 -0400 Subject: [PATCH 6/6] Added test for Custom BC --- test/unit/test_boundary_conditions.py | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index 83f385cc7..4b69017be 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -543,6 +543,10 @@ def test_string_for_field_in_dirichletbc(): bc.create_dirichletbc(V, fenics.Constant(1), surface_marker) +def custom_fun(T, solute, param1): + return 2 * T + solute - param1 + + @pytest.mark.parametrize( "bc", [ @@ -552,19 +556,22 @@ def test_string_for_field_in_dirichletbc(): (festim.MassFlux(h_coeff=1, c_ext=1, surfaces=1)), (festim.RecombinationFlux(Kr_0=1e-20, E_Kr=0, order=2, surfaces=1)), ( - festim.ImplantationDirichlet( - surfaces=1, - phi=1e18, - R_p=1e-9, - D_0=1, - E_D=0, - Kr_0=None, - E_Kr=None, - Kd_0=None, - E_Kd=None, - P=None, + festim.CustomDirichlet( + surfaces=[1, 2], + function=custom_fun, + param1=2 * festim.x + festim.t, + field=0, + ) + ), + ( + festim.CustomFlux( + surfaces=[1, 2], + function=custom_fun, + param1=2 * festim.x + festim.t, + field=0, ) ), + (festim.ImplantationDirichlet(surfaces=1, phi=1e18, R_p=1e-9, D_0=1, E_D=0)), (festim.DirichletBC(surfaces=1, value=1, field=0)), (festim.HenrysBC(surfaces=1, H_0=1, E_H=0, pressure=1e3)), (festim.SievertsBC(surfaces=1, S_0=1, E_S=0, pressure=1e3)),