Introduction

Rocks are a combination of different materials. However, rocks exhibit poroelastic response. The amount of the stress indexed by pore pressure depends on pore content. The study of stress in a two-phase medium and in void space is essential for well integrity in oil production. The study of temperature is also important in defining the stress. The theory of thermo-poroelasticity or porothermoelasticity is developed by combining the influence of thermal stress and the difference between solid and fluid expansion (Espinoza 1983; Fredrich et al. 2000; Zare 2012).

Enhanced oil recovery refers to several processes conducted to increase oil production from a reservoir after primary and secondary recoveries, which are typically performed by injecting water or gas. The injected fluid may push the oil or interact with the reservoir rock oil system to prepare suitable conditions for recovery. Injecting water alternating gas (WAG) shows better sweep efficiency than injecting water or gas alone (Irawan and Bataee 2014; Chalaturnyk and Li 2004; Chin et al. 2002).

Thermo-poroelasticity describes the effect of the change in temperature and fluid flow on the stress in the borehole and reservoir. Injecting water results in changes in temperature, pore pressure, and stress in the reservoirs and affects the reservoir permeability and porosity. Most reservoir simulators undergo stress changes and rock deformations during production because of the considerable physical effect of the geomechanical aspects of reservoir behavior (Lewis et al. 1986; Geertsma 1973; Hansen et al. 1995).

Freeman et al. (2009) studied the geomechanics of bitumen formations. They had used two different simulators and compared the results (Freeman et al. 2009). Du and Wong (2005) had developed the coupled geomechanical thermal flow simulator. They had used the finite element method to express the reservoir model (whereas in most of the studies the flow is modeled by the finite difference method). The finite element formulation is explained well, but the result was not comprehensively expressed (Du and Wong 2005).

Yin et al. had developed a finite element model of stress coupled with finite difference model for the flow in the reservoir and done some examples related to the model. Although some of the examples are not applicable for the reservoir and one or two formulae were obsolete, the results are a good representative of what is actually and accurately happening in the reservoir (Yin et al. 2009).

The simulation study had used the iterative coupling method and studied the result of stability with the different initial values of parameters (Joseph et al. 2011).

Safari and Ghassemi (2011) analyzed the geomechanical aspect of huff and puff process. They had done the study for a fractured geothermal reservoir. Their model had shown a good agreement with the field measurements. They had analyzed different geomechanical and flow behavior of the fractures after some years (Safari and Ghassemi 2011).

Chiaramonte and Zoback had published some books on the subject of reservoir geomechanics and CO2 sequestration simulation. They had done another CO2-EOR simulation project in a fractured reservoir (2012). They had investigated the mobility of CO2 in a fractured field (Chiaramonte 2012).

Tran et al. (2004) developed new iterative coupling method and had applied it in CMG reservoir simulator. They had also corrected the porosity formula for the method. They call it pseudo-coupling and their study had shown that the result of this model is like the fully coupling method, but with higher speed. One year later (2005), they compare the different methods of coupling and their results (Tran et al. 2004).

Mendes et al. (2012) had done a study of coupling with heterogeneity. They get their special boundary conditions and solve the two-phase flow problem using Monte Carlo algorithm. They reach to the result of locally conservative numerical solution and impress that there is an obvious change in production resulted by heterogeneity (Mendes et al. 2012).

Some research tried to model the sand production around the wellbore. Bianco and Halleck analyzed the mechanisms of arch instability and sand production in two-phase saturated poorly consolidated sandstones (Bianco and Halleck 2001). Wan and Wang starts to model the sand production within a continuum mechanics framework (Wan and Wang 2000). He continued his work on sand production and published a paper 4 years later on the topic of “Analysis of Sand Production in Unconsolidated Oil Sand, Using a Coupled Erosional-Stress-Deformation Model” (Wan and Wang 2004). Some years later he analyzed the borehole failure modes and the pore pressure effects on it (Papamichos 2010). Papamichos developed the relation between sand production rate under multiphase flow and water breakthrough (Papamichos 2010).

A flow simulation is based on time. This process determines initial conditions and goes through a time in a defined time step (Irawan and Bataee 2014a, b). Geomechanical calculations are not based on time, except for such phenomena as creep that are usually ignored (Lewis et al. 1989; Rutqvist et al. 2010). However, the deformation and pore volume changes feed back to the time-based flow results. The degree of frequency of this updating procedure (implicitness) significantly affects running speed and result accuracy (Pao et al. 2001; Rutqvist 2011; Edalatkhah 2010). Such frequency can be categorized as follows:

Full coupling: Flow and geomechanics variables (pressure, temperature, stresses, and strains) are solved simultaneously. Full coupling provides accurate solutions. However, this approach requires the solution of a large matrix and processing time is long.

Iterative coupling: Flow and geomechanics variables are solved separately and in sequence. This method has accuracy close to that of full implicit coupling but with higher speed.

Explicit coupling: Pressures, saturations, and temperatures data are called from the flow simulator to the stress calculations. However, the change in porosity, permeability and hence, the corrected pressures is not calculated. This method is called one-way or explicit coupling. Explicit coupling is fast, and lots of the geomechanics simulators use this method. However, the accuracy of this method is low because the flow characteristics depend on geomechanics and it is ignored in this method.

Pseudo-coupling: Some correlations between porosity and stress are used in flow calculations to identify compaction and dilation. However, this method does not process geomechanics (e.g., stress field), and simple formulas are used in a reservoir simulator to calculate subsidence during the process. The running speed of this method is high (Bataee and Irawan 2014; Bataee and Kamyab 2010; Settari et al. 2001).

Methodology

In most coupling studies, the parameters of pressure, temperature, saturation, stress, and strain are integrated. The full coupling can be performed by several methods, such as finite difference method (FDM), finite element method, and finite volume method (FVM). Thus, a large matrix can be solved. In this study, stress and strain solved using FVM, which is a suitable method for large meshes and able to deal with mesh concentration in high-stress sensitive parts. The other parameters (i.e., pressure, temperature, and saturation) calculated by FDM.

The relation between the change in porosity and strain change was considered. The new values of porosity and permeability are integrated into the flow equation to obtain the corrected values of pressure, temperature, and saturation. The stress and strain are updated. This procedure continues until the convergence condition is obtained under a certain level of accuracy.

The overall flowchart of study is expressed in Fig. 1. As in the flowchart, there are 4 main steps in the study that should be done to model the stability of the wellbore.

Fig. 1
figure 1

The overall flowchart of this study. The flow part and stress part programed separately. After that, the iteration implemented, regarding the change in porosity and permeability

Step 1—Flow model: In this step, pressures and saturations around the wellbore are calculated. Temperature values are calculated after the results of pressures and saturations.

Step 2—Stress model: Stress and strain parameters are obtained in this part, based on the mechanical properties of wellbore rock. The stress equation is the main equation that should be discretized. The change in pressure and temperature is ignored in this part and its effect processed in next step to find the corrected stress values.

