Shirin Najdi
email: s.najdi@campus.fct.unl.pt

Ali Abdollahi Gharbali
email: a.gharbali@campus.fct.unl.pt

José Manuel Fonseca

Feature Transformation Based on Stacked Sparse Autoencoders for Sleep Stage Classification

Keywords: Sleep Stage Classification, Deep Learning, Stacked Sparse Autoencoders, Feature Transformation

In this paper a deep learning based dimension reduction, feature transformation and classification method is proposed for automatic sleep stage classification. In order to enhance the feature vector, before feeding it to the deep network, a discriminative feature selection method is applied for removing the features with minimum information. Two-layer Stacked Sparse Autoencoder together with Softmax classifier is selected as the deep network model. The performance of the proposed method is compared with Softmax and k-nearest neighbour classifiers. Simulation results show that proposed deep learning structure outperformed others in terms of classification accuracy.

Introduction

Sleep occupies significant part of human life. Diagnosis and treatment of sleep related disorders and sleep deficiency is of great importance in the sleep research community. Normal human sleep generally consists of two distinct stages with independent functions known as Non-Rapid Eye Movement (NREM) and Rapid Eye Movement (REM) sleep. In their ideal situation, NREM and REM states alternate regularly, each cycle lasting 90 minutes on average. NREM sleep accounts for 75-80% of sleep duration. According to the American Academy of Sleep Medicine (AASM) [START_REF] Berry | AASM -Manual for the Scoring of Sleep and Associated Events version 2[END_REF], NREM is subdivided into three stages: stage 1 or light sleep, stage 2 and stage 3 or Slow Wave Sleep (SWS). On the other hand, REM sleep accounts for 20-25% of sleep duration. The first REM state usually occurs 60-90 minutes after the onset of the NREM and lasts a few minutes.

A multiple-parameter test, called polysomnography (PSG), is normally used for analysis and interpretation of multiple, simultaneous physiologic events during sleep. PSG includes several body functions such as electroencephalogram (EEG), electrooculogram (EOG), chin and leg electromyogram (EMG), airflow signals, respiratory effort signals, oxygen saturation and electrocardiogram (ECG). The data acquired in this way is analyzed by an expert in a clinic or hospital environment. The proportion and distribution of sleep stages can then be used for diagnosis of sleep related problems. However, visual sleep stage classification is a subjective task and requires much time and effort. On the other hand, there is an increasing interest for at home sleep monitoring technologies that try to modernize sleep analysis and reduce the workload of healthcare centers. Therefore, there is a need for reliable automatic sleep stage classification systems that can efficiently perform sleep scoring.

One of the main challenges of automatic sleep stage classification is to compactly represent the subject's data in the form of a feature vector. This feature vector should be informative and non-redundant enough in order to decrease the computational complexity and facilitate the subsequent classification step. Proper selection of the classifier in order to achieve the highest possible classification accuracy is another challenge in these systems. Looking at the existing literature, It can be noted that a wide range of features including temporal [START_REF] Hamida | Computer Based Sleep Staging: Challenges for the Future[END_REF][START_REF] Koley | An ensemble system for automatic sleep stage classification using single channel EEG signal[END_REF][START_REF] Şen | A Comparative Study on Classification of Sleep Stage Based on EEG Signals Using Feature Selection and Classification Algorithms[END_REF], spectral [START_REF] Koley | An ensemble system for automatic sleep stage classification using single channel EEG signal[END_REF][START_REF] Radha | Comparison of feature and classifier algorithms for online automatic sleep staging based on a single EEG signal[END_REF][START_REF] Šušmáková | Discrimination ability of individual measures used in sleep stages classification[END_REF], linear/non-linear [START_REF] Şen | A Comparative Study on Classification of Sleep Stage Based on EEG Signals Using Feature Selection and Classification Algorithms[END_REF][START_REF] Hsu | Automatic sleep stage recurrent neural classifier using energy features of EEG signals[END_REF][START_REF] Dursun | Comparison of Artificial Immune Clustering with Fuzzy C-means Clustering in the sleep stage classification problem[END_REF] and statistical features [START_REF] Koley | An ensemble system for automatic sleep stage classification using single channel EEG signal[END_REF][START_REF] Radha | Comparison of feature and classifier algorithms for online automatic sleep staging based on a single EEG signal[END_REF] were extracted from different subsets of PSG recording and used for sleep scoring. Some of conventional feature transformation methods such as principal component analysis (PCA) [START_REF] Rempe | An automated sleep-state classification algorithm for quantifying sleep timing and sleep-dependent dynamics of electroencephalographic and cerebral metabolic parameters[END_REF] and kernel dimensionality reduction (KDR) [START_REF] Fukumizu | Kernel Dimensionality Reduction for Supervised Learning[END_REF] are used for reducing the dimensionality and enhancing the descriptive power of feature vector. Considering the fact that deep learning methods have found their way into many artificial intelligence applications with successful results reported from academia and industry, the main motivation for the current work was to explore the potential of deep learning for feature transformation and classification in the automatic sleep stage classification area. In view of this, the following research question emerges:

How should a deep learning technique be used for dimensionality reduction and classification of sleep stages, so that the computational complexity of classification step is reduced and the scoring accuracy is improved?

In this work, we propose an algorithm that answers this question. This paper is organized as follows: Section 2 explains how the proposed algorithm contributes to the smart systems. In Section 3, a review of the application of deep learning techniques in sleep stage classification is presented. Section 4, provides detailed description of the proposed algorithm. Simulation results and discussion are presented in Section 5. Finally, conclusion and future work are given in Section 6.

Relationship to Smart Systems

Smart systems refer to diverse range of technological systems that can perform autonomously or in collaboration with other systems. These systems have an ability to combine functionalities including sensing, actuating and controlling a particular situation. Based on the information they acquire, they have the ability to perform smart actions such as prediction or deciding and communicate with the user through highly sophisticated user interfaces. Generally, smart systems are made of several components, each having a special purpose. These components include sensors for data acquisition, information transmitting elements, command-and-control units for making decisions, components for transmitting decisions, taken, and finally actuators for triggering required action. These systems have been used to address some problems in diverse areas, such as energy, transportation, security, safety, healthcare, etc. [START_REF]CORDIS : FP7 : ICT : Micro / nanosystems : Calls[END_REF].

In healthcare area, the main goal of utilizing smart systems is to improve patient management workflow. This improvement leads to the reduction in the burden of medical staff, consultation time, waiting lists and medical costs. Smart healthcare systems, as advanced technology, are classified into three main categories: remote health monitoring systems (RHMS), mobile health monitoring systems (MHMS) and wireless health monitoring systems (WHMS). Among these three categories, WHMS refer to biosensors that can be worn by the subject and may also include one or both of RHMS and MHMS [START_REF] Baig | Smart Health Monitoring Systems: An Overview of Design and Modeling[END_REF]. Wearable sleep monitoring systems are perfect examples of WHMS. The idea behind them is to use efficient, affordable and medically reliable systems for unsupervised at-home monitoring of patients' sleep data. Typically, wearable sleep monitoring systems have an algorithm that performs automatic sleep stage classification for evaluating sleep quality [START_REF] Tsinalis | Automatic Sleep Stage Scoring Using Time-Frequency Analysis and Stacked Sparse Autoencoders[END_REF]. This work is developed in such a context to improve the performance of the classification accuracy using deep learning techniques.

State of The Art

Unlike some of the machine learning areas such as natural language processing and object classification, the potential of deep learning techniques is not fully explored in automatic sleep stage classification. This fact is also noticeable when it comes to the feature transformation for sleep scoring. To the best of our knowledge, there are few research works in this area and in the following we will try to briefly review them.

