module Drasil.PDController.ODEs where

import Language.Drasil.Code (odeInfo', odeOptions, quantvar, ODEInfo,
    ODEMethod(RK45), ODEOptions)
import Language.Drasil.CodeExpr (LiteralC(exactDbl), ExprC(sy))

import Drasil.PDController.Unitals (qdSetPointTD, qdPropGain, qdDerivGain,
    qdSimTime, qdStepTime, odeRelTolConst, odeAbsTolConst)
import Language.Drasil(InitialValueProblem, makeAIVP)
import Drasil.PDController.IModel(imPDRC)


pidODEOptions :: ODEOptions
pidODEOptions :: ODEOptions
pidODEOptions = ODEMethod -> CodeExpr -> CodeExpr -> CodeExpr -> ODEOptions
odeOptions 
  ODEMethod
RK45 (ConstQDef -> CodeExpr
forall c. (HasUID c, HasSymbol c) => c -> CodeExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstQDef
odeAbsTolConst) (ConstQDef -> CodeExpr
forall c. (HasUID c, HasSymbol c) => c -> CodeExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstQDef
odeRelTolConst) (QuantityDict -> CodeExpr
forall c. (HasUID c, HasSymbol c) => c -> CodeExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdStepTime)

pdIVP :: InitialValueProblem
pdIVP :: InitialValueProblem
pdIVP = Expr -> Expr -> [Expr] -> InitialValueProblem
makeAIVP (Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
0) (QuantityDict -> Expr
forall c. (HasUID c, HasSymbol c) => c -> Expr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdSimTime) [Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
0, Integer -> Expr
forall r. LiteralC r => Integer -> r
exactDbl Integer
0]

pidODEInfo :: ODEInfo
pidODEInfo :: ODEInfo
pidODEInfo = [CodeVarChunk]
-> ODEOptions
-> DifferentialModel
-> InitialValueProblem
-> ODEInfo
odeInfo'
  [QuantityDict -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar QuantityDict
qdPropGain, QuantityDict -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar QuantityDict
qdDerivGain, QuantityDict -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar QuantityDict
qdSetPointTD]
  ODEOptions
pidODEOptions
  DifferentialModel
imPDRC
  InitialValueProblem
pdIVP