Package: welleng
wellengwellengaspires to be a collection of useful tools for Wells/Drilling Engineers, kicking off with a range of well trajectory tools.Generate survey listings and interpolation with minimum curvatureCalculate well bore uncertainty data (utilizing either theISCWSAMWD Rev5 models) - the coded error models are within 0.001% accuracy of the ISCWSA test data.Calculate well bore clearance and Separation Factors (SF)standardISCWSAmethod within 0.5% accuracy of the ISCWSA test data.new mesh based method using theFlexible Collision Library.Support wellengwelleng is fuelled by copious amounts of coffee, so if you wish to supercharge development please donate generously:DocumentationIt's still very much in beta (or maybe even alpha), but there'sdocumentationavailable to help use the modules.New Features!Documentation:started to adddocumentationto try and make the library more accessible to starters.Maximum Curvature Method:added an alternativeSurveymethod for calculating a well trajectory from survey stations that add a more realistic (in terms of tortuosity) versus the traditionalminimum curvature method. Seethis postfor more details.Modified Tortuosity Index:added aSurveymethod for calculating amodified tortuosity indexas describedhere.Panel Plot:added thetype='panel'to theSurvey.figure()method to return plan and section plots.Torque and Drag:added a simpletorque_dragmodule and anarchitecturemodule for creating scenarios (well bore and simple strings) - see thispostfor instructions.Vertical Section:this should have been included a long time ago, but finally a vertical section will be calculated if thevertical_section_azimuthparameter is included in theSurveyHeaderwhen initiating aSurveyinstance. Otherwise, to return the vertical section for a given azimuth (e.g. 45 degrees), or to set the vertical section azimuth and add the vertical section data to theSurveythen:survey.get_vertical_section(45)survey.set_vertical_section(45)Hello version 0.4:major version update to reflect all of the changes happening in the back end. If you have code that's built on previous versions ofwellengthen please lock that version in your env since likely it will require modifying to run with version 0.4 and higher.Project Ahead:you can now project a survey from the last station to the bit or project to a target to see how to get back on track:>>> node_bit = survey.project_to_bit(delta_md=9.0)
>>> survey_to_target = survey.project_to_target(node_target, dls_design=3.0, delta_md=9.0)Interpolate Survey on TVD Depth:newsurveyfunction for interpolating fixed TVD intervals along awellengSurveyinstance, e.g. to interpolatesurveyevery 10mTVD and return the interpolated survey ass_interp_tvd:>>> s_interp_tvd = survey.interpolate_survey_tvd(step=10)OWSG Tool Error Models:the ISCWSA curated Rev 4 and Rev 5 tool models have been coded up and continue to honor the ISCWSA diagnostic data. The OWSG tool errors areexperimentalwith the following status:Working: MWD, SRGM, _Fl, SAG, IFR1, IFR2, EMSNot Currently Working Correctly: AX, GYROThe available error models can be listed with the following command:>>> welleng.errors.ERROR_MODELSWorld Magnetic Model Calculator:calculates magnetic field data from theWorld Magnetic Modelif magnetic field strength is not provided with the survey data.Import from Landmark .wbp files:using theexchange.wbpmodule it's now possible to import .wbp files exported from Landmark's COMPASS or DecisionSpace software.importwellengaswewp=we.exchange.wbp.load("demo.wbp")# import filesurvey=we.exchange.wbp.wbp_to_survey(wp,step=30)# convert to surveymesh=we.mesh.WellMesh(survey,method='circle')# convert to meshwe.visual.plot(mesh.mesh)# plot the meshExport to .wbp files(experimental):using theexchange.wbpmodule, it's possible to convert a planned survey file into a list of turn points that can be exported to a .wbp file.importwellengaswewp=we.exchange.wbp.WellPlan(survey)# convert Survey to WellPlan objectdoc=we.exchange.wbp.export(wp)# create a .wbp documentwe.exchange.wbp.save_to_file(doc,"demo.wbp")# save the document to fileWell Path Creation:the addition of theconnectormodule enables drilling well paths to be created simply by providing start and end locations (with some vector data like inclination and azimuth). No need to indicatehowto connect the points, the module will figure that out itself.Fast visualization of well trajectory meshes:addition of thevisualmodule for quick and simple viewing and QAQC of well meshes.Mesh Based Collision Detection:the current method for determining the Separation Factor between wells is constrained by the frequency and location of survey stations or necessitates interpolation of survey stations in order to determine if Anti-Collision Rules have been violated. Meshing the well bore interpolates between survey stations and as such is a more reliable method for identifying potential well bore collisions, especially wth more sparse data sets.More coming soon!Techwellenguses a number of open source projects to work properly:trimesh- awesome library for loading and using triangular meshes.Flexible Collision Library- for fast collision detection.numpy- the fundamental package for scientific computing with Python.scipy- a Python-based ecosystem of open-source software for mathematics, science, and engineering.vedo- a python module for scientific visualization, analysis of 3D objects and point clouds based on VTK.magnetic-field-calculator- a Python API for the British Geological Survey magnetic field calculator.Simple InstallationA default, minimalwellenginstallation requiresnumpyandscipywhich is sufficient for importing or generating trajectories with error models. Other libraries are optional depending on usage - most ofwelleng's functionality can be unlocked with theeasyinstall tag, but if you wish to use mesh collision functionality, then an advanced install is required using theallinstall tag to getpython-fcl, after first installing the compiled dependencies as described below.You'll receive someImportErrormessages 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 wellengEasy install with most of the dependencies and no compiled dependencies:pip install welleng[easy]Advanced InstallationIf you want to use the mesh collision detection method, then the compiled dependencies are required prior to installing all of thewellengdependencies.UbuntuHere's how to get the trickier dependencies manually installed on Ubuntu (further instructions can be foundhere):sudo apt-get update
sudo apt-get install libeigen3-dev libccd-dev octomap-toolsOn 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 (thedevbranch is usuall a version or two ahead of themain).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.WindowsDetailed instructions for installingwellengin a Windows OS can be found in thispost.ColaboratoryPerhaps the simplest way of getting up and running withwellengis to with acolab notebook. The required dependencies can be installed with the following cell:!apt-getinstall-yxvfbx11-utilslibeigen3-devlibccd-devoctomap-tools!pipinstallwelleng[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, thewellengengine can be used to generate data in the notebook. Test it out with the following code:!pipinstallplotlyjupyter-dashpint!pipinstall-Ugit+https://github.com/Kitware/ipyvtk-simple.gitimportwellengasweimportplotly.graph_objectsasgofromjupyter_dashimportJupyterDash# create a surveys=we.survey.Survey(md=[0.,500.,2000.,5000.],inc=[0.,0.,30.,90],azi=[0.,0.,30.,90.])# interpolate survey - generate points every 30 meterss_interp=s.interpolate_survey(step=30)# plot the resultsfig=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 StartHere's an example usingwellengto construct a couple of simple well trajectories with theconnectormodule, 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.importwellengaswefromtabulateimporttabulate# construct simple well pathsprint("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 covariancesprint("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 pathsprint("Generating well meshes...")mesh_reference=we.mesh.WellMesh(survey_reference)mesh_offset=we.mesh.WellMesh(survey_offset)# determine clearancesprint("Setting up clearance models...")c=we.clearance.Clearance(survey_reference,survey_offset)print("Calculating ISCWSA clearance...")clearance_ISCWSA=we.clearance.ISCWSA(c)print("Calculating mesh clearance...")clearance_mesh=we.clearance.MeshClearance(c,sigma=2.445)# tabulate the Separation Factor results and print themresults=[[md,sf0,sf1]formd,sf0,sf1inzip(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 wellslines=we.visual.get_lines(clearance_mesh)# plot the resultwe.visual.plot([mesh_reference.mesh,mesh_offset.mesh],# list of meshesnames=['reference','offset'],# list of namescolors=['red','blue'],# list of colorslines=lines)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.For more examples, including how to build a well trajectory by joining up a series of sections created with thewelleng.connectormodule (see pic below), check out theexamplesand follow thejonnymaseratiblog.Well trajectory generated bybuild_a_well_from_sections.pyTodosAdd aTargetclass to see what you're aiming for -in progressDocumentation -in progressGenerate a scene of offset wells to enable fast screening of collision risks (e.g. hundreds of wells in seconds)WebApp for those that just want answersAdd aunitsmodule to handle any units system -in progressIt's possible to generate data for visualizing well trajectories withwelleng, as can be seen with the rendered scenes below.ISCWSA Standard Set of Well PathsThe ISCWSA standard set of well paths for evaluating clearance scenarios have been rendered inblenderabove. See theexamplesfor the code used to generate avolvescene, extracting the data from thevolveEDM.xml file.LicenseApache 2.0Please 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 withjonnycorcutt, but the intent of this library is to assist development.