DrillPyze package

Module contents

An accelerated drillstring dynamics simulator and estimator for a fully coupled axial-torsional drillstring with bit-rock interaction.

Submodules

DrillPyze.drillstring module

A class describing a bottom hole assembly (BHA) and a drillstring for a typical rotary deep drilling system.

The BHA description may be loaded from a file in either xls or csv format.

class DrillPyze.drillstring.BHA(name, filename)

Bases: object

A class describing a bottom hole assembly with the ability to discretize the string

discretize(dx, bit_depth)

Discretize the drillstring into compoments of maximum length dx. Not all components will be the same length

Parameters

dxfloat

Maximal spacial discretization length

bit_depthfloat

Desired length of the drillstring

DrillPyze.dynamics module

A module that contains the simulation class and associated functions to enable simulation of a coupled axial-torsional drillstring model with a choice of bit-rock interaction models.

The estimation class is used to estimate the bit-rock interaction model parameters.

class DrillPyze.dynamics.Estimator(num_instances, wellbore, bha)

Bases: object

A class to maintain and update an ensemble based estimation technique

increment(time, TD_SETPOINT=0, TD_ACT=0)

Increment the simulations with a certain topdrive rpm and recorded top drive torque. The simulations simulate forward at the topdrive rpm and then update their estimation assuming the topdrive torque is measured at the end of the simulation increment.

The simulation pool is then sorted by smallest error and all simulations are cloned to be equal to the best simulation.

Parameters

timefloat

Number of seconds to step the simulations forward

TD_SETPOINTfloat

Top drive rpm setpoint. Default is 0

TD_ACTfloat

Top drive actual torque. Default is 0

initialize(bit_depth, sim_length, estimate_freq)

Initialize the simulations to the same start point

Parameters

bit_depthfloat

Current bit depth

sim_lengthint

Number of seconds to simulate

estimate_freqfloat

Frequency (in Hz) of available data

class DrillPyze.dynamics.Simulation(name, wellbore, bha)

Bases: object

A class to maintain simulation state and describe a coupled axial-torsional drillstring model with a choice of bit-rock interaction models

clone_estimator(source)

For ensemble based estimation, clone self to match best estimator

Parameters

sourceDrillPyze.Simulation

the best estimator

initialize_estimator(array_size, intensity)

Initialize the estimator.

Parameters

array_sizeint

Length to preallocate for estimation

intensityfloat

Intensity of update

initialize_simulation(bitdepth, simulation_length=100, update_period=30, bit_constant=2000, params=None)

Initialize the simulation with the bit at a certain bitdepth

Parameters

bitdepthfloat

Current depth of the bit

simulation_lengthint

Length (in seconds) of the simulation. Used to preallocate arrays. Default value is 100 seconds.

paramsdict

A dictionary of optional parameters to set up the simulation Default value is None

parstep()

Helper function for multiprocessing

speedhelper(dt=0.1, TD_RPM_SP=None, WOB_SP=None, bit_constant=None)

Step the simulation forward by dt seconds. Computations are vectorized in x

Parameters

dtint

Number of seconds to advance the simulation

TD_RPM_SPfloat

A change in the top drive set point. Default is None, meaning no change in top drive set point

WOB_SPfloat

Current WOB setpoint

step(dt=0.1, TD_RPM_SP=None, WOB_SP=None, bit_constant=None)

Step the simulation forward by dt seconds. Computations are vectorized in x

Parameters

dtint

Number of seconds to advance the simulation

TD_RPM_SPfloat

A change in the top drive set point. Default is None, meaning no change in top drive set point

WOB_SPfloat

Current WOB setpoint

update_estimate(tau_act)

Update the parameter estimates based on the actual value of surface torque

Parameters

tau_actFloat

the actual surface torque

class DrillPyze.dynamics.Simulation(name, wellbore, bha)

Bases: object

A class to maintain simulation state and describe a coupled axial-torsional drillstring model with a choice of bit-rock interaction models

clone_estimator(source)

For ensemble based estimation, clone self to match best estimator

Parameters

sourceDrillPyze.Simulation

the best estimator

initialize_estimator(array_size, intensity)

Initialize the estimator.

Parameters

array_sizeint

Length to preallocate for estimation

intensityfloat

Intensity of update

initialize_simulation(bitdepth, simulation_length=100, update_period=30, bit_constant=2000, params=None)

Initialize the simulation with the bit at a certain bitdepth

Parameters

bitdepthfloat

Current depth of the bit

simulation_lengthint

Length (in seconds) of the simulation. Used to preallocate arrays. Default value is 100 seconds.

paramsdict

A dictionary of optional parameters to set up the simulation Default value is None

parstep()

Helper function for multiprocessing

speedhelper(dt=0.1, TD_RPM_SP=None, WOB_SP=None, bit_constant=None)

Step the simulation forward by dt seconds. Computations are vectorized in x

Parameters

dtint

Number of seconds to advance the simulation

TD_RPM_SPfloat

A change in the top drive set point. Default is None, meaning no change in top drive set point

WOB_SPfloat

Current WOB setpoint

step(dt=0.1, TD_RPM_SP=None, WOB_SP=None, bit_constant=None)

Step the simulation forward by dt seconds. Computations are vectorized in x

Parameters

dtint

Number of seconds to advance the simulation

TD_RPM_SPfloat

A change in the top drive set point. Default is None, meaning no change in top drive set point

WOB_SPfloat

Current WOB setpoint

update_estimate(tau_act)

Update the parameter estimates based on the actual value of surface torque

Parameters

tau_actFloat

the actual surface torque