Step 3—Iterative coupling between two models: The fluid flow in porous media alters the stresses, porosity, and permeability. This effect results in the change in pressure distribution, which requires using two-way coupling method. The coupling study conducted after obtaining the required parameters. The nodes in the FDM and FVM are in different positions. Thus, the values are obtained using bi-linear interpolation of the nearby nodes. The relation between the change in porosity and permeability change is considered.

Step 4—Wellbore Stability model: Based on the results of stress values, which are obtained

Stability model is based on the result of corrected stress values (from step 3). Proper failure criterion should be used to calculate the failure index around the wellbore.

Step 1: flow and energy modeling

FDM employed to solve the parameters, namely, pressure, temperature, and saturation. The continuity equation for the water flow expanded with following conditions: cylindrical model, considering gravity, considering turbulence effect attributed to high injection rate, incompressible water, and slightly compressible oil and compressible gas with the use of implicit pressure–explicit saturation (IMPES) method while ignoring tangential flow. The turbulence effect is only considered in the wellbore with the Muscat equation. The condition for the pressure and temperature is chosen for immiscible WAG (iWAG). The water is injected, and the gas is injected subsequently under an immiscible condition. The constants for the equation related to rock properties were chosen for the sandstone reservoir. The energy balance equation for the three phases can be expanded after the saturation (from the flow part) is obtained to calculate the temperature values. The conditions for solving the temperature are as follows: cylindrical, implicit method and convection and conduction with the tangential flow ignored.

The flowchart of the study in this part is expressed in Fig. 2. The programs are based on the equations obtained. First, the initial and boundary conditions for pressure and saturation should be set. Subsequently, the water injection (i.e., IMPES method) should be set. This process considers the loop of pressure in the loop of saturation for each time step. Gas injection is considered after a certain period of water injection. A thermal study was conducted after flow study and acquisition of all pressure and saturation data for any time of injection. The pressure in this study is expressed for different radius, degree, height, and time.

Fig. 2
figure 2

The methodology to obtain, pressures, saturations and temperature describes in this flowchart. After the convergency of the pressures and saturations, temperature values calculated

If we want to deal with the wellbore flow, the equations should be defined first and then discretized for the FDM. Thereafter, a program that can be used to determine the pressure and saturation for each node should be developed. The energy balance equation that uses the saturation obtained in the previous part should be discretized. After obtaining the temperature, the heterogeneity study can be conducted with the random matrix for porosity and permeability distribution through special random functions. The boundary condition may be changed to find the values in different cases.

Pressures and saturations

The steps in this part include water injection, gas injection, water–oil system, and three-phase flow. The continuity equation for the water flow expanded for the finite difference method with the following conditions: cylindrical model, considering gravity, considering turbulence effect attributed to high injection rate, incompressible water, and slightly compressible oil and compressible gas with the use of implicit pressure–explicit saturation (IMPES) method while ignoring tangential flow.

These are boundary conditions for flow cases:

$$p_{i} = \bar{p} + \rho gz , \quad \quad \rho_{i} \frac{{k_{i} }}{{\mu_{i} }}( - \nabla p_{i} + h_{i} g)^{T} \cdot n = Q_{i} \forall_{X} \in \varGamma_{Qi}$$
(1)
$$p_{i} = \bar{p}, \forall_{X} \in \varGamma_{p}$$
(2)
Water flow

After considering and expanding the mass conservation equation and momentum conservation in the form of Darcy’s law, the following equation is obtained:

$$\phi \rho c_{t} \frac{\partial p}{\partial t} = \frac{1}{r}\frac{\partial }{\partial r}\left[ {\frac{r\rho k}{\mu }\left( {\frac{\partial p}{\partial r} - \rho g\frac{\partial z}{\partial r}} \right)} \right] + \frac{1}{{r^{2} }}\frac{\partial }{\partial \theta }\left[ {\frac{\rho k}{\mu }\left( {\frac{\partial p}{\partial \theta } - \rho g\frac{\partial z}{\partial \theta }} \right)} \right] + \frac{\partial }{\partial z}\left[ {\frac{\rho k}{\mu }\left( {\frac{\partial p}{\partial z} - \rho g\frac{\partial z}{\partial z}} \right)} \right] + q_{w}$$
(3)

The flow in the tangential direction (the second term) is eliminated in this study. The derivation of z over z is equal to 1. The equation should then be prepared for the finite difference study:

$$q_{w} r_{i} \Delta r^{2} \Delta z^{2} \Delta t\left( {\mu + \beta \rho uk} \right) + \Delta z^{2} \Delta t\left\{ {\rho k\left[ {\left(r_{{i + \frac{1}{2}}} \left( {P_{i + 1}^{n + 1} - P_{i}^{n + 1} - \rho g(z_{i + 1} - z_{i} } )\right)\right) - \left(r_{{i - \frac{1}{2}}} \left( {P_{i}^{n + 1} - P_{i - 1}^{n + 1} - \rho g(z_{i} - z_{i - 1} } )\right)\right)} \right]} \right\} + r_{i} \Delta r^{2} \Delta t\rho^{2} kg\left( {P_{i + 1}^{n + 1} - 2P_{i}^{n + 1} + P_{i - 1}^{n + 1} } \right) - r_{i} \Delta r^{2} \Delta z^{2} \rho c_{f} \phi \left( {\mu + \beta \rho uk} \right)\left( {P_{i}^{n + 1} - P_{i}^{n} } \right) = 0$$
(4)

The total compressibility used in the case of oil flow equation is:

$$c_{t} = S_{w} c_{w} + S_{o} c_{o} + S_{g} c_{g} + c_{R} *\left( {\frac{{\phi_{0} }}{\phi }} \right)$$
(5)
Gas flow

By considering and expanding the gas density and compressibility in the form of Darcy’s law, the following equation obtained:

$$\frac{{\phi \mu c_{g} }}{k}\frac{{\partial p^{2} }}{\partial t} = \Delta p^{2} + \frac{2ZRT\mu }{Wk}q$$
(6)

The equation should then be prepared as follows for the finite difference study:

$$q_{g} r_{i} \Delta r^{2} 2ZRT\Delta t\left(\mu + \beta \rho {\rm uk} \right) + M_{w} \Delta tk \left[ r_{i + \frac{1}{2}} \left( P_{i + 1}^{{n + 1}^{2}} - P_{i}^{{n + 1}^{2}} \right) - r_{i - \frac{1}{2}} \left( P_{i}^{{n + 1}^{2}} - P_{i - 1}^{{n + 1}^{2}} \right) \right] - r_{i} \Delta r^{2} M_{w} c_{g} \phi \left(\mu + \beta \rho uk \right)\left( P_{i}^{{n + 1}^{2}} - P_{i}^{{n}^{2}} \right) = 0$$
(7)
Two-phase immiscible water–oil

To solve the two-phase problems, four equations require obtaining the four unknowns, namely, P w, P o, S w, and S o. The four equations are water flow, oil flow, capillary, and total saturation equations.

Water flow system

$$\nabla \cdot \left( {\frac{{\rho_{\text{w}} }}{{\mu_{\text{w}} }}k_{\text{w}} \left( {\nabla p_{\text{o}} - \frac{{{\text{d}}p_{\text{c}} }}{{{\text{d}}S_{\text{w}} }}\nabla S_{\text{w}} - \rho_{\text{w}} g\nabla z} \right)} \right) = \frac{{\partial \left( {\phi \rho_{\text{w}} S_{\text{w}} } \right)}}{\partial t} - q_{\text{w}}$$
(8)

