jonnymaserati / welleng

A collection of Wells/Drilling Engineering tools, focused on well trajectory planning for the time being.
Apache License 2.0
113 stars 31 forks source link
directional-drilling drilling drilling-engineering engineering error-model survey survey-listings survey-stations uncertainty wbp well-design well-engineering wellbore

welleng

Open Source Love svg2 PyPI version Downloads License welleng-tests Actions Status

welleng aspires to be a collection of useful tools for Wells/Drilling Engineers, kicking off with a range of well trajectory tools.

Support welleng

welleng is fuelled by copious amounts of coffee, so if you wish to supercharge development please donate generously:

Buy Me A Coffee

Documentation

It's still very much in beta (or maybe even alpha), but there's documentation available to help use the modules.

New Features!

Tech

welleng uses a number of open source projects to work properly:

Simple Installation

A default, minimal welleng installation requires numpy and scipy which is sufficient for importing or generating trajectories with error models. Other libraries are optional depending on usage - most of welleng's functionality can be unlocked with the easy install tag, but if you wish to use mesh collision functionality, then an advanced install is required using the all install tag to get python-fcl, after first installing the compiled dependencies as described below.

You'll receive some ImportError messages and a suggested install tag if you try to use functions for which the required dependencies are missing.

Default install with minimal dependencies:

pip install welleng

Easy install with most of the dependencies and no compiled dependencies:

pip install welleng[easy]

Advanced Installation

If you want to use the mesh collision detection method, then the compiled dependencies are required prior to installing all of the welleng dependencies.

Ubuntu

Here's how to get the trickier dependencies manually installed on Ubuntu (further instructions can be found here):

sudo apt-get update
sudo apt-get install libeigen3-dev libccd-dev octomap-tools

On a Mac you should be able to install the above with brew and on a Windows machine you'll probably have to build these libraries following the instruction in the link, but it's not too tricky. Once the above are installed, then it should be a simple:

pip install welleng[all]

For developers, the repository can be cloned and locally installed in your GitHub directory via your preferred Python env (the dev branch is usuall a version or two ahead of the main).

git clone https://github.com/jonnymaserati/welleng.git
cd welleng
pip install -e .[all]

Make sure you include that . in the final line (it's not a typo) as this ensures that any changes to your development version are immediately implemented on save.

Windows

Detailed instructions for installing welleng in a Windows OS can be found in this post.

Colaboratory

Perhaps the simplest way of getting up and running with welleng is to with a colab notebook. The required dependencies can be installed with the following cell:

!apt-get install -y xvfb x11-utils libeigen3-dev libccd-dev octomap-tools
!pip install welleng[all]

Unfortunately the visualization doesn't work with colab (or rather I've not been able to embed a VTK object) so some further work is needed to view the results. However, the welleng engine can be used to generate data in the notebook. Test it out with the following code:

!pip install plotly jupyter-dash pint
!pip install -U git+https://github.com/Kitware/ipyvtk-simple.git

import welleng as we
import plotly.graph_objects as go
from jupyter_dash import JupyterDash

# create a survey
s = we.survey.Survey(
    md=[0., 500., 2000., 5000.],
    inc=[0., 0., 30., 90],
    azi=[0., 0., 30., 90.]
)

# interpolate survey - generate points every 30 meters
s_interp = s.interpolate_survey(step=30)

# plot the results
fig = go.Figure()
fig.add_trace(
    go.Scatter3d(
        x=s_interp.x,
        y=s_interp.y,
        z=s_interp.z,
        mode='lines',
        line=dict(
            color='blue'
        ),
        name='survey_interpolated'
    ),
)

fig.add_trace(
    go.Scatter3d(
        x=s.x,
        y=s.y,
        z=s.z,
        mode='markers',
        marker=dict(
            color='red'
        ),
        name='survey'
    )
)
fig.update_scenes(zaxis_autorange="reversed")
fig.show()

Quick Start

