1 Introduction

Shale gas development has the characteristics of large quantity, poor quality and difficulty in mining. It is difficult to carry out an economical and efficient model for large-scale development methods through traditional theories. Therefore, it is necessary to create cluster horizontal wells, to increase the number of wells per platform and reduce the number of well factory platforms. Shale gas development first needs to determine the well pattern in the target area, then the location and number of platforms, and the relationship between each platform and the target. Optimizing the location of the drilling platform could reduce the cost of shale gas development. The concept of platform position optimization was first proposed by Devine and Lesso [1], who developed a model for offshore drilling. Since then, it has been studied by many scholars [2,3,4]. The solving algorithms for optimization model established by predecessors mainly include implicit enumeration method [5], graph theory algorithm [2], clustering analysis method [6], genetic algorithm [7], etc. The objective function mainly includes the minimum total well depth, the minimum sum of horizontal displacement and the minimum drilling cost. On the basis of minimum drilling cost, Wang established an optimization model of well factory platform position considering learning effect [8]. Most of the above studies have been applied to field practice of horizontal well development in shale gas fields, with drilling cost as the optimization objective. The objective function is usually just the accumulation of drilling cost with respect to a single well. However, water resource management is also an important factor affecting the optimization of platform location (Fig. 1).

Fig. 1
figure 1

Shale gas development model diagram in mountainous areas

As fracturing technology and horizontal drilling technology rapidly improving, the development potential of shale gas is gradually revealed [9]. Hydraulic fracturing requires a large number of freshwater [10] and produces wastewater with high salinity [11], which brings great harm to the environment. To solve the above problems, many studies on water resources management have been applied in the shale gas development. Shih and Krupnick [12] considered the interests of multiple parties and established a framework for a multi-objective sewage management planning model. Zhang et al. [13] established an uncertain optimization model for shale gas wastewater treatment by taking the minimum economic cost as the objective function. Bartholomew and Mauter [14] established a mixed-integer linear programming model considering the two goals of the maximum economic cost and minimum environmental impact. Existing water resources management literature only considered the issues of water access and sewage distribution, ignoring the scale effect of sewage treatment. Under the well factory model, the scale effect plays a vital role in sewage treatment cost, and it is also an important factor that affects the optimization of platform location.

2 Process of Treatment and Reuse of Flowback Fluid

One of the main processes for shale gas development is hydraulic fracturing. The part of the injected fluid that returns to the surface is called the flowback fluid, which is high in salinity. If it is not treated, flowback fluids will contaminate the aquifer and surface water [15]. The composition of flowback fluid changes constantly during flowback process, and the total dissolved solids (TDS) are used to express the total amount of dissolved substance in the flowback fluid [11]. The first few days after hydraulic fracturing is called the flowback period. At this time, a surprising amount of sewage flows back to the surface, which contains a low TDS value and can be reused after simple treatment. In the production period of shale gas, the TDS value of flowback fluid will gradually increase to a peak constant value [16], and the flowback rate will gradually decrease and become stable. For sewage during the production period, decision-makers will conduct on-site treatment or deep well injection based on scientific calculation and optimization [17] (Fig. 2).

Fig. 2
figure 2

Example flowback volume vs. TDS profile

2.1 Scale Effect

Obviously, it is convenient to deal with flowback fluid in centralized way for well factory development mode. As the number of fractured wells on the platform increases, the scale of the flowback fluid correspondingly increases. Meanwhile, the unit treatment cost of flowback fluid decreases significantly.

The recycling process of fracturing flowback fluid is mainly composed of sedimentation filtration and other technical units which efficiently remove suspended particles, colloids, bacteria and other impurities in flowback fluid to meet the requirements of recycling. The field treatment of fracturing fluid is mainly affected by raw water quality, equipment scale and treatment grade. In this paper, the treatment of flowback fluid in production period is divided into three levels according to the treatment grade. Primary treatment clarifies and removes suspended solids; secondary treatment softens and removes hardness ions; three-stage treatment is desalination and reduces TDS concentration. After these three levels of treatment, the flowback fluid will reach the standard of discharge and can be used again.

The operating costs which have a nonlinear relationship with the processing scale mainly include energy consumption, medicinal materials, personnel costs, etc. Dore classified sewage based on the different pollutants contained in sewage and first proposed treatment curve considering scale effect [18]. In the actual sewage treatment unit, the following function can be used to express the specific relationship:

$$ y_{t} = \beta_{1} x_{t}^{{\beta_{2} }} + \varepsilon_{t} $$
(1)

