Introduction

Nanofluids are a type of engineered fluid consisting of a base fluid, such as water, oil, or ethylene glycol (EG), with suspended nanoparticles typically with a size ranging from 1 to 100 nm. The nanoparticles can be made of various materials, including metals, ceramics, and polymers, and are chosen for their unique thermal, electrical, or mechanical properties (Bakthavatchalam et al. 2020).

Due to their unique properties, such as high thermal conductivity, high specific heat capacity, and enhanced convective heat transfer, nanofluids have gained considerable attention in recent years for their potential applications in various fields, like energy, electronics, biomedicine, and manufacturing.

However, the study and application of nanofluids present several challenges. One of the most significant challenges is the measurement and modeling of their properties, such as viscosity, thermal conductivity, and stability. As a result, the development of accurate and efficient methods for measuring and predicting the properties of nanofluids is essential for advancing research and applications in this field.

One of the critical parameters that affect the behavior and performance of nanofluids is viscosity, which refers to the resistance of a fluid to deformation or flow. Accurately predicting the viscosity of nanofluids is essential for optimizing their performance and applications, as it influences their heat transfer and fluid dynamics properties.

Modeling the viscosity of nanofluids is a challenging task due to the complex interactions between nanoparticles and the base fluid. Therefore, the development of accurate and efficient methods for measuring the viscosity of nanofluids is essential for advancing research and applications in this field.

Several empirical models have been introduced to predict the viscosity of nanofluids, considering various parameters such as nanoparticle concentration, size, and temperature (Hemmat Esfe and Rostamian 2017; Udawattha et al. 2019; Klazly and Bognár 2022). However, most of these models have limitations in terms of accurately capturing the complex relationships between these parameters and the resulting viscosity. Many of these models are based on simplifying assumptions, neglecting certain factors that can significantly affect the viscosity of nanofluids. These models are also often limited to specific types of nanofluids. This is because the models are typically based on experimental data for a particular system and may not apply to other types of nanofluids with different particle types, sizes, or concentrations. To overcome this limitation, researchers often need to develop or modify empirical models for each specific nanofluid system they are working with. As a result of empirical models’ limitations, researchers have been exploring alternative methods to model the viscosity of nanofluids.

In recent years, artificial intelligence (AI) has emerged as a powerful tool for modeling and predicting complex phenomena in various fields, including fluid’s thermophysical properties (Valderrama et al. 2014; Taghizadehfard et al. 2019; Pierantozzi et al. 2022). Specifically, artificial neural networks (ANNs), a type of machine learning algorithm inspired by the structure and function of the human brain, have shown promising results in modeling the viscosity of nanofluids (Ma et al. 2021).

The ability of ANNs to learn from data and identify complex patterns between input and output parameters, without the need for an explicit knowledge of the physical mechanisms (Maaoui et al. 2022), makes them a useful tool for modeling complex systems such as nanofluid’s viscosity which depends on several factors such as nanoparticle size, concentration, and temperature.

In recent studies, significant attention has been directed towards the use of ANNs for the prediction of fluid and nanofluid viscosities (Longo et al. 2017; Rostamian et al. 2017; Amani et al. 2017; Çolak 2021; Esfe et al. 2022, 2023a, b, c; Moslehi et al. 2023; Maaoui et al. 2023). These investigations involved the utilization of experimental viscosity data for nanofluids to both train and validate the ANN models. Consequently, these models were subsequently employed for viscosity predictions of novel nanofluid samples featuring varying particle properties. The application of AI and ANN models to forecast nanofluid viscosity has yielded encouraging outcomes, demonstrating the potential to surpass the constraints associated with empirical models.

Implementing ANN models into a web application would make them more accessible and easier to use by researchers and engineers. It is worth noting that since the emergence of Web 2.0, websites have undergone a significant shift from static, information-based pages, to dynamic, software-like web applications. This change paved the way for an entirely new experience for internet users, offering a more interactive, immersive, and personalized experience (Torres Kompen et al. 2019; Chitanana 2021).

