You are on page 1of 65

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

Jnana Sangama, Belagavi, Karnataka-590 014

A PROJECT REPORT
ON

“DIGITAL TWIN FOR WATER DOMAIN”


Project report submitted in partial fulfillment of the requirement for
the award of the degree of

BACHELOR OF ENGINEERING
IN
MECHANICAL ENGINEERING
Submitted by

MANOJ M HOLAGI 1NH16ME056

Under the guidance of


Mr. Naresh K S
Asst. Professor
Dept. of Mechanical
NHCE, Bengaluru
2

NEW HORIZON COLLEGE OF ENGINEERING


DEPARTMENT OF MECHANICAL ENGINEERING
BANGALORE-560 103
2019-20
DEPARTMENT OF MECHANICAL ENGINEERING

CERTIFICATE
It is certified that the Project work entitled “Digital Twin For Water Domain”
carried out by MANOJ M HOLAGI (1NH16ME056), the bonafide student of New
Horizon College of Engineering, Bengaluru, in partial fulfillment for the award
of Bachelor of Engineering in Mechanical Engineering of the Visvesvaraya
Technological University, Belagavi during the year 2019-2020. It is further
certified that all corrections/suggestions indicated for internal assessment has
been incorporated in the report deposited in the department library. The Project
has been approved as it satisfies the academic requirements in respect of Project
Work prescribed for the Bachelor of Engineering degree.

Signature of the Guide Signature of the HOD Signature of the Principal


Mr. NARESH K S Dr. M S GANESHA PRASAD Dr. MANJUNATHA
Assistant Prof. Dean, Prof. and HoD-ME Principal
Dept. of Mechanical Engineering. Dept. of Mechanical Engineering. NHCE

Name(s) of the student: University Seat Number:


Manoj M Holagi 1NH16ME056

External Viva
Examiner Signature with date:
1.
2.
ACKNOWLEDGEMENTS

We thank the Lord Almighty for showering His blessings on us.

It is indeed a great pleasure to recall the people who have helped us in carrying
out this project. Naming all the people who have helped us in achieving this goal would
be impossible, yet we attempt to thank a selected few who have helped use in diverse
ways.
We wish to express our sincere gratitude to Dr. Manjunatha, Principal, NHCE,
Bangalore, for providing us with facilities to carry out this project.
We wish to express our sincere gratitude to Dr. M S Ganesha Prasad Dean,
Prof. & HoD-Mechanical Engg., for his constant encouragement and cooperation.
We wish to express our sincere gratitude to our teacher and guide Mr. Na resh K
S, Asst. Professor in the Department of Mechanical Engg., NHCE, for his valuable
suggestions, guidance, care & attention shown during the planning, conduction stages of
this project work.
We express our sincere thanks to project coordinators, all the staff members and
non-teaching staff of Department of Mechanical Engg., for the kind cooperation extended
by them.
We thank our parents for their support and encouragement throughout the course
of our studies.
ABSTRACT

Increasing the efficiency of heating, ventilation and air conditioning (HVAC) system by
reducing the power consumption has become extensively important due to the rising cost
of nonrenewable fossil fuels and environmental concern. Therefore, finding an ideal way
to reduce power consumption in commercial buildings without compromising with the
indoor comfort is analytically challenging. One of the proven ways to achieve energy
efficient HVAC system is by novel design of system configuration. Each component of an
HVAC has specific design requirement and it provides us the opportunities for energy
saving. Energy efficient HVAC can be created by reconfiguring the traditional existing
system, but it’s cost effective. This project investigates and reviews an approach for
increasing the performance of an existing HVAC system without replacing any of the
components and to demonstrate its ability to improve the performance by reducing
power consumption. This is possible by analyzing the previously collected data and
determining a data pattern that is subjected to various environmental conditions and to
obtain optimal parameters that is required to run HVAC system. By making the system run
at optimal rate, consumption of power reduces and cooling increases.
Digital Twin for Water Domain

CONTENTS

ABSTRACT 01

1. INTRODUCTION
1.1 Statistical Analysis 05
1.2 Problem Statement 05
1.3 Existing Solution 06
1.4 Proposed Solution 06
1.5 Digital Twin 06
1.6 HVAC System 07
1.7 Refrigeration Cycle 08

2. LITERATURE SURVEY
2.1 Comparative analysis of Energy efficiency in Air-conditioning systems 10
2.2 Methods to improve energy efficiency in air conditioners 10

2.3 Energy Efficiency technologies for HVAC System 11


2.4 Design and implementation of energy efficient HVAC System 11
2.5 System solution to improve energy efficiency of HVAC System 11

3. REQUIREMENT SPECIFICATION
3.1 Hardware Requirements
3.1.1 Arduino UNO 12

3.1.2 Raspberry Pi 13
3.1.3 Current sensor 14
3.1.4 Hall Effect sensor 14

3.1.5 AC voltage controller 15


3.1.6 Vapor compression refrigerator 16
3.1.7 Humidity and temperature sensor 17

3.1.8 Water proof temperature sensor 17


3.2 Software Requirements 18
3.3 Functional Requirements 19

3.4 Non-Functional Requirements 20

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 2


Digital Twin for Water Domain

4. DESIGN
4.1 Design Goal 21
4.2 System Architecture 21
4.2.1 HVAC System 22
4.2.2 Cloud System 23

4.2.3 Client System 24


4.3 Flow chart 26

5. IMPLEMENTATION
5.1 HVAC Setup 27
5.2 Cloud Setup 28

5.3 Client Setup 29


5.3.1 User Interface 30
5.3.1.1 Tabbed window 30
5.3.1.2 QLabel 31

5.3.1.3 QLineEdit 31
5.3.1.4 PyQt5 graph 32
5.3.2 Connectivity module 33

5.3.3 Machine learning module 34


5.3.3.1 Scikit-learn 35
5.3.3.2 Matplotlib 35

5.3.3.3 Numpy 35
5.3.3.4 Pandas 36

6. RESULT 37

7. CONCLUSION 38

8. FUTURE SCOPE 39

9. APPENDIX 40

10. REFERENCES 61

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 3


Digital Twin for Water Domain

LIST OF FIGURES

1.1 Digital twin concept 07


1.2 HVAC architecture 08
1.3 Refrigeration cycle 09

3.1 Arduino UNO 12


3.2 Raspberry Pi 3 B+ 13
3.3 Pin configuration of Pi 3 13

3.4 Current sensor 14


3.5 Hall Effect sensor 14
3.6 AC voltage controller 15

3.7 Serial and Parallel port 15


3.8 Supply input and load output port 15
3.9 Front view Vapor compression refrigerator 16
3.10 Inner view Vapor compression refrigerator 16

3.11 Hum & Temp sensor 17


3.12 Water-proof temp sensor 17
3.13 Tools and platform 18

4.1 System Architecture 21


4.2 HVAC system 23
4.3 Sample dashboard of Adafruit.IO 24

5.1 Dashboard for monitoring HVAC 28


5.2 UI - Main page 29

5.3 UI - Side page 29


5.4 Tabbed window 30
5.5 QLabel 31

5.6 QLineEdit 31
5.7 PyQt5 graph 32
5.8 Plot of RPM vs condenser temperature 36

5.9 Firmata protocol 36

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 4


Digital Twin for Water Domain

CHAPTER - 01

INTRODUCTION

Increased standards of living, lack of fossil fuel, concern towards environment and
increasing fossil fuel cost have forced researchers and scholars to concentrate on those
systems that consumes large amount of power, so that the old system is replaced by a
newly designed system. One among them is HVAC system.

HVAC is abbreviated as Heating, ventilation and air conditioning system. This system is
extensively used in each and every place, to ensure thermal comfort, air dryness and good
air quality for an indoor environment. This system solely consumes nearly 25% of world
electricity. Hence designing an efficient HVAC system can save a large amount power.

1.1 Statistical Analysis