In [START_REF] Giri | Combining Generative and Discriminative Neural Networks for Sleep Stages Classification[END_REF], the main idea is using hybrid deep learning models to increase the performance of sleep stage classification. Deep Belief Networks (DBNs) are applied on 28 hand-crafted feature set for unsupervised generation of higher level features. For classification another deep structure, namely, Long Short Term Memory (LSTM) is used. In this work, sleep stage classification is regarded as a time series and sequence classification problem, therefore the ability of LSTM models for recognizing the patterns from a sequence of events is mentioned as the reason for using this classifier. The proposed algorithm is tested on two datasets of sleep recording and the features are extracted from EEG, EOG and EMG. The performance of the proposed algorithm (DBN +LSTM) is compared to three other sleep stage classification algorithms, namely DBN only, LSTM only and DBN with Hidden Markov Model (HMM). Simulation results show that two hybrid methods DBN+LSTM and DBN+HMM have significantly better performance than single DBN and single LSTM, while DBN+LSTM performs better than DBN+HMM for both datasets. It has been concluded that LSTM boosted the performance of DBN much better than HMM.

Tsinalis et al. [START_REF] Tsinalis | Automatic Sleep Stage Scoring Using Time-Frequency Analysis and Stacked Sparse Autoencoders[END_REF] proposed an algorithm for sleep stage classification using on time-frequency analysis based features and Stacked Sparse Autoencoders (SSAE). For each epoch, in total 557 features are extracted from the time-frequency representation of the single channel EEG signal. Complex Morlet wavelet is used for creating time-frequency representation. In this paper, it has been showed that the classification accuracy can be improved by including the features from neighboring epochs. According to the simulation results, the proposed method leads to 1-2% scoring improvement compared to four other sleep scoring algorithms, that don't use deep learning. They succeeded to reduce the gap between the mean performance between S1 (as the most misclassified stage) and all other stages. Also, the adverse effect of inherent class imbalance in sleep data on the classification accuracy is highlighted. Authors tried to alleviate this effect by creating a balanced dataset in which all stages are equally represented.

In [START_REF] Längkvist | Sleep Stage Classification Using Unsupervised Feature Learning[END_REF], the main focus is on generating meaningful data representations from unlabeled data. For this purpose, the performance of a two-layer DBN with 200 hidden units was compared with another feature transformation algorithm consisting of conventional methods (PCA + Sequential Backward Selection (SBR) + Gaussian Mixture Model (GMM)). These feature selection methods are applied on a vector of 28 hand-crafted features. Newly generated feature sets are classified by using Softmax classifier and Hidden Markov Model (HMM) respectively. Experimental results showed that DBN-based feature transformation performs much better the other method for sleep stage classification Dong et al. in [START_REF] Dong | Mixed Neural Network Approach for Temporal Sleep Stage Classification[END_REF], proposed a practical approach was proposed for mitigating the limitations of single-channel automatic sleep stage classification using Mixed Neural Network (MNN). MNN is a deep learning-based feature transformation and classification technique and is composed of a Rectifier Neural Network (RNN), a Long Short-Term Memory (LSTM) and a Softmax regression. The input to this system is a feature vector with time-frequency domain, statistical and time domain features. Considering temporal dependency of sleep stages to each other, in addition to the features of the current epoch, the features from previous EEG epochs are also fed to the system. In this paper, several alternative electrode placements are explored and finally a convenient single forehead EEG channel together with an EOG channel configuration is proposed for the low-cost, at-home sleep monitoring applications.

Materials and Methods

Data

In this paper, we used a publically available dataset, called ISRUC-Sleep [START_REF] Khalighi | ISRUC-Sleep: A comprehensive public dataset for sleep researchers[END_REF]. The data were acquired from 10 healthy adults, including 9 male and 1 female subjects aged between 30 and 58. The recordings were done in Sleep Medicine Centre of the Hospital of Coimbra University (CHUC) during an all-night session (eight hours). The PSG recordings of each subject were scored by two experts according to the AASM manual [START_REF] Berry | AASM -Manual for the Scoring of Sleep and Associated Events version 2[END_REF]. All EEG, EOG and chin EMG recordings were performed with a sampling rate of 200 Hz. The quality of the PSG recordings of this dataset have improved through a pre-processing step. In this pre-processing step, 1) a notch filter is applied to eliminate 50 Hz electrical noise, 2) EEG and EOG recordings are filtered using a bandpass Butterworth filter with a lower cut-off frequency of 0.3 Hz and higher cut-off frequency of 35 Hz, and 3) EMG channels are filtered using a bandpass Butterworth filter with a lower cut-off frequency of 10 Hz and higher cut-off frequency of 70 Hz. For the evaluation of our proposed method, we used C3-A2 EEG channel, right EOG and chin EMG channels. In this paper, we used all the data from 10 healthy subjects from ISRUC-Sleep dataset. The number of epochs for these 10 subjects is 954, 941, 824, 794, 944, 853, 814, 1000, 969, and 796. Totally we have 8889 epochs from this database and to avoid overfitting we used all of them.

Feature Extraction

All signals used in this study, were divided into 30-second epochs. A set of features were extracted from each epoch of EEG, EOG and EMG recordings of each subject. This feature set includes 49 features that can be considered as time, frequency, joint time-frequency domain, entropy-based and nonlinear types. Table 1 shows a summary of these features. For more detail see [START_REF] Najdi | A Comparison of Feature Ranking and Rank Aggregation Techniques in Automatic Sleep Stage Classification Based on Polysomnographic Signals[END_REF].

Normalization

In order to standardize the range of Features, scaling normalization method was applied. Each feature ( ij x ) is independently normalized by applying the following equation:

min( ) max( ) min( )     ij i ij ii x x x xx (1)
where i x is the vector of i th feature.

Discriminative Feature Selection

There are many potential advantages in removing the features before final modelling and classification. Fewer features mean lower computational complexity. Also, some features may reduce the performance by their corrupt distributions. Consider a feature that a single value for all of the samples. According to [START_REF] Kuhn | Applied Predictive Modeling[END_REF], this feature is called "zero-variance predictor". Even if it has little effect on the next step, this feature should be discarded from feature set, because it has no information. Similarly, some features may have few unique values that occur with low frequency. These features are called "near-zero variance predictors". Kuhn et al. [START_REF] Kuhn | Applied Predictive Modeling[END_REF] defines two criteria for detecting near-zero variance features as follows:

a) The ratio of unique values to the number of samples is low, for example 10%. b) The ratio of the frequency of the most dominant value to the frequency of the second dominant value is high, for example 20.

Using these two criteria, we applied Discriminative Feature Selection (DFS) to remove the features that didn't have enough discriminative power. As a result, the dimension of feature set reduced to 37.

Stacked Sparse Autoencoder (SSAE)

An autoencoder is a special type of neural network whose output values are equal to the inputs. An autoencoder typically consists of an encoder and a decoder and it is trained in an unsupervised manner using backpropagation. During training, a cost function that measures the error between input and output of the autoencoder is optimized, in other words, the autoencoder tries to learn the identity function. By applying special constraints on the network such as the number of hidden units, an autoencoder can learn new representation or coding of the data [START_REF] Ng | UFLDL Tutorial[END_REF]. Suppose the input vector to the autoencoder is a set of un-labelled data  x D

x

. This vector is encoded to another vector

1  D z
in the hidden layer as follows:

  1 1 1  h z W x b (2)
where h 1 is the transfer function of the encoder, W 1 is the weight matrix and b 1 is the bias vector of the encoder. Then, the autoencoder tries to decode this new representation back to the original input vector as follows:

  2 2 1 1 ˆ   hh x z W x b (3)
where h 2 is the transfer function of decoder, W 2 is weight matrix and b 2 is bias vector of the decoder. Sparse autoencoder is a specific type of autoencoder in which in order to encourage the sparsity of the output of the hidden layer, a constraint is imposed on the number of active hidden neurons. The cost function of sparse autoencoder is slightly different from the original autoencoder as follows:

  2 weight regularization sparsity regularization mean squared error

