import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
ratio_manual=16
max_t_in_hour = 4
k = 0.2
l=0.8e-3
U = (k/l)/ratio_manual
A = 0.075
T_hot = 36
m = 1.25
c = 4186
T0 = 0
time_constant = m * c / (U * A)
t = np.linspace(0, max_t_in_hour*3600, 3000)
T_cool = T_hot - (T_hot - T0) * np.exp(-t / time_constant)
A2 = A/2
time_constant2 = m * c / (U * A2)
T_cool_2 = T_hot - (T_hot - T0) * np.exp(-t / time_constant2)
for index, T in enumerate(T_cool):
if T<25 and T_cool[index+1]>=25:
t1 = t[index]
for index, T in enumerate(T_cool_2):
if T<25 and T_cool_2[index+1]>=25:
t2 = t[index]
plt.figure(figsize=(10, 6))
plt.plot(t/3600, T_cool, 'g-', linewidth=2, label='水温 (°C) - 当前配置')
plt.plot(t/3600, T_cool_2, 'b-', linewidth=2, label='水温 (°C) - 瓶身半侧隔热')
plt.axhline(y=T_hot, color='r', linestyle='-', label=f'恒温侧温度 ({T_hot}°C)')
plt.axhline(y=25, color='y', linestyle='--', label=f'达到({25}°C)耗时:[{t1/3600:.1f}, {t2/3600:.1f}]小时')
plt.title('1.25升冰水-贴身 温升曲线 (初始温度 0°C)', fontsize=14)
plt.xlabel('时间 (小时)', fontsize=12)
plt.grid(True, linestyle='--', alpha=0.7)
plt.legend()
plt.show()
print(f"系统时间常数: {time_constant/3600:.2f} 小时")
print(f"{2}小时后水温: {T_cool[-1]:.2f} °C")