Skip to content

Commit fbb2434

Browse files
committed
added checkes to GCI function
1 parent 27800f7 commit fbb2434

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

mhkit/river/io/d3d.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,8 @@ def calculate_grid_convergence_index(
915915
Results from the coarser grid.
916916
refinement_ratio: float
917917
Refinement ratio between the grids.
918+
factor_of_safety: float
919+
Factor of safety (default is 1.25).
918920
order: int
919921
Order of accuracy (default is 2).
920922
@@ -923,6 +925,19 @@ def calculate_grid_convergence_index(
923925
gci: float
924926
Grid Convergence Index (GCI).
925927
"""
928+
929+
# Validate inputs
930+
if not (np.issubdtype(refinement_ratio.dtype, np.number)):
931+
raise TypeError("refinement_ratio must be a numeric values")
932+
if not (np.issubdtype(factor_of_safety.dtype, np.number)):
933+
raise TypeError("factor_of_safety must be a numeric values")
934+
if not (np.issubdtype(order.dtype, np.number)):
935+
raise TypeError("order must be a numeric values")
936+
if not (np.issubdtype(fine_grid.dtype, np.number) and np.issubdtype(coarse_grid.dtype, np.number)):
937+
raise TypeError("fine_grid and coarse_grid must contain numeric values")
938+
if fine_grid.shape != coarse_grid.shape:
939+
raise ValueError("fine_grid and coarse_grid must have the same shape")
940+
926941
# Calculate the approximate relative error
927942
error = np.abs((fine_grid - coarse_grid) / fine_grid)
928943

0 commit comments

Comments
 (0)