Prognostics 102: Efficient Bayesian-Based Prognostics Algorithm in MATLAB

Ting Dong, Dawn An and Nam H. Kim

### Abstract

An efficient Bayesian-based algorithm is presented for physics-based prognostics, which combines a physical model with observed health monitoring data. Unknown model parameters are estimated using the observed data, from which the remaining useful life (RUL) of the system is predicted. This paper focuses on the Bayesian method for parameter estimation of a damage degradation model where epistemic uncertainty in model parameters is reduced with the observed data. Markov-chain Monte Carlo sampling is used to generate samples from the posterior distribution, which are then propagated through the physical model to estimate the distribution of the RUL. A MATLAB script of 76 lines is included in this paper with detailed explanations. A battery degradation model and crack growth model are used to explain the process of parameter estimation, the evolution of degradation and RUL prediction. The code presented in this paper can easily be altered for different applications. This code may help beginners to understand and use Bayesian method-based prognostics.

Keywords: Bayesian method, physics-based prognostics, remaining useful life, MATLAB code, crack growth, battery degradation

#### 1. Introduction

Structural health monitoring (SHM) [1, 2] is the process of identifying damage and evaluating the safety of a system based on online and/or off-line data. It uses an array of sensors to obtain measurement data that are directly or indirectly related to damage. The statistical analysis of these measurements can help predict the future state of the system and thus improve the safety of the system. SHM can be found in a wide variety of applications such as bridges and dams, buildings, stadiums, platforms, airframes, turbines, etc. Prognostics is an extension of SHM, which is the process of estimating the time beyond which a system can no longer function to meet desired performances [3]. The time, in terms of cycles/hours, remaining to run the system before it fails is called the remaining useful life (RUL).

There are two types of prognostics methods: data-driven and physics-based approaches. The data-driven approaches are advantageous when many training data are available for a complex system, while the physics-based approaches are good when a physical model of damage degradation is available. The physics-based approach is used for prognostics in this paper with a well-defined physics model.

Measured data is used to estimate model parameters, which are then used to predict the RUL.

inference technique called the Bayesian method (BM) is used in this paper to estimate the model parameters based on measured data. Many other methods, such as particle filter and Kalman filter, also use Bayesian inference to estimate the model parameters. In BM, all model parameters are estimated in the form of a joint probability density function (PDF), whose distribution can be represented using samples. Among various sampling methods, Markov-chain Monte Carlo (MCMC) algorithm is employed to draw samples from the distribution. These samples of model parameters are then substituted in the physical model to calculate the sam-

In this section, a degradation model of a battery is used to explain the physicsbased prognostics algorithm using the Bayesian method. The degradation model of crack growth will also be explained in Section 4. It is expected that the users develop a degradation model for their own application. This section explains the basic

In a lithium-ion battery, it is well known that the capacity of a secondary cell degrades over cycles in use. Therefore, the capacity can be used as a degradation feature. The degradation feature is an output of the degradation model that shows a monotonic trend as a function of time. The system is considered failed when the degradation feature goes beyond a threshold. In the case of a lithium-ion battery, the failure threshold is defined when the charging capacity fades by 30% of that of a pristine battery. In this paper, the C/1 capacity (capacity at a nominally rated current of 1A) of the battery is used as a degradation feature. Since the C/1 capacity is inversely proportional to the sum of the transfer resistance and the electrolyte

Although the degradation process of a battery is complicated, a simple empirical model is available when the usage of the battery is the repetition of fully chargingdischarging cycles. In such a case, the degradation model can be written as a function of time only. Since the capacity of a battery degrades over time, the ratio of the capacity compared to that of the pristine battery is expressed by an exponential

where b is the model parameter, t is the time, and ~y tð Þ ; b is the relative degradation of the C/1 capacity compared to the pristine capacity. The notation in Eq. (1) is chosen such that the degradation model depends on both the time of usage and model parameters. In general, the degradation model is either monotonically decreased (e.g., the capacity decay of a battery) or monotonically increased

The main goal of the physics-based prognostics is to predict the degradation behavior using the degradation model. If the model is perfect, then it can be used to

where ythreshold is the failure threshold. Since the relative capacity is used as a degradation feature, the failure threshold is defined at ythreshold ¼ 0:7. Let the

~y tð Þ¼ ; b exp ð Þ �bt (1)

~y tð Þ¼ EOL; b ythreshold (2)

tRUL ¼ tEOL � tCUR (3)

