DEPARTMENT OF MECHANICAL ENGINERING
Case Study
Report
on
SIMULATION OF NEWTON’S LAW OF
COOLING USING PYTHON PROGRAMMING
Prepared By:
GANGAVARAPU RISHI PRAKASH (A-420)
GUPTA SATYAM FULCHAND (A-426)
GURAV PRASAD SURENDRA (A-427)
JAISWAR VIKAS VIJAY (A-434)
1
DEPARTMENT OF MECHANICAL ENGINERING
CONTENTS
Sr. No. Contents Page No.
1. INTRODUCTION 3
2. OBJECTIVE 3
3. THEORETICAL BACKGROUND 3
4. PYTHON SIMULATION 4
5. RESULT AND ANALYSIS 4-5
6. CONCLUSION 5
7. FUTURE WORK 6
8. REFERENCE 6-7
2
DEPARTMENT OF MECHANICAL ENGINERING
A case study on – Simulation of Newton’s Law of Cooling Using Python
Programming
1. Introduction
Newton's Law of Cooling states that the rate of heat loss of a body is directly
proportional to the difference in the temperatures between the body and its
surroundings. This law is often used to model the temperature change of an object
over time as it cools or heats up in a different temperature environment. This study
aims to simulate Newton's Law of Cooling using Python and analyse the
temperature change of an object over time.
2. Objective
To model and analyse the temperature change of an object over time according
to Newton's Law of Cooling using Python. This analysis will demonstrate how the
object's temperature approaches the ambient temperature.
3. Theoretical Background
Newton's Law of Cooling Equation: dT/dt = -k(T - Ta) Where: o dT/dt is the
rate of change of the object's temperature with respect to time.
• T is the temperature of the object at time t.
• Ta is the ambient temperature (temperature of the surroundings).
• k is the cooling constant, which depends on the properties of the object and its
surroundings (e.g., surface area, heat transfer coefficient).
• Key Parameters:
⎯ Initial Temperature of the Object (T0)
⎯ Ambient Temperature (Ta)
⎯ Cooling Constant (k)
⎯ Time (t)
3
DEPARTMENT OF MECHANICAL ENGINERING
4. Python Simulation
import numpy as np
import [Link] as plt
#Given constants
Temperature1 = 300 # Ambient temperature (K)
k = 0.02 # Cooling constant
Temperature0 = 500 # Initial temperature (K)
dt = 1 # Time step (seconds)
time_end = 500 #Total time duration (seconds)
# Euler's method for solving dT/dt = -k(T - T1)
Temperature = Temperature0 # Start at initial temperature
for _ in range(time_end):
Temperature = Temperature - k * (Temperature - Temperature1) * dt
# Print final temperature
print(f"Final Temperature after {time_end} seconds: {Temperature:.2f} K")
5. Result and Analysis
The simulation shows how the temperature of the object decreases
exponentially over time, approaching the ambient temperature.
- The rate of cooling is faster when the temperature difference between the
object and its surroundings is larger.
- The cooling constant k determines how quickly the object cools. A larger k
value indicates faster cooling.
- After the simulated time period, the object's temperature has significantly
decreased and is much closer to the ambient temperature.
4
DEPARTMENT OF MECHANICAL ENGINERING
6. Conclusion
This Python simulation effectively models Newton's Law of Cooling,
demonstrating the temperature change of an object as it exchanges heat with its
environment. The analysis highlights the dependence of the cooling rate on the
temperature difference and the cooling constant. This simulation provides a visual
and numerical understanding of this fundamental heat transfer principle.
5
DEPARTMENT OF MECHANICAL ENGINERING
7. Future Work
-Investigate the effect of varying the cooling constant k and the ambient
temperature Ta on the cooling process.
-Compare the simulated results with experimental data for a real-world
scenario.
-Extend the model to include factors like heat generation within the object or
variations in the ambient temperature over time.
8. Reference
• Newton’s Law of Cooling – General Overview:
⎯ Newton, I. (1701). "Philosophiæ Naturalis Principia Mathematica". The
foundational text where the principle of cooling was introduced.
⎯ Wikipedia article: Newton's Law of Cooling
o This provides a concise explanation of the concept and its applications.
• Mathematical Background:
⎯ Differential Equations for Engineers by William E. Boyce and Richard C.
DiPrima.
o This textbook explains the mathematical formulation and solution
techniques for ordinary differential equations, including those related to
cooling processes.
⎯ Applied Mathematics: A Very Short Introduction by Alain Bensoussan and J.
A. (Tony) S. Bennett.
• Online Learning Resources:
⎯ Khan Academy has excellent resources on differential equations, including
how to solve first-order linear differential equations, which are the type
Newton's Law of Cooling falls under. Differential Equations - Khan Academy
⎯ MIT OpenCourseWare (OCW) - Differential Equations, 18.03. This course
includes video lectures and problem sets that help understand the
applications of differential equations, including cooling models.
o Link: MIT OCW 18.03
6
DEPARTMENT OF MECHANICAL ENGINERING
• Python for Data Analysis by Wes McKinney:
⎯ This book provides an introduction to using Python for scientific computing
and data analysis. It includes sections on using numpy, matplotlib, and
scipy—tools used in solving and visualizing differential equations like
Newton’s Law of Cooling.
• Numerical Methods in Engineering with Python 3 by Jaan Kiusalaas:
⎯ This book focuses on using Python for solving engineering problems,
including those involving differential equations. It uses libraries like scipy
and provides examples for implementing numerical solutions.
• Matplotlib Documentation:
⎯ To understand how to visualize data in Python, you can refer to the official
documentation for matplotlib, which is used to create the plots in the case
study.
o Link: Matplotlib Documentation
• Python Data Science Handbook by Jake VanderPlas:
⎯ This handbook covers a variety of Python-based methods and libraries for
scientific computing, including differential equation solvers and data
visualization.
o Available on: Python Data Science Handbook