Before the appearance of Web 2.0, websites were typically limited to displaying static content, where users could only read and access the information available on the page (Niaz et al. 2022). However, with the emergence of new technologies and programming languages, such as JavaScript, websites became much more dynamic and interactive. This means that users can interact with the content on a website, which makes websites turn out like software applications rather than just a collection of static pages (França et al. 2021).

As a result of these changes, websites became more engaging and interactive, with features like real-time updates, multimedia content, and user-generated content. This shift also allowed websites to offer a more personalized experience to their users (Tavakoli and Wijesinghe 2019).

This paper aims to combine web technology and artificial intelligence, specifically artificial neural networks, to develop an intelligent user-friendly web application to predict the viscosity of EG-based nanofluids with five different types of nanoparticles (Al2O3, CeO2, CuO, Fe, and Ag) from input parameters such as nanoparticle type, particle size, concentration, and temperature.

Database presentation

The database used in this work is composed of 470 experimental viscosity measurements for five different types of nanoparticles (Al2O3, CeO2, CuO, Fe, and Ag) suspended in ethylene glycol (EG) base fluid.

EG-based nanofluids have various applications in different systems, including vehicles, electronics, and computer cooling (Mutuku 2016). The primary benefit of adding nanoparticles to EG base fluid is the improvement of the obtained nanofluid’s thermal conductivity compared to pure ethylene glycol (Sawicka et al. 2020). This increased thermal conductivity enables more efficient heat transfer and can lead to smaller and lighter heat exchangers, which is a significant advantage in many applications. By incorporating EG-based nanofluid as a coolant, these systems can achieve better performance and improved energy efficiency, leading to more sustainable and cost-effective operations. This underscores the intensified attention directed towards comprehensive investigations into the thermophysical properties of this particular nanofluid over recent years (Traciak et al. 2022; Farbod and Rafati 2022; Zafar et al. 2022).

The viscosity measurements of various nanofluids utilized in this study were collected from diverse literature sources. Table 1 presents the different types, sizes, and concentrations of nanoparticles for each nanofluid sample next to the range of temperature measurements.

Table 1 Experimental characteristics of nanofluid samples

It is well known that temperature can significantly affect the viscosity of nanofluids. The increase in the nanofluid’s temperature leads to a decrease in its viscosity. This phenomenon is due to the effect of the temperature on intermolecular attractions between the base fluid and its suspended nanoparticles. The effect of these interactions decreases when temperature increases (Mishra et al. 2014). In addition to the effect of temperature, the nanoparticle concentration in the base fluid has a significant effect on the nanofluid’s viscosity. Raising the concentration of nanoparticles in nanofluids leads to an increase in their viscosity. These effects are clearly demonstrated by the experimental measurements conducted in the studies (Pastoriza-Gallego et al. 2011; Hemmat Esfe et al. 2014; Zadeh and Toghraie 2018; Yadav et al. 2020).

Web applications

A web application is a software-like program that is hosted on a server and accessed through a web browser over the internet. It is designed to operate on a web server and allows users to access it from any device (laptop, tablet, or smartphone). It is composed of two main parts: the frontend and the backend. The frontend represents the part of the application that the user interacts with, while the backend is responsible for processing data and responding to requests from the frontend.

The frontend typically presents the user interface, the design, and the layout of the application. It is responsible for presenting the data in a user-friendly manner and providing user interactivity (Filipova and Vilão 2018a). The frontend is usually built using languages such as HTML, CSS, and JavaScript and frameworks like Angular, React, or Vue.

The heart of Angular lies in the creation of components, encapsulating specific functionalities and user interface elements. For each component, three files will be created. The first will contain the HTML code which is composed of the structural foundation of the component (Headings, paragraphs, buttons, input fields…). The second will contain the CSS code that is used to add style and enhance the visual of the interface like specifying colors, font style, and the position of each element. The third file is composed of TypeScript, a superset of JavaScript, which will be used to make the application dynamic and handle the logic such as responding to user actions like button clicks.

On the other hand, the backend is responsible for handling the business logic of the application. It processes the requests received from frontend and returns the appropriate response (Filipova and Vilão 2018b). There are multiple server-side languages such as PHP, Python, or JavaScript that are used for backend development.

