Files
brewpi/scripts/demos/plant/demo_pot.py
T
jensandClaude Sonnet 4.6 80da55da85 Make ambient temperature configurable and wire it everywhere it was hardcoded
brewpi.py passed a literal 20 as theta_amb to Pot, and
temp_controller_smith.py's two internal Pot models (and every demo's
Pot/TempController instantiation) silently relied on Pot's default of
20 instead. Add a top-level ambient_temperature key to
config.json(.templ/.sim), thread it through brewpi.py into both the
real plant and the Smith predictor's models via a new theta_amb param
on TempController, and make the demos pass it explicitly too.

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

60 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_params, 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")