According to a survey conducted by US scholars in 2012 it’s been found 50% of the world
electricity is solely consumed by buildings and 47% of building electricity consumption is
due to HVAC system. Energy Information Administration (EIA) of US has reported that
minimum 30% of the HVAC energy is wasted worldwide. The expanding use of HVAC
system in commercial, industrial and residential environment has resulted in huge energy
consumption, especially in summer. Hence developing energy efficient HVAC system is
crucial, to protect environment from green house effect.

1.2 Problem Statement

To increase the performance of an HVAC system without replacing any of the components
in the existing system, by designing an HVAC monitoring system for analyzing the pattern
of performance for various environmental conditions and running it at optimal rate.

1.3 Existing Solution

The rapid development in science and technology has provided several methods for
achieving efficient HVAC system. One of the methods is to design HVAC system based on
the requirement provided by the organization such as space, load, people, machinery,
zones, compartments, time etc. Designing the HVAC based on their requirement can be
done through highly skilled HVAC engineer. The entire system has to be then replaced by

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 5


Digital Twin for Water Domain

a new one, which is highly costly and time consuming. Hence most of the people avoid
this method to save their money and time.

1.4 Proposed Solution

Most of the companies while designing the HVAC system consider the external
temperature to be constant. Hence the HVAC system works normally throughout the year.
But due to the seasonal weather change, there is continuous fluctuation in environment
temperature. This make the system run at non optimal rate, resulting in large
consumption of power. This project helps identify optimal rate at which the components
in HVAC have to run for various environment conditions, by continuously collecting and
evaluating data at different node points of the HVAC system. Finally a data pattern is
generated for various environments. This data pattern can be used for running the HVAC
system at optimal rate. Hence even if there is any fluctuation in the external temperature,
the HVAC system keeps note of it and chooses the optimal rate of operation from data
pattern. This results in optimal performance of the HVAC system.

1.5 Digital Twin

Digital twin is the buzzing technology of feature in the field of maintenance. It was first
introduced by Grieves in the University of Michigan as one of the concept of Product
lifecycle management (PLM). Digital twin is the digital replica of real-world assets such as
places, system and devices. It bridges the real and virtual world through data. The data is
seamlessly collected from physical object through sensors and then transmitted to virtual
object. This process makes the virtual object similar to physical object in its characteristics.
Digital twin is the integration of various field of technology such as Internet of things (IOT),
Artificial Intelligence (AI), Data analysis and Digital simulation model. A digital twin
continuously learns and updates itself by numerously collecting real time data in various
environment conditions. The virtual object is then used for simulation by varying the
parameters. If the simulation provides a positive result, then the changes are
implemented in the real assert, by this method we are able to increase the productivity
and also save time. Nowadays companies such as Azure, IBM and Siemens have started
working with digital twin to satisfy their customers. The most commonly used tool for
working with digital twin is SAP Predictive Engineering, a tool developed by SAP using
computer aided engineering.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 6


Digital Twin for Water Domain

Fig 1.1 Digital twin concept

1.6 HVAC System

HVAC is abbreviated as Heating, ventilation and air conditioning (HVAC) system is a


discipline in the field of indoor comfort. The primary objectives of HVAC system are
thermal comfort and air filtration. Designing an HVAC system, requires a proper
understanding of thermodynamics, fluid mechanics and heat transfer. Nowadays HVAC
has become an important part of commercial buildings, schools and hospitals. It’s been
found that nearly 25% of the world electricity is solely consumed by HVAC.

The main units of HVAC are Heating unit, Ventilation unit and air-conditioning unit.

Heating unit - Heating is mostly done using furnace in industries and boilers in residential
buildings. It makes use of pipes for transferring the heat and ducts for forcing the air in
and out.

Ventilation unit - Ventilation is the process of transferring and removing air from the
indoor space. It can be done either using forced method or natural method.

Air-conditioning unit – Air conditioning is the process of removing heat and moisture from
interior space. It also includes air filtration in order to remove CO 2. As CO2 level increases
the productivity and performance decreases. Hence it’s necessary to maintain good
quality of air.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 7


Digital Twin for Water Domain

Fig 1.2 HVAC architecture

1.7 Refrigeration cycle

Refrigeration cycle is a mathematical and conceptual model, behind the working heat
pumps and refrigerators. A heat pump transfers heat from lower temperature location to
higher temperature location, were as a refrigerator transfers heat from higher
temperature location to lower temperature location. In both the case, the principal of
operation are identical. This cyclic process is continuously takes place in chiller of an HVAC
system.

Refrigeration cycle primarily consist of

• compressor
• condenser
• expansion valve
• evaporator
• refrigerant

The refrigerant absorbs the heat from the indoor environment through evaporator coil
and become warm, the warm refrigerant is then sent to compressor, were the refrigerant
changes its state to high temperature and high pressure vapor, the high temperature and
high pressure vapor is then sent to condenser to remove the heat from refrigerant and

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 8


Digital Twin for Water Domain

the refrigerant then changes its state to low temperature high pressure liquid, the low
temperature high pressure liquid is then passed through expansion valve to reduce the
pressure and the refrigerant reaches low temperature low pressure state and the cycle
continuous.

Fig 1.3 Refrigeration cycle

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 9


Digital Twin for Water Domain

CHAPTER - 02

LITERATURE SURVEY

Literature survey is the most important step in the design and development of a
prototype. We have referred several papers for understanding the working of HVAC
system, calculating the co efficient of performance and improving the performance. The
papers include Comparative analysis of HVAC system, Economic and technical solutions
for improving air conditioner efficiency, Energy efficient technologies for HVAC and Design
and implementation of HVAC system based on PIR. This section includes a brief
description of work done by various scholars that helped us in designing the prototype for
the project

2.1 Comparative analysis of Energy efficiency in Air-conditioning systems

This paper focuses on use of energy efficient air-conditioning systems in public buildings.
For the analysis purpose, they have considered three buildings, the first one with cold &
heat sources, the second one with electricity-driven refrigerating unit and the third one
with direct-fired Li-Br absorption refrigerating and heating unit. Attempt is made to
analyze the actual operating performance of air-conditioning system and evaluate the
system energy efficiency in different buildings. The results show that ground-source heat
pump air-conditioning system without adequate design and management is not always
better than other traditional air-conditioning systems.

2.2 Methods to improve energy efficiency in air conditioners

This paper focuses on understanding the difference between EER and SEER. EER is
calculated at 35°C ambient temperature. Moreover, it does not consider varying weather
conditions prevailing over a season. Seasonal Energy Efficiency Ratio (SEER) gives a better
representation of AC efficiency because it considers seasonal temperature variations also.
A comparative analysis is performed for inverter AC vs. conventional AC using standard
tests data from the manufacturers to compare EER and SEER values at different ambient
temperatures. The effect of temperature differential on AC performance is also studied.
The test result indicates SEER values to be more consistent.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 10


Digital Twin for Water Domain

2.3 Energy Efficiency technologies for HVAC system

This paper focuses and reviews the different technologies and approaches, to
demonstrate their ability to improve the performance of HVAC systems in order to reduce
energy consumption. For each strategy, a brief description is first presented and then by
reviewing the previous studies, the influence of that method on the HVAC energy saving
is investigated. Finally, a comparative study between these approaches is carried out.

2.4 Design and implementation of energy efficient HVAC system

This paper focuses on designing an HVAC system to run at optimal rate by simulating the
system for various parameters. Energy efficiency process has been made by controlling of
alternative current (AC) drivers for ventilation and exhaust fans, according to supplied air
flow capacity and differential air pressure between supplied and exhaust air. Supervisory
controller software was developed by using programmable controllers and human
machine interface (HMI) units to improve its performance. The new designed HVAC
control system would save 40% of power, when compared to the existing system, without
any additional cost

2.5 System solution to improve energy efficiency of HVAC system

This paper focuses on reduction in energy consumption significantly, by adopting variable-


speed compressor systems, the market penetration has been limited to less than 10% of
the total HVAC units and a vast majority of systems installed in new construction remains
single speed. A few reasons may explain this phenomenon such as the complexity of the
electronic circuitry required to vary compressor speed as well as the associated system
cost. This paper outlines a system solution to boost the Seasonal Energy Efficiency Rating
(SEER) of a traditional single-speed unit, by using a low power electronic converter that
allows the compressor to operate at multiple low capacity speed.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 11


