{-# LANGUAGE PostfixOperators #-}
module Drasil.PDController.GenDefs where

import Data.Drasil.Quantities.PhysicalProperties (mass)
import Data.Drasil.Concepts.Math (equation)
import Drasil.PDController.Assumptions
import Drasil.PDController.Concepts
import Drasil.PDController.References
import Drasil.PDController.TModel
import Language.Drasil
import Theory.Drasil (GenDefn, gd, othModel')
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Language.Drasil.Sentence.Combinators as S
import Data.Drasil.Citations ( pidWiki )
import Drasil.PDController.Unitals

genDefns :: [GenDefn]
genDefns :: [GenDefn]
genDefns = [GenDefn
gdPowerPlant]

----------------------------------------------

gdPowerPlant :: GenDefn
gdPowerPlant :: GenDefn
gdPowerPlant
  = forall u.
IsUnit u =>
ModelKind ModelExpr
-> Maybe u
-> Maybe Derivation
-> [DecRef]
-> String
-> [Sentence]
-> GenDefn
gd (forall e. RelationConcept -> ModelKind e
othModel' RelationConcept
gdPowerPlantRC) (forall a. Maybe a
Nothing :: Maybe UnitDefn) forall a. Maybe a
Nothing
      [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
pidWiki, forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
abbasi2015]
      String
"gdPowerPlant"
      [Sentence
gdPowerPlantNote]

gdPowerPlantRC :: RelationConcept
gdPowerPlantRC :: RelationConcept
gdPowerPlantRC
  = forall e.
Express e =>
String -> NP -> Sentence -> e -> RelationConcept
makeRC String
"gdPowerPlantRC"
      (ConceptChunk
ccTransferFxn forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`the_ofThe` ConceptChunk
powerPlant)
      Sentence
EmptyS
      Expr
gdPowerPlantEqn

gdPowerPlantEqn :: Expr
gdPowerPlantEqn :: Expr
gdPowerPlantEqn
  = forall r. (ExprC r, LiteralC r) => r -> r
recip_ (forall r. (ExprC r, LiteralC r) => r -> r
square (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdFreqDomain) forall r. ExprC r => r -> r -> r
`addRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
qdFreqDomain forall r. ExprC r => r -> r -> r
`addRe` forall r. LiteralC r => Integer -> r
exactDbl Integer
20)

gdPowerPlantNote :: Sentence
gdPowerPlantNote :: Sentence
gdPowerPlantNote
  = [Sentence] -> Sentence
foldlSent
      [forall n. NounPhrase n => n -> Sentence
atStartNP (ConceptChunk
ccTransferFxn forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`the_ofThe` ConceptChunk
secondOrderSystem),
         forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource TheoryModel
tmSOSystem,
         String -> Sentence
S String
"is reduced to this equation by substituting the",
         forall n. NamedIdea n => n -> Sentence
phrase UnitalChunk
mass, String -> Sentence
S String
"(m) to 1 Kg", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aMass Sentence -> Sentence -> Sentence
`sC`
         forall n. NounPhrase n => n -> Sentence
phraseNP (forall t. NamedIdea t => t -> NP
the ConceptChunk
ccDampingCoeff), Sentence -> Sentence
sParen (Symbol -> Sentence
P Symbol
symDampingCoeff),
         String -> Sentence
S String
"to 1", forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aDampingCoeff Sentence -> Sentence -> Sentence
`sC` Sentence
EmptyS
         Sentence -> Sentence -> Sentence
`S.andThe` forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
ccStiffCoeff, Sentence -> Sentence
sParen (Symbol -> Sentence
P Symbol
symStifnessCoeff),
         String -> Sentence
S String
"to 20" Sentence -> Sentence -> Sentence
+:+. forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aStiffnessCoeff,
       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
"Additionally, there are no external disturbances to the power plant",
         forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
aExtDisturb]