1 ˆ        weights sparsity E N xx ( 4
)
where N is length of the input vector,  is the weight regularization parameter  is the sparsity regularization parameter [START_REF] Olshausen | Sparse coding with an overcomplete basis set: A strategy employed by V1?[END_REF]. A Stacked Sparse Autoencoder (SSAE) is a neural network with several sparse autoencoders. In this architecture, the output of each autoencoder is fully connected to the inputs of the next autoencoder. Greedy layer-wise training strategy is usually used for training SSAE. After the training of each layer is complete, a fine tuning is usually performed for enhancing the learned weights using backpropagation algorithm. Fine tuning can greatly improve the performance of the stacked autoencoder [START_REF] Ng | UFLDL Tutorial[END_REF].

Softmax Classifier

After SSAE, Softmax classifier is stacked to the network as the output layer. Softmax classifier has a probabilistic interpretation of each. It is the generalization of binary Logistic Regression classifier to multiple classes. In sleep stage classification, the number of output classes is equal to the number of sleep stages.

Experimental Results and Discussion

For evaluating the performance of the proposed sleep stage classification algorithm, we used all data from 10 healthy subjects as described in section 4.1. The EEG, EOG and EMG signals of each subject were divided into 30-second epochs. After feature extraction and normalization, the feature sets were fed to DFS block to eliminate the variance features. According to the criteria mentioned in section 4.3, 12 features were recognized as near-zero variance feature and removed from our sleep data model, as follows: maximum value (F1), minimum value (F2), variation (F5), median (F8), Petrosian fractal dimension (F31), permutation entropy (F30), Hjorth parameter (Activity) (F10), zero crossing number (F9), total power in the EMG frequency spectrum (F43), mean of power in the EMG frequency spectrum (F45), absolute energy of the time domain EMG signal (F47), maximum value of time domain EOG signal (F38).

After the feature vector was set, data were divided into two parts, training, testing, using 10-fold cross validation method. For fine tuning step of SSAE, part of training data was utilized. Our deep learning consists of three layers, a two-layer SSAE and a Softmax layer. The number of hidden units for the first and second layer of SSAE was 20 and 12, respectively.

For finding the best hyper-parameters for the autoencoders, we tried several models by adjusting sparsity regularization parameter, weight regularization parameter and the number of iterations. We used autoencoders with logistic sigmoid activation function for both of the layers. The performance of the proposed algorithm was compared with two other classifiers, Softmax and k-Nearest Neighbor (k-NN) classifier. The number of neighbors was set to 18 and Euclidean distance was used as a measure of distance for k-NN. To evaluate our systems' performance we used classification accuracy as the evaluation criterion.

Table 2 shows the individual sleep stage and overall classification accuracy extracted from confusion matrix for three different classifiers. The boldface numbers indicates the best performance. It is noticeable that SSAE method outperforms the other two classifiers in terms of overall accuracy. Also, for the individual sleep stages, in most of the cases SSAE discriminates the stages better. In addition to the higher performance, SSAE provides a considerable reduction in the dimension of the feature vector.

Considering that the second layer of SSAE had 12 hidden units, SSAE succeeded to decrease the dimension from 37 to 12, which means 67% reduction. Therefore, SSAE is a powerful tool to generate more descriptive features from original feature vector. In order to confirm the advantage of DFS block, the performance of SSAEbased sleep stage classification with and without this step was investigated. Without using DFS block, 49 original features were fed to SSAE.

The classification accuracy achieved in this way was 74.1% which is almost 8% less than accuracy with DFS block.

Conclusions and Future Works

Although feature transformation based on deep learning has already used in several machine learning applications, the advantages and potentials of applying these methods in sleep stage classification problem have not explored yet. This paper is a contribution in this regard. We proposed a method for dimension reduction and feature transformation based on SSAEs. The results show that SSAE can be considered as an appropriate tool for decreasing the complexity of sleep scoring issues. Future works will include comparing the performance of other conventional classifiers such as SVM and RF with SSAE in sleep stage classification.

Figure 1 Fig. 1 .

 11 Figure 1 shows an overview of proposed sleep stage classification algorithm with proposed feature transformation scheme. Feature Extraction Normalization DFS Block

Table 1 .

 1 Summary of the features extracted from PSG recordings.

	Signal Category	Feature Name
		Statistical Features (Minimum Value, Maximum
	Time Domain (F1 to F12)	Value, Arithmetic Mean, Standard Deviation, Variance, Skewness, Kurtosis, Median), Zero-crossing Rate, Hjorth Parameters (Activity, Mobility
		and Complexity) [20].
	EEG	Features Coefficients including Energy of α, δ, β1, β2, θ and Extracted from Wavelet Packet
	Time-Frequency	Spindle bands, Total Energy of all bands, Energy
	Domain (F13 to F26)	ratio of (	  	,	  	,	  	,	 	,	 	), Statistical
		Features (mean and standard deviation of
		coefficients in all of the bands).

Table 2 .

 2 Results of the statistical analysis for comparison of each stage and overall accuracy.

	Classifiers	Wake (%)	REM (%)	S1 (%)	S2 (%)	SWS (%)	Overall Accuracy (%)
	Softmax	80	61.66	65	90	78.33	74.9
	k-NN	85	66.66	61.66	70	83.33	73.33
	SSAE	91	77	69	87	87	82.2

Acknowledgment. This work was partially funded by FCT Strategic Program UID/EEA/00066/203 of UNINOVA, CTS.


Irina Fedotova

Bernd Krause
email: bernd.krause@hs-anhalt.de

Eduard Siemens
email: e.siemens@emw.hs-anahlt.de

Upper Bounds Prediction of the Execution Time of Programs Running on ARM Cortex-A Systems

Keywords: Extreme Value Theory, Worst-Case Execution Time, Probabilistic Timing Analysis, Timing Verification

This paper describes the application of statistical analysis of the timing behavior for a generic real-time task model. Using specific processor of ARM Cortex-A series and an empirical approach of time values retrieval, the algorithm to predict the upper bounds for the task of the time acquisition operation has been formulated. For the experimental verification of the algorithm, we have used the robust Measurement-Based Probabilistic Timing Analysis based on the Extreme value theory (EVT). In the ongoing work, we provide a systematic method for safe worst-case execution time estimations of programs running on the specific hardware. We focus here primary on the consequences of EVT assumptions and their correct interpretation for the upper bounds prediction.

Introduction

The implementation of most smart systems nowadays presumes the availability of high computing, memory and IO-resources on very small and low-power consuming hardware platforms -so called SoC devices. In this area, the ARM Cortex-A platform plays a central role. On such systems, the time acquisition process is one of the most critical steps in meeting real-time requirements. This presumes certain guarantees that the probability of the system failing to meet its timing constraints is below an acceptable threshold. However, the CPU of said system includes many features, which imposes correspondent limitations to the aimed timing analysis. One way to get suitable values for meeting real-time requirements is the development of statistical methods, predicting the probability distribution of the timing operations delays for particular tasks.

Nowadays, deterministic as well as probabilistic approaches pursue the goal of providing a safe upper bound of execution time for a particular task [START_REF] Wilhelm | The WCET Problem -Overview of Methods and Survey of Tools[END_REF]. The difference between these approaches is mainly that the deterministic method produces a single worst-case execution time (WCET) estimation, while probabilistic -multiple WCET estimates with their respective probabilities. Both approaches have their static and measurement-based variants. Classical static timing analysis operates on deterministic processor architectures and provide safe WCET estimates as they are proven to be the worst ones [START_REF] Abella | On the Comparison of Deterministic and Probabilistic WCET Estimation Techniques[END_REF]. However, most real-time operating systems have become increasingly complex and it makes the applicability of static timing analysis is very challenging. On the contrary, measurement-based methods provide an estimation based on the derived maximal and minimal observed execution times or their distributions. In fact, with a probabilistic hardware architecture and measurement-based approaches, it is possible to guarantee an accurate probabilistic pWCET, what is solved by applying the Measurement-Based Probabilistic Timing Analysis (MBPTA).