Digital Twin for Water Domain

CHAPTER - 03

REQUIREMENT SPECIFICATION

3.1 Hardware Requirements

• Arduino UNO
• Raspberry Pi 3 B+
• ACS712 Current sensor
• Hall Effect sensor module
• 8 Bit AC voltage controller
• Vapor compression refrigerator setup
• DHT11 Humidity and temperature sensor
• DS18B20 Waterproof temperature sensor

3.1.1 Arduino UNO

Arduino UNO is an open-source 8 bit microcontroller based on ATmega328P developed


by microchip. It has 14 digital I/O pins and 6 analog input pins, out of 14 digital pins, 6 can
be used as PWM outputs. Arduino UNO has a 16MHz ceramic resonator which can be used
for clock generation and an inbuilt analog to digital convertor for performing ADC
operation. It has a power jack and USB connection for power supply and data transfer.
Programming an Arduino UNO board requires an integrated development environment
called Arduino IDE for writing and uploading code in their respective boards.

Fig 3.1 Arduino UNO

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 12


Digital Twin for Water Domain

3.1.2 Raspberry Pi

Raspberry Pi is a low cost, single-board, credit card sized computer with 64 bit quad core
processor developed by Raspberry Pi foundation in United Kingdom. It consists of
Broadcom system on chip (SOC), ARM central processing unit (CPU) and on-chip graphics
processing unit (GPC). The speed of processor ranges from 700MHz - 1.4GHz with Random
access memory (RAM) of 1GB. It has a micro SD card slot for storing Operating system and
Program memory. The board is also provided with 2 no’s of 2.0 USB port and 2no’s of 3.0
USB port. It has a HDMI port for display purpose and a 3.5mm jack for audio output. It is
also provided with on-board Bluetooth, WIFI and Ethernet port for Internet connectivity.
Raspberry Pi is also provided with camera module port for interfacing Pi camera through
ribbon cable. Raspberry Pi 3 B+ model has several General purpose input output (GPIO)
pins which supports i2c protocol for interfacing sensors and actuators. There are several
OS on which Raspberry Pi can be operated such as Raspbian, Noobs and Ubuntu.
Raspberry Pi also supports multiple programming languages such as C, C++ and python to
be compatible for all programmers.

Fig 3.2 Raspberry Pi 3 B+

Fig 3.3 Pin configuration of Pi 3

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 13


Digital Twin for Water Domain

3.1.3 Current sensor

Current sensor is an electronic device that measures current through the wire and
generates an analog voltage signal proportional to the current. It consists of 3 pins Vcc,
Gnd and output. The output generated is an analog signal. The analog signal is used for
determining the peak and trough of the current signal. This data is then used for displaying
the current in Amps. The sensor can measure both direct current (DC) as well as
alternating current (AC) ranging from 0 to 20Amps.

Fig 3.4 Current sensor

3.1.4 Hall Effect sensor

Hall Effect sensor is an electronic device which is used for measuring the magnetic field
around it. The sensor provides output voltage that is directly proportional to the strength
of the magnetic field. The Hall Effect sensor consists of three pins namely Vcc, Gnc and
Output. Whereas the Hall Effect sensor module consist of four pins namely Vcc, Gnd, A0
and D0. Vcc and Gnd are used for powering the sensor. A0 provides an analog voltage
proportional to the magnetic field, whereas the D0 provides a voltage 5V when a magnetic
field is detected around it and provides a voltage of 0V when there is no presence of
magnetic field.

Fig 3.5 Hall Effect sensor

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 14


Digital Twin for Water Domain

3.1.5 AC voltage controller

AC voltage controller is an electronic device which is used for controlling the AC supply
provided to the load. It consists of two port supply input port and load output port. The
AC supply is connected to supply input port and the load appliance is connected to load
output port. The load voltage can be controlled by 8 bit binary data. In hexadecimal the
data ranges from 00 to FF, were 00 is the minimum value and FF is the maximum value.
The 8 bit data can be provided in serial or parallel manner. The controller consists of two
more ports for data reception i.e. serial data reception port and parallel data reception
port. Serial data reception port consists of two pins named Rx and Gnd were as parallel
data reception port consists of eight pins named D0 - D7 for controlling the voltage. The
controller consists of supply port with two pins named Vcc and Gnd for powering the
device.

Fig 3.6 AC voltage controller

Fig 3.7 Serial and parallel Fig 3.8 Supply input


. Port and load output port

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 15


Digital Twin for Water Domain

3.1.6 Vapor compression refrigerator

Vapor compression refrigeration system is the widely used refrigeration setup for
designing Air-conditioners, in which the refrigerant undergoes phase changes during its
cycle. It consists of compressor, condenser, evaporator and expansion valve. The
compressor compresses the refrigerant entering it, which results in rise in temperature
and pressure. Condenser is typically a heat exchanger, which removes heat from the
refrigerant and transfers it to flow of water. The water is then passed to cooling tower for
removal of heat. Evaporator is also a heat exchanger, were the low temperature
refrigerant entering in absorbs heat from environment through evaporator coil and
become warm. The expansion valve expands the refrigerant entering it, resulting in drop
temperature and pressure.

Fig 3.9 Front view Vapor compression refrigerator

Fig 3.10 Inner view Vapor compression refrigerator

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 16


Digital Twin for Water Domain

3.1.7 Humidity and temperature sensor

DHT11 is the commonly used sensor for measuring temperature and humidity. This sensor
is the combination of two sensors namely, capacitive humidity sensor and thermistor,
which measuring humidity and temperature respectively. The sensor can measure
humidity and temperature ranging from 20-90%RH and 0-50°C, with the accuracy of
±5%RH and ±2°C respectively. It consists of 3 pins Vcc, Gnd and output. The output is in
digital form and it makes use of single data bus for communication. It takes about 40ms
for 40 bits of data communication. The data format is 8 bits for integer humidity + 8 bits
for decimal humidity + 8 bits for integer temperature + 8 bits for decimal temperature +
8 bits for check sum in the respective order. This data format can be analyzed by controller
for determining real time temperature and humidity of the surrounding.

Fig 3.11 Hum & Temp sensor

3.1.8 Water proof temperature sensor

DS18B20 is the widely used water-proof temperature sensor. It can measure temperature
ranging from -55°C to 125°C with accuracy of ±5°C. The sensor makes use of 1-wire
interface to communicate with devices. Each sensor is provided with unique silicon serial
number. Hence multiple sensors can be connected to a common 1-wire bus and it can be
accessed with unique slave address. The sensor consist of three wires Vcc, Gnd and
output. The Vcc, Gnd and output is colored by red, black and yellow wire respectively. The
output is digital and it provides 12 bit temperature reading.

Fig 3.12 Water-proof temp sensor

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 17


Digital Twin for Water Domain

3.2 Software Requirements

Operating System

• Windows or Linux (any distro)


• Raspbian for Raspberry Pi

Integrated development Environment

• Pycharm
• Geany

Programming Language

• Python

Libraries

• PyQt5 for Graphical user interface


• Adafruit.io for cloud service
• Pandas for data manipulation
• Scikit-learn for machine learning
• Standard Firmata for data transfer

Fig 3.13 Tools and platforms

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 18


Digital Twin for Water Domain

3.3 Functional Requirements

Functional requirements are those which are related to the functionality of the system. A
functional requirement can be defined as the collection of requirements for software or
a system to behave as project or a system. It processes the input and gives an expected
kind of output. It provides a specified behavior between input and their corresponding
output. It helps us to capture the anticipated performance of the system. All the
requirements relevant to calculations, technical details, and data manipulation fall under
functional requirement.
These are the requirement that the end user exclusively ask as basic functions, that the
system should perform. Functional requirements are constrained by the non-functional
requirements which impose restriction on system design and its implementation. It
focuses on the application of the product. Functional requirement helps recognize absent
requirements and helps to clearly mark out the system behavior. Functional requirements
show how the system should function and how the system should be.

The functional requirements of this project are

