# Data-Driven and Machine-Learning-Based Real-Time Viscosity Measurement Using a Compliant Mechanism
## 1 Introduction  
Continuous viscosity measurement is becoming important in food, paint, and other process industries. The conventional methods of offline measurement with rotational, capillary, and other types of sensors are not suitable for dynamic and accurate viscosity measurement. There is a need for equipment capable of accurate, reliable, and affordable measurements of a fluid's viscosity in a real-time mode. There have been attempts to design a viscosity sensor using piezoelectric material, where the device is in a macroscopic or microscopic form. The macroscopic form is preferred for continuous measurements in process industries that use vibrating piezoelectric materials. The present design is motivated by previous research, where a vibrating mechanical structure was used for the viscosity measurements. The structure was made to undergo dynamic vibrations using a suitable actuator, and the electrical, as well as the mechanical responses of the system, were analyzed to estimate the fluid's viscosity. The measurement procedure involves the high-frequency excitation of piezoelectric material and the measurement of its vibration and electrical properties to estimate fluid viscosity [1]. Other types of devices use a self-sensing resonating structure with a piezoelectric crystal, and the electromechanical impedance is monitored to estimate fluid viscosity [2]. [PERSON] et al. (2017) [3] estimated the fluid viscosity of redox battery liquid by evaluating the pressure drop through the porous medium of a half-cell structure. The authors investigated the relationship between the electrolyte's viscosity, temperature, and state of charge using an online measurement tool and a neural network model. Ultrasound Doppler Velocimetry (UDV) was used by [PERSON] et al. (2006) [4] in order to measure the viscosity of non-Newtonian fluids across a broad range of shear rates by evaluating the velocity profile in the pipe flow, the shear rate distribution, and the shear stress distribution. The authors compared the results to those of conventional techniques to demonstrate its better accuracy and the significant reduction in the measurement time. [PERSON] et al. (2013) [5] introduced a transparent suspended microchannel resonator for the dynamic measurement of fluid density and viscosity. A number of samples were evaluated, including those of crude oil, and the results were reported with a resolution of 0.01 kg/m\({}^{3}\) for density measurements and 0.025 mPa-s for viscosity measurements, making it suitable for applications in pharmaceutical, chemical, and petroleum industries. [PERSON] et al. (2018) [6] presented a viscosity sensor comprising piezoelectric material vibrating in the tangential and normal directions. The device was able to excite piezoelectric material, creating vibrations in the structure, which were measured to estimate the viscosity of the fluid. A piezoelectric whisker transducer was used in a resonating structure comprising a cantilever beam and a sphere for the simultaneous measurement of fluid viscosity and density. Other types of devices use piezoelectric material fitted into a mechanical structure, arranged to provide vibrations to this mechanical structure. The structure vibrates in bending or shear mode, and the resonance frequency and the vibration amplitude are measured to determine the viscosity [7,8]. Devices working with piezoelectric material operate in bending or shear mode, where the resonant frequency and the vibration amplitude are used to correlate the dynamic viscosity [8]. [PERSON] et al. (2024) [9] used a cuboidal-shaped piezoelectric actuator operating at several resonant frequencies, where the vibrations were measured, and machine learning (ML) tools were used for viscosity estimation. [PERSON] et al. (2024) [10] presented the theoretical simulation results for a viscosity measurement system that uses a piezoelectric diaphragm, which is used for excitation as well as detection.