Skip to content

Commit

Permalink
test new helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Oct 20, 2023
1 parent 449abf4 commit 00befdd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/test_dirichlet_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,24 @@ def test_integration_with_HTransportProblem(value):
if isinstance(expected_value, Conditional):
expected_value = float(expected_value)
assert np.isclose(computed_value, expected_value)


def test_species_predefined():
"""Test a ValueError is rasied when the species defined in the boundary
condition is not predefined in the model"""

subdomain = F.SurfaceSubdomain1D(1, x=1)
vol_subdomain = F.VolumeSubdomain1D(1, borders=[0, 1], material=dummy_mat)

my_model = F.HydrogenTransportProblem(
mesh=F.Mesh(mesh),
subdomains=[vol_subdomain, subdomain],
)
my_model.species = [F.Species("H")]
my_bc = F.DirichletBC(subdomain, 1.0, "J")
my_model.boundary_conditions = [my_bc]
my_model.settings = F.Settings(atol=1, rtol=0.1)
my_model.settings.stepsize = 1

with pytest.raises(ValueError):
my_model.initialise()

0 comments on commit 00befdd

Please sign in to comment.