The objective of the MBPTA is to derive the timing behavior of a task by means of statistical modeling. It aims at modeling extreme execution times for characterizing the worst-case, relied on both execution time measurements and the application of the Extreme Value Theory (EVT). The EVT deals with the extreme deviations from the median of probability distributions and estimates the tails, where the worst case should lie. However, hardware effects in real-time systems make EVT applicability difficult with regard to its required theoretical hypotheses. In this work, we focus on a particular hardware presented on the Atmel SAMA5D4 board with one ARM Cortex-A5 core, which can be a common example of realistic embedded applications. The platform based on these series of processors employs a cache of random-replacement policy. It facilitates upper bounding the probability of pathological worst-cases behaviors to extremely low levels (failure probability of 10 -9 ) [START_REF] Altmeyer | Static probabilistic timing analysis for realtime systems using random replacement caches[END_REF]. For our investigations, the failure probability at the level 10 -9 < P < 10 -7 (from hazardous class) was chosen. This level is proposed by PED certification [START_REF]Guidelines and methods for conducting the safety assessment process on civil airborne systems and equipment[END_REF] and usually applied in flight control systems.

In the related work, a number of methods for application of EVT theory for WCET estimations has been proposed [START_REF] Abella | On the Comparison of Deterministic and Probabilistic WCET Estimation Techniques[END_REF], [START_REF] Radojkovic´ | Thread Assignment in Multicore/Multithreaded Processors: A Statistical Approach[END_REF], [START_REF] Guet | On the Reliability of the Probabilistic WCET Estimates[END_REF]; nevertheless, a considerable uncertainty due to the complexity of the problem still exists. Results of statistical tests are often fuzzy and it is hard to make a correct decision on their basis to fulfill EVT requirements. To overcome difficulties with EVT, it is necessary to perform a complete set of diagnostic tests, check hypotheses for generalizing the EVT applicability and assume the validity of different methods. In this article, we intent to significantly reduce the existing ambiguities and suggest a systematic step-by-step method. Moreover, while previous studies have investigated time bounds for the whole application using corresponding benchmarks, we focus on the particular task for obtaining time values. The MBPTA approach is then applied only for this most critical part of the system, as other components can be assessed with more deterministic methods. The rest of the paper is organized as follows: the relation of the ongoing research to smart systems is discussed in Section 2, followed by discussion on related work in Section 3. The description of the problem of the realtime probabilistic modeling, as well as the main steps of proposed algorithm are presented in Section 4. Section 5 describes the experiment setup. The proof of fitting the target distribution and obtaining WCET estimators are provided in Section 6. Finally, Section 7 sums up and collects the conclusions and future work.

ARM based SoC and Smart Systems

What principally differentiates the ARM Cortex-A series from others, is their wide use in performance-intensive systems. However, for our research the choice of these processors is based not only on the high performance and low power capabilities of the hardware, but also on the extensive application in control smart systems with timing constraints. The term "smartness" refers to the ability of the system performing very complex set of heuristic operations, based on a rich data basis, often gathered from external cloud environments within some given time boundaries, networking and real-time capabilities. Here selected embedded devices play a dominant role. A wide range of applications for Cortex-A is possible also due to the support of rich OSs such as Linux or Android. However, using them in embedded systems brings additional challenges to the development process. While one of the primary aim of any smart system is making decisions more predictive under certain conditions, in fact, the standard Linux OS is not productive enough for that. It follows therefore the necessity to better address some challenges related to the reaction of the system, especially where highly precise timing must be kept at one microsecond level.

The specific feature of these series of processor is, that CPU cycle counter is not directly available from user-space and wraps around in every 6.5 minutes. Thereupon, the investigations of timing capabilities are being performed within the high performance HighPerTimer library [START_REF] Fedotova | A High-precision Time Handling Library[END_REF], which main idea is to simplify the process of timestamps acquisition. It allows avoiding the invocation of any system calls, since the main timing mechanism (supporting the procedure of handling overflows) is processed in user space. While microsecond precision of time stamping becomes standard for the development of remote monitoring and control systems, the underlying OS (particularly due to invoking system calls) is not able to meet the realtime requirements. Moreover, exactly the task for obtaining time values from the hardware can often take up to 20% of the whole program execution time. Therefore, it is important to minimize the cost of time retrieval and provide the precise time bounds of this critical task. Therefore, based on the used implementation of timing, it is possible to move forward in the direction of calculating worst-case execution time and predict the upper bound. These predictions allow a verification if the timing constraints will be met at run-time and so help to lead to a faster and more secure design process of the system.

Related Work

One of the first comprehensive comparisons among timing analysis techniques was presented by J. Abella et al. in [START_REF] Abella | On the Comparison of Deterministic and Probabilistic WCET Estimation Techniques[END_REF]. Authors compare static and MBPTA methods in qualitative and quantitative terms under different cache configurations. Besides this, their previous work [START_REF] Cazorla | Upper-bounding Program Execution Time with Extreme Value Theory[END_REF] establishes requirements to EVT with the MBPTA method to derive WCET estimates. Thereby they address the WCET problem by introducing randomization into the timing behavior of the system hardware and software.

The recent work by F. Guet et al. [START_REF] Guet | On the Reliability of the Probabilistic WCET Estimates[END_REF] proposes a DIAGnostic tool, which applies the MBPTA method without human intervention. Depending on the certain theoretical hypotheses of the EVT, the logical work flow of the framework derives its probabilistic pWCET estimate from traces of execution times. Concerning the DIAGnostic tool, K. Berezovskyi et al. in [START_REF] Berezovskyi | WCET Measurement-based and Extreme Value Theory Characterization of CUDA Kernels[END_REF], [START_REF] Berezovskyi | MBPTA is for Graphics Process or Units[END_REF] also investigate different methods inside the EVT theory for Graphical Processor Units (GPUs). The main results showed that hardware time-randomization is not that essential for the applicability of EVT and can be applied even to some non-time-randomized systems as GPUs.

An approach based on EVT theory has also been used for optimal performance analysis. Radojković et al. [START_REF] Radojkovic´ | Thread Assignment in Multicore/Multithreaded Processors: A Statistical Approach[END_REF] presented a new method for predicting the performance of the thread assignment in multi-core processors. Using statistical inference of each thread assignment in a random sample, the authors estimates the optimal one.

Despite the intensive research in this area over the past few years, open problems in applying MBPTA for computing probabilistic WCET estimate still remain. In particular, said approaches give little information about the sequences of checking statistical hypotheses and making safe decision on their basis. Ongoing work intents to overcome these challenges by developing systematic and more coherent approach of analyzing the timing behavior. Moreover, the innovation novelty of this work is to cluster tasks exactly for time acquisition and apply the MBPTA method only for this critical non-deterministic part of the system.

The Probabilistic Modeling of Timing Behavior

Measurement-based methods produce estimates (for parameters of some distributions) by executing the given task on the given hardware and measuring the execution time of the task or of its parts. In particular, MBPTA approaches are aimed at modeling extreme execution times and characterizing its worst-case. The probabilistic theory that focuses on extreme values and large deviations from the average values is the EVT theory [START_REF] Coles | An Introduction to Statistical Modeling of Extreme Values[END_REF]. It estimates the probability of occurrence of extremely large values, which are known to be rare events. More precisely, the EVT predicts the distribution function for the max (or min) values of a set of n observations, which are modeled with random variables. Its main result is provided in the Fisher-Tippett-Gnedenko theorem, which characterizes the max-stable distribution functions for a single family of continuous cumulative distribution functions (CDFs), known as the generalized extreme value (GEV) distribution. The result implies that an average discrete cumulative distribution function belongs to the Maximum Domain of Attraction (MDA) of the GEV.