\(y_{t}\) represents the equipment operation and maintenance cost per unit handling capacity;\(x_{t}\) is the processing scale designed for the device; \(\varepsilon_{t}\) represents error coefficient; \( \beta_{1}\) and \(\beta_{2}\) refer to regression coefficient (Fig. 3).

Fig. 3
figure 3

Processing cost versus processing scale

3 Mathematic Model

In shale gas development, drilling cost and water resource management cost make up the relatively large part of the total cost, so these two factors should be taken into account when optimizing well factory platform mode. The optimization problem of platform [19] can be expressed as follows: On the premise of the given configuration of the horizontal well, the optimal parameters (including location, platform number, platform allocation and water resources management parameters [20]) can minimize the total cost. Actually, this is a 0–1 integer programming problem. After elaborating the objective function and constraints, the optimization model can be established.

3.1 Transportation Cost

In shale gas development, the transportation of water resources includes clean water and sewage. The influencing factors of transportation involve transportation cost per unit distance, transportation volume and total distance [21]. The cost of sewage transportation represents transporting sewage from the well site to the abandonment well, which can be expressed by considering truck transportation

$$ {\text{Cos}} t^{{{\text{truck}}}} = C^{{{\text{truck}}}} \cdot D_{j,s} \cdot \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{i,j,t}^{{{\text{disposal}}}} } } } $$
(2)

The clean water transportation cost [22] denotes transporting the clean water from the water source to the well site

$$ {\text{Cos}}\,t^{{{\text{tube}}}} = C^{{{\text{tube}}}} \cdot D_{j,d} \cdot \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{i,j,t}^{fw} } } } $$
(3)

The sewage produced two weeks before the return period is set as \(l_{1}\) class, and the sewage produced after the production period is set as \(l_{2}\) class. Hydraulic fracturing process includes \(l_{1}\) and \(l_{2}\).

$$ f_{i,j,t}^{fw} + \sum\limits_{l} {f_{i,j,l,t}^{rw} } = F_{i,j,t} ,\forall i,j,t $$
(4)
$$ \mathop \sum \limits_{t = 0}^{{t_{i,j}^{^{\prime}} }} F_{i,j,t} = F_{i,j} ,\forall i,j $$
(5)

\({\text{Cos}} \,t^{{{\text{truck}}}}\) stands for sewage transportation cost; \({\text{Cos}} \,t^{{{\text{tube}}}}\) represents the transport cost of clean water; \(C^{{{\text{truck}}}}\) is the unit distance transportation cost per unit of flowback fluid transported by truck; \(C^{{{\text{tube}}}}\) is the unit distance transportation cost per unit of freshwater transported by pipe; \(D_{j,s}\) represents the distance between abandonment well \(s\) and platform \(j\); \(D_{j,d}\) denotes the distance between water source \( d\) and platform \(j\); \(f_{i,j,l,t}^{rw}\) represents the level \( l\) sewage volume used in hydraulic fracturing of well \(i\) of platform \(j\) in week \( t\); \(f_{i,j,t}^{fw}\) is the clearwater of well \(i\) transported to platform \(j\) in week \( t\);\(f_{i,j,t}^{{{\text{disposal}}}}\) represents the quantity of sewage directly discarded from well \(i\) of platform \(j\) in week \( t\);\(F_{i,j,t}\) is a constant, which represents the water required for fracturing of well \(i\) of platform \(j\) in week \( t\); \(F_{i,j}\) is the total amount of water required for fracturing of well \(i\) of platform \(j\), \(t_{i,j}^{^{\prime}}\) is the time required to complete fracturing of well \(i\) of platform \(j\).

3.1.1 Sewage Management During Flowback Period

According to engineering experience from literature works, most of the flowback period is within 7–14 days [13, 23]. It is difficult to determine the fluctuation of flowback sewage in the flowback period every day, so this paper takes a week as the unit time. If the actual flowback period is less than two weeks, it can be reflected by reducing the average weekly flowback rate. Therefore, it is meaningful to select the first two weeks as the flowback period, which is beneficial to model construction.

During the flowback period, the amount of sewage produced by well \(i\) of platform \(j\) is related to the flowback rate and the total water required for hydraulic fracturing of the well [20]. The specific relationship is given as follows:

$$ \mathop \sum \limits_{{t = t_{i,j}^{^{\prime}} + 1}}^{{t_{i,j}^{^{\prime}} + 2}} F_{i,j,t}^{fb} = \eta_{fb} F_{i,j} ,\forall i,j,t_{i,j}^{^{\prime}} $$
(6)

There would be reusing and abandonment of the flowback sewage produced in the first two weeks of hydraulic fracturing directly.

