{"id":29109665,"url":"https://github.com/sintefmath/pyjutuldarcy","last_synced_at":"2025-06-29T07:04:40.051Z","repository":{"id":287405853,"uuid":"964496445","full_name":"sintefmath/PyJutulDarcy","owner":"sintefmath","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-11T14:14:33.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-11T15:30:34.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sintefmath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-11T09:57:15.000Z","updated_at":"2025-04-11T14:14:37.000Z","dependencies_parsed_at":"2025-04-11T15:40:47.249Z","dependency_job_id":null,"html_url":"https://github.com/sintefmath/PyJutulDarcy","commit_stats":null,"previous_names":["sintefmath/pyjutuldarcy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sintefmath/PyJutulDarcy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintefmath%2FPyJutulDarcy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintefmath%2FPyJutulDarcy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintefmath%2FPyJutulDarcy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintefmath%2FPyJutulDarcy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sintefmath","download_url":"https://codeload.github.com/sintefmath/PyJutulDarcy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintefmath%2FPyJutulDarcy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262553202,"owners_count":23327588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-29T07:04:17.244Z","updated_at":"2025-06-29T07:04:40.037Z","avatar_url":"https://github.com/sintefmath.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyJutulDarcy\n\nPython wrapper for [JutulDarcy.jl, a fully differentiable reservoir simulator written in Julia](https://github.com/sintefmath/JutulDarcy.jl). Key features:\n\n- Immiscible, black-oil and compositional multiphase flow\n- Geothermal simulation and simulation of CO2 sequestration\n- Can read standard input files and corner-point grids, or make your own\n\nThis package facilitates automatic installation of JutulDarcy from Python, as well as a minimal interface that allows fast simulation of .DATA files in pure Python. For more details about JutulDarcy.jl, please see the [Julia Documentation](https://sintefmath.github.io/JutulDarcy.jl/dev/). If you want to run MPI or CUDA accelerated simulations we recommend working either in Julia or the [standalone compiled version](https://github.com/sintefmath/JutulDarcyApps.jl).\n\nThe package also provides access to all the functions of the Julia version under `jutuldarcy.jl.JutulDarcy`, `jutuldarcy.jl.GeoEnergyIO` and `jutuldarcy.jl.Jutul`. These functions are directly wrapped using [JuliaCall](https://github.com/JuliaPy/PythonCall.jl). For more details, see the [JuliaCall Documentation on converting of types](https://juliapy.github.io/PythonCall.jl/stable/conversion-to-julia/).\n\n## Installation\n\nThe package can be installed with pip:\n\n```julia\npip install jutuldarcy\n```\n\nOn first time usage of the package [JuliaCall](https://github.com/JuliaPy/PythonCall.jl) will automatically install Julia and manage all dependency packages.\n\n### Activating plotting\n\nThere is highly experimental support for 3D and 2D visualization. To enable, you can either add `GLMakie` to your environment manually, or run the following:\n\n```python\nimport jutuldarcy as jd\njd.install_plotting()\n```\n\nNote that this requires that you are running in an environment that supports plotting (OpenGL capable, i.e. not at a SSH remote without forwarding).\n\n## Examples\n\nCopies of these examples can be found in the `examples` directory.\n\n### A minimal example: Running a benchmark file\n\n```python\nimport jutuldarcy as jd\n# Load SPE9 dataset to disk\npth = jd.test_file_path(\"SPE9\", \"SPE9.DATA\")\n# Simulate the model and convert to Python dicts\nres = jd.simulate_data_file(pth, convert = True)\n# Get field quantities and plot\nimport matplotlib.pyplot as plt\nfopr = res[\"FIELD\"][\"FOPR\"]\ndays = res[\"DAYS\"]\nplt.plot(days, fopr)\nplt.ylabel(\"Field oil production\")\nplt.xlabel(\"Days\")\nplt.show()\n```\n\n\u003cimg width=\"299\" alt=\"pyplot_fopr\" src=\"https://github.com/user-attachments/assets/9b69bdee-91d9-4b37-ba20-05725f224cd9\" /\u003e\n\nHere, res is a standard dict containing the following fields:\n\n- \"FIELD\": Field quantities (average pressure, total water injection, etc) as numpy arrays.\n- \"WELLS\": Well quantities (bottom hole pressures, injection rates, production rates, etc)\n- \"STATES\": Reservoir states for all active cells, given as a list with a dict for each timestep. For example, `res[\"STATES\"][10][\"Rs\"]` will give you an array of the solution gas-oil-ratio at step 10.\n- \"DAYS\": Array of the number of days elapsed for each step.\n\nOptionally, if the keyword argument `convert` to `simulate_data_file` is set to `False` or left defaulted, the \"full\" output as seen in Julia will be returned, where it is possible to get access to grid geometry, model parameters, and so on.\n\n### Setting up a simulation without input file\n\nThis example is a port of [the first JutulDarcy.jl documentation example](https://sintefmath.github.io/JutulDarcy.jl/dev/man/first_ex). If you want to understand a bit more about what is going on, please refer to that page.\n\nNote that only a subset of the full set of routines are available directly in the wrapper. PRs that add more wrapping functionality is welcome.\n\n```python\nimport jutuldarcy as jd\nimport numpy as np\n# Grab some unit conversion factors\nday = jd.si_unit(\"day\")\nDarcy = jd.si_unit(\"darcy\")\nkg = jd.si_unit(\"kilogram\")\nmeter = jd.si_unit(\"meter\")\nbar = jd.si_unit(\"bar\")\n# Set up mesh\nnx = ny = 25\nnz = 10\ncart_dims = (nx, ny, nz)\nphysical_dims = (1000.0*meter, 1000.0*meter, 100.0*meter)\ng = jd.CartesianMesh(cart_dims, physical_dims)\n# Convert to unstructured representation\ng = jd.UnstructuredMesh(g)\ndomain = jd.reservoir_domain(g, permeability = 0.3*Darcy, porosity = 0.2)\nInjector = jd.setup_vertical_well(domain, 1, 1, name = \"Injector\")\nProducer = jd.setup_well(domain, (nx, ny, 1), name = \"Producer\")\n# Show the properties in the domain\nphases = (jd.LiquidPhase(), jd.VaporPhase())\nrhoLS = 1000.0*kg/meter**3\nrhoGS = 100.0*kg/meter**3\nreference_densities = [rhoLS, rhoGS]\nsys = jd.ImmiscibleSystem(phases, reference_densities = reference_densities)\nmodel, parameters = jd.setup_reservoir_model(domain, sys, wells = [Injector, Producer])\n# Replace dynamic functions with custom ones\nc = np.array([1e-6/bar, 1e-4/bar])\ndensity = jd.jl.ConstantCompressibilityDensities(\n    p_ref = 100*bar,\n    density_ref = reference_densities,\n    compressibility = c\n)\nkr = jd.jl.BrooksCoreyRelativePermeabilities(sys, np.array([2.0, 3.0]))\njd.replace_variables(model, PhaseMassDensities = density, RelativePermeabilities = kr)\n# Set the initial conditions\nstate0 = jd.setup_reservoir_state(model,\n    Pressure = 120*bar,\n    Saturations = np.array([1.0, 0.0])\n)\n# Set up reporting steps\nnstep = 25\ndt = np.repeat(365.0*day, nstep)\n# Set up timestepping and well controls\npv = jd.pore_volume(model, parameters)\ninj_rate = 1.5*np.sum(pv)/sum(dt)\nI_ctrl = jd.setup_injector_control(inj_rate, \"rate\", np.array([0.0, 1.0]), density = rhoGS)\nP_ctrl = jd.setup_producer_control(100*bar, \"bhp\")\ncontrols = dict(Injector = I_ctrl, Producer = P_ctrl)\nforces = jd.setup_reservoir_forces(model, control = controls)\nresult = jd.simulate_reservoir(state0, model, dt, parameters = parameters, forces = forces)\n```\n\n#### Converting to Python dict\n\nWe can convert the result into a standard `dict` with `numpy` array types:\n\n```python\ncase = jd.setup_jutul_case(state0, model, dt, forces, parameters)\nres_py = jd.convert_to_pydict(result, case, units = \"field\")\n```\n\n#### Plotting results (experimental)\n\nWe can also plot the results if the plotting has been installed:\n\n```python\nplt = jd.plot_reservoir(model, result.states)\njd.make_interactive()\n```\n\u003cimg width=\"790\" alt=\"front\" src=\"https://github.com/user-attachments/assets/8b7f1f99-131d-4275-8290-51813ba96b43\" /\u003e\n\n## Paper and citing\n\nThe main paper describing `JutulDarcy.jl` is *JutulDarcy.jl - a Fully Differentiable High-Performance Reservoir Simulator Based on Automatic Differentiation*:\n\n```bibtex\n@article{jutuldarcy_ecmor_2024,\n   author = \"M{\\o}yner, O.\",\n   title = \"JutulDarcy.jl - a Fully Differentiable High-Performance Reservoir Simulator Based on Automatic Differentiation\", \n   year = \"2024\",\n   volume = \"2024\",\n   number = \"1\",\n   pages = \"1-9\",\n   doi = \"https://doi.org/10.3997/2214-4609.202437111\",\n   publisher = \"European Association of Geoscientists \\\u0026 Engineers\",\n   issn = \"2214-4609\",\n}\n```\n\n## Contributing\n\nContributions that expose additional functionality is welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsintefmath%2Fpyjutuldarcy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsintefmath%2Fpyjutuldarcy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsintefmath%2Fpyjutuldarcy/lists"}