Coverage for C:\src\imod-python\imod\mf6\clipped_boundary_condition_creator.py: 100%

1 import imod

2 from imod.mf6 import ConstantHead

3 from imod.select.grid import active_grid_boundary_xy

4 from imod.typing import GridDataArray

5

6

7 def create_clipped_boundary(

8 idomain: GridDataArray,

9 state_for_clipped_boundary: GridDataArray,

10 original_constant_head_boundaries: list[ConstantHead],

11) -> ConstantHead:

12 """

13 Create a ConstantHead package on boundary cells that don't have any assigned to them. This is useful in

14 combination with the clip_box method which can produce a domain with missing boundary conditions.

15

16 Parameters

17 ----------

18 idomain:

19 The clipped domain

20 state_for_clipped_boundary :

21 The values to be assigned to the created ConstantHead package

22 original_constant_head_boundaries :

23 List of existing ConstantHead boundaries

24

25 Returns

26 -------

27 ConstantHead package providing values for boundary cells that are not

28 covered by other ConstantHead packages

29

30 """

31 active_grid_boundary = active_grid_boundary_xy(idomain == 1)

32 unassigned_grid_boundaries = _find_unassigned_grid_boundaries(

33 active_grid_boundary, original_constant_head_boundaries

34 )

35

36 constant_head = state_for_clipped_boundary.where(unassigned_grid_boundaries)

37

38 return imod.mf6.ConstantHead(

39 constant_head, print_input=True, print_flows=True, save_flows=True

40 )

41

42

43 def _find_unassigned_grid_boundaries(

44 active_grid_boundary: GridDataArray,

45 boundary_conditions: list[ConstantHead],

46) -> GridDataArray:

47 unassigned_grid_boundaries = active_grid_boundary

48 for boundary_condition in boundary_conditions:

49 unassigned_grid_boundaries = (

50 unassigned_grid_boundaries & boundary_condition["head"].isnull()

51 )

52

53 return unassigned_grid_boundaries