diff --git a/src/xtgeo/grid3d/_ecl_inte_head.py b/src/xtgeo/grid3d/_ecl_inte_head.py index 5739f27c2..9a7ccb4ac 100644 --- a/src/xtgeo/grid3d/_ecl_inte_head.py +++ b/src/xtgeo/grid3d/_ecl_inte_head.py @@ -91,6 +91,9 @@ def num_active(self): @property def phases(self): """The phase system used for simulation""" + if "300" in str(self.simulator): + # item 14 in E300 runs is number of tracers, not IPHS; assume oil/wat/gas + return Phases.OIL_WATER_GAS return self._optional_index_lookup(14, Phases) @property diff --git a/tests/test_grid3d/test_ecl_inte_head.py b/tests/test_grid3d/test_ecl_inte_head.py index c4eb0d21d..2415e895b 100644 --- a/tests/test_grid3d/test_ecl_inte_head.py +++ b/tests/test_grid3d/test_ecl_inte_head.py @@ -1,7 +1,6 @@ import numpy as np import pytest - -from xtgeo.grid3d._ecl_inte_head import InteHead +from xtgeo.grid3d._ecl_inte_head import InteHead, Phases from xtgeo.grid3d._ecl_output_file import Simulator, TypeOfGrid, UnitSystem @@ -25,6 +24,23 @@ def test_intehead_non_standard_simulator(): assert intehead.simulator == Simulator.ECLIPSE_100 +def test_intehead_iphs_when_e300(): + intehead_values = [0] * 100 + intehead_values[94] = 300 # simulator is Ecl 300 + intehead_values[14] = 8 # 14 is IPHS code in E100 but no. tracers in E300, here 8 + assert ( + InteHead(intehead_values).phases == Phases.OIL_WATER_GAS + ), "phases always OIL_WATER_GAS in Eclipse 300" + + +def test_intehead_iphs_fail_when_outsiderange_e100(): + intehead_values = [0] * 100 + intehead_values[94] = 100 # simulator is Ecl 100 + intehead_values[14] = 8 # 14 is IPHS code in E100 but 8 is not a valid code + with pytest.raises(ValueError, match="not a valid Phases"): + InteHead(intehead_values).phases + + def test_intehead_type_of_grid(): intehead = InteHead(np.full(shape=411, fill_value=3, dtype=np.int32))