Furthermore, the GEV distribution is characterized by three parameters: location µ, scale σ, and shape ξ and by their estimation, we can prove the resulting GEV distribution. If the shape parameter is ξ > 0, than the measured values in trace belong to Fréchet distribution, whereas if ξ < 0, than this is a "reversed" Weibull case. If the shape parameter ξ = 0, than values belong to a Gumbel distribution, which in most previous works [START_REF] Cucu-Grosjean | MBPTA for Multi-path Programs[END_REF], [START_REF] Hansen | Statistical-Based WCET Estimation and Validation -viewcontent[END_REF], has been assumed as applied to the pWCET distribution. Nonetheless, there is no restriction on the values that ξ can take and the resulting distribution, we intent to check all three distributions, in order to be close to the accurate estimation of the parameter. Therefore, for applying the EVT, the following hypotheses are required to be verified: that n random variables of execution time measurements are: i) independent, ii) identically distributed and iii) the existence of a distribution in the MDA of the GEV distribution is given [START_REF] Guet | On the Reliability of the Probabilistic WCET Estimates[END_REF]. These three elements are checked for guaranteeing the safety of the reliable probabilistic pWCET estimates.

Selecting Extreme Values

Within the EVT context, there are several approaches to measure the extreme values. The Peak over Threshold (PoT) method is preferred and presents a good model for the upper tail, providing reliable extrapolation for exceedances over a sufficiently high threshold. The Pickands-Balkema-de Haan theorem [START_REF] Balkema | Residual Life Time at Great Age[END_REF], on which the PoT method is based, corresponds to the basic principle of extracting the execution time measurements from the trace above a threshold u and fitting of the Generalized Pareto Distribution (GPD) to the exceedances. The PoT allows to use data more efficient than other approaches, though the evident disadvantage is the selection of the suitable threshold value. Moreover, in the single-path case the PoT appears to be more accurate (with respect to the measurements), but the increase of the threshold u can result into more pessimistic pWCET estimations [START_REF] Balkema | Residual Life Time at Great Age[END_REF], [START_REF] Santinelli | On the Sustainability of the EVT for WCET Estimation[END_REF].

Proposed WCET Estimation Algorithm

Considering the probabilistic modelling briefly described above, the following algorithm for WCET estimation is suggested: Step 1. Selecting extreme values. The objective of this step is to collect from the original distribution the values, which fit into the tail, and hence can be modeled with the GEV distribution. For estimation of extremes, the PoT method was chosen: Step 1.1. The choice of the best-fitted threshold. It is based on the method of graphical diagnostic, which includes: mean residual life plot and parameter stability plot. They allow finding the lowest possible threshold, for which the extreme value model provides a reasonable fit to exceedances; Step 1.2. Filtering values above the threshold. Step 2. Fitting the GEV distribution: Gumbel, Fréchet and Weibull. If none of three types distributions fits, then going back to Step 1.1 and increase the threshold value. Step 3. Estimating the remaining parameters of the fitted distribution: µ, σ and ξ. Step 4. Verification of EVT hypotheses of independence and identical distribution: Step 4.1. Checking that the data are identically distributed; Step 4.2. Proving that samples are independent.

Step 5. Return WCET estimation based on µ, σ and ξ parameter. Due to the space constrains, a more detailed description of the Step 4 is omitted here. However, the statistical analysis shows that EVT can be applied to the obtained results with high confidence (95%). At the same time, it must be considered that recent work [START_REF] Berezovskyi | MBPTA is for Graphics Process or Units[END_REF] shows that independence is not a necessary hypothesis for EVT applicability and the theory can be applied even for stationary weakly dependent time series, even if the identical distribution of random variables does not represent a limiting hypothesis to EVT applicability.

Experimental Setup

There are multiple ways, in which measurements can be performed for the probabilistic approach. The most evident method is by extra instrumentation of the program code that collects a timestamp or CPU cycle counter. All experiments for this research have been carried out on ARM Cortex-A5 (see Section 2). We have evaluated the overhead of setting two consecutive timers of HighPerTimer library [START_REF] Fedotova | A High-precision Time Handling Library[END_REF], which practically gives the estimate of the timer cost; the job, which is required to be performed in order to measure executions times of any program or the piece of code. The measured process is scheduled by SCHED_OTHER -the default scheduling policy of the Linux kernel version 4.4.11, used in these investigations. The influence of the real-time scheduling policy and kernel extensions are out of scope of this work. We rather concern about measuring the time acquisition process under the standard conditions. Table 1 lists basic statistics of the 27 minute estimation part of a representative trace. The representation of complementary cumulative distribution function (CCDF) for this execution time is shown in Fig. 1 (a). As can be seen from the graph, the distribution peaks near the mean and falls with rapidly decreasing probability density below 1 μsec. The Fig. 1

Fitting the GPD Distribution and Estimation the Upper Bounds

Having determined the threshold value, the parameters of the GPD can be calculated by the maximum likelihood estimation (MLE). The appropriate goodness-of-fit statistics compares observed data to quantiles of the specified distribution. We estimate three distributions by the critical value of Chi-square test, the Bayesian (BIC) and Akaike (AIC) information criteria and QQ-plot. Firstly, since preliminary test series show that the shape parameter ξ can't be negative, the case of Weibull distribution was excluded. Secondly, based on the Chi-square test the hypotheses that data follow Gumbel or Fréchet distributions can't be rejected. Thirdly, comparing models according to the AIC and BIC criteria, the hypothesis that data fit Fréchet distribution is slightly preferred against the Gumbel case. Fourthly, the straight diagonal line of a QQ-plot indicates that Gumbel distribution is a relatively good fit to the tail. However, since the difference of most statistics results for Gumbel and Fréchet models is not significantly differed, it makes sense to retrieve the WCET estimate for both cases. The final step is to use the computed and verified GPD parameters and the exceedance probability of failure p to estimate the WCET. The WCET estimate is derived based on parameters ξ and αu for each respective scenario as following [START_REF] Embrechts | Modelling Extremal Events for Insurance and Finance[END_REF]: [START_REF] Wilhelm | The WCET Problem -Overview of Methods and Survey of Tools[END_REF] where αu is an estimated scale parameter, k -the number of peaks over the threshold u. Table 2 gives modeling results of the extreme execution times and Fig. 2 (a) shows the distribution convergence for Gumbel and Fréchet scenarios. The x-axis shows the pWCET estimation, the y-axis shows the respective probabilities. We use a CCDF of GPD to predict the potential values. According to the Table 2 the WCET estimates for both distributions differ significantly. Formally, too pessimistic results of Fréchet are quite tight and practically less useful: for failure probability p = 10 -9 the bound is 5.921 sec. The Gumbel distribution converges to 0 faster than the Fréchet and it decreases the pessimism of the WCET thresholds. Moreover, shape parameter stability plot (on Fig. 2 (b)) estimates maximum likelihood of ξ over a range of threshold and confirms the hypothesis that data fit Gumbel distribution with ξ = 0 respectively.

Having possibility to run the experiment including the target risk probabilities, we can compare the real max value and predicted WCET estimates. Therefore, the max value of the original dataset is 5.99 msec (Table 1) and the predicated upper bound using parameters for Gumbel distribution for failure probability p = 10 -9 gives 7.67 msec, which fits the assumption. Considering any real-time system (soft or firm), these results allow to verify the timing constraints specifically for the application component, which includes operations for time acquisition. This can help to design more stable and secure system running on platforms based on the ARM Cortex-A core.

Table 2. EVT results for the hazardous class of p considering GPD expressed in cycles and msec.

Conclusion

