-- | Defines some basic equations of physics and their wrappers as concepts.
module Data.Drasil.Equations.Defining.Physics where

import Language.Drasil
import qualified Language.Drasil.Sentence.Combinators as S (is, of_, the_ofThe)

import qualified Data.Drasil.Quantities.Physics as QP (acceleration, time,
  force, height, velocity, position)
import qualified Data.Drasil.Quantities.PhysicalProperties as QPP (mass, specWeight, vol)
import Data.Drasil.Concepts.Documentation (body, constant)

------------------------------------------------------------------------------------------------------
-- * Equations

weightEqn, newtonSLEqn, hsPressureEqn, speedEqn :: ExprC r => r
newtonSLEqn :: forall r. ExprC r => r
newtonSLEqn               = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.mass forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.acceleration
weightEqn :: forall r. ExprC r => r
weightEqn                 = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.vol forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.specWeight
hsPressureEqn :: forall r. ExprC r => r
hsPressureEqn             = forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.specWeight forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.height
speedEqn :: forall r. ExprC r => r
speedEqn                  = forall r. ExprC r => r -> r
norm (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.velocity)

velocityEqn, accelerationEqn :: ModelExpr
velocityEqn :: ModelExpr
velocityEqn               = forall r c. (ModelExprC r, HasUID c, HasSymbol c) => r -> c -> r
deriv (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.position) UnitalChunk
QP.time
accelerationEqn :: ModelExpr
accelerationEqn           = forall r c. (ModelExprC r, HasUID c, HasSymbol c) => r -> c -> r
deriv (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.velocity) UnitalChunk
QP.time

------------------------------------------------------------------------------------------------------
-- * Concepts

accelerationQD :: ModelQDef
accelerationQD :: ModelQDef
accelerationQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef UnitalChunk
QP.acceleration ModelExpr
accelerationEqn

velocityQD :: ModelQDef
velocityQD :: ModelQDef
velocityQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef UnitalChunk
QP.velocity ModelExpr
velocityEqn

newtonSLQD :: ModelQDef
newtonSLQD :: ModelQDef
newtonSLQD = forall e.
String -> NP -> Sentence -> Symbol -> Space -> e -> QDefinition e
fromEqn' String
"force" (String -> NP
nounPhraseSP String
"Newton's second law of motion")
  Sentence
newtonSLDesc (forall q. HasSymbol q => q -> Symbol
eqSymb UnitalChunk
QP.force) Space
Real forall r. ExprC r => r
newtonSLEqn

newtonSLDesc :: Sentence
newtonSLDesc :: Sentence
newtonSLDesc = [Sentence] -> Sentence
foldlSent [String -> Sentence
S String
"The net", forall a. Quantity a => a -> Sentence
getTandS UnitalChunk
QP.force, String -> Sentence
S String
"on a",
  forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
body Sentence -> Sentence -> Sentence
`S.is` String -> Sentence
S String
"proportional to", forall a. Quantity a => a -> Sentence
getTandS UnitalChunk
QP.acceleration Sentence -> Sentence -> Sentence
`S.the_ofThe`
  forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
body Sentence -> Sentence -> Sentence
`sC` String -> Sentence
S String
"where", forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch UnitalChunk
QPP.mass, String -> Sentence
S String
"denotes", forall n. NamedIdea n => n -> Sentence
phrase UnitalChunk
QPP.mass Sentence -> Sentence -> Sentence
`S.the_ofThe`
  forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
body, String -> Sentence
S String
"as the", forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
constant Sentence -> Sentence -> Sentence
`S.of_` String -> Sentence
S String
"proportionality"]