$$ f_{i,j,t}^{{{\text{fbdisposal}}}} + f_{i,j,t}^{{{\text{directuse}}}} = F_{i,j,t}^{fb} ,\forall i,j,t $$
(7)

The recycled flowback drainage shall not exceed the flowback drainage available at the wellsite. The sewage produced during the return period is placed in a series of centralized storage tanks. Referring to the idea of state transfer equation, the following equations can be obtained:

$$ fbx_{t} - fbx_{t - 1} = \sum\limits_{j} {\sum\limits_{i} {f_{i,j,t}^{{{\text{directuse}}}} } } ,\forall t $$
(8)
$$ \sum\limits_{j} {\sum\limits_{i} {f_{{i,j,l_{1} ,t}}^{rw} } } \le fbx_{t} - fby_{t} ,\forall j,t $$
(9)

The amount of indirect abandoned sewage in the flowback period is affected by the amount of flowback sewage and the total amount of reuse.

$$ f_{fbo}^{{{\text{disposal}}}} = \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {F_{i,j,t}^{fb} } } } - \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{{i,j,l_{1} ,t}}^{rw} } } } ,\forall i,j,t $$
(10)

\(F_{i,j,t}^{fb}\) represents the flowback liquid quantity of well \(i\) at platform \(j\) in week \( t\) of flowback schedule; \(\eta_{fb}\) said flowback rate of fracturing in the first two weeks; \(f_{i,j,t}^{{{\text{fbdisposal}}}}\), \(f_{i,j,t}^{{{\text{directuse}}}}\) is the decision variable, \(f_{i,j,t}^{{{\text{fbdisposal}}}}\) means the amount of sewage discarded in return period of well \(i\) of platform \(j\) in week \( t\),\(f_{i,j,t}^{{{\text{directuse}}}}\) means the amount of sewage reused in return period of well \(i\) of platform \(j\) in week \( t\);\(f_{fbo}^{{{\text{disposal}}}}\) represents the total amount of sewage produced in flowback period that needs to be transported to the disposal well, because it is not directly reused to the subsequent fracturing process;\(fbx_{t}\) is the total amount of available sewage stored in the centralized pool at the beginning of week \( t\), and \(fby_{t}\) is the total amount of remaining available sewage after the configuration of pressure cracking fluid at the end of week \( t\).

3.1.2 Sewage Management During the Production Period

During the production period of shale gas, the amount of sewage produced by well \(i\) of platform \(j\) is also related to the flowback rate and the total water required for hydraulic fracturing. The specific relationship is as follows:

$$ \sum\limits_{t} {F_{i,j,t}^{pr} } = \eta_{pr} F_{i,j} $$
(11)

The sewage produced during the production period of shale gas can be managed by reuse after on-site treatment and direct disposal.

$$ f_{i,j,t}^{{{\text{onsite}}}} + f_{i,j,t}^{{{\text{prdisposal}}}} = F_{i,j,t}^{pr} ,\forall i,j,t $$
(12)

The recycled flowback drainage shall not exceed the flowback drainage available at the wellsite. The sewage produced during the return period is placed in a series of centralized storage tanks. Referring to the idea of state transfer equation, the following expression can be obtained:

$$ prx_{t} - prx_{t - 1} = \gamma \cdot \sum\limits_{j} {\sum\limits_{i} {f_{i,j,t}^{{{\text{onsite}}}} } } ,\forall t $$
(13)
$$ \sum\limits_{j} {\sum\limits_{i} {f_{{i,j,l_{2} ,t}}^{rw} } } \le prx_{t} - pry_{t} ,\forall j,t $$
(14)

The total amount of abandoned sewage includes the discarded sewage in the flowback period after hydraulic fracturing of each well at each well site and the other comes from production period. The specific expression is as follows:

$$ f_{i,j,t}^{{{\text{fbdisposal}}}} + f_{i,j,t}^{{{\text{prdisposal}}}} = f_{i,j,t}^{{{\text{disposal}}}} ,\forall i,j,t $$
(15)

The amount of indirect abandoned sewage in the production period is affected by the amount of sewage treated on-site and the total amount of reuse.

$$ f_{{{\text{pro}}}}^{{{\text{disposal}}}} = \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{i,j,t}^{{{\text{onsite}}}} } } } - \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{{i,j,l_{2} ,t}}^{rw} } } } ,\forall i,j,t $$
(16)

