-- | 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               = UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.mass r -> r -> r
forall r. ExprC r => r -> r -> r
$* UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.acceleration
weightEqn :: forall r. ExprC r => r
weightEqn                 = UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.vol r -> r -> r
forall r. ExprC r => r -> r -> r
$* UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.specWeight
hsPressureEqn :: forall r. ExprC r => r
hsPressureEqn             = UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QPP.specWeight r -> r -> r
forall r. ExprC r => r -> r -> r
$* UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.height
speedEqn :: forall r. ExprC r => r
speedEqn                  = r -> r
forall r. ExprC r => r -> r
norm (UnitalChunk -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
QP.velocity)

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

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

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

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

newtonSLQD :: ModelQDef
newtonSLQD :: ModelQDef
newtonSLQD = String
-> NP -> Sentence -> Symbol -> Space -> ModelExpr -> ModelQDef
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 (UnitalChunk -> Symbol
forall q. HasSymbol q => q -> Symbol
eqSymb UnitalChunk
QP.force) Space
Real ModelExpr
forall r. ExprC r => r
newtonSLEqn

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