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

feature: Enable use in docker/julia #3

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[deps]
CSP11 = "48eaa45b-cddd-4e20-968f-8db8a6d464dd"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GeoEnergyIO = "3b1dd628-313a-45bb-9d8d-8f3c48dcb5d4"
HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771"
Jutul = "2b460a1a-8a2b-45b2-b125-b5c536396eb9"
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,25 @@ You can now run the example:
```julia
include("run_mrst_grid_spe11.jl")
```

## Running in docker

To run it inside a [Docker](https://docs.docker.com/desktop/) image, either build the image described uner _docker/jutul-spe11csp-juliaimg.Dockerfile_ or pull it from public [docker repository](https://hub.docker.com)

```bash
docker build --build-arg VERSION=v0 -t jutul-juliaimg-spe11csp -f jutul-spe11csp-juliaimg.Dockerfile .
```

or

```bash
docker push jafranc/jutul-juliaimg-spe11csp:latest
```

Then you can run it

```bash
docker run -it --rm -v /path/to/output:/tmp image_name julia -e "import Pkg;Pkg.add([\"Jutul\",\"JutulDarcy\",\"HYPRE\"]);Pkg.develop(path=\"/opt/spe11csp/CSP11\");include(\"docker_run_mrst_grid_spe11.jl\")"
```

where _image_name_ is to be replaced either by name taken during local build step (suggested above _jutul-juliaimg-spe11csp_) or by pulled image name _jafranc/jutul-juliaimg-spe11csp_. _/path/to/output_ to be replaced by the path to a local folder. Note that generated results will be root-owned as per vanilla docker logic.
29 changes: 29 additions & 0 deletions docker/jutul-spe11csp-juliaimg.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG VERSION


FROM julia:${VERSION} AS system_stage

ARG SPE11_DIR=/opt/spe11csp

RUN apt update
RUN apt install -y git git-lfs
RUN apt install -y openssh-server ca-certificates vim

FROM system_stage AS spe11csp_stage

#ENV SPE_CASE=a
#ENV INPUT_PATH=/opt/spe11csp/examples/
#ENV CASEFILE=csp11${SPE_CASE}

#RUN apt install -y python3 python3-venv python3-pip git
RUN git clone https://github.com/jafranc/CSP11_JutulDarcy.jl -b feat/docker ${SPE11_DIR}

WORKDIR ${SPE11_DIR}
RUN git-lfs install
RUN git-lfs pull

#RUN julia --project=${SPE11_DIR} \
# -e "import Pkg; Pkg.develop(path=\"${SPE11_DIR}/CSP11\");Pkg.instantiate();"

#CMD ["julia","--project=\".\"" ,"-e", "\"import Pkg;Pkg.instantiate();Pkg.add([\"Jutul\",\"JutulDarcy\",\"HYPRE\"]);Pkg.develop(path=./CSP11);include(\"docker_run_mrst_grid_spe11.jl\");\""]
#CMD ["sh", "-c", "/usr/local/bin/pyopmcsp11 -i /opt/spe11csp/examples/csp11${SPE_CASE}.txt -o output_csp11${SPE_CASE}"]
34 changes: 34 additions & 0 deletions docker_run_mrst_grid_spe11.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Jutul, JutulDarcy, HYPRE, CSP11

basename = "cPEBI_2640x380"; specase = :b
basename = "cPEBI_819x117"; specase = :b
basename = "horizon-cut_100x50"; specase = :b

kg = :tpfa

case, name = setup_spe11_case_from_mrst_grid(basename, case = specase, thermal = true, nstep_initialization = 0, use_reporting_steps = false, kgrad = kg);
pth = jutul_output_path(name, subfolder = "csp11")
domain = reservoir_domain(case.model)

hook, csv_pth, f = CSP11.get_reporting_hook(pth, domain);
sim, config = setup_reservoir_simulator(case,
output_path = pth,
max_timestep = 1*si_unit(:year),
report_level = 0,
tol_cnv = 0.01,
nonlinear_tolerance = Inf,
post_ministep_hook = hook,
relaxation = SimpleRelaxation(),
max_nonlinear_iterations = 20,
max_timestep_cuts = 100,
target_ds = 0.1,
info_level = 3
);
##
res = simulate_reservoir(case,
simulator = sim,
config = config,
);
ws, states = res;