ples of RUL, from which the statistical distribution is evaluated.

Prognostics 102: Efficient Bayesian-Based Prognostics Algorithm in MATLAB

resistance, it represents the overall performance of a battery.

2.1 Model definition

decaying model as [10]

(e.g., crack growth).

7

find the time tEOL at the end of life from

current time be tCUR, then the RUL can be defined as

requirements of a degradation model.

DOI: http://dx.doi.org/10.5772/intechopen.82781

Recently, many prognostics algorithms have been published in the literature [4–8]. However, many of the proposed algorithms are complex and not easily applicable. This complexity can present a serious hurdle for the beginner. In addition, using commercial programs may not be the best choice in teaching algorithms to students. As a continuation of our educational paper on prognostics algorithm [9], the objective of this paper is to explain the fundamentals of a Bayesian-based prognostics method and demonstrate how to use it using a simple MATLAB code.

The MATLAB code consists of 76 lines, which is further divided into three parts: (1) problem definition; (2) prognostics using the Bayesian method (BM); and (3) post-processing. The program is structured in such a way that the users only need to modify the problem definition part for their own application. This paper shows an example of battery degradation and crack growth models, and attempts to explain prognostics using BM with MATLAB code.

The remaining sections are organized as follows: In Section 2, the overall process of BM is explained; in Section 3, implementation of the code is explained with details using battery degradation example; and in Section 4, modification of the code for crack growth example is described, followed by conclusions in Section 5.

### 2. Methodology

In this section, a physics-based approach is explained using the procedure shown in Figure 1. The theoretical discussions in this section are mainly to help understand the MATLAB implementation in Section 3. The physics-based approach comprises of the following steps: (1) developing or identifying a physical model that describes the degradation of system health, (2) collecting data by operating the system under usage conditions and measuring degradation at a sequence of times/cycles, (3) estimating the model parameters by fitting the measured data, (4) progressing the physical model to the future times/cycles, and (5) predicting the RUL. A statistical

Figure 1. Flowchart of physics-based prognostics.

Prognostics 102: Efficient Bayesian-Based Prognostics Algorithm in MATLAB DOI: http://dx.doi.org/10.5772/intechopen.82781

inference technique called the Bayesian method (BM) is used in this paper to estimate the model parameters based on measured data. Many other methods, such as particle filter and Kalman filter, also use Bayesian inference to estimate the model parameters. In BM, all model parameters are estimated in the form of a joint probability density function (PDF), whose distribution can be represented using samples. Among various sampling methods, Markov-chain Monte Carlo (MCMC) algorithm is employed to draw samples from the distribution. These samples of model parameters are then substituted in the physical model to calculate the samples of RUL, from which the statistical distribution is evaluated.

#### 2.1 Model definition

Measured data is used to estimate model parameters, which are then used to predict

Recently, many prognostics algorithms have been published in the literature [4–8]. However, many of the proposed algorithms are complex and not easily applicable. This complexity can present a serious hurdle for the beginner. In addition, using commercial programs may not be the best choice in teaching algorithms to students. As a continuation of our educational paper on prognostics algorithm [9], the objective of this paper is to explain the fundamentals of a Bayesian-based prognostics method and demonstrate how to use it using a simple MATLAB code. The MATLAB code consists of 76 lines, which is further divided into three parts: (1) problem definition; (2) prognostics using the Bayesian method (BM); and (3) post-processing. The program is structured in such a way that the users only need to modify the problem definition part for their own application. This paper shows an example of battery degradation and crack growth models, and attempts to explain

The remaining sections are organized as follows: In Section 2, the overall process

In this section, a physics-based approach is explained using the procedure shown in Figure 1. The theoretical discussions in this section are mainly to help understand the MATLAB implementation in Section 3. The physics-based approach comprises of the following steps: (1) developing or identifying a physical model that describes the degradation of system health, (2) collecting data by operating the system under usage conditions and measuring degradation at a sequence of times/cycles, (3) estimating the model parameters by fitting the measured data, (4) progressing the physical model to the future times/cycles, and (5) predicting the RUL. A statistical

of BM is explained; in Section 3, implementation of the code is explained with details using battery degradation example; and in Section 4, modification of the code for crack growth example is described, followed by conclusions in Section 5.

the RUL.

2. Methodology

Figure 1.

6

Flowchart of physics-based prognostics.

prognostics using BM with MATLAB code.