The ability to predict the exceedance probability and reduce the cost to perform trustworthy timing analysis makes the MBPTA approach along with the EVT theory very attractive. The main contribution of this paper is to propose a systematics for the estimation of probabilistic WCET of a time acquisition task. Assuming several cases of GPD distributions, we compare WCET estimates for them. Our results show the least pessimistic estimation (about 7.67 msec for failure probability levels of 10 -9 ), using parameters for Gumbel distribution. Therefore, this method of predicting the upper bound is acceptable for the single-core ARM Cortex-A5 processor. For the future work, the investigation of other systems and hardware effects, such as the presence of multiple cores, cache memory effects or impacts of scheduling tasks by Linux kernel are planned. Considering hardware aspects should lead to significant improvements of the dependence metrics, reduction of the pessimism of the pWCET estimation and as a result, make applications, running on Linux, using ARM Cortex-A processors more time-predictable and so more suitable for being used in smart devices and applications.

  (b) gives the general picture of the time behavior showing additionally sigma values: σ and 3σ.

Fig. 1 .

 1 Fig. 1. The original dataset of time execution: (a) its CCDF representation; (b) samples with statistical properties (mean, min/max, 3σ, σ) grouped into 50 clusters.

Fig. 2 .

 2 Fig. 2. EVT results: (a) estimation of upper bounds; (b) shape parameter stability plot.

Table 1 .

 1 Statistical properties of the original data set.

	Mean execution time Std. deviation	Max value	Min value
	0.519 μsec	2.217 μsec	5.995 msec	0.455 μsec


Pedro M L P Magalhães

João F A Martins

António L M Joyce

Performance Assessment of Tank Fluid Purging and Night Cooling as Overheating Prevention Techniques for Photovoltaic-thermal (PV-T) Solar Water Heating Systems

Keywords: photovoltaic, thermal, stagnation, night, cooling, purging

Tank fluid purging and night cooling are two overheating prevention techniques with potential to prevent photovoltaic-thermal collectors from experiencing temperatures capable of undermining their longevity and commercial appeal. Both techniques are readily available, inexpensive but inherently wasteful to use. Dynamic numerical simulations were conducted to determine the primary energy efficiency and the level of protection afforded by these techniques in active residential grid-connected solar domestic hot water systems. Also evaluated was the use of occupancy rate information, possible via so-called "smart systems", to complement the techniques. The results revealed better performances for systems using stagnation control schemes relative to those not using them. Also, night cooling was shown to be unable to prevent overheating reliably while tank fluid purging proved to be more apt but resulted in substantial waste of water annually, which could be reduced by combining it with night cooling, which in turn revealed the highest performances observed.

Introduction

Solar water heating systems such as those for domestic hot water or space heating routinely experience stagnation events, particularly during the Summer months. During this period, ambient temperature and irradiation levels are at their highest and demand tends to be low by design (e.g., space heating) or due to absence periods (e.g., vacations). While standard collectors for low temperature applications (<100ºC) such as flat-plate and evacuated tube collectors are generally designed to withstand their worst case scenario stagnation temperatures (100-300ºC), hybrid photovoltaic-thermal (PV-T) collectors are sensitive to temperatures in excess of 85ºC -in part due to the limited temperature stability of common photovoltaic (PV) array encapsulants, namely ethylene vinyl acetate (EVA) -which can occur during stagnation [START_REF] Dupeyrat | Efficient single glazed flat plate photovoltaic-thermal hybrid collector for domestic hot water system[END_REF][START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF]. As a result, PV-T systems require stagnation control methods to prevent overheating in addition to the protections typically required in standard solar heating systems.

Stagnation control methods commonly used in solar heating systems can be categorised as either stagnation handling or overheating prevention [START_REF] Frank | Overheating prevention and stagnation handling in solar process heat applications[END_REF]. Stagnation handling methods do not prevent stagnation but instead mitigate its harmful consequences such as thermal stress to other components in the collector circuit due to heat carrier evaporation, heat carrier degradation, accelerated corrosion and plugging of pipes [START_REF] Hillerns | The behaviour of heat transfer media in solar active thermal systems in view of the stagnation conditions[END_REF]. Examples of stagnation handling methods include the drainback, draindown and steamback systems or the use high system pressures in the collector loop [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF]. In contrast, overheating prevention methods avoid the onset of temperatures capable of compromising a system's functional integrity by avoiding stagnation or limiting the temperatures reached. Examples include collector shading systems, night cooling of the storage tank, tank fluid purging, active heat dumping, passive venting and defocusing (for tracking systems). Of the two categories, overheating prevention methods are necessary for glazed PV-T systems, whose temperatures can reach around 150ºC under stagnation, even though some stagnation handling measures can be seen as desirable or complementary [START_REF] Dupeyrat | Efficient single glazed flat plate photovoltaic-thermal hybrid collector for domestic hot water system[END_REF][START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF][START_REF] Lämmle | A PVT collector concept with variable film insulation and low-emissivity coating[END_REF][START_REF] Lämmle | Development and modelling of highly-efficient PVT collectors with low-emissivity coatings[END_REF].

The present endeavour focuses on the performance of two overheating prevention methods, namely tank fluid purging and night cooling of the storage tank, in active residential solar domestic hot water (SDHW) systems using glazed PV-T collectors producing electricity and feeding it to the local utility grid using grid-tie inverters. Both methods have a low initial cost -one of which (night cooling) is a common feature in many commercial controllers -and are designed to lower the storage tank temperature and in doing so indirectly prevent stagnation and high temperatures.

Tank fluid purging consists of disposing of hot tank fluid -generally water -using a single purge valve and replacing it with colder fluid to prevent the tank from being fully charged. In doing so, stagnation due to low temperature differences between the collector and tank or due to the maximum allowed collector temperature being reached can be avoided indirectly. However, the hottest fluid in the tank (i.e., from the top) is wasted and in the case of water predominantly when it is scarce (Summer months) while requiring parasitic energy to power the pump(s) and valve -assuming the latter is not thermostatic. On the other hand, the method is unsuitable for some fluids and the valve is used sparingly during the Winter months which may cause it to fail prematurely unless periodic discharges or careful maintenance is carried out [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF].

In contrast, night cooling of the storage tank does so by running the collector circuit pump at night in order to prevent stagnation from taking place the following day. It does not require additional components other than possibly a controller, relies on the often-used collector loop, requiring parasitic energy to do so but does not waste water. On the other hand, the method can only be used effectively when solar energy collection is not possible -unlike tank fluid purging which can be used preventively or during the collection period -and must necessarily anticipate periods of mismatched supply and demand, either using predictive or conservative controls [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF][START_REF] Frank | Overheating prevention and stagnation handling in solar process heat applications[END_REF].

The implicitly wasteful nature of both methods contrasts with their low implementation cost but can nevertheless penalise the performance of SDHW systems. At the same time, cooling the tank results in lower collector temperatures and higher PV yields for solar cells exhibiting negative cell efficiency temperature coefficients, although these are generally low in absolute value (e.g., -0.45%/K for monocrystalline silicon). In other words, these methods are likely to contribute to a degradation of the system's energy efficiency and cost-effectiveness, which is unlikely to be outweighed by the positive effect on the electrical performance of PV-T systems [START_REF] Dupeyrat | Efficient single glazed flat plate photovoltaic-thermal hybrid collector for domestic hot water system[END_REF][START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF][START_REF] Lämmle | A PVT collector concept with variable film insulation and low-emissivity coating[END_REF]. Nevertheless, this hypothesis needs to be tested in accordance with the scientific method and the magnitude of the performance variation quantified.

As such, the objective of the work described in this paper is to evaluate and compare implementations of tank fluid purging and night cooling with respect to the problem of stagnation and their impact on the performance of residential SDHW systems using glazed PV-T collectors. Although these methods have been to some extent discussed in the literature prior to this effort, the emphasis has not been on quantifying the effect they have on the performance of SDHW PV-T systems [START_REF] Harrison | A review of strategies for the control of high temperature stagnation in solar collectors and systems[END_REF].