• The Raspberry-pi has to be integrated correctly with the HVAC setup.

• The sensors connected with the raspberry-pi have to provide accurate values.

• The sensors values must be stored in raspberry-pi as well as in a database.

• The sensor values must be taken at regular intervals.

• The system must have initiated a cloud connection during its initiation process.

• The sensor values must be sent to the cloud in a cyclic process i.e. with a regular
time gap of around 1-2 minutes.

• The client system containing GUI must have proper visualization of widgets.

• The UI must provide the information about data in real time.

• The machine learning module that predicts the optimal fan speed must be called
when the user pushes the predict button or optimize button.

• The graph visualizing in the UI module must provide with proper information.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 19


Digital Twin for Water Domain

3.4 Non-Functional Requirements

Non-functional requirements are those which are not related to the functionality of the
system, but they are necessary for proper functioning of the system. The non-functional
requirements are the quality control that the system must meet according to the project
contract. They signify a set criterion that is used to critic a specific functionality in the
system. If the non-functional requirements are not met, the system is fails to meet the
user requirements. The priority or extent to which these factors are implemented varies
from one project to other.
Commonly used terminologies for non-functional requirements are "constraints", "quality
attributes", "quality goals", "quality of service requirements" and "non-behavioral
requirements".
Some of the quality attributes are enlisted below:

Accessibility: Accessibility is a common word which is used to define the extent to which
a product, device, service, or an environment is accessible to as many entities as possible.
In this project., the client system is just limited to computers and the client-module, the
project can be improved by extending the support to hand-held mobiles.

Maintainability: In the domain of software engineering, maintainability refers to the


ease with which a software product can be modified for defect correction and for meeting
the newer requirements. This definitely requires maintainability; the system must be
calibrated regularly because of the use of sensors.

Scalability: Currently the system works on a simple HVAC refrigeration setup with
minimal components. The system can be scaled higher to work on bigger HVAC setups
with few additional components.

Portability: In software engineering, the term ‘portability’ refers to the ability of the
existing code to be reused without requiring the need to write new code during platform
change or environment shifting. Our application is portable. So moving from one OS to
other doesn’t create any problem.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 20


Digital Twin for Water Domain

CHAPTER - 04

DESIGN

4.1 Design Goal

To design an HVAC monitoring system for analyzing the pattern of performance for
various environmental conditions and to improve the system performance by running it
at optimal rate.

4.2 System Architecture

Fig 4.1 System Architecture

The System can broadly be classified into three sub-systems

• HVAC System
• Cloud System
• Client System

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 21


Digital Twin for Water Domain

4.2.1 HVAC System

The HVAC system used in the project is “Vapor-Compression refrigerator”, which works
on the concept of Refrigeration cycle and it is primarily based on the concept of heat
transfer.

The law of heat transfer states that ‘Heat flows from higher energy level to lower energy
level’ i.e. an object at higher temperature loses its heat to an object at lower temperature
in order to balance the system. In order to improve the performance of the system we
have to make the system run at optimal rate.

Co-efficient of performance

The Co-efficient of performance of a refrigerator is defined as ratio Refrigeration effect to


the work done.

Cop = Refrigeration effect / Work done

Refrigeration effect = m * Cp * ΔT KW

Refrigeration effect = m * Cp * (Tout – Tin) KW

m = Mass flow rate of refrigerant


Cp = Specific heat of refrigerant
ΔT = outlet - inlet temperature
Tout = Temperature at outlet
Tin = Temperature at inlet

Work done = Energy consumed by system

From the above equation we understand that Refrigeration effect is directly proportional
to mass flow rate of refrigerant, Specific heat of refrigerant and difference at outlet and
inlet temperature.

So in order to improve the performance of the system we have three methods

Method 1

Increase the mass flow rate of the refrigerant, which requires physical changes to be made
in the system which is cost effective. Hence this method cannot be employed.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 22


Digital Twin for Water Domain

Method-2

Improve the specific heat of refrigerant. Since Specific heat of a refrigerant is constant,
hence in order to improve it we have to replace the existing refrigerant with better one.
For this to take place we have to replace the entire components in the refrigeration cycle
which is highly costly. Hence this method cannot be employed.

Method-3

Increase the difference between the outlet and inlet temperature. This can be done by
reducing the temperature at the outlet. So we have to remove larger amount of heat from
inlet. This can be done by running cooling tower at optimal rate. So that large amount of
heat is removed from less power.

Based on the above methods the most feasible one for our project is method 3 as there is
no hardware change that has to be made. Hence we have implemented the same.

Fig 4.2 HVAC system

4.2.2 Cloud System

The cloud system used in the project is “Adafruit.IO”

Adafruit.IO is a cloud service provider. That provides us with a platform for running and
managing the data with less programming. We can connect to it over internet across the
world. It’s primarily used for storing and retrieving the data. There are many other
features.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 23


Digital Twin for Water Domain

Features of Adafruit.IO

• Connect projects to services such as maps, weather etc


• Displays data in real time, with pre-built custom dashboard.
• Makes the project internet connected and triggers if the set limit exceeds.
• It provides MQTT API for connecting devices over internet using M2M protocol.

Fig 4.3 Sample dashboard of Adafruit.IO

4.2.3 Client System

The client system consists of UI and modeling interface for analyzing the data collected
from the HVAC system.

The UI is built using PyQt5.

PyQt is a GUI toolkit for interface python with Qt. It’s one of the most popular and
powerful platforms for GUI libraries. PyQt is a mixture of python programming and Qt
libraries. PyQt is software developed by Riverbank computing in United Kingdom of Great
Britain.

PyQt imports around 440+ classes and 6000+ function methods and it includes

• A massive number of GUI elements.


• Auto access of data from the database.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 24


Digital Twin for Water Domain

• SQL database can be accessed using classes.


• Scintilla-based open source software as text-editor.
• Uses Extensible markup language for encoding documents.
• Supports scalable vector graphics for two-dimensional graphics.

Analyzing the data in order to obtain the optimal rate of working is done through machine
learning algorithm. To be more specific we use a multi linear regression model for the
analysis.

Transfer of data from client system to cloud system and vice versa is done through MQTT
protocol.

MQTT

Message Queuing Telemetry Transport is an open ISO standard which uses public-
subscriber network protocol for transferring data between devices. This protocol runs
over TCP/IP. MQTT is supported by those networks that provide ordered, lossless and bi-
directional connection. MQTT sends connection credentials in the form of plain text and
it does not include any form of authentication for security purpose.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 25


Digital Twin for Water Domain

4.3 Flow chart

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 26


Digital Twin for Water Domain

CHAPTER - 05

IMPLEMENTATION

The process of improving the efficiency mainly depends on optimizing the speed of the
fan near the condenser coil which therefore improves the rate of absorption near the
evaporator coil.

5.1 HVAC Setup

We are mainly interested in 4 temperature spots excluding the valves of external-inlet and
external-outlet valves, those are:

• Condenser inlet and outlet


• Evaporator inlet and outlet

To simplify the development process we have integrated the HVAC system with a
Raspberry-pi to monitor the data and simultaneously transfer the data to the cloud.

Temperature sensors are fixed near these valves to read data and store them in the
raspberry-pi. The temperature sensors used are water-proof, Hence we have no problem
even is the sensor become wet due to leakage of water.

The values that has to be calculated other then the temperature to find the COP are rpm
of the fan and the electric consumption.

The RPM of the fan is calculated using the hall-effect sensor which works on the principal
to magnetic field detection. The electric consumption is derived using the voltage value
and the current value found by the current sensor.

The Cop is calculated using the existing values, then the calculated value is sent to cloud
along with sensor data using Raspberry pi. Raspberry Pi before uploading the data in cloud
makes not of in a file. The values stored in cloud is then analysed by client to build the
model.

The cloud service is provided by Adafruit.io and it makes use of MQTT protocol to publish
the data in cloud.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 27


Digital Twin for Water Domain

5.2 Cloud Setup