The information between clients and servers is exchanged through Hypertext Transfer Protocol (HTTP). The client, typically a web browser, sends an HTTP request to the server, which then responds with an HTTP response. The HTTP request contains a URL, which identifies the resource being requested, and a body, for POST requests, which contains information collected from users through a web form. The HTTP response typically contains a status code, which indicates whether the request was successful or not, and the requested resource itself, which can be in the form of files (HTML, JavaScript, CSS, or any type of static files) or any data form like JSON (JavaScript Object Notation) (Mardan 2018).

For example, when a user enters data into a web form, the frontend sends an HTTP request to the backend, which then processes the data and returns an HTTP response. This communication is what enables the frontend and backend to work together seamlessly to provide a user-friendly and dynamic web application experience.

To develop a cross-device intelligent web application for the prediction of nanofluid’s viscosity, Python and it is framework Django (Rubio 2017) were used for server-side development (Backend). For frontend, Angular, which is a very popular open-source framework developed and maintained by Google (bin Uzayr et al. 2019), was used to build the user interface of this application.

Artificial neural networks

Artificial neural networks (ANNs) are designed to replicate the structural and operational aspects of the human brain. These networks consist of interconnected nodes, known also as neurons, which process information and make predictions. The origins of ANNs trace back to the 1940s when Warren McCulloch and Walter Pitts proposed the first mathematical concept of an artificial neuron (He et al. 2020).

Every artificial neuron obtains inputs from other neurons. Subsequently, a summation function is executed. This function involves adding up the products of each input and its corresponding weight. The outcome of this summation then proceeds through an activation function, which serves to calculate the final output of the neuron (Hosseini and Pierantozzi 2019; Mazumder and Prasad M 2023).

In ANNs, neurons are systematically organized into layers. The prevailing architecture, used for regression, is the feedforward neural network, a paradigm where artificial neurons are structured in layers, each neuron exclusively linked to all those in the subsequent layer (Hemmat Esfe and Afrand 2020). This architecture facilitates the segmentation of the ANN into three distinct segments. The primary segment encompasses the input layer, composed of neurons that represent the initial parameters supplied to the ANN. These parameters will pass for processing within the subsequent hidden layers. The hidden layers, constituting the second segment, serve as the computational core where data manipulation occurs. This section can encompass single or multiple layers. Ultimately, the last segment corresponds to the output layer, responsible for the final predictions of the ANN. The number of neurons in this layer aligns with the quantity of parameters anticipated for prediction (Maaoui et al. 2023).

Numerous tools are available for the development and training of ANNs, spanning different programming languages and frameworks. Examples of these tools encompass the Neural Network Toolbox, tailored for MATLAB, and Keras, designed for Python. In the context of the present project, which involves developing a web application utilizing the Django backend framework, Keras was chosen as the ideal option. This selection was primarily influenced by Keras’ seamless compatibility with Django, streamlining the integration of the ANN model into the web application.

Keras provides a good environment for the construction of ANNs (Moolayil 2019). It grants researchers the ability to configure key architectural components of the model. Specifically, the number of layers within the network, the count of neurons within each layer, the selection of suitable activation functions, and the optimization function. This configurability helps to mold the ANN’s architecture according to the complexity of the research domain.

The Adam optimizer is one of the most successful and widely used optimization functions (Xue et al. 2022). This crucial component is responsible for guiding the model’s training process by iteratively adjusting the weights and minimizing a loss function that quantifies the difference between the predicted output of the ANN model and the actual target values. Gradient-based optimizers like Adam use the gradients of the loss function with respect to the parameters to update them in a way that reduces the loss (Wang et al. 2022). These weight adjustments are made until the model’s output aligns closely with the experimental values, effectively enhancing the model’s predictive accuracy.

To enhance the training phase further, a regularization algorithm could be incorporated. The L2 regularization, also known as weight decay, plays an important role in preventing the model from becoming overly complex during training. This is achieved by adding a penalty term to the loss function, discouraging the model from assigning excessively high weights to certain features (Xie et al. 2022). This regularization technique contributes to a more balanced distribution of weights, mitigating the risk of overfitting and promoting a more generalized representation of the data.