Fault Detection, Diagnosis and Prognosis

In this section, a degradation model of a battery is used to explain the physicsbased prognostics algorithm using the Bayesian method. The degradation model of crack growth will also be explained in Section 4. It is expected that the users develop a degradation model for their own application. This section explains the basic requirements of a degradation model.

In a lithium-ion battery, it is well known that the capacity of a secondary cell degrades over cycles in use. Therefore, the capacity can be used as a degradation feature. The degradation feature is an output of the degradation model that shows a monotonic trend as a function of time. The system is considered failed when the degradation feature goes beyond a threshold. In the case of a lithium-ion battery, the failure threshold is defined when the charging capacity fades by 30% of that of a pristine battery. In this paper, the C/1 capacity (capacity at a nominally rated current of 1A) of the battery is used as a degradation feature. Since the C/1 capacity is inversely proportional to the sum of the transfer resistance and the electrolyte resistance, it represents the overall performance of a battery.

Although the degradation process of a battery is complicated, a simple empirical model is available when the usage of the battery is the repetition of fully chargingdischarging cycles. In such a case, the degradation model can be written as a function of time only. Since the capacity of a battery degrades over time, the ratio of the capacity compared to that of the pristine battery is expressed by an exponential decaying model as [10]

$$
\tilde{\jmath}(t;b) = \exp\left(-bt\right) \tag{1}
$$

where b is the model parameter, t is the time, and ~y tð Þ ; b is the relative degradation of the C/1 capacity compared to the pristine capacity. The notation in Eq. (1) is chosen such that the degradation model depends on both the time of usage and model parameters. In general, the degradation model is either monotonically decreased (e.g., the capacity decay of a battery) or monotonically increased (e.g., crack growth).

The main goal of the physics-based prognostics is to predict the degradation behavior using the degradation model. If the model is perfect, then it can be used to find the time tEOL at the end of life from

$$
\tilde{\mathcal{Y}}(t\_{\text{EOL}}; b) = \mathcal{Y}\_{\text{threshold}} \tag{2}
$$

where ythreshold is the failure threshold. Since the relative capacity is used as a degradation feature, the failure threshold is defined at ythreshold ¼ 0:7. Let the current time be tCUR, then the RUL can be defined as

$$\mathbf{t}\_{\rm RUL} = \mathbf{t}\_{\rm EOL} - \mathbf{t}\_{\rm CUR} \tag{3}$$

In practice, however, the degradation model is not perfect in the sense that the model form, as well as the model parameters, may not be accurate. The error in the model form can be handled by introducing a model form error and identifying the error using measured data, which would be considered as the out of the scope of this paper. Interested readers can refer to Guan et al. [11].

parameters. In particular, the goal is to accurately predict the end of life in Eq. (2)

Prognostics 102: Efficient Bayesian-Based Prognostics Algorithm in MATLAB

It is important to note that the data should show a significant change in the damage feature over time. In the case of crack growth in Section 4, for example, when the crack size is small, it grows very slowly. Therefore, the measurement data in an early stage do not show a significant change in the crack size. In such a case, the signal-to-noise ratio is too low and it is difficult to estimate the model parameters. In this paper, instead of measuring the degradation of a real battery, the degradation data are generated based on an assumed true model. This has a couple of advantages. First, since the true model and its model parameters are known, it is possible to evaluate the accuracy of the estimation process and that of the RUL. It also allows us to investigate the effect of noise on the performance of prognostics algorithms. In this paper, the relative capacity data are generated based on Eq. (1) with the true model parameter btrue = 0.012. It is assumed that the C/1 capacity of the battery is measured once a week up to the ninth week. In order to simulate the

) is added to