Adafruit.IO provides feeds to store the data. Feeds are the core of Adafruit IO. They hold
both the data you uploaded and meta-data about the data your sensors push to Adafruit
IO. For example: the date and time when it was uploaded. Or, the GPS coordinates where
the data was originated. A dashboard is an integrated feature into Adafruit IO which
allows you to chart, graph, gauge, log, and visualize your data. You can view your
dashboards from anywhere in the world.

The feeds update the values of their corresponding name and it can be visualized in the
dashboard the dashboard provides no use to us in this project, but we can visualize the
data pattern.

The MQTT protocol enables the published data to be transmitted to the client system
which had subscribed to receive the data from the Adafruit.IO.

Fig 5.1 Dashboard for monitoring HVAC

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 28


Digital Twin for Water Domain

5.3 Client Setup

The client system contains 3 modules

• UI
• Connectivity module (that connects the client system to the cloud)
• Machine Learning module

5.3.1 User Interface

The UI is developed using PyQt5. PyQt is a python binding cross platform GUI toolkit for
Qt, implemented as a python plug-in. PyQt is a free developed by the British firm
Riverbank Computing.The IDE used was PyCharm which enabled improved productivity
and The PyQt5-tools also provided an interface to develop an GUI using a GUI , drag-and-
drop interface.

Fig 5.2 UI - Main page

Fig 5.3 UI - Side page

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 29


Digital Twin for Water Domain

The GUI widgets used are

5.3.1.1 Tabbed window

PyQt5 has a widget to generate tabs known as QTabWidget. The QTabWidget can include
tabs (QWidgets), which have widgets on them such as labels, buttons, images

Fig 5.4 Tabbed window

CODE SNIPPET

class CustomTabWidget(QWidget)

self.t = QTabWidget()
self.t1 = QWidget()
self.t2 = QWidget()
self.t.resize(600,400)

self.t.addTab(self.t1,"Tab 1")
self.ts.addTab(self.t2,"Tab 2")

self.t1.layout = QVBoxLayout(self)
self.pB1 = QPushButton("PyQt5 button")
self.t1.layout.addWidget(self.pB1)
self.t1.setLayout(self.t1.layout)

self.layout.addWidget(self.t)
self.setLayout(self.layout)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 30


Digital Twin for Water Domain

5.3.1.2 QLabel

A QLabel object acts as a placeholder to exhibit non-editable text or image, or a movie of


animated GIF. It can also be used as a mnemonic key for other widgets. Plain text,
hyperlink or rich text can be displayed on the label.

Fig 5.5 QLabel

CODE SNIPPET

l = QLabel()

l.setText("Text in a label")

5.3.1.3 QLineEdit

QLineEdit object is the most frequently used input field. It provide a box in which one line
of text can be entered. In order to enter multi-line text, QTextEdit object is required.

Fig 5.6 QLineEdit

CODE SNIPPET

e1 = QLineEdit()

e1.setMinLength(5)

e1.setAlignment(Qt.AlignLeftt)

