- refactored temp controllers
This commit is contained in:
@@ -169,7 +169,7 @@ if __name__ == '__main__':
|
|||||||
hold_counter -= 1
|
hold_counter -= 1
|
||||||
ctrl.process()
|
ctrl.process()
|
||||||
plant.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)
|
ctrl.set_theta_ist(temp_ist)
|
||||||
|
|
||||||
y = 3500*ctrl.get_power()
|
y = 3500*ctrl.get_power()
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class TempController(AttributeChange):
|
|||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
# Process Kalman of Model
|
# 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)
|
xp_model = self.kalman_model.process(Z_model)
|
||||||
theta_ist_model = xp_model[0, 0]
|
theta_ist_model = xp_model[0, 0]
|
||||||
heatrate_ist_model = xp_model[1, 0] * 60
|
heatrate_ist_model = xp_model[1, 0] * 60
|
||||||
@@ -195,7 +195,7 @@ if __name__ == '__main__':
|
|||||||
hold_counter -= 1
|
hold_counter -= 1
|
||||||
ctrl.process()
|
ctrl.process()
|
||||||
plant.process()
|
plant.process()
|
||||||
temp_ist = plant.get_temperature_delayed()
|
temp_ist = plant.get_temperature()
|
||||||
ctrl.set_theta_ist(temp_ist)
|
ctrl.set_theta_ist(temp_ist)
|
||||||
|
|
||||||
y = 3500*ctrl.get_power()
|
y = 3500*ctrl.get_power()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Pot(APlant):
|
|||||||
self.Td = params['Td']
|
self.Td = params['Td']
|
||||||
self.kn = params['kn']
|
self.kn = params['kn']
|
||||||
self.temp = params['theta']
|
self.temp = params['theta']
|
||||||
|
self.temp_intermediate = params['theta']
|
||||||
|
|
||||||
self.theta_amb = theta_amb
|
self.theta_amb = theta_amb
|
||||||
|
|
||||||
@@ -28,10 +29,11 @@ class Pot(APlant):
|
|||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
leak = 1/self.M * self.L * (self.theta_amb - self.temp)/self.theta_amb
|
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
|
# Delay
|
||||||
self.delay.put(self.temp)
|
self.delay.put(self.temp_intermediate)
|
||||||
|
self.temp = self.delay.get()
|
||||||
|
|
||||||
def is_activated(self):
|
def is_activated(self):
|
||||||
return True
|
return True
|
||||||
@@ -45,5 +47,5 @@ class Pot(APlant):
|
|||||||
def get_temperature(self):
|
def get_temperature(self):
|
||||||
return self.temp
|
return self.temp
|
||||||
|
|
||||||
def get_temperature_delayed(self):
|
def get_temperature_intermediate(self):
|
||||||
return self.delay.get()
|
return self.temp_intermediate
|
||||||
|
|||||||
Reference in New Issue
Block a user