class DrillPyze.dynamics.Estimator(num_instances, wellbore, bha)

Bases: object

A class to maintain and update an ensemble based estimation technique

increment(time, TD_SETPOINT=0, TD_ACT=0)

Increment the simulations with a certain topdrive rpm and recorded top drive torque. The simulations simulate forward at the topdrive rpm and then update their estimation assuming the topdrive torque is measured at the end of the simulation increment.

The simulation pool is then sorted by smallest error and all simulations are cloned to be equal to the best simulation.

Parameters

timefloat

Number of seconds to step the simulations forward

TD_SETPOINTfloat

Top drive rpm setpoint. Default is 0

TD_ACTfloat

Top drive actual torque. Default is 0

initialize(bit_depth, sim_length, estimate_freq)

Initialize the simulations to the same start point

Parameters

bit_depthfloat

Current bit depth

sim_lengthint

Number of seconds to simulate

estimate_freqfloat

Frequency (in Hz) of available data

DrillPyze.hydraulics module

Hydraulics module for DrillPyze.

This module contains functions for calculating the flow rate, fluid velocity, Reynolds number for a pipe and the frictional pressure for a pipe and an annulus.

DrillPyze.hydraulics.fluid_velocity(Q, Do, Di=None)

Calculate the fluid velocity in a pipe or an annulus.

Parameters

Qfloat

Flow rate in gpm

Dofloat

Outer diameter of the pipe in inches

Difloat

Inner diameter of the pipe in inches. If Di is None, then the function will calculate the fluid velocity for a pipe.

DrillPyze.hydraulics.friction_factor(NRe)

Calculate the friction factor for a pipe or an annulus.

Parameters

NRefloat

Reynolds number for the pipe

DrillPyze.hydraulics.frictional_pressure_drop(rho, Q, mu, L, Do, Di=None)

Calculate the frictional pressure drop in a pipe or an annulus.

Parameters

rhofloat

Fluid density in ppg

Qfloat

Flow rate in gpm

mufloat

Fluid viscosity in cp

Lfloat

Length of the pipe in ft

Dofloat

Outer diameter of the pipe in inches

Difloat

Inner diameter of the pipe in inches. If Di is None, then the frictional pressure drop is calculated for a pipe.

DrillPyze.hydraulics.reynolds_number(rho, v, mu, Do, Di=None)

Calculate the Reynolds number for a pipe or an annulus.

Parameters

rhofloat

Fluid density in lbm/ft^3

vfloat

Fluid velocity in ft/s

mufloat

Fluid viscosity in cp

Dofloat

Outer diameter of the pipe in inches

Difloat

Inner diameter of the pipe in inches. If Di is None, then the function will calculate the Reynolds number for a pipe.

DrillPyze.statics module

This module contains functions for calculating static forces and torques along the drillstring.

DrillPyze.statics.normal_forces(well, bha, WOB=0, TOB=0, mu=0.3)

Calculate the normal forces along the drillstring.

Reference: Johancsik, Friesen and Dawson. Torque and Drag in Directional Wells – Prediction and Measurement. Journal of Petroleum Technology. 1984

Parameters

wellDrillPyze.well.well_bore

A well_bore object initialized with a well profile. The wellpath must already be interpolated.

bhaDrillPyze.drillstring.BHA

A BHA object initialized with a drillstring configuration. The BHA must already be discretized.

WOBfloat

axial force at the bit (weight on bit). Default value = 0

TOBfloat

torque at the bit. Default value = 0

mufloat

friction coefficient. Default value = 0.3

DrillPyze.util module

A module containing functions for plotting the results of the simulation and other useful functions.

DrillPyze.util.plot(fig, axes, sim, bha, M)

Update the plot

Parameters

figmatplotlib.pyplot.figure

Figure to plot in

axes : tuple of axes objects sim : DrillPyze.dynamics.simulation

Simulation object

bhaDrillPyze.drillstring.BHA

BHA object

Mnumpy.array

Array of static friction torques

DrillPyze.util.plot_estimates(fig, axes, sim, bha, M, data)

Update the plot

Parameters

figmatplotlib.pyplot.figure

Figure to plot in

axestuple of axes objects

Axes to plot in

simDrillPyze.dynamics.simulation

Simulation object

bhaDrillPyze.drillstring.BHA

BHA object

Mnumpy.array

Array of static friction torques

DrillPyze.util.plot_estimates_multiple(fig, axes, sims, bha, M, data)

Update the plot

Parameters

figmatplotlib.pyplot.figure

Figure to plot in

axestuple of axes objects

Axes to plot in

simDrillPyze.dynamics.simulation

Simulation object

bhaDrillPyze.drillstring.BHA

BHA object

Mnumpy.array

Array of static friction torques

DrillPyze.util.plot_map(time, depths, rpm, torque)
DrillPyze.util.setup_plotting(live=False)

Setup the plotting

Parameters

livebool

if True, then live animation is available

DrillPyze.util.setup_plotting_estimates(live=False)

Setup the plotting

Parameters

livebool

if True, then live animation is available

DrillPyze.well module

A class for a wellbore, which includes a well path, a casing setting depth and a hole size.

The well_profile library is used to interpolate along a wellbore survey.

class DrillPyze.well.wellbore(well_survey, casing_depth, hole_size)

Bases: object

A class for a wellbore, which includes a well path, a casing depth and a dimension. This class uses the well_profile library to interpolate along a wellbore survey.

get_interpolated(md)

Interpolated wellpath for the depths defined.

Parameters

mdnumpy array

Array of interpolation points

get_trajectory()

Return the well trajectory object