\(F_{i,j,t}^{pr}\) represents the flowback fluid quantity of well \(i\) of platform \(j\) in week \( t\) at production period; \(\eta_{pr}\) represents the flowback rate during production period; \(f_{i,j,t}^{{{\text{prdisposal}}}}\), \(f_{i,j,t}^{{{\text{onsite}}}}\) is the decision variable, \(f_{i,j,t}^{{{\text{prdisposal}}}}\) represents the quantity of sewage discarded in production period of well \(i\) of platform \(j\) in week \( t\), \(f_{i,j,t}^{{{\text{onsite}}}}\) represents the quantity of sewage reuse in production period of platform \(j\) in week \( t\); \(f_{{{\text{pro}}}}^{{{\text{disposal}}}}\) represents the total amount of sewage produced in production period that needs to be transported to the disposal well, because it is not directly reused to the subsequent fracturing process; \(\gamma\) is parameters, said the recovery rate of sewage; \(fbx_{t}\) is the total amount of available sewage stored in the centralized pool at the beginning of week \( t\), and \(fby_{t}\) is the total amount of remaining available sewage after the configuration of pressure cracking fluid at the end of week \( t\).

3.2 Sewage Treatment Cost

On-site treatment is a technology for flowback fluid, which can effectively reduce the impact on environment. At the same time, the reuse of sewage can greatly reduce the consumption of freshwater resources. The field treatment consists of three levels. Primary treatment involves coagulation and sedimentation, and an analogy is made with data from a small municipal sewage treatment plant. The secondary treatment involves lime soda softening, and its operation and maintenance cost model are based on McGivney’s model of the same process at various sewage treatment plants [24].Third-stage treatment reducing salt content in flowback fluid includes reverse osmosis, electrodialysis, thermal method, etc. The operation cost mainly lies in power consumption, which is less affected by scale effect [25]. The operation and maintenance costs of each processing level are expressed as follows

$$ y_{j,t}^{1} = 124.0\left( {\sum\limits_{i} {f_{i,j,t}^{{{\text{onsite}}}} } } \right)^{ - 0.452} ,\forall i,j,t $$
(17)
$$ y_{j,t}^{2} = 109.8\left( {\sum\limits_{i} {f_{i,j,t}^{{{\text{onsite}}}} } } \right)^{ - 0.584} ,\forall i,j,t $$
(18)
$$ y_{j,t}^{3} = 0.417\left( {\sum\limits_{i} {f_{i,j,t}^{{{\text{onsite}}}} } } \right)^{ - 0.3048} ,\forall i,j,t $$
(19)

The total operation and maintenance cost of on-site treatment of sewage produced during the shale gas development and production period can be obtained

$$ {\text{Cos}} \,t^{{{\text{onsite}}}} = \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{i,j,t}^{{{\text{onsite}}}} \cdot (y_{j,t}^{1} + y_{j,t}^{2} + y_{j,t}^{3} )} } } ,\forall i,j,t $$
(20)

When the amount of sewage treated on-site is less than the minimum treatment scale, the treatment cost is no longer affected by the scale effect. Therefore, when considering the scale effect, the amount of sewage treated on-site is required to meet the following expression

$$ \sum\limits_{i} {f_{i,j,t}^{{{\text{onsite}}}} } \ge f_{\min }^{{{\text{onsite}}}} $$
(21)

\(f_{i,j,t}^{{{\text{onsite}}}}\) is the decision variable, representing the amount of sewage treated on-site at well \(i\) of platform \(j\) in week \( t\);\(y_{j,t}^{1}\), \(y_{j,t}^{2}\) and \(y_{j,t}^{3}\) represent the operation and maintenance costs of each processing level of platform \(j\) in week \( t\), respectively; \({\text{Cos}} \,t^{{{\text{onsite}}}}\) represents the cost of sewage treatment on-site; \(f_{\min }^{{{\text{onsite}}}}\) represents the minimum on-site processing size.

3.3 Water Resources Management

Based on the original research, we introduce the scale effect into water resources management. The flowback fluid has a high concentration of dissolved solids, fracturing agents and other substances. Without on-site treatment, sewage will cause waste of water resources and do harm to the environment. Water resources management involves the allocation of clean water, sewage treatment and the recycling of treated sewage, which is a systematic engineering problem (Fig. 4).

Fig. 4
figure 4

Water flow in shale gas development

Water resources management usually needs to consider the economic cost and the environmental impact comprehensively. The environmental impact is represented by the amount of sewage reinjected into the deep well, and the economic cost is represented by the transportation cost and the treatment cost [26]. The economic cost of the treatment is expressed as

