2.1. Water Hammer Model
The propagation of water hammer waves in the wellbore is essentially governed by the combined effects of fluid mass conservation and momentum conservation. Its transient response is jointly controlled by wellbore geometric parameters, fluid compressibility, tubing elasticity, and bottomhole boundary conditions. For transient flow propagating along the wellbore axis, the classical water hammer theory can be employed to establish the coupled governing equations for pressure and flow rate, thereby describing the propagation and attenuation of pressure disturbances immediately following pump shut-in.
The transient pressure behavior in the wellbore is governed by the one-dimensional momentum and continuity equations [
25]:
where
denotes the wave velocity, m/s;
A is the cross-sectional area of the pipe, m
2;
Q is the flow rate, m
3/s; and
D is the pipe diameter, m.
where
H is the hydraulic head, m; and
z is the elevation above the reference datum, m. The water hammer wave velocity in the wellbore can be expressed as follows [
26]:
where
K denotes the bulk modulus, GPa;
ρ is the fluid density, kg/m
3;
E is the Young’s modulus of the pipe wall, GPa; and
Ψ is a dimensionless parameter introduced to account for different structural conditions, including rigid pipes, thick-walled elastic pipes, thin-walled elastic pipes, and tunnels passing through hard rock. It is determined by the following equation:
where
e is the pipe wall thickness (mm), and
ν is the Poisson’s ratio of the pipe material. Equations (1) and (2) constitute a pair of linear hyperbolic partial differential equations and therefore can only be solved numerically. To this end, the method of characteristics is employed to transform the governing partial differential equations into four ordinary differential equations, which are subsequently solved using the finite difference method. The resulting formulations can be written in terms of the characteristic equations along the
C+ and
C− lines, as given in Equations (6) and (7).
where
B denotes the characteristic impedance of the pipe, as given by
;
r denotes the pipe resistance coefficient, as defined by
; and
f is the friction factor appearing in Equation (8):
where
D is the pipe diameter, m;
ε is the pipe roughness; and Re is the Reynolds number. To fully characterize the coupled wellbore–fracture transient response after pump shut-in during hydraulic fracturing, both the wellhead flow boundary condition and the bottomhole fracture boundary condition must be specified.
At the wellhead, the flow rate is assumed to decrease linearly to zero during pump shutdown. Accordingly, the wellhead boundary condition can be defined in terms of the variation in flow rate, as expressed in Equation (9).
where
Q(
t) denotes the wellhead boundary flow rate, which varies with time during pump shut-in. By incorporating the wellhead flow boundary condition, the corresponding characteristic equations can be solved simultaneously to obtain the transient pressure response at the wellhead boundary. Based on the prescribed wellhead boundary flow rate, the hydraulic head at the wellhead boundary can then be calculated by combining Equations (7) and (9).
To simplify the bottomhole boundary, multiple fractures are represented by an equivalent single-fracture system. Following the bottomhole fracture boundary formulation proposed by Carey et al. [
14], the fracture boundary condition can be modeled by an equivalent electrical circuit consisting of constants
R,
C and
I.
Accordingly, the boundary condition is expressed as follows:
The relationships among
R,
C and
I are given by Equations (11)–(14). In the RCI-equivalent circuit model,
R,
C, and I correspond to the resistance, capacitance, and inductance elements in an electrical circuit, respectively. In the hydraulic fracturing model,
R characterizes the resistance effect generated during fluid flow in the near-wellbore region, mainly reflecting near-wellbore frictional losses (Pa·s/m
3);
C represents the storage and elastic response capacity of the fracture system, corresponding to the capacitance associated with fracture compliance (m
3/Pa); and
I characterizes the inertial effect of fluid flow in the wellbore–fracture coupled system, i.e., the inertance of the system (Pa/(m
3/s
2)).
where
Q0 is the injection rate before pump shut-in, m/s, Δ
Pnwf is the near-wellbore frictional pressure drop, MPa, Δ
V is the change in fracture volume, m
3, and Δ
P is the change in fracture pressure, MPa. The average net pressure Δ
P0 is defined as the difference between the average fracture pressure (
) and the minimum horizontal principal stress (
), MPa.
The average net pressure is related to the fracture dimensions through the following equation, and the fractures are classified into long fractures (2
Lf/
hf ≥ 1) and short fractures (2
Lf/
hf < 1) [
27].
E(
m) is the complete elliptic integral of the second kind, where the definition of
m is given in Equation (18).
The formulas for calculating fracture length, width, and height are given below.
where
Lf is the fracture half-length, m,
hf is the fracture height, m, and
w is the fracture width, m.
Previous studies have demonstrated that water hammer models based on RCI boundary conditions can effectively characterize the effects of the bottomhole fracture system on pressure wave propagation and attenuation, and have been successfully applied to the analysis of fracture length, attenuation behavior, and multi-cluster fracturing responses [
28]. Related studies further indicate that water hammer signals are highly sensitive to fracture geometry and near-wellbore boundary conditions, and generally show good agreement with monitoring results obtained from microseismic and other diagnostic techniques [
29]. Therefore, the integration of water hammer dynamic models with automated signal identification and global optimization-based inversion methods provides both a sound theoretical foundation and practical engineering feasibility for the quantitative interpretation of hydraulic fracture parameters in field applications.
2.2. Adaptive Kalman Filter-Based Shape-Preserving Denoising
Field water hammer signals recorded after pump shut-in during hydraulic fracturing typically exhibit pronounced non-stationary characteristics. At the initial stage of pump shut-in, the pressure usually undergoes a rapid drop, followed by a stage of continuously decaying oscillations, and finally transitions gradually into a relatively stable recovery process. Meanwhile, measured data are often contaminated by high-frequency random noise, local spike outliers, and abnormal disturbances, which can easily obscure the effective transient features of the original signal. If feature identification and parameter fitting are performed directly on the raw signal, significant errors may be introduced. The classical Kalman filtering method has a solid theoretical foundation in time-series signal processing and achieves optimal state estimation of the system through recursive updating [
30]. However, this method usually assumes that the process noise covariance and observation noise covariance are constant, that is, the system approximately satisfies stationary conditions. In the case of water hammer signals, which represent a typical non-stationary scenario, fixed noise parameters are difficult to adapt to the signal characteristics at different stages. During periods of abrupt transient variation, the filter response may lag behind the actual signal, leading to amplitude attenuation; during relatively stable stages, insufficient noise suppression may occur. Therefore, it is necessary to introduce an adaptive improvement to the conventional Kalman filter.
To address the above issues, this study proposes an adaptive Kalman filtering method driven by local variation intensity. Based on the local rate of change in the pressure signal, a dimensionless indicator reflecting the dynamic characteristics of the signal is constructed, and the noise parameters in the filtering process are dynamically adjusted accordingly, thereby achieving stage-wise adaptive optimization of the filtering performance.
- (1)
Data preprocessing
Let the original pressure time series be defined as follows:
Here,
ti denotes the sampling time,
p(
ti) is the corresponding wellhead pressure value, and N is the total number of sampling points. To correct isolated spike outliers that may occur in the acquired data, a Hampel filtering method based on the local median and median absolute deviation (MAD) is first employed for robust preprocessing. For the
i-th sampling point, within a local window Ω
i centered at that point with a half-window length of
k, the local median is defined as follows:
where
denotes the local median within the window corresponding to the
i-th point,
represents the median operator,
denotes the
j-th pressure value within the window, and Ω
i is the moving window set centered at the
i-th point.
The local scale estimate is given by the following:
where
denotes the locally robust estimate of the standard deviation, MPa, 1.4826 is the scaling factor used to convert the MAD into an estimate of the standard deviation, and
represents the residual relative to the median, MPa.
If a sampling point satisfies the outlier criterion, it is identified as an isolated outlier and replaced with the local median; otherwise, the original value is preserved.
is the threshold coefficient used for outlier identification and is typically chosen in the range of 3–5.
After this treatment, a pre-cleaned pressure series, ppre(ti) is obtained, namely, the pressure series after outlier correction, MPa. The purpose of this step is to remove local spike outliers without distorting the main pressure fluctuation pattern, thereby preventing anomalous points from being amplified during subsequent differentiation and threshold-based identification.
- (2)
Construction of the variation intensity indicator
To characterize the variation intensity of the water hammer signal at different stages, the rate of pressure change between two adjacent sampling instants is adopted in this study as the basic measure of local variation intensity. This indicator can reflect the dynamic differences in the pressure signal during transient abrupt changes, oscillatory decay, and stable recovery stages. A larger rate of change indicates that the signal is more likely to be in a genuine transient response stage near that instant, whereas a smaller rate of change suggests that the signal tends to become stable and that the proportion of noise components may be higher.
Therefore, after obtaining the preprocessed series, a local variation intensity indicator is further constructed to enable the subsequent adaptive adjustment of filtering parameters. The adjacent difference and the time step are defined as follows:
where Δ
pi and Δ
ti denote the pressure difference (MPa) and the time interval (s) between two adjacent sampling points, respectively. Accordingly, the absolute value of the local pressure-change slope can be expressed as follows:
where
si denotes the absolute value of the pressure change rate, MPa/s.
Considering that field signals often contain outliers and non-Gaussian disturbances, the median
smed and the median absolute deviation
smad of this sequence are further calculated to improve robustness against abnormal local fluctuations. Based on these quantities, a normalized motion score is constructed as follows:
where
smed denotes the median of the slope sequence, and
smad denotes the median absolute deviation of the slope sequence.
It is then constrained to the interval [0, 1], as follows:
where
mi is the normalized variation intensity indicator, ranging from 0 to 1, and min and max denote the truncation functions. A larger value of
mi indicates that the signal changes more abruptly in the vicinity of that time instant, and is therefore more likely to correspond to a genuine transient response rather than a stable background segment. In the present algorithm, this indicator is used to dynamically adjust the process noise and observation noise in the Kalman filtering procedure.
- (3)
Adaptive updating of Q and R
On this basis, an adaptive adjustment model for the process noise and observation noise is established as follows:
where
Q0 and
R0 are the baseline process noise and observation noise parameters, respectively;
α and
γ are adjustment coefficients; and
β is the lower-bound constraint parameter for the observation noise. The core idea of this adaptive strategy is as follows: when the signal varies abruptly,
Qk is increased to enhance the filter’s responsiveness to state variations, while
Rk is reduced to increase confidence in the observations, thereby avoiding excessive smoothing of the true oscillatory signal. In contrast, when the signal tends to become stable,
Qk is reduced and
Rk is increased so as to strengthen the denoising capability.
- (4)
Standard Kalman filtering recursion
After the dynamic updating of the noise parameters is completed, the filtering process still follows the standard recursive Kalman filtering framework, including two stages: state prediction and measurement update.
Through the above adaptive mechanism, the filter can dynamically match signal characteristics across different time scales, thereby enabling shape-preserving denoising of transient water hammer signals. Compared with the conventional Kalman filter with fixed parameters, the proposed method significantly reduces high-frequency noise interference while preserving the amplitude and phase characteristics of pressure oscillations, thus improving the signal-to-noise ratio and interpretability of the signal.
Overall, the proposed adaptive Kalman filtering method based on local variation intensity can adjust the filtering parameters in real time according to the dynamic variation characteristics of the pressure signal, achieving a better balance between suppressing high-frequency noise and preserving effective transient features. Compared with fixed-parameter filtering, the present method is able to dynamically match signal variation characteristics over time scales and effectively suppress high-frequency noise and local abnormal disturbances while retaining the principal oscillation period, amplitude, and phase information of the water hammer signal. This method provides higher-quality input data for the subsequent automatic identification of effective water hammer segments and inversion of fracture parameters, and serves as a key preprocessing step in the overall automated interpretation workflow.
2.3. Automatic Identification Algorithm
Conventional water hammer signal analysis usually relies on manually extracting effective response segments from the pressure–time curve, followed by model fitting and interpretation. This process is not only time-consuming, but also strongly dependent on the interpreter’s experience, resulting in considerable subjectivity. Since the triggering of a water hammer event is typically accompanied by a pronounced pressure drop, the first-order derivative of pressure with respect to time can serve as an important basis for identifying candidate onset points. However, relying solely on negative derivatives is insufficient to distinguish genuine water hammer events from ordinary local fluctuations. To address this issue, this study introduces multi-window statistical criteria on the basis of derivative detection, so as to jointly constrain the pressure characteristics before and after candidate time instants. Considering that the water hammer phenomenon essentially originates from the short-term propagation of pressure waves induced by abrupt changes in fluid velocity, an automated identification algorithm is developed based on pressure-derivative features, local statistical characteristics, and oscillatory attenuation behavior to detect and extract physically meaningful effective water hammer response segments. The algorithm can automatically determine the triggering time, principal oscillation interval, and termination position of a water hammer event, and can further screen and score candidate segments, thereby enabling the automatic identification of multiple water hammer signals.
- (1)
Adaptive filtering
The field-measured pressure signal,
p(
t) is first filtered to improve its signal-to-noise ratio, thereby reducing the influence of sensor noise and high-frequency interference on the pressure data.
In this equation, P(t) denotes the original pressure signal, MPa, while represents the smoothed pressure signal, MPa. S{·} is the smoothing operator, which is implemented in this study using an adaptive Kalman filter.
- (2)
Detection of candidate water hammer event segments
After shape-preserving denoising is completed, the time derivative of the pressure curve used for identification is calculated as follows:
where
dp/
dt is the time derivative of pressure. The derivative reflects the transient rate of pressure change and serves as an important basis for identifying the triggering time of a water hammer event. However, negative slope alone is insufficient to effectively distinguish genuine water hammer events from ordinary fluctuations. Therefore, multi-window statistical criteria are further introduced in this study. For each candidate time instant
ti, a preceding window, a subsequent short window, and a persistence window are defined, denoted by
Wpre,
Wpost and
Wsus, respectively, and the following quantities are defined:
where
is the mean pressure before triggering, MPa
is the mean pressure within the short window after triggering, MPa.
is the mean pressure within the persistence window, MPa.
Wpre,
Wpost and
Wsus are the corresponding time windows, and ∣
W∣ denotes the window length.
In addition, the standard deviation of the preceding window is defined as follows:
where
denotes the standard deviation of the pre-trigger window.
Meanwhile, three types of pressure drop indicators are defined as follows:
Here, Δpshort denotes the instantaneous pressure drop, MPa, which characterizes the intensity of the local abrupt drop; Δpmean represents the mean pressure difference over a short time scale before and after triggering and is referred to as the mean pressure drop MPa, and Δpsus characterizes whether the signal remains in a sustained oscillatory attenuation state after the event, and is referred to as the oscillatory-stage pressure drop, MPa. Δn is the short-window length, expressed as the number of sampling points.
If a candidate point
i satisfies the following conditions, then it is identified as a valid candidate triggering point.
The manually extracted results were jointly determined by field engineers with practical interpretation experience based on the onset of the pressure drop and the first complete oscillation cycle, and were therefore used as a practical reference baseline for evaluating the algorithmic identification results, rather than as absolute ground truth. The rationale for imposing the above threshold conditions is that a genuine water hammer event usually occurs after a relatively high and stable pressure plateau, and is accompanied by a pronounced short-term pressure drop followed by sustained oscillatory attenuation until the signal gradually approaches a low-pressure stable state. Therefore, compared with a single pressure-threshold method, the multi-window joint constraint is better able to capture the full structural characteristics of the water hammer formation process.
To avoid repeated identification of multiple neighboring points around the same water hammer event, candidate points with time intervals smaller than a prescribed merging threshold are grouped into the same candidate cluster. The composite score of a candidate point is defined as follows:
Si denotes the score assigned to each candidate onset point. Within each candidate cluster, only the point with the highest score is retained as the final trigger point. This scoring function does not merely emphasize abrupt changes in the pressure derivative; instead, it comprehensively accounts for the persistence of the post-drop response, the contrast between the pre- and post-event mean values, and the instantaneous rate of change. As a result, the selected trigger point is more likely to correspond to the dominant true onset of the water hammer event. This is consistent with the algorithmic procedure in which adjacent candidate points are grouped and the highest-scoring point within each cluster is chosen to define the start of the water hammer segment.
As time progresses, the oscillation energy of the water hammer gradually decays. When the pressure amplitude falls below a prescribed threshold and subsequently remains at a relatively low level, the event is considered to have ended. The amplitude threshold
is defined as follows:
where
te denotes the end time of the water hammer event, s, and
represents the average pressure during the stabilized stage, MPa.
is the amplitude threshold, which may be defined as a certain percentage of the peak amplitude.
- (3)
Envelope-assisted identification of peaks and troughs
Because field pressure signals are often accompanied by local noise disturbances, directly identifying peaks and troughs from the raw signal may easily lead to misjudgment. Therefore, an envelope-assisted identification strategy is introduced in this study to improve the robustness of peak and trough detection. Specifically, the upper and lower envelopes of the signal can be constructed using either the Hilbert transform or a local-extrema connection approach. The decay trend of the envelopes is then used to identify the true dominant oscillation peaks while suppressing false peaks caused by noise or local perturbations. This treatment helps improve the stability of water hammer segment boundary determination and key feature extraction.
Here, denotes the Hilbert transform operator, and represents the instantaneous amplitude of the signal. The decay trend of the envelope helps determine te and facilitates the elimination of false peaks caused by noise or local dissipation.
2.4. Automated Fitting and Inversion Algorithm
To quantify the agreement between the simulated results and the field measurements, this study constructs an objective function based on the sum of squared errors between the simulated pressure series and the measured pressure series. The identified effective water hammer response segment is taken as the calculation interval, and the optimal model parameters are obtained by minimizing the deviation between the two series over the entire time sequence. When necessary, weighting coefficients can also be introduced according to sampling reliability or the importance of specific time periods, so as to enhance the sensitivity of the objective function to key characteristic intervals.
To enable automatic fitting of field-measured pressure data, a global optimization-based parameter inversion strategy is employed, in which model parameters are identified by minimizing the discrepancy between simulated and measured pressure responses. The optimization framework is defined as follows. Let
P(
ti),
i = 1, 2, …,
N, denote the measured pressure series, and
Psim(
ti;
θ) the simulated pressure obtained from the numerical model, where
θ = [R,C,I] is the parameter vector to be inverted. The fitness function is defined as a weighted sum of squared errors between the simulated and measured pressures, providing a quantitative measure of the agreement between model predictions and field observations. After the optimal RCI-related parameters are obtained, they are mapped to the corresponding fracture geometric parameters through the model relationships, and the fracture half-length, fracture height, and fracture width are then calculated according to Equations (19)–(21).
where
J(
θ) denotes the objective function value;
Psim(
ti,
θ) represents the simulated pressure obtained from the model under the parameter set
θ, MPa;
P(
ti) is the measured pressure at time, MPa; and
wi is the weighting coefficient, which can be determined based on the confidence level of the measurement points or the sampling frequency.
The optimization objective is expressed as min{θ ∈ Ω} J(θ), where Ω denotes the feasible domain of parameters, representing the upper and lower bounds of the search space.
Global optimization algorithms, including the Genetic Algorithm (GA), Particle Swarm Optimization (PSO), and Simulated Annealing (SA), can all be abstracted into the following unified iterative form:
where
θk denotes the parameter vector at the
k-th generation or iteration; represents the corresponding objective function value;
ξk denotes a stochastic factor or perturbation introduced by the algorithm; and
is the update operator specific to each optimization algorithm.
Given the strong nonlinearity and non-uniqueness of the water hammer inversion problem, the solution may deviate from actual engineering conditions if no reasonable constraints are imposed on the parameter search ranges. Therefore, physically acceptable upper and lower bounds are specified for each parameter to be inverted. These parameter ranges are mainly determined based on field operation data, wellbore structural parameters, fundamental reservoir characteristics, and relevant literature, so that the search space retains sufficient flexibility while avoiding obviously unrealistic solutions. In addition, the inversion results must satisfy the basic physical constraints imposed by fracture geometric relationships and model boundary conditions, so as to prevent parameter combinations that achieve numerical fitting but lack engineering interpretability. By introducing parameter bounds and physical constraints, the stability and reliability of the inversion results can be improved.
To address the strong nonlinearity, multiple local optima, and pronounced parameter coupling in water hammer parameter inversion, this study employs the Particle Swarm Optimization (PSO) algorithm for global search [
31]. PSO is a typical swarm intelligence optimization method with relatively simple parameter settings, easy coupling with numerical forward models, and strong global search capability in complex multimodal search spaces. It is therefore well suited for constrained optimization problems such as shut-in water hammer curve fitting [
32]. During the iterative process, each particle updates its velocity and position according to its own historical best position and the global best position of the swarm, and progressively approaches the optimal solution.
The particle swarm optimization algorithm iterates as follows:
Here, w is the inertia weight, c1 is the cognitive acceleration coefficient, and c2 is the social acceleration coefficient. r1 and r2 are random numbers uniformly distributed within the interval [0, 1]. vik+1 represents the velocity of the i-th particle in the k + 1-th iteration, while xik+1 denotes the spatial position of the i-th particle in the k + 1-th iteration.
In summary, this study employs the Particle Swarm Optimization (PSO) algorithm to perform parameter searching for the water hammer model and to achieve automatic fitting to the field-measured pressure data. During the iterative process, each particle updates its velocity and position according to its own historical best position and the global best position of the swarm, and gradually converges toward the minimum value of the objective function. By coupling PSO with the above wellbore–fracture coupled forward model, automatic matching between the simulated and measured pressure curves can be achieved over the effectively identified pressure segment, thereby yielding the optimal estimates of the fracture geometric parameters.
The workflow diagram of the automatic water hammer pressure analysis algorithm, including the automatic recognition algorithm and automatic fitting algorithm, is shown in
Figure 1.