Results

Viscosity prediction using ANN

The database used in this work was divided into three parts. Sixty-three percent of datasets (296 datasets) of the database were used for training the network, 7% (33 datasets) for validation, and the other 30% (141 datasets) were used for testing (Table 2). Each dataset is composed of the input parameters: the type, the size, and the concentration of nanoparticles (φ) next to the temperature (T) of measurements and their corresponding output parameter which represents the value of the viscosity (\(\mu\)) of each input set.

Table 2 Data repartition of nanoparticle type for each database

The training database was used for training the network until it produces accurate results, the validation database was used to evaluate the model performance on unseen data during training and gives insight into the model’s effectiveness in performing prediction on unseen data, and the testing database was used after training to check the network’s ability to generalize the correlation between the different parameters constituting the input layer of the network and the viscosity of EG-based nanofluids on unseen data during the training phase.

The information about the type of nanoparticles was encoded into a format that could be understandable by the ANN. For each type, a numerical value was assigned. Al2O3, CeO2, CuO, Fe, and Ag were transformed respectively to 0, 1, 2, 3, and 4.

As statistical performance criteria for the ANN predictions, five parameters were used:

The Max error, RMSE (root mean squared error), MAPE (Mean absolute percentage error), the Max Deviation, and the coefficient of determination R2:

$$error= \overline{\mu }-\mu$$
(1)
$$RMSE={\left(\sum_{1}^{N}\frac{{\left|\overline{\mu }-\mu \right|}^{2}}{N}\right)}^\frac{1}{2}$$
(2)
$$MAPE \left(\%\right)=\frac{1}{N}\sum_{1}^{N}\frac{\left|\overline{\mu }-\mu \right|}{\mu }*100$$
(3)
$$Deviation (\%)=\frac{\left|\overline{\mu }-\mu \right|}{\mu }*100$$
(4)
$${R}^{2}={\left[\frac{N\sum \overline{\mu }.\mu -\sum \overline{\mu }.\sum \mu }{\sqrt{\left[N\sum {\overline{\mu }}^{2}-{\left(\sum \overline{\mu }\right)}^{2}\right].\left[N\sum {\mu }^{2}-{\left(\sum \mu \right)}^{2}\right]}}\right]}^{2}$$
(5)

\(\overline{\mu }\) is the value of the estimated viscosity, and N is the number of datasets.

After trying various ANN models with different numbers of hidden layers and varying numbers of neurons in each layer (Appendix Table 4), the most optimal results were achieved with the ANN architecture presented in Fig. 1 (two hidden layers with 35 and 25 neurons respectively for the first and second layer with “ReLU” as activation function).

Fig. 1
figure 1

ANN architecture

The choice of ReLU as an activation function was based on its advantages, such as avoiding the vanishing gradient problem during training which can contribute to improved generalization capabilities, aiding the network in learning robust representations from the data (Ide and Kurita 2017; Wang et al. 2020).

After the training phase, the optimized weights of the model were saved for future use.

Figure 2 illustrates the prediction results of EG-based nanofluids’ viscosity using the type, size, concentration of nanoparticles, and the temperature of measurements as inputs. The predicted values of the nanofluids’ viscosity, for the training database, were too close to the curve x = y which demonstrates that the ANN output was very close to the measured values of viscosity. This closeness was translated by low value of RMSE = 0.19 and MAPE = 1.19% (Table 3). The maximum error for viscosity prediction was equal to 1.23. This demonstrates that there is no overestimation of the nanofluid viscosity using the obtained ANN model.

Fig. 2
figure 2

Results for viscosity prediction using the ANN model

Table 3 ANN performance in training and testing database

Figure 3 illustrates the repartition of the absolute error. It is clear, from this figure, that most of absolute errors for the training database were below 0.9.

Fig. 3
figure 3

Repartition of absolute errors