$$ E_{N} = {\text{Cos}} t^{{{\text{truck}}}} + {\text{Cos}} t^{{{\text{tube}}}} + {\text{Cos}} t^{{{\text{onsite}}}} $$
(22)

The environmental impact of the treatment solution is expressed as

$$ E_{W} = \sum\limits_{j} {\sum\limits_{i} {\sum\limits_{t} {f_{i,j,t}^{{{\text{disposal}}}} } } } + f_{{{\text{fbo}}}}^{{{\text{disposal}}}} + f_{{{\text{pro}}}}^{{{\text{disposal}}}} $$
(23)

\(E_{W}\) represents environmental impact; \(E_{N}\) is the economic cost; \({\text{Cos}} t^{{{\text{truck}}}}\) stands for sewage transportation cost; \({\text{Cos}} t^{{{\text{tube}}}}\) represents the transport cost of clean water; \({\text{Cos}} t^{{{\text{onsite}}}}\) represents the cost of sewage treatment on-site; \(f_{i,j,t}^{{{\text{disposal}}}}\) represents the amount of sewage directly discarded from well \(i\) of platform \(j\) in week \( t\).

Consider minimizing economic cost and environmental impact, the multi-objective optimization [20] function of water resources management is expressed as

$$ \min F = w_{1} E_{W}^{{{\text{new}}}} + w_{2} E_{N}^{{{\text{new}}}} $$
(24)
$$ E_{W}^{{{\text{new}}}} = \frac{{E_{W} }}{{E_{W}^{*} }} $$
(25)
$$ E_{N}^{{{\text{new}}}} = \frac{{E_{N} }}{{E_{N}^{*} }} $$
(26)

\(E_{N}^{*}\) is the minimum economic cost; \(E_{W}^{*}\) represents the minimum environmental impact; \(w_{1}\) and \(w_{2}\) represent the relative importance weight of economic cost and environmental impact when the sum of the two is 1; \(E_{W}^{{{\text{new}}}}\) and \(E_{N}^{{{\text{new}}}}\) are the normalized environmental impact and economic cost, respectively. When \(w_{1}\) and \(w_{2}\) take different values, different optimal solutions can be obtained.

3.4 Drilling Cost

Single well drilling cost is closely related to borehole track, casing design, drilling and completion technology, etc. [27, 28]. Under the premise of drilling and completion construction scheme, single well drilling cost can be regarded as a function of horizontal section length, lateral displacement and longitudinal displacement between wellhead and target. Figure 5 shows the relative position relationship between platform and horizontal segment. Point \(O\) represents the platform and line \(AB\) represents the horizontal segment.

Fig. 5
figure 5

Schematic diagram of the relative position between platform and horizontal section

The lateral length is independent of the platform location, so the cost of lateral drilling part is not taken into account. The drilling cost expression of single well \(j\) of the platform is

$$ f_{i,j} \left( {l_{i} ,\rho_{i,j} ,\sigma_{i,j} } \right) = d_{1} \sigma_{i,j}^{2} + d_{2} \sigma_{i,j} + d_{3} \rho_{i,j}^{2} + d_{4} \rho_{i,j} $$
(27)

Here,

$$ \sigma_{i,j} = \left| {\left( {y_{B,i} - y_{A,i} } \right)X_{j} - \left( {x_{B,i} - x_{A,i} } \right)Y_{j} - x_{A,i} y_{B,i} + y_{A,i} x_{B,i} } \right|/l_{i} $$
(28)
$$ \rho_{i,j} = \sqrt {\left( {X_{j} - x_{A,i} } \right)^{2} + \left( {Y_{j} - y_{A,i} } \right)^{2} - \sigma_{i,j}^{2} } $$
(29)

Here, \(l_{i}\),\(\sigma_{i,j}\) and \(\rho_{i,j}\) represent the length of the horizontal segment of \(i\), longitudinal offset and lateral offset between platform \(j\) and the horizontal segment of \(i\); \(d_{1}\), \(d_{2}\), \(d_{3}\) and \(d_{4}\) represent the correlation coefficient of drilling cost of a single well; \(X_{j}\) and \(Y_{j}\) represent the coordinates of the center point of the \(j\) platform; \(x_{A,i}\), \(y_{A,i}\), \(x_{B,i}\) and \(y_{B,i}\) represent the coordinates of the heel end and finger end of the horizontal segment of \(i\), respectively.

3.5 Cost of Platform

The platform cost can be regarded as a function of the number of wells drilled on the platform [29], which is expressed as:

$$ p_{j} = \mu \left[ {a_{0} + b_{0} \left( {N_{j} - 1} \right)} \right] $$
(30)

