- use heat diffusion for water model instead of delay line
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
class HeatDiffusion:
|
||||
def __init__(self, dt, delay, ic=0):
|
||||
self.alpha = dt/delay
|
||||
self.beta = 1 - self.alpha
|
||||
self.state = ic
|
||||
|
||||
def initial(self, ic):
|
||||
self.state = ic
|
||||
|
||||
def process(self, x):
|
||||
self.state = self.beta * self.state + self.alpha*x
|
||||
return self.state
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
d = HeatDiffusion(0.1, 1)
|
||||
|
||||
for i in range(1, 200):
|
||||
y = d.process(1)
|
||||
print("In = {}, out = {}".format(i, y))
|
||||
Reference in New Issue
Block a user