- refactored temp controllers

This commit is contained in:
jens
2020-12-22 10:51:38 +01:00
parent 4c93e85dd8
commit f2aff73f40
3 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ if __name__ == '__main__':
hold_counter -= 1
ctrl.process()
plant.process()
temp_ist = plant.get_temperature_delayed() + 0.0 * np.random.randn()
temp_ist = plant.get_temperature() + 0.0 * np.random.randn()
ctrl.set_theta_ist(temp_ist)
y = 3500*ctrl.get_power()
+2 -2
View File
@@ -52,7 +52,7 @@ class TempController(AttributeChange):
def process(self):
# Process Kalman of Model
Z_model = self.kalman_model.process_measurement((self.model.get_temperature(), 0), 0.0)
Z_model = self.kalman_model.process_measurement((self.model.get_temperature_intermediate(), 0), 0.0)
xp_model = self.kalman_model.process(Z_model)
theta_ist_model = xp_model[0, 0]
heatrate_ist_model = xp_model[1, 0] * 60
@@ -195,7 +195,7 @@ if __name__ == '__main__':
hold_counter -= 1
ctrl.process()
plant.process()
temp_ist = plant.get_temperature_delayed()
temp_ist = plant.get_temperature()
ctrl.set_theta_ist(temp_ist)
y = 3500*ctrl.get_power()
+6 -4
View File
@@ -17,6 +17,7 @@ class Pot(APlant):
self.Td = params['Td']
self.kn = params['kn']
self.temp = params['theta']
self.temp_intermediate = params['theta']
self.theta_amb = theta_amb
@@ -28,10 +29,11 @@ class Pot(APlant):
def process(self):
leak = 1/self.M * self.L * (self.theta_amb - self.temp)/self.theta_amb
self.temp += (self.power_set / (self.M * self.C) + leak) * self.dt
self.temp_intermediate += (self.power_set / (self.M * self.C) + leak) * self.dt
# Delay
self.delay.put(self.temp)
self.delay.put(self.temp_intermediate)
self.temp = self.delay.get()
def is_activated(self):
return True
@@ -45,5 +47,5 @@ class Pot(APlant):
def get_temperature(self):
return self.temp
def get_temperature_delayed(self):
return self.delay.get()
def get_temperature_intermediate(self):
return self.temp_intermediate