\(p_{j}\) represents the construction cost of platform \(j\); \(\mu\) said platform of the construction costs per unit area; \(N_{j}\) represents the number of wells drilled on platform \(j\);\({ }a_{0}\) and \(b_{0}\) are constants.

3.6 Well Factory Platform Optimization

Based on the existing research [30], the proposed model takes the influence of water resources management on well factory location into account. To sum up, the total cost of all platform wells includes drilling cost, platform cost and water resources management cost, which is expressed as

$$ \min Z = \mathop \sum \limits_{j = 1}^{{N_{P} }} \left[ {\mathop \sum \limits_{i = 1}^{{N_{w} }} t_{i,j} f_{i,j} + p_{j} } \right] + E_{N} $$
(31)

Constraint conditions:

$$ \left\{ {\begin{array}{*{20}c} {\mathop \sum \limits_{j = 1}^{{N_{P} }} t_{i,j} = 1,\forall i,j} \\ {\mathop \sum \limits_{j = 1}^{{N_{W} }} t_{i,j} = N_{j} ,\forall i,j} \\ {N_{j} \le N_{\max } ,\forall j} \\ {f_{i,j} \le f_{\max } ,\forall i,j} \\ \end{array} } \right. $$
(32)

and

$$ t_{i,j} \in \left\{ {0,1} \right\},\forall i,j $$
(33)

Here, \(p_{j}\) represents the construction cost of platform \(j\); \(w_{j}\) represents the transportation cost of reinjection processing of platform \(j\); \( f_{i,j}\) represents the drilling cost of single well \(i\) of platform \(j\); \(E_{N}\) is the cost of platforms water resources management;\({ }N_{W}\) represents the number of wells to be built; \(N_{P}\) represents the number of platforms to be built; \(N_{\max }\) represents the maximum number of wells drilled on the platform. \( f_{\max }\) represents the maximum drilling cost per well; \(t_{i,j}\) is the decision variable. If well \(i\) is completed by platform \(j\), \(t_{i,j}\) = 1; otherwise, \(t_{i,j}\) = 0.

4 The Strategy of Solution

For the platform position optimization method, the previously used algorithms are only applicable to some specific simpler systems. The well factory platform optimization can be solved quickly according to the principle of genetic algorithm [31]. When using genetic algorithm [32] to solve the established model, the corresponding relationship between well and platform is considered in coding, crossover and mutation operation. On the basis of the traditional genetic algorithm [7], this paper adds the dynamic penalty function, which can reduce calculating time and minimize the possibility of falling into local optimal result.

4.1 Initialization and Encoding

The initial population is generated by random selection, and binary coding is used in the coding process. If the number of wells and the number of platforms are \(N_{W}\) and \(N_{P}\), the decision matrix is \(N_{W} \times N_{P}\). In the decision matrix, each row can only have one 1, which means that each well can only be drilled by one platform. The sum of each column should not be greater than \(N_{max}\), indicating that the number of wells in one platform should not exceed its maximum capacity. For the convenience of operation, the decision matrix is transformed into \(N_{W} \times N_{P}\) elements of the vector, and on behalf of a chromosome. Taking three wells on three platforms as an example, the coding process is as follows (Fig. 6):

Fig. 6
figure 6

Encoding diagram

4.2 Choose

In the selection operation, the chromosome with the highest fitness function value is selected according to the given fitness function for the next operation. To ensure that the number of wells drilled by platform \(j\) do not exceed the maximum capacity of the platform, the fitness function is limited by penalty factor. If the number of wells drilled by platform \(j\) is greater than the maximum capacity of the platform, the penalty term is added to punish it. The dynamic penalty function method [33] is a direct and effective method to deal with constraint optimization problems. The fitness function is expressed by:

$$ \begin{aligned} F & = N_{w} f_{\max } + N_{P} C_{\max } + E_{N\max } - N_{j} \le N_{\max } \\ & \quad \, \mathop \sum \limits_{j = 1}^{{N_{P} }} \left[ {\mathop \sum \limits_{i = 1}^{{N_{w} }} t_{i,j} f_{i,j} + p_{j} } \right] - E_{N} \\ \end{aligned} $$
(34)
$$ \begin{aligned} F & = N_{w} f_{\max } + N_{P} C_{\max } + E_{N\max } - \, N_{j} > N_{\max } \\ & \quad \mathop \sum \limits_{j = 1}^{{N_{P} }} \sigma \mathop \sum \limits_{i = 1}^{{N_{w} }} t_{i,j} f_{i,j} - \mathop \sum \limits_{j = 1}^{{N_{P} }} p_{j} - E_{N} \\ \end{aligned} $$
(35)

\(F\) is the fitness function, \(f_{\max }\) is the maximum allowable cost of single well drilling, \(C_{\max }\) is the maximum cost of platform construction, \(E_{N\max }\) is the maximum cost of platform water resources management, \(\sigma\) is the penalty factor.

In the dynamic penalty function method [34], the penalty factor \(\sigma\) varies with the number of iterations. S-type penalty function can ensure local convergence and global searching ability, as shown in Fig. 7.

$$ \sigma ({\text{gen}}) = 10^{{k_{1} }} (1 + (k_{2} \cdot {\text{gen}}/G_{\max } )^{ - 2} )^{ - 1} $$
(36)
Fig. 7
figure 7

Variation in \(\sigma\) versus \(gen\)

\({\text{gen}}\) is the number of iterations, \(G_{\max }\) is the maximum number of iterations, and \(k_{1}\) and \(k_{2}\) are parameters, whose values directly affect the range of \(\sigma\).

In the initial stage, the small value of the penalty function enables the population to obtain the optimal global solution. In contrast, at the last stage, the large value of the penalty function limits the search for the feasible region and forces the population to converge to the optimal solution.

After the fitness function of each chromosome is calculated, the roulette is used to select the chromosome, and the selection probability of the chromosome can be calculated by the following formula.

$$ P_{i} = e^{{ - \beta \frac{{F_{\max } - F_{i} }}{{F_{\max } }}}} $$
(37)

Here, \(P_{i}\) represents the selection probability of chromosome \(i\);\(\beta\) said representation selection probability of constant;\(F_{i}\) represents the fitness function value of chromosome \(i\);\(F_{max}\) represents the maximum fitness function in the population.

4.3 Cross

The crossover operation can randomly exchange the genes of two chromosomes and generate new chromosomes. In this paper, the single-point crossover method is adopted. Considering the constraints in the established model, the genes after the crossover position are exchanged.

$$ P_{{{\text{cross}}}} = unidrnd\left( {N_{w} - 1} \right)N_{p} + 1 $$
(38)

\(P_{{{\text{cross}}}}\) represents the intersection position; \(unidrnd\left( {N_{w} - 1} \right)\) means to randomly generate an integer between 1 and \(N_{w} - 1\).

4.4 Variation

Mutation operation can randomly change the selected chromosome genes, thus avoiding local convergence of the algorithm. Taking three wells and three platforms as an example, the schematic diagram of crossover and mutation operations is shown in Fig. 8.

Fig. 8
figure 8

The crossover and mutation operation diagram of the genetic algorithm

5 Case Study

A shale gas development well site in a mountainous area of Sichuan Province, China, is selected as the research object. There is a first-class tributary of the Yangtze River near the well site with abundant water, and a water transport pipeline is built between the well site and the water source. This paper referred to relevant literature and quoted water resources management parameters of a shale gas area in Sichuan, China [35]. It is assumed that the sewage produced in the flowback period meets the standard of direct reuse, and the sewage produced in the production period can meet the standard of reuse after on-site treatment.

5.1 Well Site Situation

It is known that the planned number of wells in a shale block is eight. After measurement, fifteen potential platform positions are determined to be selected, and the maximum number of wells that each platform can accommodate is eight [30]. Water management parameters, target coordinates of horizontal section and platform positions to be selected are shown in Tables 1, 2 and 3, respectively. Assuming the flowback rate during the flowback period is 6.5%, the production rate during the production period is 0.1%.

Table 1 Water management parameters
Table 2 Platform position
Table 3 Horizontal target coordinates

5.2 Water Resources Management Optimizing

The weight of economic cost and environmental impact takes 0.1 as the step length, from 0 to 1, respectively, and the sum is 1. When the environmental impact \(w_{1}\) is 1 and the economic cost \(w_{2}\) is 0, the solving problem is transformed into a single-objective optimization problem considering only the optimal environmental impact. When the economic cost \(w_{2}\) is 1 and the environmental impact \(w_{1}\) is 0, the solution problem is transformed into a single-objective optimization problem considering only the optimal economic cost. It is assumed that the number of possible wells on each platform is 2, 4 and 8. Optimization results are shown in Fig. 9.

Fig. 9
figure 9

Water resources management optimization results

In the original model [8, 14], the water resources management cost would reduce linearly as the sewage flow increases. However, because the proposed model considers the scale effect, the linear relationship is not maintained. The analysis results show that the optimization model considering scale effect can effectively reduce the cost. This occurs because the more sewage treated on-site, the lower the unit treatment cost. Moreover, as the number of wells per platform increases, the cost reduces as well. The minimal value of the cost can reach $1,510,984 when the wells number per platform is 8. This is because the amount of sewage generated by the platform will increase as the number of wells on the platform increases. Therefore, the proposed model is appropriate for the development of well factory platform.

Decision-makers can change the weight coefficients to make specific decisions according to preferences (including environmental impact and economic cost). Under the same weight, the results of water resources management are different with respect to various numbers of platform. When the weight of environmental impact is \(w_{1} = 0.9\) and the weight of economic cost is \(w_{2} = 0.1\), water resources management results are shown in Table 4.

Table 4 Water resources optimization results considering scale effect (\(w_{1} = 0.9\), \(w_{2} = 0.1\))

It can be seen that environmental impact and economic cost reduce as the number of wells per platform increases. When the number of platform wells reaches the maximum, the water resource management cost is $1,289,059, and 41,984 cubic meters of sewage is discharged. Compared with without considering scale effect, the water resource management cost was reduced by 25.02%, and the total amount of sewage disposal was reduced by 27.2%. At the same time, the more the number of platform wells, the more sewage will be treated on-site. The analysis results show that the scale effect can effectively increase the proportion of sewage reuse, thereby improving the water use efficiency of the well factory.

5.3 Well Factory Platform Optimization

It was assumed that the vertical depth of the horizontal well was the same, and when the horizontal well \(i\) was completed by the \(j\) platform, the expression of the drilling cost of a single well is

$$ f_{i,j} \left( {l_{i} ,\rho_{i,j} ,\sigma_{i,j} } \right) = 4.5 \times 10^{{{ - }5}} \sigma_{i,j}^{2} + 0.01\sigma_{i,j} + 2.5 \times 10^{{{ - }5}} \rho_{i,j}^{2} + 0.01\rho_{i,j} $$
(39)

The platform construction cost of drilling \(N_{j}\) wells is

$$ p_{j} = 50 + 3\left( {N_{j} - 1} \right) $$
(40)

Here, the crossover probability and mutation probability were set to 0.8 and 0.2, respectively, in genetic algorithm, and the population size was set to 300. The optimization results under different preference weights are shown in Table 5.

Table 5 Well factory platform optimization results

The optimal economic cost is $1,786,784, and the optimal environmental impact is 15,200 m3. The above results refer to a single-objective consideration, so the optimal environmental impact and the optimal economic cost can never be achieved at the same time. For example, when the weight of environmental impact is higher, it will result that the environmental impact is relatively lower and the economic cost is relatively higher. Decision-makers can obtain specific decisions based on the affordability of economic cost and environmental impact. With the weight increase in environment impact, the number of wells per platform changed from 4 to 8, which shows that the well factory model is conducive to the reduction in environmental impact. This result tells us that when developing shale gas areas with high environmental requirements, decision-makers should maximize the number of wells per platform.

Assuming that the weight of environmental impact is \(w_{1} = 0.9\) and the weight of economic cost is \(w_{2} = 0.1\), the platform position optimization results were obtained as shown in Figs. 10 and 11.

Fig. 10
figure 10

The optimal platform location considering scale effect

Fig. 11
figure 11

The optimal platform location without considering scale effect

It can be seen that after considering the scale effect, eight wells are drilled by one platform. Without considering the effect of scale, the result is to build two platforms, each with four wells. The total expense with scale effect is $2,718,400, a decrease of 12.67% compared to the total expense without scale effect of $3,112,570. Considering the scale effect, the total sewage disposal volume is 41,984 m3, which is 27.2% less than the total sewage disposal volume of 58,739 m3 without considering the scale effect (Table 6).

Table 6 Optimization results of well factory platform

6 Conclusion

In well factory mode, the scale effect can significantly affect the water resources management and the shale gas development. The water resources management considering the scale effect has lower unit sewage treatment costs, which is beneficial to the continued development of shale gas. The example analysis shows that the scale effect can reduce the cost of water resources management by 25.02% and the sewage discharge by 27.2%. The proposed model considering the water resources management can reduce the number of platforms and increase the number of wells per platform, which is beneficial to the application of well factory mode technology. The optimization of well factory platform location can be solved quickly according to the principle of genetic algorithm. The weight of environmental impact is the important factor affecting the platform location. For case study analysis, the scale effect in shale gas development can take full advantage of the well factory mode and reduce the cost of shale gas development by 12.67% and 27.2% of the sewage discharge. This paper’s results would provide theoretical support and practical guidance for platform optimization and water resources management in the shale gas development with scale effect.