In order to do so, dynamic annual simulations were conducted. These focused on a reference system without any stagnation control method and systems employing each control method or both as a way to evaluate their potentially complementary nature and implications for systems with more frequent stagnation events such as space heating systems. Finally, the results were primarily analysed from the viewpoint of primary energy efficiency but other figures of merit were considered, namely overheating impact, pump cycling and likelihood of premature system failure.

Relationship to Smart Systems

The research efforts undertaken and described in this paper concern the study of two overheating prevention methods, namely tank fluid purging and night cooling, whose use can be enhanced by the features commonly associated with so-called "smart systems", namely sensing, (internet) connectivity, informed decision-making and actuation [START_REF] Akhras | Smart materials and smart systems for the future[END_REF]. These features could render the preventive use of both methods more reliable and overall better performing than alternative control schemes. For instance, rather than cooling the tank according to a static temperature setpoint during a given time window at night, the control unit could hypothetically determine which flow rate to use if any, for how long and the timing of the operation dynamically.

Ideally, preventive use of both methods should consider dynamic weather forecasts, occupancy rates, electricity prices and other factors to select the most appropriate method (if more than one is available) and timing, which would require a combination of internet connectivity, sensors and control modules with predictive capabilities able to use such information in a timely manner. In practice, a predictive stagnation control scheme could be too complex and costly to implement relative to its potential benefits over simpler methods. Therefore, the current study focuses on the evaluation of simpler stagnation control solutions for SDHW PV-T systems yet consistent with the features associated with "smart systems".

Concretely, the use of occupancy rate information possibly provided by sensors, schedules or remote communication with the main unit to disable the backup heater and/or select different night cooling setpoints for normal load and load absence periods were evaluated since these are simple to implement and also have advantages from the standpoint of energy efficiency and user comfort when users are away.

System Overview

The solar heating systems under consideration for the purposes of this study are small active (i.e., forced-circulation) residential grid-connected SDHW systems featuring parallel-connected glazed PV-T collectors supplying the electricity generated to the local utility grid. These systems typically have a collector area in the range of 4-6 m 2 , tanks sized according to specific storage volumes of 40-70 L/m 2 of collector area and featuring internal heat exchangers of the immersed coil variety, which have a propensity for low thermal stratification [START_REF] Eicker | Solar Technologies for Buildings[END_REF][START_REF] Kaltschmitt | Renewable Energy: Technology, Economics and Environment[END_REF][START_REF] Cruickshank | Storing Energy, With Special Reference to Renewable Energy Sources Sensible Thermal Energy Storage: Diurnal and Seasonal Elsevier[END_REF]. Moreover, the systems are prepared to perform night cooling of the tank whereas purging tank fluid requires an actuator valve on the demand loop. The generic diagram for all three systems evaluated (no stagnation control, night cooling and purging) is given in Figure 1. Regular system operation is governed by simple controls, namely hysteretic controllers for the backup heater and pump as well as safety overrides designed to protect the system components other than the collector from high temperatures (>95ºC) by disabling heat carrier circulation. For the systems considered here, the backup heater is turned on once tank fluid temperatures drop below 55ºC and remains on until temperatures reach 60ºC (5ºC deadband) and in doing so prevents the growth of legionella while not significantly enhancing the formation of limestone deposits [START_REF] Kaltschmitt | Renewable Energy: Technology, Economics and Environment[END_REF][START_REF] Dupeyrat | Study of the thermal and electrical performances of PVT solar hot water system[END_REF]. Similarly, heat carrier circulation is initiated if the temperature difference (ΔT) between the heat carrier at the collector outlet and the tank fluid near the heat exchanger increases beyond the turn on setpoint (ΔTon = 10 K) and ends if it drops below the turn off setpoint (ΔToff = 2 K) leading to stagnation in the collector loop.

On the other hand, the night cooling takes place when three conditions are met. The first condition is a negative temperature difference between the collector and tank to indicate cooling is possible while the second and third conditions concern a timer enable (in this case, active between midnight and 5 a.m. local time) and a minimum tank temperature setpoint to regulate the cooling period and how much cooling is to take place, respectively. Moreover, the tank temperature setpoint alternates between a value for normal occupancy periods (Tn) and another for periods of user absence (Tnl), according to occupancy information conveyed by the "smart" system elements.

