Files
jensandClaude Sonnet 4.6 296d3a333d Pot: require plant params and ambient temperature via setters, not the constructor
Pot.__init__ now only takes dt; set_plant_params() and set_ambient_temperature()
must be called before process(), which now raises RuntimeError if either is
missing instead of silently computing on whatever the constructor happened to
default to. set_ambient_temperature() only seeds the plant's starting
temperature the first time it's called, so changing ambient mid-run still
can't clobber an in-progress simulated temperature. Updates all callers
(server/brewpi.py, TempController(Smith)'s two internal models,
SudForecastEstimator, and the plant/pid/sud demo scripts) to call the setters
right after construction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DkkuG48uHFCGKe6dPSERFk
2026-06-22 18:15:08 +02:00

62 lines
1.2 KiB
Python

import numpy as np
from matplotlib.pyplot import plot, figure, subplot, grid, show, legend
from components.plant.pot import Pot
if __name__ == '__main__':
dt = 1.0
theta_amb = 20
power_on = 3500
steps_heat = 4000
steps_cool = 40000
pot_params = {
"theta" : 20,
"C" : 4190,
"M" : 20,
"L" : 0.4,
"Td" : 30,
"gain" : 1.0
}
pot = Pot(dt)
pot.set_plant_params(pot_params)
pot.set_ambient_temperature(theta_amb)
_t = np.empty(0)
_temp = np.empty(0)
_p_pot = np.empty(0)
_power = np.empty(0)
t = 0
pot.set_power(power_on)
for _ in range(steps_heat):
pot.process()
_t = np.append(_t, t)
_temp = np.append(_temp, pot.get_temperature())
_p_pot = np.append(_p_pot, pot.get_p_pot())
_power = np.append(_power, pot.get_power())
t += 1
pot.set_power(0)
for _ in range(steps_cool):
pot.process()
_t = np.append(_t, t)
_temp = np.append(_temp, pot.get_temperature())
_p_pot = np.append(_p_pot, pot.get_p_pot())
_power = np.append(_power, pot.get_power())
t += 1
figure(1)
subplot(2, 1, 1)
plot(_t, _temp, '-b', linewidth=1)
legend(["temp"])
grid(True)
subplot(2, 1, 2)
plot(_t, _power, '-g', _t, _p_pot, '-r', linewidth=1)
legend(["power", "p_pot"])
grid(True)
show()
print("End of program")