real measurement environment, a Gaussian noise <sup>ε</sup> � <sup>N</sup>(0, 0.005<sup>2</sup>

the true data. The following MATLAB commands can be used to generate the

Once the measurement data are generated, the true model parameters and the information of noise are not used. Table 1 and Figure 2 show the true degradation data and simulated measurement data up to the current time tCUR ¼ 9 weeks. Based on the true model, the end of life of the battery is tEOL ¼ 29:72 weeks, and thus, the

Once the measurement data are available, the next step would be to estimate the

Pð Þ¼ Θ∩Y Pð Þ ΘjY P Yð Þ¼ P Yð Þ jΘ Pð Þ Θ (4)

model parameters. Among many parameter estimation methods, the Bayesian inference is explained in this section. In the following explanation, Θ represents the random variable of the unknown model parameter, and Y represents the random variable of degradation feature. A variable with an upper case denotes a random variable, while a variable with a lower case denotes a realization of the random variable. Bayesian inference estimates the degree of belief in a hypothesis based on collected evidence. Bayes [12] formulated the degree of belief using the identity in

where Pð Þ ΘjY is the conditional probability of Θ given Y. In the case of estimating the model parameter using measured data, the conditional probability of Θ when

Time (weeks) 0 1 2 3 4 5 6 7 8 9 True degradation 1.000 0.988 0.976 0.965 0.953 0.942 0.931 0.919 0.909 0.898 Measured degradation 0.995 0.983 0.975 0.974 0.942 0.938 0.930 0.920 0.911 0.895

the probability of measured data Y is available can be written as

Measurement data (relative capacity) for the battery degradation example.

and the RUL in Eq. (3).

DOI: http://dx.doi.org/10.5772/intechopen.82781

measured data:

>> time=(0:9)'; >> b=0.012;

>> trueData=exp(-b\*time);

true RUL should be tRUL ¼ 20:72 weeks.

2.2 Bayesian parameter estimation

conditional probability:

Table 1.

9

>> measuData=trueData+0.005\*randn(10,1);

Once the model form is accepted, the next task is to identify the accurate model parameters. In the case of the battery degradation model in Eq. (1), the parameter b needs to be identified. In most cases, the model parameters are not an intrinsic property but depend on operating conditions and environment. Therefore, these parameters can be different for different batteries and need to be identified for the specific battery of interest. In fact, the major task of physics-based prognostics is to identify the model parameters.

The model parameter b for a specific battery can be identified by measuring the capacity degradation during regular operation. The measuring process is often called health monitoring, where the degradation feature is measured over time. It is possible that the degradation feature can be monitored online. However, for the purpose of prognostics, the real-time continuous monitoring may not be necessary. Therefore, it is often suggested to collect data in a discrete set of times. Then, many different physics-based prognostics algorithms use these data to identify the model parameters so that the degradation model represents the degradation feature the best. For example, nonlinear least-squares method minimizes the error between measured data and the model prediction. Kalman filter, particle filter, and Bayesian methods are using Bayesian inference to estimate the model parameters. Different methods use different assumptions and different numerical approaches. Interested readers are referred to Kim et al. [3] for details of these methods.

If the measured data are accurate, then a small number of measured data should be good enough to estimate the model parameters. In reality, however, most measured data include noise and bias, which make the estimation process difficult. Noise is a random fluctuation of signals due to uncontrollable factors in the measurement environment, while bias is a systematic departure from the average data. If the measurement is repeated, noise can be changed, while the bias may remain the same. The bias can occur because of calibration error of the sensors, but it may also occur due to the model form error. The effect of the model form error can partially be addressed by introducing the bias in the estimation process. Bias can be added in the model as an extra term and estimated in the same way as other parameters. The distribution of estimated bias is a good indicator if the model can represent degradation data well enough. If estimated bias is widely distributed, it means model form error is large. If it is narrowly distributed and the mean is close to 0, it means the model is accurate. Since noise is random, it is important to compensate for its effect in the parameter estimation process. It is obvious that a large level of noise makes the process difficult. Therefore, it is important to keep the signal-to-noise ratio as high as possible. It is also important to understand the statistical characteristics of the noise. In this paper, it is assumed that the noise follows a Gaussian distribution with a zero mean and unknown standard deviation. On the other hand, the effect of bias will not be considered. Therefore, in addition to the unknown model parameters, it is necessary to estimate the unknown standard deviation of noise in data.

Because of noise and bias, it is often expected that a large number of data be required to estimate the model parameters accurately. In prognostics, it is often assumed that Ndata data are collected from a start time to the current time t∈½ � t0; tCUR . Time does not have to be a physical time; it can also be the number of cycles of operation. Then, the model parameters are estimated using Ndata data, and future degradation is predicted using the degradation model with the estimated

Prognostics 102: Efficient Bayesian-Based Prognostics Algorithm in MATLAB DOI: http://dx.doi.org/10.5772/intechopen.82781

parameters. In particular, the goal is to accurately predict the end of life in Eq. (2) and the RUL in Eq. (3).

It is important to note that the data should show a significant change in the damage feature over time. In the case of crack growth in Section 4, for example, when the crack size is small, it grows very slowly. Therefore, the measurement data in an early stage do not show a significant change in the crack size. In such a case, the signal-to-noise ratio is too low and it is difficult to estimate the model parameters.

In this paper, instead of measuring the degradation of a real battery, the degradation data are generated based on an assumed true model. This has a couple of advantages. First, since the true model and its model parameters are known, it is possible to evaluate the accuracy of the estimation process and that of the RUL. It also allows us to investigate the effect of noise on the performance of prognostics algorithms. In this paper, the relative capacity data are generated based on Eq. (1) with the true model parameter btrue = 0.012. It is assumed that the C/1 capacity of the battery is measured once a week up to the ninth week. In order to simulate the real measurement environment, a Gaussian noise <sup>ε</sup> � <sup>N</sup>(0, 0.005<sup>2</sup> ) is added to the true data. The following MATLAB commands can be used to generate the measured data:

>> time=(0:9)';

>> b=0.012;

In practice, however, the degradation model is not perfect in the sense that the model form, as well as the model parameters, may not be accurate. The error in the model form can be handled by introducing a model form error and identifying the error using measured data, which would be considered as the out of the scope of this

Once the model form is accepted, the next task is to identify the accurate model parameters. In the case of the battery degradation model in Eq. (1), the parameter b needs to be identified. In most cases, the model parameters are not an intrinsic property but depend on operating conditions and environment. Therefore, these parameters can be different for different batteries and need to be identified for the specific battery of interest. In fact, the major task of physics-based prognostics is to

The model parameter b for a specific battery can be identified by measuring the

capacity degradation during regular operation. The measuring process is often called health monitoring, where the degradation feature is measured over time. It is possible that the degradation feature can be monitored online. However, for the purpose of prognostics, the real-time continuous monitoring may not be necessary. Therefore, it is often suggested to collect data in a discrete set of times. Then, many different physics-based prognostics algorithms use these data to identify the model parameters so that the degradation model represents the degradation feature the best. For example, nonlinear least-squares method minimizes the error between measured data and the model prediction. Kalman filter, particle filter, and Bayesian methods are using Bayesian inference to estimate the model parameters. Different methods use different assumptions and different numerical approaches. Interested

If the measured data are accurate, then a small number of measured data should be good enough to estimate the model parameters. In reality, however, most measured data include noise and bias, which make the estimation process difficult. Noise is a random fluctuation of signals due to uncontrollable factors in the measurement environment, while bias is a systematic departure from the average data. If the measurement is repeated, noise can be changed, while the bias may remain the same. The bias can occur because of calibration error of the sensors, but it may also occur due to the model form error. The effect of the model form error can partially be addressed by introducing the bias in the estimation process. Bias can be added in the model as an extra term and estimated in the same way as other parameters. The distribution of estimated bias is a good indicator if the model can represent degradation data well enough. If estimated bias is widely distributed, it means model form error is large. If it is narrowly distributed and the mean is close to 0, it means the model is accurate. Since noise is random, it is important to compensate for its effect in the parameter estimation process. It is obvious that a large level of noise makes the process difficult. Therefore, it is important to keep the signal-to-noise ratio as high as possible. It is also important to understand the statistical characteristics of the noise. In this paper, it is assumed that the noise follows a Gaussian distribution with a zero mean and unknown standard deviation. On the other hand, the effect of bias will not be considered. Therefore, in addition to the unknown model parameters, it is

readers are referred to Kim et al. [3] for details of these methods.

necessary to estimate the unknown standard deviation of noise in data.

Because of noise and bias, it is often expected that a large number of data be required to estimate the model parameters accurately. In prognostics, it is often assumed that Ndata data are collected from a start time to the current time

t∈½ � t0; tCUR . Time does not have to be a physical time; it can also be the number of cycles of operation. Then, the model parameters are estimated using Ndata data, and future degradation is predicted using the degradation model with the estimated

paper. Interested readers can refer to Guan et al. [11].

identify the model parameters.

Fault Detection, Diagnosis and Prognosis

8

>> trueData=exp(-b\*time);

>> measuData=trueData+0.005\*randn(10,1);

Once the measurement data are generated, the true model parameters and the information of noise are not used. Table 1 and Figure 2 show the true degradation data and simulated measurement data up to the current time tCUR ¼ 9 weeks. Based on the true model, the end of life of the battery is tEOL ¼ 29:72 weeks, and thus, the true RUL should be tRUL ¼ 20:72 weeks.