Conversely, tank fluid purging is triggered by any one of three conditions. The first condition is met when the collector fluid outlet temperature is within a preset tolerance (ΔTf,tol=5ºC) of its maximum allowed level (Tf,max=95ºC) during fluid circulation. The second condition is met when the tank temperature exceeds the tank purge setpoint (Tpurge, lower than the tank's maximum allowed temperature) and until the former drops to a safe level (Tsafe, set to at least 5ºC below Tpurge). The third and final condition is met when ΔT approaches ΔToff during heat carrier circulation and the temperature difference between Tf,max and the tank fluid is lower than ΔTon. Although unlikely to be frequently triggered, it concerns high temperature cycling and could prevent the system from being stuck in high temperature stagnation since if stagnation were to set in once ΔT dropped below ΔToff while Tf,max -Ttank < ΔTon, the collector fluid temperature could exceed the maximum value for which circulation is allowed (95ºC) before it could resume (ΔT> ΔTon) and after which fluid purging would not be effective since the system would be stuck until temperatures dropped.

Methodology

In order to address the proposed objectives, a set of annual dynamic simulations of the aforementioned SDHW PV-T systems were conducted. The choice of simulation work rather than physical experiments was based on the former's reasonable accuracy and the ability to compare systems under the same exact conditions in a time-and cost-effective manner. Annual simulation periods were selected due to the pertinence of evaluating the all-year round performance of the control methods and the system, even though stagnation events predominantly take place during Summer.

The simulations employed the models described in [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF] except those for the stagnation controllers and the utility water temperature. The latter was modelled as 7ºC-amplitude 15ºC-average annual triangular wave, whose extrema were made to coincide (time-wise) with those of the outdoor temperature [START_REF] Dupeyrat | Study of the thermal and electrical performances of PVT solar hot water system[END_REF]. Typical meteorological year (TMY) data for Lisbon, Portugal (38º42'N, 9º8'W) was used, as represented in Figure 2. However, the simulations assumed the lack of appreciable wind (vwind=0 m/s) as a worst case scenario and focused on common situations likely to lead to high stagnation temperatures in well-sized SDHW systems, namely the use of representative load patterns including Summer vacations and weekends off. A full load day corresponded to 200 L at 45ºC and no load periods included a weekend off every four weeks and four one-week Summer vacations spread a month apart.

The simulations were run using MATLAB and most models implemented were validated against their respective counterparts from other well known simulation tools, namely TRNSYS, as described in [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF]. Conversely, the dynamic PV-T collector model used is based on the equation for the quasi-dynamic test method featured in the standard EN 12975-2:2006 and reproduces the performance of the PV-T collector described in [START_REF] Dupeyrat | Efficient single glazed flat plate photovoltaic-thermal hybrid collector for domestic hot water system[END_REF], which was measured according to the aforementioned standard. Moreover, the system's performance is in line with the results found in [START_REF] Silva | Hybrid photovoltaic/thermal (PV/T) solar systems simulation with Simulink/Matlab[END_REF], which focused on the same location, using comparable PV-T technology and areas.

At the same time, the dynamic PV-T collector model used does not incorporate longwave radiative heat losses explicitly (c4 or ε = 0), which has thermodynamic implications particularly for night cooling with PV-T collectors lacking lowemissivity coatings, as is the case [START_REF] Dupeyrat | Efficient single glazed flat plate photovoltaic-thermal hybrid collector for domestic hot water system[END_REF]. Nevertheless, the implications are arguably minor for the present study since the temperature differences between the hot storage tank and the outdoors still allow for significant convective heat transfer (and thus a conservative cooling power assessment) whereas night cooling of cold storage tanks (e.g., used in space cooling systems) requires radiative heat transfer [START_REF] Eicker | Photovoltaic-thermal collectors for night radiative cooling of buildings[END_REF]. Additional information on the parameters used, unless stated otherwise, can be found in [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF]. The simulations' primary results were used to assess the system's primary energy efficiency using a weighted primary energy savings adapted from [START_REF] Lämmle | Thermisches management von pvt-kollektorenergebnisse aus systemsimulationen[END_REF] and defined as:

Qpes = fpv*Epv -fpar*Epar -faux*(Eaux-Eref) . ( 1
)
where the primary energy factors for PV electricity (fpv), parasitic energy (fpar) and auxiliary energy (faux) were all set to 2.5 (general purpose electricity) [START_REF][END_REF]. Moreover, the backup heater (i.e., an immersed electrical heating element) efficiency to 100%, the power converter efficiency to 95% and the pump power (Ppump) defined as a cubic function of the collector array mass flow rate (mc) according to [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF], where the pump power coefficient (Kp) was set to 1000 W 1 Kg -3 s 3 after [START_REF] Nhut | A study on automatic optimal operation of a pump for solar domestic hot water system[END_REF]. Ppump = Kp*mc 3 .

(2)

Simulations and Analysis

The simulations revealed marginal primary energy savings and cumulative overheating period variations as the result of disabling the backup heater during periods of low energy demand. In particular, the increase in Qpes from this measure was limited to no more than 2 kWh for all flow rates whereas the reduction in cumulative overheating was only observed at low flow rates and limited to less than 3 hours. These results can be explained by the fact that the tank is usually charged during those periods and because overheating is more likely at low flow rates. With regard to stagnation control schemes, the simulations revealed night cooling as having a limited ability to prevent collector overheating, unlike tank fluid purging. Concretely, none of the systems simulated using tank fluid purging overheated -in contrast with results reported in [START_REF] Magalhães | Comparative analysis of overheating prevention and stagnation handling measures for photovoltaic-thermal (PV-T) systems[END_REF] -while those relying exclusively on night cooling still overheated for at least a few hours annually although less than without a stagnation control method, as exemplified in Figure 3. The inadequacy of night cooling for overheating prevention did not result from low collector loop cooling power but rather the inability to predict the need for cooling as such, as overheating was observed even during full load days in addition to low demand periods -either vacations or weekends off. Moreover, meeting the night cooling tank temperature setpoint while employing the nominal mass flow rate used during the daytime was routinely achieved in a fraction of the time available to do so (the average night cooling cycle lasted under 3 hours but some lasted almost 5 hours, particularly at the lowest flow rates) and overheating tended to drop as either of the setpoints was lowered, although 'no load' setpoints lower than 45ºC did not substantially reduce it. At the same time, tank fluid purging either individually or combined with night cooling led to a substantial volume of water being flushed, mainly at low specific mass flow rates and predominantly during the Summer. While the water volume itself was not recorded, the energy wasted as the result of purging using tank purge setpoints from 75ºC to 85ºC ranged from 88 up to 927 kWh for the lowest flow rates, which is equivalent to approximately 13 and 135 full load days. Alternatively, this corresponds to between 1.2 and 14.3 m 3 of water at Tpurge being replaced by utility water at Summertime temperatures (18.5ºC) -all reasonable estimates for the estimation of the actual volume of water purged -which is equivalent volume-wise to between 6 and 72 normal load days annually. However, the minimum energy waste and equivalent volume corresponding to the use of tank fluid purging as stand-alone were 126 kWh (18 days) and 1.6 m 3 (8 days), respectively. Thus, combining both methods allowed for a reduction of the amount of purging and energy waste (see Figure 4) and effectively constitutes a more environmentally viable solution.

Primary energy efficiency-wise, PV-T systems using night cooling, tank fluid purging or both were able to outperform those not using any stagnation control method, particularly at low and medium collector specific mass flow rates, high purge setpoints (80 and 85ºC) and if night cooling was limited to vacation periods, as shown in Figures 3 and4. Conversely, excessive purging brought on through the use of purge setpoints as low as 75ºC (Tsafe=70ºC) inverted this trend while still reliably preventing overheating. Similarly, allowing night cooling during short 'no load' periods (i.e., weekends off) resulted in less overheating, mainly at low flow rates, but also slightly lower performances, predominantly at high flow rates. On the other hand, the range of performance variation itself was not significant: from -16 kWh up to 35 kWh relative to a maximum Qpes of 3633 kWh. Nevertheless, the general outcome reflects higher PV yields (up to 22 kWh) due to cell cooling, despite increases in the parasitic (up to 1 kWh) and auxiliary (up to 55 kWh, and highest at high flow rates) energy consumptions, which ultimately stemmed from the methods' ability to cool the tank and the correlation between high irradiance periods and the need for cooling.

Moreover, the performance enhancement was highest for systems using tank fluid purging, either exclusively or combined with night cooling of the storage tank, which proved to be the most effective schemes in preventing overheating and in securing the highest primary energy efficiency. In this regard, the combined use of tank fluid purging and night cooling led to the highest observed primary energy efficiency.

Conclusions

Dynamic simulations of SDHW PV-T systems were conducted to evaluate implementations of tank fluid purging and night cooling of the storage tank as overheating prevention methods. While none of the methods evaluated can be useful in the event of black-outs, the results have shown tank fluid purging as a more effective method for overheating prevention than non-predictive night cooling of the storage tank. As such, the tank fluid purging implementation used for this study seemingly overcame the overheating problems reported in the literature.

Performance-wise, the PV-T systems simulated using tank fluid purging, night cooling or both combined surpassed the primary energy efficiency of the reference PV-T system not using any stagnation control method. In particular, the combined use of both individual methods led to the best performances of all, although the performance differences are arguably within the simulations' error range.

Moreover, combined use of both methods reduced the volume of water purged relative to the individual use of tank fluid purging, which proved significant. Thus, fluid purging is not environmentally sound vis-à-vis water scarcity, particularly if used in space heating systems, and can be completed inexpensively by night cooling.

With regard to the implementation tweaks conceivably possible using features associated with "smart systems", the simulations did not reveal noticeable energy efficiency increases by using occupancy information to disable the auxiliary system. Conversely, using that information to alternate between normal and (lower) 'no load' night cooling setpoints reduced the cumulative duration of overheating events annually -even if insufficient to effectively prevent overheating as a whole -and improved the systems' primary energy efficiency. As such, night cooling has potential to improve and become the standard, low cost, effective and environmentally friendly overheating protection method for SDHW PV-T systems and others.

Fig. 1 .

 1 Fig. 1. Generic diagram for the solar domestic hot water (SDHW) systems studied.

Fig. 2 .

 2 Fig. 2. Monthly horizontal irradiation (H), average outdoor (Ta,avg) and utility water temperatures (Tu,avg) according to the (Lisbon) TMY data used in the simulations conducted.

Fig. 3 .

 3 Fig. 3. Cumulative annual duration of overheating periods (Δt) and normalised primary energy savings (fpes) versus the specific mass flow rate (mc/Ac) for the SDHW PV-T systems simulated. Legend: NSC, no stagnation control; NC, night cooling (Tn=80ºC; no load mode limited to vacations, i.e., excludes weekends); TFP, tank fluid purging (Tpurge=85ºC; mpurge=mc).

Fig. 4 .

 4 Fig. 4. Normalised primary energy savings (fpes) and normalised thermal energy waste due to fluid purging (Npurge) versus the specific mass flow rate for the SDHW PV-T systems simulated. Legend: NSC, no stagnation control; NC, night cooling (Tn=80ºC; no load mode limited to vacations); TFP, tank fluid purging (Tsafe=Tpurge-5ºC; mpurge=mc).

Acknowledgments. The current study was made possible by a doctoral grant (reference SFRH/BD/76747/2011) issued by the Foundation for Science and Technology (FCT). The authors would like to thank the National Laboratory of Energy and Geology (LNEG) and the Faculty of Science and Technology, New University of Lisbon (FCT-UNL) for the institutional support.