def test_pvt_reek(): """Test that the Reek PVT input can be parsed individually""" eclfiles = EclFiles(DATAFILE) pvto_df = pvt.pvto_fromdeck(eclfiles.get_ecldeck()) assert "PVTNUM" in pvto_df assert "PRESSURE" in pvto_df assert "VOLUMEFACTOR" in pvto_df assert "VISCOSITY" in pvto_df assert max(pvto_df["PVTNUM"]) == 1 assert max(pvto_df["PRESSURE"]) == 700.1 # Check count of undersaturated lines pr. RS: # (nb: double brackets in .loc to ensure dataframe is returned) assert len(pvto_df.set_index("RS").loc[[0]]) == 2 assert len(pvto_df.set_index("RS").loc[[15.906]]) == 1 assert len(pvto_df.set_index("RS").loc[[105.5]]) == 15 assert len(pvto_df["RS"].unique()) == 20 assert pvto_df["VOLUMEFACTOR"].max() == 2.851 assert pvto_df["VISCOSITY"].max() == 1.0001 dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(pvto_df)) pd.testing.assert_frame_equal(dframe_via_string, pvto_df) density_df = pvt.density_fromdeck(eclfiles.get_ecldeck()) assert "PVTNUM" in density_df assert "OILDENSITY" in density_df assert "WATERDENSITY" in density_df assert "GASDENSITY" in density_df assert len(density_df) == 1 assert density_df["WATERDENSITY"].values[0] == 999.04 dframe_via_string = pvt.density_fromdeck(pvt.df2ecl_density(density_df)) pd.testing.assert_frame_equal(dframe_via_string, density_df) rock_df = pvt.rock_fromdeck(eclfiles.get_ecldeck()) assert "PVTNUM" in rock_df assert len(rock_df) == 1 assert "PRESSURE" in rock_df assert "COMPRESSIBILITY" in rock_df assert rock_df["PRESSURE"].values[0] == 327.3 pvtw_df = pvt.pvtw_fromdeck(eclfiles.get_ecldeck()) assert "PVTNUM" in pvtw_df assert pvtw_df["PVTNUM"].values[0] == 1 assert len(pvtw_df) == 1 assert "PRESSURE" in pvtw_df assert "VOLUMEFACTOR" in pvtw_df assert "COMPRESSIBILITY" in pvtw_df assert "VISCOSITY" in pvtw_df assert "VISCOSIBILITY" in pvtw_df assert pvtw_df["VISCOSITY"].values[0] == 0.25 pvdg_df = pvt.pvdg_fromdeck(eclfiles.get_ecldeck()) assert "PVTNUM" in pvdg_df assert "PRESSURE" in pvdg_df assert "VOLUMEFACTOR" in pvdg_df assert "VISCOSITY" in pvdg_df assert len(pvdg_df["PVTNUM"].unique()) == 1 assert pvdg_df["PVTNUM"].max() == 1 assert len(pvdg_df) == 15
def test_pvto_strings(): """Test PVTO parsing from strings""" pvto_deck = """PVTO 0 1 1.0001 1 200 1.000 1.001 / 18 25 1.14 0.59 / / -- One table (pvtnum=1), two records (two gor's) """ dframe = pvt.pvto_fromdeck(EclFiles.str2deck(pvto_deck)) assert "PVTNUM" in dframe assert "RS" in dframe assert "PRESSURE" in dframe assert "VISCOSITY" in dframe assert "VOLUMEFACTOR" in dframe assert len(dframe) == 3 assert len(dframe["RS"].unique()) == 2 assert len(dframe["PRESSURE"].unique()) == 3 assert len(dframe["VOLUMEFACTOR"].unique()) == 3 assert len(dframe["VISCOSITY"].unique()) == 3 assert set(dframe["PVTNUM"].values) == {1} assert max(dframe["PRESSURE"]) == 200 dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe)) pd.testing.assert_frame_equal(dframe_via_string, dframe) # Provide TABDIMS in first test.. Infer later pvto_deck = """TABDIMS 1 2 / PVTO 0 1 1.0001 1 200 1.000 1.001 / 18 25 1.14 0.59 / / 1 2 1.0001 1 333 1.000 1.001 / 19 30 1.14 0.59 / / """ dframe = pvt.pvto_fromdeck(EclFiles.str2deck(pvto_deck)) assert len(dframe) == 6 assert "PVTNUM" in dframe assert set(dframe["PVTNUM"].astype(int).unique()) == {1, 2} assert len(dframe["RS"].unique()) == 4 assert len(dframe["PRESSURE"].unique()) == 6 assert len(dframe["VOLUMEFACTOR"].unique()) == 3 dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe)) pd.testing.assert_frame_equal(dframe_via_string, dframe) # Now test the same but without TABDIMS: pvto_deck = """ PVTO 0 1 1.0001 1 200 1.000 1.001 / 18 25 1.14 0.59 / / 1 2 1.0001 1 333 1.000 1.001 / 19 30 1.14 0.59 / / """ dframe = pvt.pvto_fromdeck(pvto_deck) assert len(dframe) == 6 assert "PVTNUM" in dframe assert set(dframe["PVTNUM"].astype(int).unique()) == {1, 2} assert len(dframe["RS"].unique()) == 4 assert len(dframe["PRESSURE"].unique()) == 6 assert len(dframe["VOLUMEFACTOR"].unique()) == 3 dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe)) pd.testing.assert_frame_equal(dframe_via_string, dframe) # Test emtpy data: inc = pvt.df2ecl_pvto(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty