Files
brewpi/components/plant/pot.py
T
jensandClaude Sonnet 4.6 fef0f1e2a3 Consolidate States/DEFAULT_THRESHOLDS into temp_controller_base.py
tc_constants.py only held States and DEFAULT_THRESHOLDS, both used
exclusively by temp_controller_base.py and its subclasses; fold them
into temp_controller_base.py directly and drop the now-empty module.
Also drop heat_diffusion.py, unused since pot.py switched to the
delay-line model, and the matching dead import in pot.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-19 16:57:35 +02:00

76 lines
1.6 KiB
Python

from components.aplant import APlant
from components.plant import delay
class Pot(APlant):
def __init__(self, dt, params, theta_amb=20):
APlant.__init__(self)
self.dt = dt
self.e = 0
self.x = 0
# Plant power gain (efficiency)
self.gain = params['gain']
# Plant specific thermal capacity [W*s/(kg*K)]
self.C = params['C']
# Plant mass [kg]
self.M = params['M']
# Plant energy loss coefficient [W/(kg*K)]
# Negative input power as a function of plant mass and temperature difference T_plant and T_ambient
# P_loss = L * Mass * (T_plant - T_ambient)
self.L = params['L']
# Energy transport propagation delay
self.Td = params['Td']
# Plant temperature [°C]
self.temp = params['theta']
# Ambient temperature [°C]
self.theta_amb = theta_amb
# Set power [W]
self.power_set = 0
# Plant delay [s]
self.delay = delay.Delay(dt, self.Td, 0)
self.p_in = 0
self.p_pot = 0
def initial(self, temp):
self.temp = temp
def activate(self, enable):
pass
def process(self):
self.p_in = self.gain * self.power_set
self.delay.put(self.p_in)
p_loss = self.L * self.M * (self.temp - self.theta_amb)
self.p_pot = self.delay.get() - p_loss
print(f"p_loss: {p_loss}")
print(f"theta_amb: {self.theta_amb}")
print(f"temp: {self.temp}")
self.temp = min(100, self.temp + self.p_pot/(self.M * self.C) * self.dt)
def is_activated(self):
return True
def set_power(self, power):
self.power_set = power
def get_power(self):
return round(self.power_set, 1)
def get_temperature(self):
return self.temp
def get_p_pot(self):
return self.p_pot