Oil flow system

$$\nabla \cdot \left( {\frac{{\rho_{\text{o}} }}{{\mu_{\text{o}} }}k_{\text{o}} \left( {\nabla p_{\text{o}} - \rho_{\text{o}} g\nabla z} \right)} \right) = \frac{{\partial \left( {\phi \rho_{\text{o}} (1 - S_{\text{w}} )} \right)}}{\partial t} - q_{\text{o}}$$
(9)

Total saturation

$$S_{\text{w}} + S_{\text{o}} = 1$$
(10)

Capillary equation

$$p_{\text{cwo}} = \left( {p_{\text{c}} } \right)_{{S_{\text{wc}} }} \left( {\frac{{1 - S_{\text{w}} - S_{\text{orw}} }}{{1 - S_{\text{wc}} - S_{\text{orw}} }}} \right)^{{n_{\text{p}} }}$$
(11)

For the water and oil relative permeabilities the Pirson’s correlation is used:

$$K_{\text{relw}} = \sqrt {S_{\text{w}}^{*} } S_{\text{w}}^{3}$$
(12)
$$K_{\text{relo}} = \left[ {1 - \left( {\frac{{S_{\text{w}} - S_{\text{wc}} }}{{1 - S_{\text{wc}} - S_{\text{or}} }}} \right)} \right]^{2}$$
(13)

in which S w* is obtained from the following equation:

$$S_{\text{w}}^{ *} = \frac{{S_{\text{w}} - S_{\text{wc}} }}{{1 - S_{\text{wc}} }}$$
(14)

The water and oil flow equation should be prepared for the finite difference study:

