Skip to content

Commit

Permalink
Fix issues related to vfp df2res
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe committed Jan 24, 2024
1 parent fdf25e4 commit 5f4c4f0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ res2df/version.py
.\#*
venv*
build
kenv*
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": [],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
5 changes: 1 addition & 4 deletions res2df/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ def comment_formatter(multiline: Optional[str], prefix: str = "-- ") -> str:
"""
if multiline is None or not multiline.strip():
return ""
return (
"\n".join([prefix + line.strip() for line in multiline.splitlines()]).strip()
+ "\n"
)
return "\n".join([prefix + line for line in multiline.splitlines()]) + "\n"


def handle_wanted_keywords(
Expand Down
2 changes: 1 addition & 1 deletion res2df/vfp/_vfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def df2res(

if filename:
with open(filename, "w") as fout:
fout.write(str_vfp)
fout.write(str_vfps)

return str_vfps

Expand Down
2 changes: 2 additions & 0 deletions res2df/vfp/_vfpcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ def _write_vfp_range(
deck_str += format % value
if (i + 1) % values_per_line == 0 and i < len(values) - 1:
deck_str += "\n"
else:
deck_str += " "
deck_str += " /\n"
deck_str += "\n"

Expand Down
4 changes: 3 additions & 1 deletion res2df/vfp/_vfpinj.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,13 @@ def _write_table_records(
if (n + 1) % values_per_line == 0:
if n < no_flow_values - 1:
deck_str += "\n"
deck_str += " " * 2
deck_str += " " * 11
else:
deck_str += "\n"
elif n == no_flow_values - 1:
deck_str += "\n"
else:
deck_str += " "

deck_str += "/\n"

Expand Down
4 changes: 3 additions & 1 deletion res2df/vfp/_vfpprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def _write_table_records(
gfr_indices: np.ndarray,
alq_indices: np.ndarray,
table: np.ndarray,
format: str = "%10.3",
format: str = "%10.6g",
values_per_line: int = 5,
) -> str:
"""Creates a :term:`include file` content string representing a
Expand Down Expand Up @@ -931,6 +931,8 @@ def _write_table_records(
deck_str += "\n"
elif n == no_flow_values - 1:
deck_str += "\n"
else:
deck_str += " "

deck_str += "/\n"

Expand Down
34 changes: 17 additions & 17 deletions tests/test_vfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,35 @@
+ """METRIC BHP /
-- GAS units - sm3/day ( 3 values )
50000 500000 5e+06 /
50000 500000 5e+06 /
-- THP units - barsa ( 2 values )
40 100 /
40 100 /
-- WGR units - sm3/sm3 ( 2 values )
0 1e-05 /
0 1e-05 /
-- GOR units - sm3/sm3 ( 2 values )
500 4000 /
500 4000 /
-- '' units - ( 1 values )
0 /
0 /
1 1 1 1 160.11 130.21 180.31
1 1 1 1 160.11 130.21 180.31
/
1 1 2 1 140.12 110.22 160.32
1 1 2 1 140.12 110.22 160.32
/
1 2 1 1 165.13 135.23 185.33
1 2 1 1 165.13 135.23 185.33
/
1 2 2 1 145.14 115.24 165.34
1 2 2 1 145.14 115.24 165.34
/
2 1 1 1 240.15 210.25 260.35
2 1 1 1 240.15 210.25 260.35
/
2 1 2 1 220.16 190.26 240.36
2 1 2 1 220.16 190.26 240.36
/
2 2 1 1 245.17 215.27 265.37
2 2 1 1 245.17 215.27 265.37
/
2 2 2 1 225.18 195.28 245.38
2 2 2 1 225.18 195.28 245.38
/
""",
pd.DataFrame(
Expand Down Expand Up @@ -614,14 +614,14 @@
3 3200.0 GAS THP METRIC BHP /
-- GAS units - sm3/day ( 3 values )
50000 500000 5e+06 /
50000 500000 5e+06 /
-- THP units - barsa ( 2 values )
100 200 /
100 200 /
1 180.11 170.21 150.31
1 180.11 170.21 150.31
/
2 270.12 260.22 240.32
2 270.12 260.22 240.32
/
""",
pd.DataFrame(
Expand Down

0 comments on commit 5f4c4f0

Please sign in to comment.