Python Forum
Calculate time taken to cool down a pool in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate time taken to cool down a pool in python
#1
0


I'm taking a programming class in python so i'm a beginner. We got an assignment where we were supposed to calculate and plot the time taken for a pool to reach 5 degrees celcius. I've tested the time taken with 3 smaller containers (0.3L, 0.5L, and 1.2L) and plotted them in a python program to find a k-value. Where the k-value is the projected time taken to cool them down. Then i've used regression in a program called "GeoGebra" to find a function for k given the volume V. Now im stuck.

The pool i'm gonna use is 1.250.000L, and i don't know how to get that into code and get it plotted, anyone got any tips?

This is the code that i used for the plotting of the three smaller containers;

import numpy as np
from matplotlib import pyplot as plt
 
filename = "temperatur.txt"
 
data = np.loadtxt(filename, float, skiprows = 1)
measurement_start = 0
time = data[measurement_start:, 0]
time -= time[0]
 
temperature = data[measurement_start:, 1]
 
plt.plot(time, temperature, 'x', label = "MÃ¥lingene")
plt.xlabel("Time(s)")
plt.ylabel("Temperaturen(C)")
 
k = 0.00022
temp_outside = 5
T_0 = temperature[0]
 
space = 1       # space between measurements
t_start = 0
t_end = 45 * 60
 
 
N = int((t_end - t_start) / space + 1)
 
t = np.linspace(t_start, t_end, N)
T = np.zeros(N)
T[0] = T_0
 
# Eulers method
 
for i in range(N-1):
    T[i+1] = T[i] + k * (temp_outside - T[i]) * space
print(f"Last valuei: {T[-1]}")
 
plt.plot(t, T, label = "Model")
plt.plot(t, (temp_outside +1) * np.ones(N), "--", label = "Temp outside + one degree")
plt.title(f"k = {k}")
 
plt.legend()
This is the outcome i want, just with the pool size

Thanks in advance!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calculate using Python HoustonM11 2 2,058 Aug-26-2019, 03:43 AM
Last Post: millpond
  Beginner Python Homework Question (Calculate Gross Pay) matchamochi7 4 5,672 Nov-02-2018, 01:06 PM
Last Post: buran
  Please explain me Pathos Pool() Antigr 1 3,699 Jun-27-2018, 06:25 PM
Last Post: Larz60+
  Help! For pool to While pool nikecorei5 4 4,323 Dec-06-2017, 11:04 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020