Figure 4 showcases the repartition of deviations. The maximum obtained deviation was found to be equal to 6.15%; this value indicates that there was no overestimation of the nanofluid’s viscosity using the obtained ANN model in the training database and that the model has successfully learnt pattern between the different input parameters and the viscosity.

Fig. 4
figure 4

Repartition of deviations

The close error metrics values between the validation database and those for the training database (Table 3; Figs. 2, 3, and 4) suggest that the model would be able to perform prediction on new unseen data accurately.

To evaluate the obtained ANN model and determine its ability to generalize the correlation between the inputs and the viscosity of the EG-based nanofluids, this model was tested using the testing database which is consisting of datasets that were not used during the training phase. Using the obtained ANN model to predict viscosity using the testing database is a crucial step in assessing the model’s ability to predict new inputs accurately (Faúndez et al. 2020). This evaluation provides insights into the statistical error metrics involved in the prediction process, indicating the model’s reliability and accuracy in making predictions for unseen data. The testing phase is a critical evaluation step in developing a robust ANN model for predicting the viscosity of the EG-based nanofluids.

The close proximity of the predicted viscosity values for the testing database to the curve x = y in Fig. 2 indicates that the model has successfully generalized the correlation between the various input parameters and the viscosity of the nanofluids. The statistical error metrics obtained, RMSE = 0.67 and MAPE = 2.33%, demonstrate the excellent performance achieved using the ANN model (Table 3).

Figure 3 shows that the absolute error, for the testing database, was greater than 0.9 only for a few instances, indicating the high accuracy of the ANN model in predicting the viscosity of EG-based nanofluids, even for data that were not included in the training phase.

Furthermore, the distribution of deviations for the testing database, illustrated in Fig. 4, and the maximum deviation, which was found to be 11.17%, indicate that the model did not overestimate the viscosity value.

To further validate the acquired ANN model, its performance was compared with the models presented in the studies listed in Table 1. However, it is noteworthy that the viscosity has been modeled in only two of the listed works. Specifically, Pawan Kumar Singh et al. (2020) and Zadeh and Toghraie (2018) have respectively obtained MOD = 10% and MOD = 8%. These error metrics correspond to the maximum deviation in this study, and they align closely with the obtained value using our ANN model (11.17%) although our model is more general and works for five different types of nanoparticles. It is worth mentioning that this value of deviation was occurred for a data point taken from Hemmat Esfe et al. (2014).

Overall, these results demonstrate the reliability and accuracy of the developed ANN model in predicting the viscosity of EG-based nanofluids.

In the context of evaluating the developed ANN model and assessing its generalization capabilities, random values for nanoparticles concentration were employed, along with a value of size that was not included in training examples but close to the training data range. Additionally, a smaller temperature step than that used in the original experimental measurements was utilized to make predictions. The aim of these predictions was to analyze how viscosity behaves when varying input parameters based on the ANN model outputs.

As depicted in Fig. 5, for the five types of nanoparticles, an increase in concentration correlates with an increase in viscosity while an increase in temperature would decrease the viscosity. These observed behaviors are consistent with findings reported in the literature. The unpronounced effect of φ on the viscosity of CeO2 and CuO was also noticed in experimental measurements.

Fig. 5
figure 5

Prediction of the viscosity of EG-based nanofluids for different nanoparticle concentration using the ANN model

This comparison between the model’s predictions and experimental results suggests that the ANN model effectively captured the relationship between the different input features and viscosity, showcasing its ability to generalize to new data points.

Implementing the obtained ANN model in a web application

To facilitate the use of the obtained model, it was implemented in a web application. This web application was developed using Angular in frontend and Django in backend. The web application features a user-friendly interface that allows users to input chosen values for the input parameters and perform viscosity prediction of EG-based nanofluids. The input parameters, collected from the user, will be sent to the server in JSON format where the calculation of the viscosity will be performed using the obtained ANN model, and then results will be sent back to the user, and an excel file containing the results will be created in the server. The interface offers the option to visualize results in the form of figures, tables, or to download results in Excel format, providing users with flexibility in how they choose to analyze and interpret the data (Fig. 6).

Fig. 6
figure 6

Web application screenshots (manual input)

