Skip to content

pywellgeo.well_tree

pywellgeo.well_tree.well_tree_tno.WellTreeTNO

__init__

__init__(
    x: float64,
    y: float64,
    z: float64,
    radius: float,
    xroot: Optional["WellTreeTNO"] = None,
    perforated: Optional[bool] = True,
    color: Optional[str] = "black",
    name: Optional[str] = "main",
) -> None

create a wellTree object, as a multiple linked list (allowing for multiple branches)

:param x: np array (1d) x coordinates :param y: nd array (1d) y coordinates :param z: nd array (1d) z coordinates :param radius: radius of the well :param xroot: connecting wellTree node (default is None :param perforated: perforation status (default is True) :param color: color of the wellTree node (default is black) :param name: name of the wellTree node (default is 'main')

copy classmethod

copy()

create a deep copy of the current instance :return: copy of the current instance

from_xyz classmethod

from_xyz(
    x: ndarray,
    y: ndarray,
    z: ndarray,
    radius: Optional[float] = 0.10795,
    sname: Optional[str] = "main",
    nroot: Optional["WellTreeTNO"] = None,
) -> "WellTreeTNO"

create a wellTree object from x,y,z coordinates

:param x: np array (1d) with x coordinates :param y: np array (1d) with y coordinates :param z: np array (1d) with z coordinates :param radius: radius of the well :return: wellTree object, name is 'main'

add_xyz

add_xyz(
    x: ndarray,
    y: ndarray,
    z: ndarray,
    sbranch: Optional[str] = "branch",
    color: Optional[str] = "black",
    radius: Optional[float] = 0.10795,
) -> None

add a branch to the well tree from x,y,z coordinates, it will insert the branch at the last point where the branch connects to the existing wellTree

:param x: np array (1d) with x coordinates :param y: np array (1d) with y coordinates :param z: np array (1d) with z coordinates :param sbranch: name of the new branch :param color: color of the new branch :param radius: radius of the new branch

from_trajectories classmethod

from_trajectories(
    trajectory: Dict[str, DataFrame], radius: float
) -> "WellTreeTNO"

obtain wellTree object from 'main' and trajectories 'branch1', 'branch2', etc from the well stored in dictionary trajectory from trajectory[branchname] and columns for 'x','y', 'TVD' (if branchname is 'main') else columns for branchname + '_x', branchname + '_y', branchname + '_TVD'. It will automatically remove any duplicate segements from branches above the kickoff point

trajectory is created by the trajectories.py class from yml input

:param trajectory: :param branchname: :param includebranchname: :return: wellTree for the well main and branches

from_vertical classmethod

from_vertical(x, y, zmax, radius)

create a vertical wellTree object from x,y,z coordinates

:param x: x coordinate :param y: y coordinate :param zmax: maximum z coordinate :param radius: radius of the well :return: wellTree object, name is 'main'

sameLocation

sameLocation(x: float64, y: float64, z: float64) -> bool

check if the wellTree node is at the location x,y,z

:param x: float :param y: float :param z: float :return: boolean if the wellTree node is at the location x,y,z

exist

exist(
    x: float, y: float, z: float
) -> Union[Tuple[bool, None], Tuple[bool, WellTreeTNO]]

find the wellTree node in the wellTree which corresponds to the point with coordinates x,y,z

:param x: float :param y: float :param z: float :return: boolean if the point exists, corresponding wellTree node

init_ahd

init_ahd() -> None

initialize the along hole depth (AHD) for the wellTree

init_temperaturesoil

init_temperaturesoil(tsurface: float, tgrad: float) -> None

initialize the Soil temperature surrounding the wellTree based on a surface temperature at Z=0 [C] and a temperature gradient [C/m]

:param tsurface: surface temperature [C] :param tgrad: temperature gradient [C/m]

getAHDincrement

getAHDincrement() -> float64

get the along hole depth increment for the current node

:return: float ahdincrement

cumulative_ahd

cumulative_ahd() -> float64

find (cumulative) ahd of the branches from this node

:return: ahd of the branches in the root

get_ahd

get_ahd(
    TVD: Union[float, int],
    branchname: Optional[str] = "main",
) -> float64

get the along hole depth (or MD) of TVD, if it cannot be reached it returns the maximum AHD

:param TVD: target true vertical depth :param branchname: name of the branch to inspect, if it is not specified it follows the main branch :return: value of along hole depth corresponding to TVD

minmax

minmax(minx=None, maxx=None)

determine the min and max coordinates

:param minx: min cooridnates tuple :param maxx: max coordinates tuple :return:

findlastsame

findlastsame(
    x: ndarray, y: ndarray, z: ndarray
) -> Tuple[WellTreeTNO, ndarray, ndarray, ndarray]

finds the first coordinates in x,y,z starting from the last index which match the existing wellTreeNode if found it returns the wellTreeNode where the branch kicks off from existing wellTree and it returns the sliced arrays of x,y,z, coordinates containing the branch from the kickoff point

:param x: np array (1d) with x coordinates of branch trajectory :param y: np array (1d) with y coordinates of branch trajectory :param z: np array (1d) with z coordinates of branch trajectory :return: the kickoff wellTree node for the branch and sliced arrays starting from the kickoff point

get_xyzasnparay staticmethod

get_xyzasnparay(
    trajectory: Dict[str, DataFrame],
    branchname: str,
    includebranchname: Optional[bool] = False,
) -> Tuple[ndarray, ndarray, ndarray]
obtain x,y,z coordinate arrays from specific branches (or main) from the well stored in dictionary trajectory
from trajectory[branchname] and columns for 'x','y', 'TVD' (if includebranchname is False) else
columns for branchname + '_x', branchname + '_y', branchname + '_TVD'
trajectory is created by the trajectories.py class from yml input

:param trajectory: :param branchname: :param includebranchname: :return: x,y,z numpy 1d arrays of coordinates (assuming ordered towards toe of well)

splitz

splitz(z)

split the well tree at depth z, adding z to the well tree if it is not already there

:param z: depth to split the well tree

scale

scale(scalevec)

scale the well tree by a vector scalevec

:param scalevec: scale vector

coarsen

coarsen(segmentlength=100, perforated=True)

coarsen the topology to the target segmentlength and only the (non)perforated section if perforated!=None

:param segmentlength: target segment length (m), alonh hole depth :param perforated: consider only (non) perforated section (if !=None) :return:

splitwell

splitwell(ztop, zbase)

split the well tree to isolate the perforated section from ztop to zbase

:param ztop: top coordinate (negative value) :param zbase: base coordinate (more negative value) :return:

setperforate

setperforate(ztop, zbase)

set the perforation status of the well tree segments

:param ztop: float top coordinate (negative value) :param zbase: float base coordinate (more negative value) :return:

perforate

perforate(ztop, zbase)

insert additional nodes to isolate the perforated section from ztop to zbottom, label the corresponding segments as perforated and color them blue

:param ztop: top coordinate (negative value) :param zbase: bottom coordinate (more negative value)

condenseBranch staticmethod

condenseBranch(wlistin, segmentlength=10)

condense the branch to the target segment length

:param wlistin: list of well tree nodes :param segmentlength: target segment length :return:

getbranch

getbranch(
    name: Optional[str] = None,
    perforated: Optional[bool] = True,
    includemain: Optional[bool] = False,
    wlist: Optional[List["WellTreeTNO"]] = None,
) -> None

collect the (perforated) segments in a list of welltree nodes, and begiining and ned points name and radius, this routine is used for the well index calculation

:param name: name of the branch :param perforated: section (True or False) or ignored (perforated==None) :param includemain: include the main branch :param wlist: list of well tree nodes :return: dataframe with start and end points of the tree elements corresponding to name and perforated

getbranchlist

getbranchlist(
    name: Optional[str] = None,
    perforated: Optional[bool] = True,
    includemain: Optional[bool] = False,
    wlist: Optional[List["WellTreeTNO"]] = None,
) -> List["WellTreeTNO"]

collect the (perforated) segments in a list of welltree nodes, and begiining and ned points name and radius, this routine is used for the well index calculation

:param name: name of the branch :param perforated: section (True or False) or ignored (perforated==None) :param includemain: include the main branch :param wlist: list of well tree nodes :return: list of well tree nodes correspondng to the name and perforated

getBranchSurvey

getBranchSurvey(
    name=None,
    perforated=True,
    includemain=False,
    wlist=None,
)

collect survey points of selected (perforated) segments

:param name: name of the branch :param perforated: section (True or False) or ignored (perforated==None) :param includemain: include the main branch :param wlist: list of well tree nodes :return: dataframe with start and end points of the tree elements corresponding to name and perforated

temploss

temploss(
    wdot: Series,
    temp: Series,
    time: int,
    kt: int,
    at: float,
    wellradius: Optional[float] = None,
) -> Series

calculate the temperature loss for the well branch

:param wdot: massflow * heat capacity rate (W/m3) :param time: reference time (s) :param kt: thermal conductivity (W/mK) :param at: thermal diffusivity (m2/s) :param wellradius: well radius (m) :return: temperature loss

plotTree3D

plotTree3D(fig=None, ax=None, doplot=True, tofile=None)

plot the welltree in a 3D window

:param fig: included only when appending to existing plot :param ax: included only when appending to existing plot :param doplot: if True the plot is finalized if False the result can be appended using return values in next call :param tofile: specify a file to save the resulting plot :return: fig, ax objects for next call when appending to existing (if doplot==False)

plotTree

plotTree(fig=None, ax=None, axis=0)

plot the welltree in (x,y), (x,z) or (y,z) plot

:param fig: included only when appending to existing plot :param ax: included only when appending to existing plot :param axis: 0 means xy plot, 1 :return: fig, ax objects for next call when appending to existing (if doplot==False)