Skip to content

Commit

Permalink
Refactor PyscalFactory (#448)
Browse files Browse the repository at this point in the history
* Refactor create_water_oil

* Code refactoring

* Merge update

* Fix ruff issue

* test deprecated api work and warnings are emitted

---------

Co-authored-by: Bartek Florczyk Vik (CCI RPT RES1) <[email protected]>
Co-authored-by: Bartek Florczyk Vik (CCI RPT RES1) <[email protected]>
  • Loading branch information
3 people authored Sep 2, 2024
1 parent 0b036ec commit a7c078d
Show file tree
Hide file tree
Showing 7 changed files with 1,340 additions and 1,188 deletions.
12 changes: 6 additions & 6 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ equivalent to the code lines above (except for capillary pressure) is then:

.. code-block:: python
from pyscal import PyscalFactory
from pyscal import create_water_oil
params = dict(swl=0.05, sorw=0.03, h=0.1, nw=2.1, krwend=0.6,
now=2.5, kroend=0.9, tag="Foobarites")
wo = PyscalFactory.create_water_oil(params)
wo = create_water_oil(params)
print(wo.SWOF())
Note that parameter names to factory functions are case *insensitive*, while
Expand Down Expand Up @@ -230,7 +230,7 @@ some of the saturation endpoints, as there are compatibility constraints. For
this reason, it is recommended to initialize both the ``WaterOil`` and
``GasOil`` objects trough a ``WaterOilGas`` object.

There is a corresponding ``PyscalFactory.create_gas_oil()`` support function with
There is a corresponding ``create_gas_oil()`` support function with
dictionary as argument.

For plotting, ``GasOil`` object has a function ``.plotkrgkrog()``.
Expand Down Expand Up @@ -305,9 +305,9 @@ the SCAL recommendation holds three GasWater objects, but works similarly.
from pyscal import SCALrecommendation, PyscalFactory
low = PyscalFactory.create_water_oil_gas(dict(nw=1, now=1, ng=1, nog=1, tag='low'))
base = PyscalFactory.create_water_oil_gas(dict(nw=2, now=2, ng=2, nog=3, tag='base'))
high = PyscalFactory.create_water_oil_gas(dict(nw=3, now=3, ng=3, nog=3, tag='high'))
low = create_water_oil_gas(dict(nw=1, now=1, ng=1, nog=1, tag='low'))
base = create_water_oil_gas(dict(nw=2, now=2, ng=2, nog=3, tag='base'))
high = create_water_oil_gas(dict(nw=3, now=3, ng=3, nog=3, tag='high'))
rec = SCALrecommendation(low, base, high)
interpolant = rec.interpolate(-0.4)
Expand Down
1,823 changes: 976 additions & 847 deletions src/pyscal/factory.py

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions src/pyscal/pyscalcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
getLogger_pyscal,
plotting,
)

from .factory import PyscalFactory
from pyscal.factory import (
create_pyscal_list,
create_scal_recommendation_list,
load_relperm_df,
)

EPILOG = """
The parameter file should contain a table with at least the column
Expand Down Expand Up @@ -258,9 +261,7 @@ def pyscal_main(
__name__, {"debug": debug, "verbose": verbose, "output": output}
)

parametertable = PyscalFactory.load_relperm_df(
parametertable, sheet_name=sheet_name
)
parametertable = load_relperm_df(parametertable, sheet_name=sheet_name)

assert isinstance(parametertable, pd.DataFrame)
logger.debug("Input data:\n%s", parametertable.to_string(index=False))
Expand All @@ -282,9 +283,7 @@ def pyscal_main(
# Then we should do interpolation
if int_param_wo is None:
raise ValueError("No interpolation parameters provided")
scalrec_list = PyscalFactory.create_scal_recommendation_list(
parametertable, h=delta_s
)
scalrec_list = create_scal_recommendation_list(parametertable, h=delta_s)
assert isinstance(scalrec_list[1], SCALrecommendation)
if scalrec_list[1].type == WaterOilGas:
logger.info(
Expand All @@ -300,7 +299,7 @@ def pyscal_main(
)
wog_list = scalrec_list.interpolate(int_param_wo, None, h=delta_s)
else:
wog_list = PyscalFactory.create_pyscal_list(
wog_list = create_pyscal_list(
parametertable, h=delta_s
) # can be both water-oil, water-oil-gas, or gas-water

Expand Down
Loading

0 comments on commit a7c078d

Please sign in to comment.