Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vfp] Fix issue related to df2res #478

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 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