- fixed water model
This commit is contained in:
+7
-11
@@ -3,7 +3,7 @@ from components.aplant import APlant
|
||||
|
||||
|
||||
class Pot(APlant):
|
||||
def __init__(self, params):
|
||||
def __init__(self, params, theta_amb=20):
|
||||
APlant.__init__(self)
|
||||
self.dt = params['dt']
|
||||
self.alpha = 1.0
|
||||
@@ -17,10 +17,9 @@ class Pot(APlant):
|
||||
self.L = params['L']
|
||||
self.Td = params['Td']
|
||||
self.kn = params['kn']
|
||||
self.theta_amb = params['theta_amb']
|
||||
self.temp = params['theta']
|
||||
|
||||
self.theta = 0
|
||||
self.temp = self.theta_amb
|
||||
self.theta_amb = theta_amb
|
||||
self.alpha = self.dt / 1
|
||||
self.alpha_delay = self.dt/self.Td
|
||||
|
||||
@@ -34,12 +33,8 @@ class Pot(APlant):
|
||||
# Delay
|
||||
self.power_actual = (1-self.alpha_delay) * self.power_actual + self.alpha_delay * self.power_set
|
||||
|
||||
self.e = self.e * (1 - ((self.L * self.theta) * self.dt) / (self.M * self.C))
|
||||
self.x = (1 - self.alpha) * self.x + self.gain * self.alpha * self.power_actual
|
||||
self.e += self.x
|
||||
self.theta = self.e / (self.M * self.C)
|
||||
|
||||
self.temp = self.getTemperature()
|
||||
leak = 1/self.M * self.L * (self.theta_amb - self.temp)/self.theta_amb
|
||||
self.temp += (self.power_actual / (self.M * self.C) + leak) * self.dt
|
||||
|
||||
def setPower(self, power):
|
||||
self.power_set = power
|
||||
@@ -48,4 +43,5 @@ class Pot(APlant):
|
||||
return round(self.power_actual, 1)
|
||||
|
||||
def getTemperature(self):
|
||||
return round(self.theta + self.theta_amb + self.kn * np.random.normal(0, 1) / np.sqrt(12.0), 1)
|
||||
#return round(self.theta + self.theta_amb + self.kn * np.random.normal(0, 1) / np.sqrt(12.0), 1)
|
||||
return self.temp
|
||||
Reference in New Issue
Block a user