Here's an example using welleng to construct a couple of simple well trajectories with the connector module, creating survey listings for the wells with well bore uncertainty data, using these surveys to create well bore meshes and finally printing the results and plotting the meshes with the closest lines and SF data.

import welleng as we
from tabulate import tabulate

# construct simple well paths
print("Constructing wells...")
connector_reference = we.survey.from_connections(
    we.connector.Connector(
        pos1=[0., 0., 0.],
        inc1=0.,
        azi1=0.,
        pos2=[-100., 0., 2000.],
        inc2=90,
        azi2=60,
    ),
    step=50
)

connector_offset = we.survey.from_connections(
    we.connector.Connector(
        pos1=[0., 0., 0.],
        inc1=0.,
        azi1=225.,
        pos2=[-280., -600., 2000.],
        inc2=90.,
        azi2=270.,
    ),
    step=50
)

# make survey objects and calculate the uncertainty covariances
print("Making surveys...")
sh_reference = we.survey.SurveyHeader(
    name="reference",
    azi_reference="grid"
)
survey_reference = we.survey.Survey(
    md=connector_reference.md,
    inc=connector_reference.inc_deg,
    azi=connector_reference.azi_grid_deg,
    header=sh_reference,
    error_model='ISCWSA MWD Rev4'
)
sh_offset = we.survey.SurveyHeader(
    name="offset",
    azi_reference="grid"
)
survey_offset = we.survey.Survey(
    md=connector_offset.md,
    inc=connector_offset.inc_deg,
    azi=connector_offset.azi_grid_deg,
    start_nev=[100., 200., 0.],
    header=sh_offset,
    error_model='ISCWSA MWD Rev4'
)

# generate mesh objects of the well paths
print("Generating well meshes...")
mesh_reference = we.mesh.WellMesh(
    survey_reference
)
mesh_offset = we.mesh.WellMesh(
    survey_offset
)

# determine clearances
print("Setting up clearance models...")
c = we.clearance.Clearance(
    survey_reference,
    survey_offset
)

print("Calculating ISCWSA clearance...")
clearance_ISCWSA = we.clearance.IscwsaClearance(
    survey_reference, survey_offset
)

print("Calculating mesh clearance...")
clearance_mesh = we.clearance.MeshClearance(
    survey_reference, survey_offset, sigma=2.445
)

# tabulate the Separation Factor results and print them
results = [
    [md, sf0, sf1]
    for md, sf0, sf1
    in zip(c.reference.md, clearance_ISCWSA.sf, clearance_mesh.sf)
]

print("RESULTS\n-------")
print(tabulate(results, headers=['md', 'SF_ISCWSA', 'SF_MESH']))

# get closest lines between wells
lines = we.visual.get_lines(clearance_mesh)

# plot the result
plot = we.visual.Plotter()
plot.add(mesh_reference, c='red')
plot.add(mesh_offset, c='blue')
plot.add(lines)
plot.show()
plot.close()

print("Done!")

This results in a quick, interactive visualization of the well meshes that's great for QAQC. What's interesting about these results is that the ISCWSA method does not explicitly detect a collision in this scenario wheras the mesh method does.

image

For more examples, including how to build a well trajectory by joining up a series of sections created with the welleng.connector module (see pic below), check out the examples and follow the jonnymaserati blog.

image

Well trajectory generated by build_a_well_from_sections.py

Todos

It's possible to generate data for visualizing well trajectories with welleng, as can be seen with the rendered scenes below. image ISCWSA Standard Set of Well Paths

The ISCWSA standard set of well paths for evaluating clearance scenarios have been rendered in blender above. See the examples for the code used to generate a volve scene, extracting the data from the volve EDM.xml file.

License

Apache 2.0

Please note the terms of the license. Although this software endeavors to be accurate, it should not be used as is for real wells. If you want a production version or wish to develop this software for a particular application, then please get in touch with jonnycorcutt, but the intent of this library is to assist development.