major_lib module
Module defines most functions used in calculator
- major_lib.a_mat_fix(file_name)[source]
Temperature equalization factor [m²/s], based on input file
- Parameters:
file_name – excel input file
- Returns:
matrix with columns 1-material number,2- temperature equalization factor [m²/s], 3- thermal conductivity coefficient [W/m*K]
- major_lib.check_mat(IN, Grid, n2e, nc)[source]
Selecting and linking material to elements, by coordinates R and Z
- Parameters:
IN – well geometry with temperature distribution from imput excel file matrix
Grid – grid nodes matrix
n2e – nodes numbering with elements matrix
nc – nodes coordinates matrix
- Returns:
matrix with elements assosiated with material
- major_lib.cols(a)[source]
Function returns the number of columns in a matrix a
- Parameters:
a – matrix
- Returns:
number of columns in a matrix a
- major_lib.disribute_temp_changes(t0, twellNew, twell0, node_in_zone, node_with_brine)[source]
Function determines how the temperature changes in nodes filled with brine and nodes on the exchanger wall
- Parameters:
t0 – distribution of temperature in nodes
twellNew – distribution of temperature in well after time
twell0 – distribution of temperature in well at the beginning
nodes_in_zone – nodes in elements filled by fluid
node_with_brine – nodes filed by brine
- Returns:
new distibution of temperature
- major_lib.divide_from_to(x1, x2, dx1, ndx)[source]
The function divides the segment from x1 to x2, where last spatial step is dx1
- Parameters:
x1 – first point of segment
x2 – second point of segment
dx1 – last spatial step of interval
ndx – number of intervals
- Returns:
coordinate list of intervals
- major_lib.divide_z(x1, x2, nz)[source]
The function divides the segment from x1 to x2 into nz equal parts
- Parameters:
x1 – first point of segment
x2 – second(last) point of segment
nz – number of intervals
- Returns:
coordinate list of intervals
- major_lib.eq_temp_in_zone(t, NinZ)[source]
Equalize temperatures in the zone. The important is temperature in the node with the highest number
- Parameters:
t – matrix of temperatures in well
NinZ – nodes in elements filled by fluid
- Returns:
equalized temperature distribution matrix in zones
- major_lib.find_node(node_number, n2e)[source]
Idefntyfication how a node(node_number) is numbered belonging to elements and how it contact to other nodes
- Parameters:
node_number – numbers of the nodes
n2e – affiliation of nodes to elements
- Returns:
information where nNode is the first (e0), second (e1), third (e2) and fourth (e3)
Note
nodes numbering similar to nodes2elements(NC, R, Z) - see above
- major_lib.first_type_boundary(nc, n2e, mat)[source]
Recognition and determination of the 1st type boundary condition
- Parameters:
nc – matrix of R and Z coordinates
n2e – nodes numbering with elements matrix
mat – elements associated with materials matrix
- Returns:
list of nodes with 1st boundary condition
Note
If any node lays on a boundary, then in an element it belongs will contain -1.So if -1 is founded it informs us that the node is 1st type boundary condition If a node belongs to an element where Mat=0 (Mat=0 means fluid, eg. geohtermal water) then it is the 1st type boundary condition
- major_lib.grid_gener(geom, max_z, nr)[source]
Function for grid generation
- Parameters:
geom – geometry definition from excel input file
max_z – maximal allowed step on Z axis (depth)
nr – increasement of R behind the defined zone (IN variable)
- Returns:
matrix of grid nodes
- major_lib.initial_temp(nc, IN)[source]
Fixing temperature in the nodes at the begining vs depth
- Parameters:
nc – nodes coordinates
IN – geometry of well in input file
- Returns:
matrix of temperature at the beginning in nodes
- major_lib.inj_calculations(wws, dtime, dtime_max, t0, twell0, n2e, nc, Z, R, mat, am, NinWell, NfbB, actvN, others, nodes_top, nodes_bottom, nodes_in_elements)[source]
Main function for calculation of injection well
- Parameters:
wws – well working schedule from input excel file
dtime – maximal allowed time step
dtime_max – maximal allowed time step
t0 – initial temperature in modell
twell0 – temperature distribution in nodes in well
n2e – nodes numbering with elements matrix
nc – nodes coordinates matrix
Z – nodes coordinate Z
R – nodes coordinate R
mat – elements associated with materials matrix
am – matrix with material numbers, temperature equalization factor and heat conduction coefficient from input excel file
NinWell – nodes in elements filled by fluid
NfbB – nodes filled by brine
actvN – active nodes
others – parameters from “others sheet” in excel input file
nodes_top – nodes on the top of the well
node_in_elements – matrix with nodes in elements
- Returns:
matrix of temperatures distribution in model
Note: Here are graphs defined which are displayed at the end of simulation.
- major_lib.inj_well_guess_press_head(m, t, pBottom, S, tr, tRockMatrix, dtime, fi, acc, n2e, nc, Z, mat, am, nodes_top, nodes_in_elements)[source]
Function which assess pressure at the wellhead
- Parameters:
m – mass flow rate
t – temperature of injected fluid
pBottom – pressure at the bottom of well
S – mineralisation
tr – matrix of rock temperature in nodes belonged to a well
tRockMatrix – matrix of temperatures in rock
dtime – maximal allowed time step
fi – pipe wall roughness coefficient
acc – iterative accuracy from input excel file
n2e – nodes numbering with elements matrix
nc – nodes coordinates matrix
z – nodes coordinate Z
mat – elements associated with materials matrix
am – matrix with material numbers, temperature equalization factor and heat conduction coefficient from input excel file
nodes_top – nodes on the top of the well
node_in_elements – matrix with nodes in elements
- Returns:
pressure at wellhead [Pa]
- major_lib.interp_1d(a, x)[source]
Linear interpolation between fixed values; 1d case
- Parameters:
a – matrix
x – searched value
- Returns:
return interpolated value
- major_lib.max_dtime(nc, n2e, mat, am, quality)[source]
Checking maximal allowed time step dtime [s], dependently on the grid shape and loaded coordinates
- Parameters:
nc – matrix of R and Z coordinates
n2e – nodes numbering with elements matrix
mat – elements associated with materials matrix
am – matrix with material numbers, temperature equalization factor and heat conduction coefficient from input excel file
quality – convergence quality, can not be lower than 4, suggesed value 5
- Returns:
maximal allowed time step [s]
Note
Solution of explicit method is stable for M>=4. Wiśniewski & Wiśniewski, Heat transfer, unit 3.4, page.147, equation 3.229
- major_lib.nodes_coordinates(r, z)[source]
Function which describes nodes coordinates
- Parameters:
r – nodes R coordinate
z – nodes Z coordinate
- Returns:
nodes numbering and coordinates fixing, col. (1) - number of node, (2) - R coordinate [m], (3) - Z coordinate [m]
- major_lib.nodes_filled_with_brine(node_in_well, n2e, mat)[source]
Procedure indicates only nodes fully filled by brine in the order typical for matrix nide_in_well but node_in_well includes also nodes partly sourounded by brine and partly by the rocks matrix
- Parameters:
node_in_well – nodes in elements filled by fluid
n2e – nodes numbering with elements matrix
mat – elements associated with materials matrix
- Returns:
matrix of nodes fully filled with brine
- major_lib.nodes_to_elements(nc, r, z)[source]
Determining the affiliation of nodes to elements, the number of the element is just the row number
numbering scheme: #1 - node of the grid no. 1, [3] - grid element no. 3 8 12 16 4 #------#-------#-------#--------# 20 0,0 ---------------► R [m] | | | | | | | [3] | [6] | [9] | [12] | | | 7| 11| 15| | | 3 #------#-------#-------#--------# 19 | | | | | | | | [2] | [5] | [8] | [11] | | | 6| 10| 14| | | 2 #------#-------#-------#--------# 18 | | | | | | | | [1] | [4] | [7] | [10] | | | 5| 9| 13| | | 1 #------#-------#-------#--------# 17 | Z [m] V 3 o----------o 0 | | | | | | 2 o----------o 1- Parameters:
nc – matrix with nodes coordinates
r – matrix with R coordinates
z – matrix with Z coordinates
- Returns:
number of node no. 0, (2) - no. of node no. 1, (3) - node no. 2, (4) - node no. 3
- Return type:
matrix with row - the element number, cols
- major_lib.nodes_zones(Z, nc, n2e, mat)[source]
The function links nodes in an element filled by fluid (eq. water), inside a well
- Parameters:
Z – Z coordinates (depth)
nc – matrix of R and Z coordinates
n2e – nodes numbering with elements matrix
mat – elements associated with materials matrix
- Returns:
list of lists, where a row = a zone, and a list element = a node number in the zone
Notes
Zones are numbered from Earth surface to the bottom of the well
- major_lib.prod_calculations(wws, dtime, dtime_max, t0, twell0, n2e, nc, Z, R, mat, am, NinWell, NfbB, actvN, others, nodes_top, nodes_in_elements)[source]
Main function for calculation of production well
- Parameters:
wws – well working schedule from input excel file
dtime – maximal allowed time step
dtime_max – maximal allowed time step
t0 – initial temperature in modell
twell0 – temperature distribution in nodes in well
n2e – nodes numbering with elements matrix
nc – nodes coordinates matrix
Z – nodes coordinate Z
R – nodes coordinate R
mat – elements associated with materials matrix
am – matrix with material numbers, temperature equalization factor and heat conduction coefficient from input excel file
NinWell – nodes in elements filled by fluid
NfbB – nodes filled by brine
actvN – active nodes
others – parameters from “others sheet” in excel input file
nodes_top – nodes on the top of the well
node_in_elements – matrix with nodes in elements
- Returns:
matrix of temperatures distribution in model after time step
Note: Here are graphs defined which are displayed at the end of simulation.
- major_lib.prof_temp_start(file_name, IN)[source]
Initial temperature generator
- Parameters:
file_name – str input excel file name
IN – geometry of well in input excel file
- Returns:
matrix with distribution of temperature in geometry
- major_lib.prt_mtx(mtx)[source]
Function which rounds elements of matrix up to 4 decimal places
- Parameters:
mtx – matrix
- Returns:
rounded elements in a matrix mtx
- major_lib.read_others(file_name)[source]
The procedure reads the other important inputs form Excel input file
- Parameters:
file_name – excel input file name
- Returns:
matrix col 1 - TDS of brine [kg_TDS/kg_pureH2O], 2 - the well casing roughnes [-], 3 - the iterative calculations accuracy [-]
- major_lib.rows(a)[source]
Function returns the number of rows in a matrix a
- Parameters:
a – matrix
- Returns:
number of rows in a matrix a
- major_lib.seek_actv_nodes(nc, fix_nodes)[source]
Procedure to find out active nodes, based on fixed nodes (boundary or the 1st type boundary condition)
- Parameters:
nc – matrix with nodes coordinates
fix_nodes – fixed nodes (boundary or the 1st type boundary condition)
- Returns:
active nodes
- major_lib.skip_small_differences(a, difference, n_digit)[source]
Function to skip small differences
- Parameters:
a – matrix
difference – factor of difference
n_digit – number of decimals to use when rounding the number
- Returns:
shortened values
- major_lib.temp_after_dtime(nw, n2e, nc, mat, am, t, dtime, nodes_in_elements)[source]
Function calculating temperature after period of time
- Parameters:
nw – node number
n2e – nodes numbering with elements matrix
nc – matrix of R and Z coordinates
mat – elements associated with materials matrix
am – matrix with material numbers,temperature equalization factor and heat conduction coefficient from input excel file
t – equalized temperature distribution matrix in zones
dtime – suggested time step [s]
nodes_in_elements – matrix with nodes in elements
- Returns:
final temperature
- major_lib.temp_in_well(node_in_zone, t, nc)[source]
Temperature in nodes describing the well surface sourouned by rock matrix
- Parameters:
node_in_zone – nodes in elements filled by fluid
t – equalized temperature distribution matrix in zones
nc – matrix of R and Z coordinates
- Returns:
temperature in nodes describing the well surface surrouned by rock matrix
- major_lib.well_geometry_in(file_name)[source]
Reading input file from excel
- Parameters:
file_name – input excel file name
- Returns:
matrix of input values
- major_lib.well_param(wws, time)[source]
Function is sending back the working conditions of a well as one rows vector
- Parameters:
wws – well working schedule from input excel file
time – simulation time
- Returns:
matrix col 1 - time [s], 2 - mass flow [kg/s], 3 - inlet temperature [°C]
- major_lib.working_scheme(file_name)[source]
The procedure reads the working scheme of the well form Excel input file
- Parameters:
file_name – excel input file name
- Returns:
matrix with cols 1 - time [s], 2 - flow [kg/s] (if positive production, negative reinjection), 3 - temperature [°C]; based on input file