fixed duplicate class declaration
This commit is contained in:
@@ -9,7 +9,6 @@ from contextlib import contextmanager
|
|||||||
class HendiException(Exception):
|
class HendiException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class HendiCtrl:
|
|
||||||
class HendiCtrl:
|
class HendiCtrl:
|
||||||
def __init__(self, port, speed):
|
def __init__(self, port, speed):
|
||||||
self.ser = serial.Serial(port, speed)
|
self.ser = serial.Serial(port, speed)
|
||||||
|
|||||||
+7
-5
@@ -69,7 +69,7 @@ def _infer_heatrate_soll_set(samples):
|
|||||||
return max(candidates, default=1.0) or 1.0
|
return max(candidates, default=1.0) or 1.0
|
||||||
|
|
||||||
|
|
||||||
def run_replay(samples, pid_params, heatrate_soll_set, plant_params, ambient, max_power, dt):
|
def run_replay(samples, pid_params, heatrate_soll_set, plant_params, ambient, max_power, heater_efficiency, dt):
|
||||||
"""Closed-loop simulation: controller drives plant, plant feeds temp back.
|
"""Closed-loop simulation: controller drives plant, plant feeds temp back.
|
||||||
|
|
||||||
The plant is seeded at the real starting temperature from the log so the
|
The plant is seeded at the real starting temperature from the log so the
|
||||||
@@ -94,7 +94,7 @@ def run_replay(samples, pid_params, heatrate_soll_set, plant_params, ambient, ma
|
|||||||
tc.set_heatrate_soll(heatrate_soll_set)
|
tc.set_heatrate_soll(heatrate_soll_set)
|
||||||
tc.process()
|
tc.process()
|
||||||
|
|
||||||
power_watts = max(0.0, tc.get_power() * max_power)
|
power_watts = max(0.0, tc.get_power() * max_power * heater_efficiency)
|
||||||
plant.set_power(power_watts)
|
plant.set_power(power_watts)
|
||||||
|
|
||||||
out.append({
|
out.append({
|
||||||
@@ -186,6 +186,8 @@ def main():
|
|||||||
help='Heat loss coefficient [W/(kg·K)] (default: %(default)s)')
|
help='Heat loss coefficient [W/(kg·K)] (default: %(default)s)')
|
||||||
parser.add_argument('--plant-Td', type=float, default=30.0, metavar='s',
|
parser.add_argument('--plant-Td', type=float, default=30.0, metavar='s',
|
||||||
help='Transport delay [s] (default: %(default)s)')
|
help='Transport delay [s] (default: %(default)s)')
|
||||||
|
parser.add_argument('--heater-efficiency', type=float, default=1.0, metavar='0-1',
|
||||||
|
help='Fraction of rated heater power delivered to the plant (default: %(default)s)')
|
||||||
|
|
||||||
for section, prefix in (('Hold', 'hold'), ('Heat', 'heat'), ('Cool', 'cool')):
|
for section, prefix in (('Hold', 'hold'), ('Heat', 'heat'), ('Cool', 'cool')):
|
||||||
for gain in ('kp', 'ki', 'kd', 'kt'):
|
for gain in ('kp', 'ki', 'kd', 'kt'):
|
||||||
@@ -234,15 +236,15 @@ def main():
|
|||||||
print('Log: {} ({} samples, dt={:.1f} s)'.format(name, len(samples), dt))
|
print('Log: {} ({} samples, dt={:.1f} s)'.format(name, len(samples), dt))
|
||||||
print('Power: max={:.0f} W'.format(max_power))
|
print('Power: max={:.0f} W'.format(max_power))
|
||||||
print('Rate: heatrate_soll_set={:.2f} K/min'.format(rate_soll))
|
print('Rate: heatrate_soll_set={:.2f} K/min'.format(rate_soll))
|
||||||
print('Plant: M={M} kg C={C} J/kgK L={L} W/kgK Td={Td} s ambient={amb} °C'.format(
|
print('Plant: M={M} kg C={C} J/kgK L={L} W/kgK Td={Td} s ambient={amb} °C heater_efficiency={eff}'.format(
|
||||||
amb=ambient, **plant_params))
|
amb=ambient, eff=args.heater_efficiency, **plant_params))
|
||||||
print('Params: {}'.format('overridden' if any_override else 'from config'))
|
print('Params: {}'.format('overridden' if any_override else 'from config'))
|
||||||
print()
|
print()
|
||||||
for section in ('Hold', 'Heat', 'Cool'):
|
for section in ('Hold', 'Heat', 'Cool'):
|
||||||
p = pid_params[section]
|
p = pid_params[section]
|
||||||
print(' {}: kp={kp} ki={ki} kd={kd} kt={kt}'.format(section, **p))
|
print(' {}: kp={kp} ki={ki} kd={kd} kt={kt}'.format(section, **p))
|
||||||
|
|
||||||
replay = run_replay(samples, pid_params, rate_soll, plant_params, ambient, max_power, dt)
|
replay = run_replay(samples, pid_params, rate_soll, plant_params, ambient, max_power, args.heater_efficiency, dt)
|
||||||
plot_replay(samples, replay, name, max_power, params_label)
|
plot_replay(samples, replay, name, max_power, params_label)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user