这里的背景是,我试图加热和冷却一个物体,我试图得到循环温度控制系统。
假设房间温度=25摄氏度(这是物体开始时的温度)。我想要构建一条在图像上看到的曲线。当物体被加热到90度后,当它达到90度时应该冷却,当物体冷却到55度时,它应该加热到90摄氏度。
图片来源:Cycling curve graph going from 50 to 90
这是我的代码:
if (温度<= 55)
热();
else if ( temperature >=90)
cool();
当温度值为56到89时,会发生什么情况?
我的解决方案是在开头放一个加热函数,比如heat (),然后是if else语句。
发布于 2017-11-23 06:13:51
你真的应该在编码方面做得更好,但我觉得很无聊
这是一个具有线性“加热/冷却”模型和bang-bang控制器的动态系统仿真。
r_t = 1 # thermal resistance
t_cold = 0.8 # cooling temp
t_hot = 2.2 # heating temp
t_lo, t_hi = 1, 2 # controller thresholds
c_t = 100 # heat capacity
t_obj = [0] # really cold start temp
h = []
for s in range(1000):
if t_obj[-1] < t_lo: # bang-bang logic
heat = 1
elif t_obj[-1] > t_hi:
heat = 0
# equation integrating the the heat/cooling input to t_obj
t_obj += [t_obj[-1] + ((heat * t_hot + (1 - heat) * t_cold) - t_obj[-1])/r_t/c_t]
h.append(heat)
plt.plot(h) # debug plot of `heat` state
plt.plot(t_obj)

https://stackoverflow.com/questions/47443491
复制相似问题