e1.setFont(QFont("Calibri",26)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 31


Digital Twin for Water Domain

5.3.1.4 PyQt5 graph

In PyQtGraph all plots are formed using the PlotWidget widget. This widget provides a
controlled canvas on which plots of any type can be added and configured. Under the
hood, this plot widget uses Qt native QGraphicsScene meaning it fast and well-organized
yet simple to assimilate with the rest of your app. You can create a PlotWidget as for any
other widget.

Fig 5.7 PyQt5 graph

CODE SNIPPET

self.graph = pg.PlotWidget()

self.setCentralWidget(self.grap)

time = [1,2,3,4,5,6,7,8,9,10]

temp = [30,32,34,32,33,31,29,32,35,45]

self.graph.plot(time, temp)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 32


Digital Twin for Water Domain

5.3.2 Connectivity module

The client system is subscribed to the Adafruit.IO cloud to receive data when the any data
gets published in the cloud.

The MQTT subscription is made available using Adafrut.io API which provides connectivity
libraries to connect to the Adafruit.io cloud using the MQTT protocol.

Adafruit IO Python client code for your Python scripts to use. There are usage
examples within the examples folder of the GitHub repository for use with MQTT, API,
and Basic IO functionality.

Connected function is used to connect the client machine to the Adafruit.io cloud, the
connection is made possible using the username and the secret key provide by the cloud.

CODE SNIPPET
def connected(client):
for _ in FEED_ID:
print('Connected to Adafruit IO! Listening for {0} changes...'.format(_))
client.subscribe(_)

Subscribe function is used to subscribe the cloud to receive the specifed data as the
feed_id.

CODE SNIPPET
def subscribe(client, userdata, mid, granted_qos,i):
# This method is called when the client subscribes to a new feed.
print('Subscribed to {0} with QoS {1}'.format(i, granted_qos[0]))

Disconnected function is used disconnect the client machine from the cloud

CODE SNIPPET
def disconnected(client):
# Disconnected function will be called when the client disconnects.
print('Disconnected from Adafruit IO!')

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 33


Digital Twin for Water Domain

Message function is used when a new data has been received by the cloud it return the
information of the feed-id , value received under the feed name etc.

CODE SNIPPET
def message(client, feed_id, payload):
print('Feed {0} received new value: {1}'.format(feed_id, payload))
print(payload)

The next module explains about the machine learning module that helps in finding the
optimal fan speed

After obtaining the optimal speed the required data that needs to be set in the HVAC
setup is transmitted to the cloud using the same procedure. The HVAC setup receive the
data from the cloud and the fan speed is controlled using the voltage regulator

5.3.3 Machine learning module

Machine learning (ML) is the study of computer algorithms that modify automatically
done with cognitive content i.e. experience. It is seen as a part of artificial intelligence.
Machine learning algorithms build a mathematical model supported on sample data,
better-known as "training data", so as to form articulation, prediction or decisions
without being explicitly programmed to try to to so. Machine learningg has a wide
variety of algorithms, they are utilized in a good sort of applications, like email
filtering and computer vision, where it's difficult or infeasible to develop
conventional algorithm to perform thee needed tasks.

.Machine learning is closely associated with computational statistics, which focuses


on making predictions using computers. The study of mathematical optimization
delivers methods, theory and application domains to the sector of machine learning.
Data mining is a related field of study, focused on explorative data analytic thinking
through unsupervised learning . In its application across business concern problems,
machine learning is also referred to as predictive analytics.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 34


Digital Twin for Water Domain

The libraries used are:

• Sci-kit learn (sklearn learn)


• Matplotlib
• Numpy
• pandas

5.3.3.1 Scikit-learn

Scikit-learn (formerly scikits.learn and better-known as sklearn) is a free software machine


learning library for the python programming language.

It contains various characteristics algorithms like regression, classification and clustering


algorithms. Including gradient boosting, DBSCAN, support vector machines, k-means and
random forests and is designed to interoperate with the python numerical, scientific-
domain and visualization libraries NumPy and SciPy.

5.3.3.2 Matplotlib

Matplotlib is a visualization library for plotting data in Python programming language and
its quantitative mathematics extension Numpy. It stipulate an object oriented API for
embedding plots into applications using general-purpose GUI toolkit like Tkinter,
wxPython, Qt or GTK. There is also a proceeding "pylab" convergence based on a state
machine (like OpenGL), organized to intimately correspond that of MATLAB, though its
use is demoralized. SciPy makes use of Matplotlib. Pyplot is a Matplotlib module which
provides a MATLAB-like user interface. Matplotlib is designed to be as usable as MATLAB,
with the quality to use Python, and the benefit of being free and open-source.

5.3.3.3 Numpy

NumPy is data-manipulation library for Python .It is mainly used in data-analysis for
woking with data of higher dimension like converting data of image pixels and
converting them into a single 1-D array of easy manipulation .Adding operation for
giant, multi-dimensional arrays and matrices, along side an outsized collection of
high-level mathematical functions to work on these arrays.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 35


Digital Twin for Water Domain

5.3.3.4 Pandas

A panda is a computer data analysis library written for the Python programming
language for data handling, manipulation and analysis. In peculiar, it offers data structures
and trading operations for modifying numerical tables and time series.

Sklearn consists of many pre-built models or formulas. We are using the multi-linear
regression to find the pattern against RPM (i.e. the speed of the fan).

Fig 5.8 Plot of RPM vs condenser temperature

From the above graph we can derive a conclusion that the temperature of the condenser
outlet decrease in increase in RPM

For a particular environment temperature, we build a multi-linear model to determine


optimal rate of operation. The optimal RPM is the applied to HVAC using Firmata protocol.

Fig 5.9 Firmata protocol

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 36


Digital Twin for Water Domain

CHAPTER - 06

RESULT

Finally, we are able to improve the performance HVAC system, by monitoring the pattern
of performance for various environments and by making the system run at optimal rate.

This can be analyzed in the Adafruit Dashboard.

From the above Dashboard we are able to analyze that the performance of the system
was improved by 0.5 by making the system run at optimal rate.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 37


Digital Twin for Water Domain

CHAPTER - 07

CONCLUSION

HAVC system is major field were electrical optimization is required. Usage of digital twin
on real-time data generating machine will help us to monitor the HVAC on regular basis,
just as the machine is with us. Security can be a major flaw as the original machine is
connected to the internet. Firewalls can be built to restrict the data transmission and
allow access only from reliable connection like from the system admins etc. Digital twin a
prospering field of maintenance has recently boomed with the improved and enhanced
IOT. Leading to the integration of industrial equipments with IOT and transforming into
IIOT. Nowadays it’s all about collecting data and analysing it, to find in-depth pattern of
the data and using it profit the organization.

The proposed can be improved with more features like firewalls, admin authentication
before accessing the machine. The development of this project also involves personal
benefits. Personal benefits could be learning new languages and technologies out of
academics and having deeper understanding of it to implement system effectively. A
personal benefit also includes experience of working in team towards the real time work
or project. The project was smoothly carried by us out without any issues.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 38


Digital Twin for Water Domain

CHAPTER - 08

FUTURE SCOPE

With the bloom of IOT and increased computation power, we can connect any device and
monitor the data-flow and improve the efficiency by analysing the data-pattern.

The concept of digital twin can be applied very efficiently on all devices. The HVAC system
is a major field and the process of increasing the efficiency. Smart Building is a great
example for implementing digital twin. Smart buildings in reality are common use case for
some IoT with Digital twin implementation. Building management systems have been
roughly for a while, mostly for energy administration, security, etc. IoT along with cheap
affordable sensors, united with data analytics have modify many use cases, including
some mentioned above like room/office occupancy, which can come in handy in case of
exigency and knowing where people are, and also for automated control of illumination

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 39


Digital Twin for Water Domain

CHAPTER - 09

APPENDIX

9.1 Python code for User Interface

import sys

from PyQt5.QtGui import *

from PyQt5.QtCore import *

from PyQt5.QtWidgets import *

from Adafruit_IO import MQTTClient

from threading import Thread

import threading

import pyqtgraph as pg

ADAFRUIT_IO_KEY = 'aio_ZHBH89tjZ2WUm1651EM598A6CVOg'

ADAFRUIT_IO_USERNAME = 'RaghavendraRaghu'

FEED_ID = ["condenser-inlet","condenser-outlet","evaporator-inlet","evaporator-
outlet","external-temp","external-humidity","fan-speed","cop","fan-speed-ml","cop-
ml"]

codindata = [10,0,0,0,10,0,0,0,0,10]

codoutdata = [10,0,0,0,0,10,0,0,0,10]

timers = []

class CenterTab(QWidget):

def __init__(self, parent):

super(QWidget, self).__init__(parent)

self.layout = QVBoxLayout(self)

self.layout.setGeometry(QRect(0,0,200,300))

self.Centertab = QTabWidget()

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 40


Digital Twin for Water Domain

self.Main = QWidget()

self.Side = QWidget()

self.codinGraph = pg.PlotWidget(self.Main)

self.codinGraph.setYRange(1,10)

self.codinGraph.setGeometry(10,10,200,200)

self.codoutGraph = pg.PlotWidget(self.Main)

self.codoutGraph.setYRange(1,10)

self.codoutGraph.setGeometry(250,10,200,200)

self.codoutGraph.setBackground('w')

self.codinGraph.setBackground('w')

self.codin = self.codinGraph.plot()

self.codout = self.codoutGraph.plot()

self.Main.setObjectName("Main")

self.Centertab.addTab(self.Main, "MAIN")

self.Main.layout = QVBoxLayout(self)

self.Main.setLayout(self.Main.layout)

self.label_5 = QLabel(self.Side)

self.label_5.setGeometry( QRect(20, 60, 101, 16))

self.label_5.setText( "Condenser-INPUT")

self.label_6 = QLabel(self.Side)

self.label_6.setGeometry( QRect(230, 60, 101, 16))

self.label_6.setTextFormat( Qt.PlainText)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 41


Digital Twin for Water Domain

self.label_6.setScaledContents(False)

self.label_6.setWordWrap(True)

self.label_6.setText( "Condenser-OUTPUT")

self.label_7 = QLabel(self.Side)

self.label_7.setGeometry( QRect(20, 140, 91, 16))

self.label_7.setText( "Evaporator-INPUT")

self.label_8 = QLabel(self.Side)

self.label_8.setGeometry( QRect(230, 140, 101, 16))

self.label_8.setText( "Evaporator-OUTPUT")

self.Cin_2 = QLabel(self.Side)

self.Cin_2.setGeometry( QRect(30, 90, 71, 16))

self.Cin_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Cin_2.setLineWidth(2)

self.Cin_2.setText("38.25")

self.Cin_2.setObjectName("condenser-inlet")

self.Cout_2 = QLabel(self.Side)

self.Cout_2.setGeometry( QRect(240, 90, 71, 16))

self.Cout_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Cout_2.setLineWidth(2)

self.Cout_2.setText("36.75")

self.Cout_2.setObjectName("condenser-outlet")

self.Ein_2 = QLabel(self.Side)

self.Ein_2.setGeometry( QRect(30, 170, 71, 16))

self.Ein_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Ein_2.setLineWidth(2)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 42


Digital Twin for Water Domain

self.Ein_2.setText("26.25")

self.Ein_2.setObjectName("evaporator-inlet")

self.Eout_2 = QLabel(self.Side)

self.Eout_2.setGeometry( QRect(240, 170, 71, 16))

self.Eout_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Eout_2.setLineWidth(2)

self.Eout_2.setText("24.875")

self.Eout_2.setObjectName("evaporator-outlet")

self.label_9 = QLabel(self.Side)

self.label_9.setGeometry( QRect(30, 220, 101, 20))

self.label_9.setObjectName("label_9")

self.label_9.setText( "Temperature-INPUT")

self.label_13 = QLabel(self.Side)

self.label_13.setGeometry( QRect(180, 290, 21, 16))

self.label_13.setObjectName("label_13")

self.label_13.setText( "RPM")

self.label_12 = QLabel(self.Side)

self.label_12.setGeometry( QRect(230, 220, 101, 20))

self.label_12.setObjectName("label_12")

self.label_12.setText( "Temerature-OUTPUT")

self.Tin_2 = QLabel(self.Side)

self.Tin_2.setGeometry( QRect(40, 250, 71, 16))

self.Tin_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Tin_2.setLineWidth(2)

self.Tin_2.setText("25.0")

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 43


Digital Twin for Water Domain

self.Tin_2.setObjectName("external-temp")

self.Tout_2 = QLabel(self.Side)

self.Tout_2.setGeometry( QRect(240, 250, 71, 16))

self.Tout_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Tout_2.setLineWidth(2)

self.Tout_2.setText("")

self.Tout_2.setObjectName("Tout_2")

self.RPM_2 = QLabel(self.Side)

self.RPM_2.setGeometry( QRect(150, 320, 71, 16))

self.RPM_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.RPM_2.setLineWidth(2)

self.RPM_2.setText("545 ")

self.RPM_2.setObjectName("fan-speed")

self.pushButton = QPushButton(self.Side)

self.pushButton.setGeometry( QRect(40, 440, 75, 23))

self.pushButton.setObjectName("pushButton")

self.pushButton.setText( "Stabilize")

self.pushButton_2 = QPushButton(self.Side)

self.pushButton_2.setGeometry( QRect(240, 440, 75, 23))

self.pushButton_2.setObjectName("pushButton_2")

self.pushButton_2.setText( "Predict")

self.label_14 = QLabel(self.Side)

self.label_14.setGeometry( QRect(180, 360, 21, 16))

self.label_14.setObjectName("label_14")

self.label_14.setText( "COP")

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 44


Digital Twin for Water Domain

self.COP_2 = QLabel(self.Side)

self.COP_2.setGeometry( QRect(150, 390, 71, 16))

self.COP_2.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.COP_2.setLineWidth(2)

self.COP_2.setText("0.747")

self.COP_2.setObjectName("cop")

self.Centertab.addTab(self.Side, "Side")

self.layout.addWidget(self.Centertab)

self.setLayout(self.layout)

self.updateplot()

self.updateplotThread = Thread(target=self.thread_func)

self.updateplotThread.start()

print("out")

def func(self,name,val):

print("setting ",name)

temp = (self.Side.findChild(QLabel,name))

temp.setText(str(val))

if name == "condenser-inlet":

codindata.pop(0)

codindata.append(val)

print(codindata)

if name == "condenser-outlet":

codoutdata.pop(0)

codoutdata.append(val)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 45


Digital Twin for Water Domain

print(codoutdata)

def thread_func(self):

print("Thread works")

timer = QTimer()

timer.timeout.connect(self.updateplot)

timer.start(1000)

timers.append(timer)

def updateplot(self):

print(threading.active_count())

print("updating")

self.codin.setData(codindata)

self.codout.setData(codoutdata)

class LeftTab(QWidget):

def __init__(self, parent):

super(QWidget, self).__init__(parent)

self.LeftFrame = QFrame(self)

self.LeftFrame.setGeometry(QRect(19, 29, 201, 351))

self.LeftFrame.setFrameShape(QFrame.StyledPanel | QFrame.Raised)

self.LeftFrame.setObjectName("LeftFrame")

self.label = QLabel(self.LeftFrame)

self.label.setGeometry(QRect(20, 40, 101, 16))

self.label.setObjectName("label")

self.label.setText("Condenser-INPUT")

self.label_2 = QLabel(self.LeftFrame)

self.label_2.setGeometry(QRect(20, 90, 101, 16))

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 46


Digital Twin for Water Domain

self.label_2.setTextFormat(Qt.PlainText)

self.label_2.setScaledContents(False)

self.label_2.setWordWrap(True)

self.label_2.setObjectName("label_2")

self.label_2.setText("Condenser-OUTPUT")

self.label_3 = QLabel(self.LeftFrame)

self.label_3.setGeometry(QRect(20, 150, 91, 16))

self.label_3.setObjectName("label_3")

self.label_3.setText("Evaporator-INPUT")

self.label_4 = QLabel(self.LeftFrame)

self.label_4.setGeometry(QRect(20, 210, 101, 16))

self.label_4.setObjectName("label_4")

self.label_4.setText("Evaporator-OUTPUT")

self.Cin = QLabel(self.LeftFrame)

self.Cin.setGeometry(QRect(70, 70, 71, 16))

self.Cin.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Cin.setLineWidth(2)

self.Cin.setText("40")

self.Cin.setObjectName("condenser-inlet")

self.Cout = QLabel(self.LeftFrame)

self.Cout.setGeometry(QRect(70, 120, 71, 16))

self.Cout.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Cout.setLineWidth(2)

self.Cout.setText("38")

self.Cout.setObjectName("condenser-outlet")

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 47


Digital Twin for Water Domain

self.Ein = QLabel(self.LeftFrame)

self.Ein.setGeometry(QRect(70, 180, 71, 16))

self.Ein.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Ein.setLineWidth(2)

self.Ein.setText("36")

self.Ein.setObjectName("evaporator-inlet")

self.Eout = QLabel(self.LeftFrame)

self.Eout.setGeometry(QRect(70, 240, 71, 16))

self.Eout.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Eout.setLineWidth(2)

self.Eout.setText("38")

self.Eout.setObjectName("evaporator-outlet")

self.Current_readingTab = QLabel(self.LeftFrame)

self.Current_readingTab.setGeometry(QRect(10, 10, 111, 21))

self.Current_readingTab.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.Current_readingTab.setLineWidth(3)

self.Current_readingTab.setObjectName("Current_readingTab")

self.Current_readingTab.setText("CURRENT READINGS")

self.frame = QFrame(self)

self.frame.setGeometry(QRect(19, 379, 201, 201))

self.frame.setFrameShape(QFrame.StyledPanel | QFrame.Raised)

self.frame.setObjectName("frame")

self.label_10 = QLabel(self.frame)

self.label_10.setGeometry(QRect(20, 50, 81, 16))

self.label_10.setObjectName("label_10")

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 48


Digital Twin for Water Domain

self.PowUsage = QLabel(self.frame)

self.PowUsage.setGeometry(QRect(50, 90, 81, 21))

self.PowUsage.setFrameShape(QFrame.Panel | QFrame.Sunken)

self.PowUsage.setLineWidth(2)

self.PowUsage.setText("")

self.PowUsage.setObjectName("PowUsage")

self.label_10.setText("POWER USAGE")

def func(self,name,val):

temp = (self.LeftFrame.findChild(QLabel, name))

temp.setText(str(val))

class App(QWidget):

def __init__(self):

super(App, self).__init__()

self.initUI()

def initUI(self):

hbox = QHBoxLayout(self)

self.centralwidget = QWidget()

right = QFrame()

right.setFrameShape(QFrame.StyledPanel)

right.setStyleSheet("background-color:red;")

self.centerTabs = CenterTab(self)

self.leftTab = LeftTab(self)

splitRight = QSplitter(Qt.Horizontal)

splitRight.addWidget(self.leftTab)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 49


Digital Twin for Water Domain

splitRight.addWidget(self.centerTabs)

splitRight.addWidget(right)

splitRight.setSizes([50, 20, 30])

hbox.addWidget(splitRight)

self.setLayout(hbox)

QApplication.setStyle(QStyleFactory.create('Cleanlooks'))

self.setGeometry(50, 50, 1024, 680)

self.setWindowTitle('APP')

self.show()

def do(self,name,val):

#print("starting to do something")

self.leftTab.func(name,val)

self.centerTabs.func(name,val)

class mainApp:

def __init__(self):

proc = []

clProc = Thread(target=self.init_conn)

proc.append(clProc)

clProc.start()

uiProc = Thread(target=self.init_UI)

proc.append(uiProc)

uiProc.start()

for pro in proc:

pro.join()

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 50


Digital Twin for Water Domain

def init_conn(self):

cl = self.init()

cl.connect()

cl.loop_blocking()

def init_UI(self):

app = QApplication(sys.argv)

self.ex = App()

sys.exit(app.exec_())

def connected(self,client):

for _ in FEED_ID:

print('Connected to Adafruit IO! Listening for {0} changes...'.format(_))

client.subscribe(_)

def subscribe(self,client, userdata, mid, granted_qos,i):

# This method is called when the client subscribes to a new feed.

print('Subscribed to {0} with QoS {1}'.format(i, granted_qos[0]))

def disconnected(self,client):

# Disconnected function will be called when the client disconnects.

print('Disconnected from Adafruit IO!')

sys.exit(1)

def message(self,client, feed_id, payload):

print('Feed {0} received new value: {1}'.format(feed_id, payload))

print(payload)

self.ex.do(feed_id,payload)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 51


Digital Twin for Water Domain

def init(self):

client = MQTTClient(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

# Setup the callback functions defined above.

client.on_connect = self.connected

client.on_disconnect = self.disconnected

client.on_message = self.message

client.on_subscribe = self.subscribe

return client

if __name__ == '__main__':

App = mainApp()

from Adafruit_IO import Client, Feed,RequestError,Data

import random

feed = ["condenser-inlet", "condenser-outlet", "evaporator-inlet", "evaporator-outlet”,”


evaporator-outlet”]

def init_cloud ():

global aio

ADAFRUIT IO USERNAME ‘**********’

ADAFRUIT TO_KEY=’**********’

aio = Client (ADAFRUIT_TO_USERNAME, ADAFRUIT TO_KEY)

return aio

def send data (aio):

for i in range (8):

feed = alo.feeds (feed[1])

t= float (random. randrange (1, 100)/random. randrange (1, 100))

aio.send_data (_feed.key, t)

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 52


Digital Twin for Water Domain

print (feed[1]+” sent")

aio - init_cloud ()

send_data (aio)

9.2 Python code for RaspberryPi

os.system('modprobe w1-gpio')

os.system('modprobe w1-therm')

DHT_SENSOR = Adafruit_DHT.DHT11

DHT_PIN = 27

feed = ["condenser-inlet","condenser-outlet","evaporator-inlet","evaporator-
outlet","external-temp","external-humidity","fan-speed","cop","fan-speed-ml","cop-
ml"]

base_dir = '/sys/bus/w1/devices/'

device_folder1 = base_dir + '28-01144cef90aa'

device_file1 = device_folder1 + '/w1_slave'

device_folder2 = base_dir + '28-01144cf51caa'

device_file2 = device_folder2 + '/w1_slave'

device_folder3 = base_dir + '28-01144ceb4faa'

device_file3 = device_folder3 + '/w1_slave'

device_folder4 = base_dir + '28-01144cd61faa'

device_file4 = device_folder4 + '/w1_slave'

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 53


Digital Twin for Water Domain

Pin = 11

rev = 100

count = 0

prev_out = 0

s_time,e_time = 0,0

fins = 2

def init_cloud():

global aio

ADAFRUIT_IO_USERNAME='RaghavendraRaghu'

ADAFRUIT_IO_KEY='aio_ZHBH89tjZ2WUm1651EM598A6CVOg'

aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

return aio

def send_data(aio,t):

print(t)

for i in range(8):

_feed = aio.feeds(feed[i])

aio.send_data(_feed.key,t[i])

print(feed[i]+" sent")

def read_temp_raw1():

f = open(device_file1, 'r')

lines = f.readlines()

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 54


Digital Twin for Water Domain

f.close()

return lines

def read_temp_raw2():

f = open(device_file2, 'r')

lines = f.readlines()

f.close()

return lines

def read_temp_raw3():

f = open(device_file3, 'r')

lines = f.readlines()

f.close()

return lines

def read_temp_raw4():

f = open(device_file4, 'r')

lines = f.readlines()

f.close()

return lines

def read_temp():

lines1 = read_temp_raw1()

lines2 = read_temp_raw2()

lines3 = read_temp_raw3()

lines4 = read_temp_raw4()

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 55


Digital Twin for Water Domain

while lines1[0].strip()[-3:] != 'YES' and lines2[0].strip()[-3:] != 'YES' and lines3[0].strip()[-


3:] != 'YES' and lines4[0].strip()[-3:] != 'YES':

time.sleep(0.2)

lines1 = read_temp_raw1()

lines2 = read_temp_raw2()

lines3 = read_temp_raw3()

lines4 = read_temp_raw4()

equals_pos1 = lines1[1].find('t=')

equals_pos2 = lines2[1].find('t=')

equals_pos3 = lines3[1].find('t=')

equals_pos4 = lines4[1].find('t=')

if equals_pos1 != -1 and equals_pos2 != -1 and equals_pos3 != -1 and equals_pos4 != -1:

temp_string1 = lines1[1][equals_pos1+2:]

temp_string2 = lines2[1][equals_pos2+2:]

temp_string3 = lines3[1][equals_pos3+2:]

temp_string4 = lines4[1][equals_pos4+2:]

temp_c1 = float(temp_string1) / 1000.0

temp_c2 = float(temp_string2) / 1000.0

temp_c3 = float(temp_string3) / 1000.0

temp_c4 = float(temp_string4) / 1000.0

return temp_c1,temp_c2,temp_c3,temp_c4

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 56


Digital Twin for Water Domain

def temp():

a,b,c,d=read_temp()

print('Internal Temperature')

print(a,b,c,d)

humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)

if humidity is not None and temperature is not None:

print("External Temp={0:0.1f}C Humidity={1:0.1f}%".format(temperature, humidity))

else:

humidity, temperature = -1,-1

re = 0.037*4.187*(d-a)

tot = [a,b,c,d,temperature,humidity]

return tot,re

def cal_time():

_time = time.time()

return _time

def setup():

GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location

GPIO.setup(Pin, GPIO.IN) # Set LedPin's mode is output

def cal_cop(rp,re):

times = [93.21, 102.28, 103.10, 104.17, 105.50, 106.83]

#r = [600,500,400,300,200,100]

tempr = int(rp / 100) - 1

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 57


Digital Twin for Water Domain

pi = (10*0.7*3600)/(1500*times[tempr])

co = pi/re

return co

def loop():

global count,prev_out,data

#aio = init_cloud()

#data = open("data1.txt",'a')

#data.write("starting ....")

while True:

data = open("data.csv",'a')

out = GPIO.input(Pin)

if out:

if out == prev_out:

continue

#print("hi")

if count == 0:

count = 1

s_time = cal_time()

else:

count += 1

print(count)

prev_out = out

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 58


Digital Twin for Water Domain

if count==rev*fins:

e_time = cal_time()

print((e_time-s_time))

rpm = int(rev/((e_time-s_time)/60))

print("rpm = ",rpm)

t = []

t,re = temp()

t.append(rpm)

c = cal_cop(rpm,re)

t.append(c)

print(t)

print("writing")

for i in t:

data.write(str(i)+" , ")

data.write("\n")

data.close()

#send_data(aio,t)

count = 0

def destroy():

data.close()

GPIO.cleanup() # Release resource

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 59


Digital Twin for Water Domain

if __name__ == '__main__': # Program start from here

setup()

try:

loop()

except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will
be executed.

destroy()

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 60


Digital Twin for Water Domain

CHAPTER - 10

REFERENCES

1. Ajay N Bhagwat, S.N.Teli, Pradeep Gunaki, Dr.V.S.Majali, “Review Paper On Energy


Efficiency Technologies For Heating, Ventilation And Air Conditioning (HVAC)”,
International Journal of Scientific & Engineering Research, ISSN(Print): 2229-5518,
,Volume 6, Issue 12, December-2015.

2. Anica Iliea, Rodica Dumitrescua, Alina Giripa, Valentin Cublesana, “Study on technical
and economical solutions for improving ai conditioning efficiency in building sector ”,
Sustainable Solutions for Energy and Environment, EENVIRO 201,October-2016.

3. Anil Kumar, Vijay Kumar, Balkar Singh, “Methods Of Improving Energy Efficiency For
Domestic Air Conditioning Systems”, International Journal Of Engineering Sciences &
Research Technology, ISSN(Print): 2277-9655, August-2017.

4. MuharremImal, “Design and Implementation of Energy Efficiency in HVAC Systems


Based on Robust PID Control for Industrial Applications”, Hindawi Publishing Corporation,
Volume 2015, Article ID 954159, March-2015.

5. L Chretien, R Becerra, N P Salts, E A Groll, “System solution to improve energy efficiency


of HVAC systems”, International Conference on Compressors and their Systems, IOP Conf.
Series: Materials Science and Engineering 232 (2017) 012067.

6. Siyu Zhou, Jing zhao, “Comparative Analysis of Energy Efficiency in Airconditioning


System with GSHP, Electricity-driven Refrigerating Unit and Direct-fired Li-Br Absorption
Refrigerating and Heating Unit”, 2012 International Conference on Future Energy,
Environment, and Materials, January-2012.

7. Danny S. Parker, John Sherwin, Bart Hibbs, “High Efficiency Air Conditioner Condenser
Fan”, United States Paten, Patent No.: US 7,568,885 B2, August-2019.

Dept of Mechanical Engg., NHCE, Bengaluru 2019-20 Page 61

You might also like