To ensure accessibility, the web application was designed with a responsive layout that adapts to any size of screen, including smartphones, tablets, and laptops. This means that users can access the application from any device with an internet connection without installing any program in their devices.

In addition to the manual input of parameters through the graphical user interface, the web application also supports the upload of an Excel file that follows specific instructions (Fig. 7). The server performs the calculation of the viscosity based on the inputs in the Excel file uploaded by the user and returns the results in a new Excel file. The development of this web application makes the ANN model more accessible to researchers working in the behavior of EG-based nanofluid viscosity. By providing a user-friendly interface and multiple output options, the web application makes it easier for users to perform viscosity prediction and obtain valuable insights into the behavior of nanofluids under different input parameters.

Fig. 7
figure 7

Web application screenshot (Excel input)

Discussion

The ANN model, developed in this study, was used to predict the behavior of EG-based nanofluids’ viscosity for varying input parameters. The model was trained to predict the viscosity of nanofluids for five different types of nanoparticles (Al2O3, CeO2, CuO, Fe, and Ag) as a function of their size, concentration, and temperature of measurement.

Finding a relationship between all these parameters is very difficult using traditional empirical models due to the complex relation between all the input parameters and the viscosity. The ANN model developed in this study, however, was able to overcome this limitation by finding a correlation between all the input parameters and the viscosity. The performance of the ANN model was evaluated using statistical error metrics, and the results demonstrated high accuracy in predicting the viscosity of nanofluids for different input parameters. These results further validate the effectiveness of the ANN model in predicting the viscosity of nanofluids for four input parameters.

One of the predominant challenges when employing ANNs for modeling is the risk of overfitting. Consequently, assessing the model’s performance on unseen data during the training phase is a pivotal measure to validate the model’s integrity and ensure that it has not merely memorized the training data. To counteract the overfitting concern, in this study, a normalization layer was introduced alongside the input layer. This layer facilitated the conversion of input parameters to a mean-centered range. Additionally, an L2 regularization was implemented in the two hidden layers to avoid large weight values that could lead to dominance.

The alignment between the error metric values obtained from the testing database, which is composed of 141 datasets, and those from the training database and validation database serves as confirmation that the model did not memorize the training data during the training phase and that it has established a general correlation between the different input parameters and the viscosity.

The implementation of this ANN model in a web application offers a significant flexibility for scientific use. Researchers and engineers are typically required to handle software installation on their local machines, which can be time-consuming and may require a certain level of technical expertise. However, with web applications, users can benefit the access to the application from any device with an internet connection, making it much more convenient to use. In addition, web applications are characterized by the ease of maintenance and updates. Since web applications are hosted on servers, developers can easily maintain and update the application’s code, and other resources on the server side. This means that users do not need to download and install software updates on their local machines, reducing the need for user intervention and minimizing the risk of errors or compatibility issues.

Conclusion

In this study, an effective approach for predicting of EG-based nanofluid viscosity using an ANN model was presented. The model was able to establish a correlation between the input parameters composed of type, size, concentration of nanoparticles, and temperature of measurements and the viscosity of nanofluids, which is a complex relationship that is difficult to model using traditional empirical models. The high accuracy of the ANN model in predicting the viscosity of nanofluids for different input parameters was demonstrated through good statistical error metrics. The MAPE obtained for training and testing was equal respectively to 1.19% and 2.33%. The maximum deviation, itself, did not exceed 11.17% for the testing database.

Nonetheless, our model was not trained on an extensive size range of nanoparticle size. The influence of nanoparticle dimension remains in fact ambiguous due to the limited availability of experimental data that study the size effect. Further experimental work is essential to elucidate the nuanced effects of nanoparticle size on the overall model accuracy and outcomes.

Moreover, the development of a web application based on the ANN model provides a user-friendly interface for researchers to easily input their chosen values for the input parameters and obtain the viscosity predictions. The web application also allows users to visualize and download the results in different formats, further increasing its accessibility and convenience. This study has significant implications for researchers working in the field of nanofluids, as it provides an effective tool for predicting the behavior of EG-based nanofluid viscosity and facilitating their research.