{-# LANGUAGE PostfixOperators #-}
module Drasil.PDController.DataDefs where
import Drasil.PDController.Concepts
import Drasil.PDController.Assumptions
import Drasil.PDController.Unitals
import Drasil.PDController.References
import Drasil.PDController.TModel
import Data.Drasil.Concepts.Math (equation)
import Language.Drasil
import Theory.Drasil (DataDefinition, ddE)
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Language.Drasil.Sentence.Combinators as S
dataDefinitions :: [DataDefinition]
dataDefinitions :: [DataDefinition]
dataDefinitions = [DataDefinition
ddErrSig, DataDefinition
ddPropCtrl, DataDefinition
ddDerivCtrl, DataDefinition
ddCtrlVar]
ddErrSig :: DataDefinition
ddErrSig :: DataDefinition
ddErrSig
= SimpleQDef
-> [DecRef]
-> Maybe Derivation
-> String
-> [Sentence]
-> DataDefinition
ddE SimpleQDef
ddErrSigDefn [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
johnson2008] forall a. Maybe a
Nothing String
"ddProcessError"
[Sentence
ddErrSigNote]
ddErrSigDefn :: SimpleQDef
ddErrSigDefn :: SimpleQDef
ddErrSigDefn = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
qdProcessErrorFD Expr
ddErrSigEqn
ddErrSigEqn :: Expr
ddErrSigEqn :: Expr
ddErrSigEqn = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdSetPointFD forall r. ExprC r => r -> r -> r
$- forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdProcessVariableFD
ddErrSigNote :: Sentence
ddErrSigNote :: Sentence
ddErrSigNote
= [Sentence] -> Sentence
foldlSent
[forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
processError), String -> Sentence
S String
"is the difference between the Set-Point and" Sentence -> Sentence -> Sentence
+:+.
forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
processVariable,
forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
equation), String -> Sentence
S String
"is converted to the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
ccFrequencyDomain,
String -> Sentence
S String
"by applying the", forall n. NamedIdea n => n -> Sentence
atStart ConceptChunk
ccLaplaceTransform Sentence -> Sentence -> Sentence
+:+. forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource TheoryModel
tmLaplace,
forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
setPoint), String -> Sentence
S String
"is assumed to be constant throughout the",
forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
simulation Sentence -> Sentence -> Sentence
+:+. forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aSP,
String -> Sentence
S String
"The initial value of the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
processVariable, String -> Sentence
S String
"is assumed",
String -> Sentence
S String
"to be zero", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aInitialValue]
ddPropCtrl :: DataDefinition
ddPropCtrl :: DataDefinition
ddPropCtrl
= SimpleQDef
-> [DecRef]
-> Maybe Derivation
-> String
-> [Sentence]
-> DataDefinition
ddE SimpleQDef
ddPropCtrlDefn [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
johnson2008] forall a. Maybe a
Nothing String
"ddPropCtrl"
[Sentence
ddPropCtrlNote]
ddPropCtrlDefn :: SimpleQDef
ddPropCtrlDefn :: SimpleQDef
ddPropCtrlDefn = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
qdPropControlFD Expr
ddPropCtrlEqn
ddPropCtrlEqn :: Expr
ddPropCtrlEqn :: Expr
ddPropCtrlEqn = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdPropGain forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdProcessErrorFD
ddPropCtrlNote :: Sentence
ddPropCtrlNote :: Sentence
ddPropCtrlNote
= [Sentence] -> Sentence
foldlSent
[String -> Sentence
S String
"The Proportional Controller is the product of the", forall n. NounPhrase n => n -> Sentence
phraseNP (ConceptChunk
propGain forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`andThe`
ConceptChunk
processError) Sentence -> Sentence -> Sentence
+:+. forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource DataDefinition
ddErrSig,
forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
equation), String -> Sentence
S String
"is converted to the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
ccFrequencyDomain,
String -> Sentence
S String
"by applying the", forall n. NamedIdea n => n -> Sentence
atStart ConceptChunk
ccLaplaceTransform, forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource TheoryModel
tmLaplace]
ddDerivCtrl :: DataDefinition
ddDerivCtrl :: DataDefinition
ddDerivCtrl
= SimpleQDef
-> [DecRef]
-> Maybe Derivation
-> String
-> [Sentence]
-> DataDefinition
ddE SimpleQDef
ddDerivCtrlDefn [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
johnson2008] forall a. Maybe a
Nothing String
"ddDerivCtrl"
[Sentence
ddDerivCtrlNote]
ddDerivCtrlDefn :: SimpleQDef
ddDerivCtrlDefn :: SimpleQDef
ddDerivCtrlDefn = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
qdDerivativeControlFD Expr
ddDerivCtrlEqn
ddDerivCtrlEqn :: Expr
ddDerivCtrlEqn :: Expr
ddDerivCtrlEqn
= forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdDerivGain forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdProcessErrorFD forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdFreqDomain
ddDerivCtrlNote :: Sentence
ddDerivCtrlNote :: Sentence
ddDerivCtrlNote
= [Sentence] -> Sentence
foldlSent
[String -> Sentence
S String
"The Derivative Controller is the product of the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
derGain
Sentence -> Sentence -> Sentence
`S.andThe` String -> Sentence
S String
"differential" Sentence -> Sentence -> Sentence
`S.ofThe` forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
processError Sentence -> Sentence -> Sentence
+:+. forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource DataDefinition
ddErrSig,
forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
equation), String -> Sentence
S String
"is converted to the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
ccFrequencyDomain,
String -> Sentence
S String
"by applying the", forall n. NamedIdea n => n -> Sentence
atStart ConceptChunk
ccLaplaceTransform Sentence -> Sentence -> Sentence
+:+. forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource TheoryModel
tmLaplace,
String -> Sentence
S String
"A pure form of the Derivative controller is used in this",
String -> Sentence
S String
"application", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aUnfilteredDerivative]
ddCtrlVar :: DataDefinition
ddCtrlVar :: DataDefinition
ddCtrlVar
= SimpleQDef
-> [DecRef]
-> Maybe Derivation
-> String
-> [Sentence]
-> DataDefinition
ddE SimpleQDef
ddCtrlVarDefn [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
johnson2008] forall a. Maybe a
Nothing String
"ddCtrlVar" [Sentence
ddCtrlNote]
ddCtrlVarDefn :: SimpleQDef
ddCtrlVarDefn :: SimpleQDef
ddCtrlVarDefn = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
qdCtrlVarFD Expr
ddCtrlEqn
ddCtrlEqn :: Expr
ddCtrlEqn :: Expr
ddCtrlEqn
= forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdProcessErrorFD forall r. ExprC r => r -> r -> r
`mulRe` (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdPropGain forall r. ExprC r => r -> r -> r
`addRe`
(forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdDerivGain forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdFreqDomain))
ddCtrlNote :: Sentence
ddCtrlNote :: Sentence
ddCtrlNote
= [Sentence] -> Sentence
foldlSent
[forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
controlVariable) Sentence -> Sentence -> Sentence
+:+. String -> Sentence
S String
"is the output of the controller",
String -> Sentence
S String
"In this case" Sentence -> Sentence -> Sentence
`sC` String -> Sentence
S String
"it is the sum of the Proportional", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource DataDefinition
ddPropCtrl,
String -> Sentence
S String
"and Derivative", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource DataDefinition
ddDerivCtrl Sentence -> Sentence -> Sentence
+:+.
String -> Sentence
S String
"controllers",
String -> Sentence
S String
"The parallel", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aParallelEq,
String -> Sentence
S String
"and de-coupled", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aDecoupled,
String -> Sentence
S String
"form of the PD equation is",
String -> Sentence
S String
"used in this document"]