$$\rho c_{t} \phi \left( {\mu + \beta \rho uk} \right)\left( {\frac{{S_{{{\text{w }}i}}^{n + 1} - S_{{{\text{w}} i}}^{n} }}{\Delta t}} \right)\left( {\frac{{P_{{{\text{w}} i}}^{n + 1} - P_{{{\text{w}} i}}^{n} }}{\Delta t}} \right) = q_{\text{w}} + \frac{1}{{r_{i} \Delta r^{2} }}\left\{ {\frac{{\rho_{\text{w}} k_{\text{w}} }}{{\mu_{\text{w}} }}\left[ {\left(r_{{i + \frac{1}{2}}} \left( {P_{i + 1}^{n + 1} - P_{i}^{n + 1} - \rho g(z_{i + 1} - z_{i} } )\right)\right) - \left(r_{{i - \frac{1}{2}}} \left( {P_{i}^{n + 1} - P_{i - 1}^{n + 1} - \rho g(z_{i} - z_{i - 1} } )\right)\right)} \right]} \right\} + \frac{{\rho_{\text{w}} k_{\text{w}} }}{{\Delta z^{2} \mu_{\text{w}} }}\left( P_{i + 1}^{n + 1} - 2P_{i}^{n + 1} + P_{i - 1}^{n + 1} \right) + \left( {\frac{{S_{{{\text{w}} i + 1}}^{n + 1} - S_{{{\text{w}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left( {\frac{{P_{{{\text{w }}i + 1}}^{n + 1} - P_{{{\text{w}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left[ {3S_{{{\text{w}} i}}^{{n + 1}^{2}} (\frac{{S_{{{\text{w}} i + 1}}^{n + 1} - S_{\text{wc}} }}{{1 - S_{\text{wc}} }})^{0.5} + 0.5S_{{{\text{w}} i}}^{{n + 1}^{3}} (\frac{{S_{{{\text{w}} i + 1}}^{n + 1} - S_{\text{wc}} }}{{1 - S_{\text{wc}} }})^{ - 0.5} (\frac{1}{{1 - S_{\text{wc}} }})^{2} } \right]$$
(15)

and for the oil phase:

$$\rho c_{t} \phi \left( {\mu + \beta \rho uk} \right)\left( {\frac{{S_{{{\text{o}} i}}^{n + 1} - S_{{{\text{o}} i}}^{n} }}{\Delta t}} \right)\left( {\frac{{P_{{{\text{o}} i}}^{n + 1} - P_{{{\text{o}} i}}^{n} }}{\Delta t}} \right) = \frac{1}{{r_{i} \Delta r^{2} }}\left\{ {\frac{{\rho_{\text{o}} k_{\text{o}} }}{{\mu_{\text{o}} }}\left[ {\left( {r_{{i + \frac{1}{2}}} \left( {P_{{{\text{o}} i + 1}}^{n + 1} - P_{{{\text{o}} i}}^{n + 1} - \rho_{\text{o}} g\left( {z_{i + 1} - z_{i} } \right)} \right)} \right) - \left( {r_{{i - \frac{1}{2}}} \left( {P_{{{\text{o}} i}}^{n + 1} - P_{{{\text{o}} i - 1}}^{n + 1} - \rho_{\text{o}} g\left( {z_{i} - z_{i - 1} } \right)} \right)} \right)} \right]} \right\} + \frac{{\rho_{\text{o}} k_{\text{o}} }}{{\Delta z^{2} \mu_{\text{o}} }}\left( {P_{{{\text{o}} i + 1}}^{n + 1} - 2P_{{{\text{o}} i}}^{n + 1} + P_{{{\text{o}} i - 1}}^{n + 1} } \right) + \left( {\frac{{S_{{{\text{o}} i + 1}}^{n + 1} - S_{{{\text{o}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left( {\frac{{P_{{{\text{o}} i + 1}}^{n + 1} - P_{{{\text{o}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left[ {2(1 - (\frac{{S_{{{\text{w}} i + 1}}^{n + 1} - S_{\text{wc}} }}{{1 - S_{\text{wc}} - S_{\text{or}} }}))(\frac{1}{{1 - S_{\text{wc}} - S_{\text{or}} }})^{2} } \right]$$
(16)
Three-phase immiscible water–oil–gas

Six equations require to obtain the six unknowns, namely, P w, P o, P g, S w, S o, and S g, to solve the three-phase problems. These six equations are water flow, oil flow, gas flow, wo-capillary, OG-capillary, and total saturation equations.

WO-capillary equation

$$p_{\text{cwo}} = \left( {p_{\text{c}} } \right)_{{S_{\text{wc}} }} \left( {\frac{{1 - S_{\text{w}} - S_{\text{orw}} }}{{1 - S_{\text{wc}} - S_{\text{orw}} }}} \right)^{{n_{\text{p}} }}$$
(17)

OG-capillary equation

$$p_{\text{cgo}} = \left( {p_{\text{c}} } \right)_{{S_{\text{lc}} }} \left( {\frac{{S_{\text{g}} - S_{\text{gc}} }}{{1 - S_{\text{lc}} - S_{\text{gc}} }}} \right)^{{n_{\text{pg}} }}$$
(18)

Total saturation

$$S_{\text{w}} + S_{\text{o}} + S_{\text{g}} = 1$$
(19)

Equations 4, 5, and 6 are the same as before, but the relative permeability for the three phases adopted from Wyllie’s correlations is as follows:

$$K_{\text{rg}} = \frac{{S_{\text{g}}^{2} \left[ {\left( {1 - S_{\text{wc}} } \right)^{2} - \left( {S_{\text{w}} + S_{\text{o}} - S_{\text{wc}} } \right)^{2} } \right]}}{{\left( {1 - S_{\text{wc}} } \right)^{4} }}$$
(20)
$$K_{\text{ro}} = \frac{{S_{\text{o}}^{3} (2S_{\text{w}} + S_{\text{o}} - 2S_{\text{wc}} )}}{{\left( {1 - S_{\text{wc}} } \right)^{4} }}$$
(21)
$$K_{\text{rw}} = \left( {\frac{{S_{\text{w}} - S_{\text{wc}} }}{{1 - S_{\text{wc}} }}} \right)^{4}$$
(22)

The water, oil and gas flow equation should be prepared for the finite difference study as follows:

$$\rho c_{t} \phi \left( {\mu + \beta \rho uk} \right)\left( {\frac{{S_{{{\text{w}} i}}^{n + 1} - S_{{{\text{w}} i}}^{n} }}{\Delta t}} \right)\left( {\frac{{P_{{{\text{w}} i}}^{n + 1} - P_{{{\text{w}} i}}^{n} }}{\Delta t}} \right) = q_{\text{w}} + \frac{1}{{r_{i} \Delta r^{2} }}\left\{ {\frac{{\rho_{\text{w}} k_{\text{w}} }}{{\mu_{\text{w}} }}\left[ {(r_{{i + \frac{1}{2}}} \left( {P_{i + 1}^{n + 1} - P_{i}^{n + 1} - \rho g(z_{i + 1} - z_{i} } \right))) - (r_{{i - \frac{1}{2}}} \left( {P_{i}^{n + 1} - P_{i - 1}^{n + 1} - \rho g(z_{i} - z_{i - 1} } \right)))} \right]} \right\} + \frac{{\rho_{\text{w}} k_{\text{w}} }}{{\Delta z^{2} \mu_{\text{w}} }}\left( {P_{i + 1}^{n + 1} - 2P_{i}^{n + 1} + P_{i - 1}^{n + 1} } \right) + \left( {\frac{{S_{{{\text{w}} i + 1}}^{n + 1} - S_{{{\text{w}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left( {\frac{{P_{{{\text{w}} i + 1}}^{n + 1} - P_{{{\text{w}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left[ {4(\frac{{S_{w i + 1}^{n + 1} - S_{\text{wc}} }}{{1 - S_{\text{wc}} }})^{3} (\frac{1}{{1 - S_{\text{wc}} }})^{2} } \right]$$
(23)

For the oil phase:

$$\rho c_{\text{t}} \phi \left( {\mu + \beta \rho uk} \right)\left( {\frac{{S_{{{\text{o}} i}}^{n + 1} - S_{o i}^{n} }}{\Delta t}} \right)\left( {\frac{{P_{{{\text{o}} i}}^{n + 1} - P_{{{\text{o}} i}}^{n} }}{\Delta t}} \right) = \frac{1}{{r_{i} \Delta r^{2} }}\left\{ {\frac{{\rho_{\text{o}} k_{\text{o}} }}{{\mu_{\text{o}} }}\left[ {\left( {r_{{i + \frac{1}{2}}} \left( {P_{{{\text{o}} i + 1}}^{n + 1} - P_{{{\text{o}} i}}^{n + 1} - \rho_{\text{o}} g\left( {z_{i + 1} - z_{i} } \right)} \right)} \right) - \left( {r_{{i - \frac{1}{2}}} \left( {P_{{{\text{o}} i}}^{n + 1} - P_{{{\text{o}} i - 1}}^{n + 1} - \rho_{\text{o}} g\left( {z_{i} - z_{i - 1} } \right)} \right)} \right)} \right]} \right\} + \frac{{\rho_{\text{o}} k_{\text{o}} }}{{\Delta z^{2} \mu_{\text{o}} }}\left( {P_{{{\text{o}} i + 1}}^{n + 1} - 2P_{{{\text{o}} i}}^{n + 1} + P_{{{\text{o}} i - 1}}^{n + 1} } \right) + \left( {\frac{{S_{{{\text{o}} i + 1}}^{n + 1} - S_{{{\text{o}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left( {\frac{{P_{{{\text{o}} i + 1}}^{n + 1} - P_{{{\text{o}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left[ {\frac{{\left( {3S_{{{\text{o}} i}}^{{n + 1}^{2}} (2S_{{{\text{w}} i}}^{n + 1} + S_{{{\text{o}} i}}^{n + 1} - 2S_{\text{wc}} ) + S_{{{\text{o}} i}}^{{n + 1}^{3}} } \right)(1 - S_{\text{wc}} )^{4} }}{{(1 - S_{\text{wc}} )^{8} }}} \right]$$
(24)

and for the gas phase:

$$M_{w} r_{i} \Delta r\Delta t\left( {\frac{{S_{{{\text{g}} i + 1}}^{n + 1} - S_{{{\text{g}} i - 1}}^{n + 1} }}{2\Delta r}} \right)\left( {\frac{{P_{{{\text{g}} i + 1}}^{{n + 1}^{2}} - P_{{{\text{g}} i - 1}}^{{n + 1}^{2}} }}{2\Delta r}} \right)\left[ {\frac{{2S_{{{\text{g}} i}}^{n + 1} \left( {\left( {1 - S_{\text{wc}} } \right)^{2} - \left( {S_{{{\text{w}} i}}^{n + 1} + S_{{{\text{o }}i}}^{n + 1} - S_{\text{wc}} } \right)^{2} } \right) - 2S_{{{\text{g}} i}}^{{n + 1}^{2}} \left( {S_{{{\text{w}} i}}^{n + 1} + S_{{{\text{o}} i}}^{n + 1} - S_{\text{wc}} } \right)}}{{\left( {1 - S_{\text{wc}} } \right)^{8} }}} \right] - 4q_{\text{g}} r_{i} \Delta r^{2} ZRT\Delta t\mu_{\text{g}} - 2M_{\text{w}} \Delta tk_{\text{g}} \left[ {r_{{i + \frac{1}{2}}} \left( {P_{{{\text{g}} i + 1}}^{{n + 1}^{2}} - P_{{{\text{g}} i}}^{{n + 1}^{2}} } \right) - r_{{i - \frac{1}{2}}} \left( {P_{{{\text{g}} i}}^{{n + 1}^{2}} - P_{{{\text{g}} i - 1}}^{{n + 1}^{2}} } \right)} \right] + 2r_{i} \Delta r^{2} M_{\text{w}} c_{\text{g}} \phi \left[ {\left( {P_{{{\text{g}} i }}^{{n + 1}^{2}} - P_{{{\text{g}} i}}^{{n}^{2}} } \right)\left( {S_{{{\text{g}} i}}^{n + 1} - S_{{{\text{g}} i}}^{n} } \right)} \right] = 0$$
(25)

Temperature

The energy balance equation for the three phases may be expanded after the saturation (from the flow part) is obtained. The following are the conditions for solving the temperature: cylindrical, implicit method, convection, and conduction while ignoring tangential flow. The following is the boundary condition for the study:

$$T = T^{^\circ } ; \forall_{X} {\text{ at}}\,\, t = 0$$
(26)
$$T = \bar{T}\,\forall_{X} \in \varGamma_{T} , \left( {\rho_{i} c_{i} v_{i} T - \lambda {\text{grad}}T} \right) \cdot \hat{n} = q_{\text{t}} \left( {x,t} \right) \,\,x \in \varGamma_{\text{q}}$$
(27)

This is the energy balance equation:

$$- {\text{div}}\left( {\lambda {\text{grad}} T} \right) + \rho_{i} c_{i} v_{i} \cdot {\text{grad}} T + Q_{h} - Q_{i} c_{i} T = \frac{\partial }{\partial t}(\bar{\rho }cT)$$
(28)

After expanding for the finite difference method this relation is obtained:

$$\frac{{\left( {T_{i}^{n + 1} - T_{i}^{n} } \right)\left( {\rho_{r} c_{r} \left( {1 - \phi } \right) + \rho_{\text{w}} c_{\text{w}} S_{{{\text{w}} i}}^{n} \phi + \rho_{\text{o}} c_{\text{o}} S_{{{\text{o}} i}}^{n} \phi } \right) + T_{i}^{n + 1} \left( {\left( {S_{{{\text{w}} i}}^{n + 1} - S_{{{\text{w}} i}}^{n} } \right)\rho_{\text{w}} c_{\text{w}} \phi + \left( {S_{{{\text{o}} i}}^{n + 1} - S_{{{\text{o}} i}}^{n} } \right)\rho_{\text{o}} c_{\text{o}} \phi } \right)}}{\Delta t} = \frac{\lambda }{{r_{i} \Delta r}}\left\{ {r_{{i + \frac{1}{2}}} \left( {\frac{{T_{i + 1}^{n + 1} - T_{i}^{n + 1} }}{\Delta r}} \right) - r_{{i - \frac{1}{2}}} \left( {\frac{{T_{i}^{n + 1} - T_{i - 1}^{n + 1} }}{\Delta r}} \right)} \right\} + \frac{{T_{i + 1}^{n + 1} - T_{i - 1}^{n + 1} }}{2\Delta r}\left( {\rho_{\text{w}} c_{\text{pw}} v_{\text{w}} + \rho_{\text{o}} c_{\text{po}} v_{\text{o}} + \rho_{\text{g}} c_{\text{pg}} v_{\text{g}} } \right) + Q_{h} - (Q_{\text{w}} c_{\text{pw}} T_{{{\text{w}} inj}} + Q_{\text{o}} c_{\text{po}} T_{{{\text{o}} inj}} )$$
(29)

Step 2: stress modeling

FVM employed to determine the stress and strain parameters. The stress equation is the main equation that should be discretized. The change in pressure and temperature are ignored in this part.

The flowchart of the study is shown in Fig. 3. These procedures should be followed to determine the stress and strain parameters. First, the equation should be transformed into a weak form and must be solved for each node. Subsequently, the body shape of the study has to be meshed. The program developed to identify the strain and, subsequently, the stress for any tetrahedral meshed body. The input for the program includes the initial and boundary conditions, as well as the position of the nodes and their connectivity.

Fig. 3
figure 3

The procedure to obtain the stress and strain using FVM. It consists of the three parts; weak form of equations, shape of model and the program

FVM is employed to develop the stress model in the wellbore. The procedure consists of transforming the equations to weak form, meshing the defined shape, and programming to obtain the values for each node.

Weak form of equations

The equations should be transformed into weak form for FVM. The pressure and temperature distributions remain constant. The main equation in this part is stress Eq. (30), where “f” is the body force and is assumed zero in this case.

$${\text{div }}\sigma - f = 0$$
(30)

The equation of the poroelasticity defines the relation between stress and strain.

$$\sigma_{ij} = \lambda \varepsilon_{\text{vol}} \delta_{ij} + 2G\varepsilon_{ij} + 3\alpha_{T} K\left( {T - T_{0} } \right)\delta_{ij} - C\zeta$$
(31)

In this equation, ζ is the strain of the fluid part and may be written as follows:

$$\zeta = \phi \left( {\frac{1}{{K_{\text{s}} }} - \frac{1}{{K_{\text{f}} }}} \right)\bar{p}_{\text{f}}$$
(32)

The volumetric strain ɛ vol is as follows:

$$\varepsilon_{\text{vol}} = \varepsilon_{x} + \varepsilon_{y} + \varepsilon_{z}$$
(33)

where the strain in the x-, y-, and z-directions are expressed as in Eqs. (3436).

$$\varepsilon_{x} = \frac{\delta u}{\delta x}$$
(34)
$$\varepsilon_{y} = \frac{\delta v}{\delta y}$$
(35)
$$\varepsilon_{z} = \frac{\delta w}{\delta z}$$
(36)

Hence, Eq. (31) is transformed into Eqs. (3739).

$$\lambda \left( { \frac{{\delta^{2} u}}{{\delta x^{2} }} + \frac{{\delta^{2} v}}{{\delta y^{2} }} + \frac{{\delta^{2} w}}{{\delta z^{2} }} } \right) + 2G\frac{{\delta^{2} u}}{{\delta x^{2} }} + 3\alpha_{T} K\frac{\delta T}{\delta x} - C \phi \left( {\frac{1}{{K_{\text{s}} }} - \frac{1}{{K_{\text{f}} }}} \right)\frac{{\delta \bar{p}_{\text{f}} }}{\delta x} = 0$$
(37)
$$\lambda \left( { \frac{{\delta^{2} u}}{{\delta x^{2} }} + \frac{{\delta^{2} v}}{{\delta y^{2} }} + \frac{{\delta^{2} w}}{{\delta z^{2} }} } \right) + 2G\frac{{\delta^{2} v}}{{\delta y^{2} }} = {\text{constant}}$$
(38)
$$\lambda \left( { \frac{{\delta^{2} u}}{{\delta x^{2} }} + \frac{{\delta^{2} v}}{{\delta y^{2} }} + \frac{{\delta^{2} w}}{{\delta z^{2} }} } \right) + 2G\frac{{\delta^{2} w}}{{\delta z^{2} }} = {\text{constant}}$$
(39)

where the matrix is transformed into Eq. (40), where u, v, and w are the deformations toward the x-, y-, and z-directions.

$$\left[ {\begin{array}{*{20}c} {} & \cdots & {} \\ \vdots & \ddots & \vdots \\ {} & \cdots & {} \\ \end{array} } \right]_{*3} \left[ {\begin{array}{*{20}c} u \\ v \\ w \\ \end{array} } \right]_{3*1} = \left[ {\begin{array}{*{20}c} 0 \\ 0 \\ 0 \\ \end{array} } \right]_{3*1}$$
(40)

The procedure to change the equation to the weak form begins, and the equations for one direction (x-direction) are written. The procedure for the others is the same. The factor is taken from the equations, and the derivation of u over x is transformed to F (F = δux). The procedure used to obtain N and H is the same.

$$\lambda \left( { \frac{{\delta^{2} u}}{{\delta x^{2} }} + \frac{{\delta^{2} v}}{{\delta y^{2} }} + \frac{{\delta^{2} w}}{{\delta z^{2} }} } \right) + 2G\frac{\delta }{\delta x}\left(\frac{\delta u}{\delta x}\right) = {\text{constant}}$$
(41)

After the transformation, the matrix transforms into Eq. (42).

$$\left[ {\begin{array}{*{20}c} {} & \cdots & {} \\ \vdots & \ddots & \vdots \\ {} & \cdots & {} \\ \end{array} } \right]_{*3} \left[ {\begin{array}{*{20}c} F \\ N \\ H \\ \end{array} } \right]_{3*1} = \left[ {\begin{array}{*{20}c} 0 \\ 0 \\ 0 \\ \end{array} } \right]_{3*1}$$
(42)

Therefore, this new equation is obtained.

$$\lambda \left( { \frac{\delta F}{\delta x} + \frac{\delta N}{\delta x} + \frac{\delta H}{\delta x} } \right) + 2G\frac{\delta F}{\delta x} = {\text{constant}}$$
(43)

The equations should be multiplied by the unit volume.

$$\lambda \left( {F\Delta z\Delta y + \bar{N}\Delta z\Delta y + \bar{H}\Delta z\Delta y} \right) + 2GF\Delta z\Delta y = {\text{constant}}*v_{i}$$
(44)

After rearranging these formulas, Eqs. (4547) obtained. Therefore, they should be solved for every single node with the summation equation for all the nearby elements for F, N, and H (Eqs. 4850).

$$\frac{1}{{{{\Omega }}_{i} }}\lambda \left( {F\Delta sx + \bar{N}\Delta sx + \bar{H}\Delta sx} \right) + 2GF\Delta sx = {\text{constant}}$$
(45)
$$\frac{1}{{{{\Omega }}_{i} }}\lambda \left( {\bar{F}\Delta sy + N\Delta sy + \bar{H}\Delta sy} \right) + 2GN\Delta sy = {\text{constant}}$$
(46)
$$\frac{1}{{{{\Omega }}_{i} }}\lambda \left( {\bar{F}\Delta sz + \bar{N}\Delta sz + H\Delta sz} \right) + 2GH\Delta sz = {\text{constant}}$$
(47)
$$\bar{F} = \mathop \sum \nolimits \frac{{F{{\Delta }}x}}{{{{\Omega }}_{i} }}$$
(48)
$$\bar{N} = \mathop \sum \nolimits \frac{{N{{\Delta }}y}}{{{{\Omega }}_{i} }}$$
(49)
$$\bar{H} = \mathop \sum \nolimits \frac{{H{{\Delta }}z}}{{{{\Omega }}_{i} }}$$
(50)
Tetrahedral meshed shapes

The body shape meshed to find the values by FVM. The program in this study developed for only tetrahedral shapes. The advantage of this method is that any shape can be applied. The requirements are only meshed positions, connectivity, and boundary condition. Therefore, the mesh node positions can be imported from any software to the program.

Figure 4 shows the example of the pyramids attached to a single node. All properties should be solved with the values of all attached nodes. In this study, the values of all attached nodes should fed into Eqs. (4850).

Fig. 4
figure 4

The values of each node calculated regarding all attached elements, their volumes and node values

Figure 5 shows the projection of the triangle in the x, y, and z planes. The values for ∆sx, ∆sy, and ∆sz should be known for the main Eqs. (4547).

Fig. 5
figure 5

The surface area of triangle projection should be calculated for the FVM for each plane

The program reads the data of the node positions, connectivity, and initial and boundary conditions. Subsequently, the program calculates all the element volumes and surface projections. The program then uses the iteration method to solve the matrix of Eqs. (4550) for all nodes.

The shape of the model should be sketched (Fig. 6) to obtain the stress and strain results of the wellbore.

Fig. 6
figure 6

The shape of study is defined to investigate the wellbore condition

The shape should then be meshed (Fig. 7). This meshing system can be provided by any mesh generator software that can prepare the nodes and connectivity for the program (Fig. 8).

Fig. 7
figure 7

The wellbore shape meshed for the FVM

Fig. 8
figure 8

The nodes positions and connectivity transported to the program for stress analysis

Table 1 presents the input data of this study. The boundary conditions of the stress and flow conditions are expressed as follows:

Table 1 Rock and fluid properties and wellbore data used in this study
$${{\varGamma }}_{u} \mathop \cup \nolimits {{\varGamma }}_{\tau } = {{\varGamma }}, \quad {{\varGamma }}_{p} \mathop \cup \nolimits {{\varGamma }}_{qi} = {{\varGamma }},\quad {{\varGamma }}_{T} \mathop \cup \nolimits {{\varGamma }}_{q} = {{\varGamma }}$$
(51)
$$u = u^{^\circ } , p_{i} = p_{i}^{^\circ } ,\quad T = T^{^\circ } ,\quad \forall x\,at\,t = 0$$
(52)
$$u = \bar{u}, \quad \forall x \in {{\varGamma }}_{u} ,\quad \sigma \hat{n} = \sigma ,\quad \forall x \in {{\varGamma }}_{\tau }$$
(53)
$$p_{i} = \bar{p}, \rho_{i} \frac{{k_{i} }}{{\mu_{i} }}( - \nabla p_{i} + h_{i} g)^{T} .n = Q_{i} , \forall x \in {{\varGamma }}_{Qi}$$
(54)
$$T = \bar{T}, \forall x \in {{\varGamma }}_{T} , \left( {\rho_{i} c_{i} v_{i} T - \lambda {\text{grad}}T} \right){\cdot}\hat{n} = q_{t} (x,t), \forall x \in {{\varGamma }}_{q}$$
(55)

The simple explanation about the case in this study is that there is a wellbore shape as in Fig. 6 (meshed as in Fig. 7 for FVM study). The input parameters are as in Table 1 and the boundary conditions are as in Eqs. 5155. For the process of the flow around the wellbore, firstly, water injected into fully saturated oil medium. Then, gas injected to this OW two-phase medium. The stresses applied are horizontal maximum, minimum, and vertical stresses. Horizontal maximum in situ stress is in the direction of north–south.

Step 3: iterative coupling

In this study, stress and strain are solved using FVM, and the other parameters (i.e., pressure, temperature, and saturation) calculated using FDM. The coupling study is conducted after obtaining the required parameters. The nodes in the FDM and FVM are in different positions. Thus, the values are obtained using bi-linear interpolation of the nearby nodes. The relation between the change in porosity and strain change and that between porosity and permeability was considered. The new values of porosity and permeability are integrated into the flow equation to obtain the corrected values of pressure, temperature, and saturation. The stress and strain are updated. This procedure continues until convergency obtained under a certain level of accuracy (0.01 Psi).

The coupling is the result of the change in pressure, temperature, saturation, stress, and strain after returning from each model. First, the pressure, saturation, and temperature should be determined. The stress and strain can be calculated thereafter. The porosity and permeability change with the change in pressure and strain (Eq. 56).

$${\text{d}}\phi = {\text{d}}\left( {tr \varepsilon } \right) - \frac{1}{{3K_{\text{m}} }}I:C:{\text{d}}\varepsilon - \frac{1}{{9K_{\text{m}}^{2} }}I:C:I {\text{d}}\bar{p} + \frac{1}{{K_{\text{m}} }}{\text{d}}\bar{p}$$
(56)

Permeability changes with the porosity and correlation for the change expressed in Eq. 57.

$$k = k_{0} { \exp }\left[k_{\text{mul}} \frac{{\phi^{*} - \phi_{0} }}{{1 - \phi_{0} }}\right]$$
(57)

The new values of pressure, saturation, and temperature are calculated with the updated porosity and permeability. This iterative coupling procedure continues until it converges. The new values of pressure, saturation, and temperature are calculated with the updated porosity and permeability. This iterative coupling procedure continued until it converged.

Step 4: Wellbore stability model

The proper failure criterion for this study should have the capability of calculation the stress for three-dimensional stress direction (capable of considering intermediate stress), and it should be suitable for wellbore rock model. Drucker–Prager is the most suitable rock failure criterion among all failure criteria regarding the wellbore modeling. Therefore, failure index values will be calculated using calculated rock stresses around the wellbore.

The Drucker–Prager failure criterion is expressed, using principal stresses, as in Eqs. 5862. Equation 62 expresses the failure index and if it becomes a minus value, the failure happens.

$$\tau_{\text{oct}} = \tau_{\text{o}} + m(\sigma_{\text{oct}} - P_{\text{f}} )$$
(58)

where

$$\tau_{\text{oct}} = \frac{1}{3}\sqrt {(\sigma_{2} - \sigma_{3} )^{2} + (\sigma_{3} - \sigma_{1} )^{2} + (\sigma_{1} - \sigma_{2} )^{2} }$$
(59)
$$\sigma_{\text{oct}} = \frac{1}{3}(\sigma_{1} + \sigma_{2} + \sigma_{3} )$$
(60)
$$m = \frac{2\sqrt 2 \sin \phi }{3 - \sin \phi }$$
(61)
$$\tau_{\text{o}} = \frac{2\sqrt 2 \cos \phi }{3 - \sin \phi }$$
(62)

Results of the program

In this study, some different in situ stresses are applied to check the result of the failure index values in the wellbore. All the cases are investigated for the boundary condition equations of 51–55 and input parameters of Table 1. To find the results of the stress values, pressures and temperatures should be calculated. Temperature values are related to the saturations of each phase, therefore, saturations also should be defined for each node during the time of WAG injection. Calculation of these parameters is crucial in the first step of injection as they have a sharp change in the wellbore.

At the first stage, water injection implemented. The pressure increases as the injection continues. Figure 9 shows the graph of oil pressure versus time at 3.65 cm distance from wellbore wall. As the injection starts, the pressure increases sharply from 3600 (original reservoir pressure). It increases incrementally after 10 s of injection.

Fig. 9
figure 9

Oil pressure versus water injection time at the distance of 3.65 cm from the wellbore

The oil pressure profile is expressed in Fig. 10. It is obtained after 4 s of water injection. The pressure is boosted regarding the injection and the pressure enhancement continues to go further in the wellbore as water injection continues.

Fig. 10
figure 10

Oil pressure in different distances around the wellbore at 4th second of injection

The water saturation profile is depicted in Fig. 11. These results are obtained after 4 s of injection. The results show how oil is pushed by the water around the wellbore. After 4 s, the injected water breaks through at 8 cm distance of wellbore wall. It continued further as water injection was continued. It is obvious in the graph that after 8 cm, the area in untouched and the saturation of the water is 0.22 which is the connate water saturation.

Fig. 11
figure 11

Water saturation during water injection around the wellbore at 4th second of injection

Figure 12 shows the water saturation at the node of 3.65 cm far from wellbore wall. It shows that how saturation increases with time. After the bank of water reaches, there is a sharp increase of the water saturation. After about 15 s, the water saturation slightly increases until the point that no more oil could be removed from the pores (residual oil saturation).

Fig. 12
figure 12

Water saturation versus injection time at the distance of 3.65 cm from the wellbore

Gas injection conducted after water injection. Figure 13 shows the results recorded after 12 s of gas injection into two-phase medium of oil–water around the wellbore. As it is shown in the figure, gas phase reaches to 14 cm during this 12 s of gas injection. The gas saturation of the untouched area is zero and only water and oil phases exist in that area.

Fig. 13
figure 13

Water and gas saturation during gas injection around the wellbore (after 12 s of gas injection)

Temperature distribution obtained after the saturations of the 3 phases had been determined. Figure 14 shows the temperature distribution in nearby wellbore during injection. The initial value of the reservoir temperature is 70 °C (refer to the Table 1) and the injection temperature is 50 °C. The temperature distribution around the wellbore is highly sensitive to the injection.

Fig. 14
figure 14

Wellbore temperature during water injection process

The stress values and the failure are studied in three different cases. The three cases show different failure conditions, based on in situ stress values and injection pressures. The first case shows the normal failure (as in fracturing). The second case expresses the compressive failure and the last case describes the shear failure (as in sand production phenomenon).

Case 1

The in situ stress values and injection pressure is expressed in Table 2. Radial stress around the wellbore is depicted in Fig. 15. The horizontal maximum and minimum stresses are 35 and 30 MPa, respectively (refer to the Table 2). In the 2D graph (left side of Fig. 15), the effect of horizontal maximum stress is obvious in the direction of east–west. Radial stress values are very important in normal and compaction failure. Tangential stress values are depicted in Fig. 16. The highest tangential stress value is recorded at the wellbore and in the direction of minimum horizontal stress. Figure 17 depicts the vertical stress around the wellbore. Vertical stress is the weight of the overlying strata. The original value of the vertical stress, in this case, is 36 MPa and the distribution shows that it is almost the same around the wellbore, except in the region of the wellbore wall. It is important to note that horizontal maximum and minimum stresses have no effect on the vertical stress in each node and only the distance from the wellbore is important. The shear stress around the wellbore is depicted in Fig. 18. The direction of the maximum and minimum shear stresses is 45° with respect to the maximum and minimum horizontal stresses.

Table 2 In situ stress values and injection pressure for case 1
Fig. 15
figure 15

Radial stress values at the top level of the cube around the wellbore for case 1

Fig. 16
figure 16

Tangential stress values at the top level of the cube around the wellbore for case 1

Fig. 17
figure 17

Vertical stress values at the top level of the cube around the wellbore for case 1

Fig. 18
figure 18

Shear stress values at the top level of the cube around the wellbore for case 1

The failure index is obtained according to the stress results and the procedure of step 4. Figure 19 shows the failure index. In this case, the failure is called “normal failure”. The result of this type of the failure is fracturing. As seen in the input data from Table 2, the amount of injection pressure is very high. This high injection pressure induced high radial stress in wellbore wall (Fig. 15). Therefore, fracturing will happen in this case and it is shown (in Fig. 19) as blue color. The fracturing should be in the direction of the maximum horizontal in situ stress, and it is approved in the graph result of Fig. 19. Moreover, the direction of minimum in situ stress is in the most stable condition.

Fig. 19
figure 19

Failure index around the wellbore for case 1; normal failure

To sum it up, fracturing will happen if the injection pressure becomes very high. In this case, the wellbore wall cannot withstand the induced normal stress. The direction of the fracturing is the same as the direction of the maximum horizontal in situ stress.

Case 2

The in situ stress values and injection pressure are expressed in Table 3. The horizontal maximum and minimum stresses are 39 and 30 MPa, respectively (refer to the Table 3). Figure 20 shows the failure index. In this case, the failure is called, “compaction failure”. The result of this type of the failure is crushing the wellbore in the direction of minimum horizontal in situ stress (opposite direction from the case of normal failure). The wellbore wall crashes because the values of maximum horizontal stress are very big with regard to the minimum in situ stress value. In this case, if the wellbore pressure is not sufficient, the compaction failure will happen (as seen in the input data from Table 2, the amount of injection pressure is low). It is shown (in Fig. 20) as the blue color and it is in the opposite direction from normal failure. Such a case will happen in drilling operations, or in the production operation if the wellbore pressure drops.

Table 3 In situ stress values and injection pressure for case 2
Fig. 20
figure 20

Failure index around the wellbore for case 2; compaction failure

Case 3

The in situ stress values and injection pressure is expressed in Table 4. The horizontal maximum and minimum stresses are 35 and 30 MPa, respectively (refer to the Table 4). Figure 21 shows the failure index. In this case, the failure is called, “shear failure”. The result of this type of the failure is removing circular layers from the wellbore (as sand production). The wellbore started to produce sand because the wellbore pressure values drastically reduced regarding the oil production.

Table 4 In situ stress values and injection pressure for case 3
Fig. 21
figure 21

Failure index around the wellbore for case 3; shear failure

Sensitivity analysis

The sensitivity of wellbore fracturing to different parameters is investigated in this part. The parameters of interest in this part are injection pressure, temperature and in situ stresses. The results show the effect of each parameter on wellbore stability.

Table 5 is considered as the base case that shows the injection pressure which leads to the initiation of the failure. In this case, 3165.4 psi injection pressure will initiate the fracturing of the formation.

Table 5 Wellbore injection pressure which fractures the formation

The effect of the change in horizontal maximum stress on fracturing is expressed in Table 6. It describes that in the case of constant horizontal minimum stress, fracturing would be easier if horizontal maximum stress increases.

Table 6 The effect of horizontal maximum stress change on wellbore failure

The effect of the change in horizontal minimum stress on fracturing is showed in Table 7. It expressed that in the case of constant horizontal maximum stress the wellbore would be harder to break as horizontal minimum stress increases.

Table 7 The effect of horizontal minimum stress change on wellbore failure

Validation of failure results

The proper equipment that can serve the polyaxial test is rare and the test is very costly. Therefore, there are limited studies in this case. There are two experimental studies that can be used as the reference for this study, because of the injection condition and core characteristics. The result of this study is not completely matched the experimental results; some different facts cause this difference which is explained in each case.

Case 1

Athavale implemented an experimental study on rock failure using polyaxial testing. Figures 22 and 23 show the rock sample after failure. Figure 24 shows the result of his study (Athavale 2007; Kwasniewski et al. 2012). The vertical, horizontal maximum, minimum stress values, and injection pressure are expressed in Table 8. The result of this study is compared to the result of the model in the same table (Table 8).

Fig. 22
figure 22

Rock sample after break, top section view (Athavale 2007)

Fig. 23
figure 23

Rock sample after break, side view (Athavale 2007)

Fig. 24
figure 24

Pressure record during propagation for different cases (Athavale 2007)

Table 8 Comparison between the results of polyaxial tests and the model

Figure 25 shows the numerically simulated regarding the experiment. It is shown that the direction of fracturing is in the direction of horizontal maximum stress while the other direction is stable.

Fig. 25
figure 25

Numerical model of failure regarding the experimental result

Case 2

The hydraulic fracturing results can be used as the source of data for the validation if all the stress amounts and parameters are known. The hydraulic fracturing field data are collected from some different papers and the result is expressed and compared to the model in this part (Table 9) (Kwasniewski et al. 2012; Rahman and Rahman 2013; Raaen et al. 2006).

Table 9 Comparison between hydraulic fracturing field data and the model results

Figure 26 compares the results of the field data and the model of the study. The model predicted the results with the accuracy of 91 %.

Fig. 26
figure 26

Comparison between field data and model results of hydraulic fracturing

Case 3

Al-Ajmi (2006) presented the collection of the octahedral shear stress data for different rock samples. The data are from polyaxial tests on Shirahama sandstone rock. Table 10 shows the result from the experiment for in situ stresses and results of octahedral shear stress (Kwasniewski et al. 2012; Al-Ajmi and Zimmerman 2005, 2006; Al-Ajmi 2012). It is compared to the result of Drucker–Prager failure criteria.

Table 10 Comparison between the results of polyaxial tests and the model of this study

Figure 27 compares the results of the experiments and the model of the study. The model predicted the results with the accuracy of 81 %.

Fig. 27
figure 27

Comparison between experimental and model results

Conclusions

To ensure the wellbore stability, stresses values should be obtained. The stress values interact with pressures, temperatures and saturations regarding the change in porosity and permeability. Therefore, iterative coupling method implemented to calculate the corrected values of stress around the wellbore for WAG injection. The developed model speeds up the operation because only the parameters of stress and strain were solved by FVM, whereas the pressures, temperatures, and saturations solved by FDM.

To sum up the results of flow around the wellbore, it is recorded that the wellbore pressures and saturations changed very fast. It is due to the small wellbore area and high injection pressure. After the gas injection, OW bank pushed out of the wellbore, however, some amounts of oil and water remained in the pores and need chemical treatment to be removed. Temperature values affect the wellbore stress; in the case of injection, wellbore cooling will happen and might cause stability problems. Temperature values are related to the saturation distribution around the wellbore for each phase. Therefore, these values calculated after flow study had completed.

Stress redistribution will happen around the wellbore after the injection. The stress value is a function of in situ stresses, pressures, and temperatures. Maximum values of radial stress are in the direction of horizontal maximum in situ stress. The values are important in wellbore failure because fracturing will happen in this direction. Maximum values of tangential stress are in the direction of horizontal minimum in situ stress. Vertical stress around the wellbore is not related to horizontal maximum and minimum in situ stresses. It is a function of wellbore radius, pressures, and temperatures. The direction of the maximum shear stress is 45° with respect to maximum horizontal in situ stress.

Three different cases are investigated to show the three different failure types. In the first case, high injection pressure leads to normal failure as fracturing; it started in the direction of maximum in situ stress. In the second case, compaction failure occurred which is caused by the high difference between in situ maximum and minimum pressure and lack of well pressure support. It started in the direction of minimum in situ stress. The third case investigated the shear failure as in sand production. The low wellbore pressure caused the layers of the sand separated from the wall; this type of the failure is common in production wells.