module Numeric.DDE.Model (
Par (..)
, BandpassFiltering (..)
, rhs
) where
import qualified Data.Vector.Storable as V
import Numeric.DDE.Types
data Par =
MackeyGlass { _beta :: Double
, _gamma :: Double
}
|
RC { _fnl :: Double -> Double
, _rho :: Double
, _filt :: BandpassFiltering
}
data BandpassFiltering = BandpassFiltering
{ _tau :: Double
, _theta :: Double
} deriving Show
rhs :: Par -> RHS
rhs MackeyGlass { _beta = beta, _gamma = gamma }
((State xs), (Hist hs), _)
= State (V.singleton x')
where x' = beta * x_tau / (1 + x_tau^(10::Int)) gamma * x
x = xs V.! 0
x_tau = hs V.! 0
rhs RC { _fnl = _fnl,
_rho = _rho,
_filt = BandpassFiltering { _tau = _tau, _theta = _theta }
}
((State xs), (Hist hs), (Inp u)) = State $ V.fromList [x', y']
where
x' = (x (recip _theta) * y + _fnl (x_tau + _rho * u)) / _tau
y' = x
x = xs V.! 0
y = xs V.! 1
x_tau = hs V.! 0