module Drasil.SglPend.Unitals where

import Language.Drasil
import Language.Drasil.ShortHands
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Language.Drasil.NounPhrase.Combinators as NP
import Data.Drasil.Constraints (gtZeroConstr)
import Data.Drasil.Quantities.PhysicalProperties as QPP (len, mass)
import Data.Drasil.SI_Units (metre, radian)
import qualified Data.Drasil.Quantities.Physics as QP (position, ixPos, xPos, force, velocity,
  angularVelocity, angularAccel, gravitationalAccel, tension, acceleration, yAccel,
  xAccel, yVel, xVel, iyPos, yPos, time, torque, momentOfInertia, angularDisplacement,
  angularFrequency, frequency, period)
import Data.Drasil.Concepts.Physics (pendulum)
import Data.Drasil.Concepts.Math as CM (angle, iAngle)
import Data.Drasil.Quantities.Math as QM (unitVect, unitVectj, pi_)
import Drasil.DblPend.Concepts (rod)
import Drasil.DblPend.Unitals (lRod)


symbols:: [QuantityDict]
symbols :: [QuantityDict]
symbols = forall a b. (a -> b) -> [a] -> [b]
map forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw [UnitalChunk]
unitalChunks forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw [DefinedQuantityDict]
unitless

inputs :: [QuantityDict]
inputs :: [QuantityDict]
inputs = forall a b. (a -> b) -> [a] -> [b]
map forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw [UnitalChunk
lenRod, UnitalChunk
QPP.mass, UnitalChunk
QP.angularAccel, UnitalChunk
pendDisplacementAngle, UnitalChunk
initialPendAngle]

outputs :: [QuantityDict]
outputs :: [QuantityDict]
outputs = [forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw UnitalChunk
pendDisplacementAngle]

units :: [UnitalChunk]
units :: [UnitalChunk]
units = forall a b. (a -> b) -> [a] -> [b]
map forall c. (Unitary c, Concept c, MayHaveUnit c) => c -> UnitalChunk
ucw [UnitalChunk]
unitalChunks

unitalChunks :: [UnitalChunk]
unitalChunks :: [UnitalChunk]
unitalChunks = [UnitalChunk
lenRod, UnitalChunk
QPP.mass, UnitalChunk
QP.force, UnitalChunk
QP.ixPos, UnitalChunk
QP.xPos, UnitalChunk
QP.yPos,
   UnitalChunk
QP.angularVelocity, UnitalChunk
QP.angularAccel, UnitalChunk
QP.gravitationalAccel, UnitalChunk
QP.tension, UnitalChunk
QP.acceleration,
   UnitalChunk
QP.yAccel, UnitalChunk
QP.xAccel, UnitalChunk
QP.yVel, UnitalChunk
QP.xVel, UnitalChunk
QP.iyPos, UnitalChunk
QP.time, UnitalChunk
QP.velocity, UnitalChunk
QP.position, UnitalChunk
QP.torque,
   UnitalChunk
QP.momentOfInertia, UnitalChunk
QP.angularDisplacement, UnitalChunk
QP.angularVelocity, UnitalChunk
initialPendAngle,
   UnitalChunk
QP.angularFrequency, UnitalChunk
QP.frequency, UnitalChunk
QP.period, UnitalChunk
lenRod, UnitalChunk
pendDisplacementAngle, UnitalChunk
initialPendAngle]

lenRod, pendDisplacementAngle, initialPendAngle :: UnitalChunk

lenRod :: UnitalChunk
lenRod = forall u.
IsUnit u =>
String -> NP -> Sentence -> Symbol -> Space -> u -> UnitalChunk
uc' String
"l_rod" (String -> NP
cn String
"length of the rod")
        (forall n. NounPhrase n => n -> Sentence
phraseNP (UnitalChunk
len forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`the_ofThe` IdeaDict
rod))
        (Symbol -> Symbol -> Symbol
sub Symbol
cL Symbol
lRod) Space
Real UnitDefn
metre

pendDisplacementAngle :: UnitalChunk
pendDisplacementAngle = forall u.
IsUnit u =>
String -> NP -> Sentence -> Symbol -> Space -> u -> UnitalChunk
uc' String
"pendDisplacementAngle" (String -> NP
cn String
"displacement angle of the pendulum")
        (forall n. NounPhrase n => n -> Sentence
phraseNP (ConceptChunk
angle forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`the_ofThe` ConceptChunk
pendulum))
        (Symbol -> Symbol -> Symbol
sub Symbol
lTheta Symbol
lP) Space
Real UnitDefn
radian
        -- (sub lTheta lP) (mkFunction [Real] Real) radian

initialPendAngle :: UnitalChunk
initialPendAngle = forall u.
IsUnit u =>
String -> NP -> Sentence -> Symbol -> Space -> u -> UnitalChunk
uc' String
"initialPendAngle" (String -> NP
cn String
"initial pendulum angle")
        (forall n. NounPhrase n => n -> Sentence
phraseNP (NP -> NP
NP.the (ConceptChunk
CM.iAngle forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`of_` ConceptChunk
pendulum)))
        (Symbol -> Symbol -> Symbol
sub Symbol
lTheta Symbol
lI) Space
Real UnitDefn
radian

unitless :: [DefinedQuantityDict]
unitless :: [DefinedQuantityDict]
unitless = [DefinedQuantityDict
QM.unitVect, DefinedQuantityDict
QM.unitVectj, DefinedQuantityDict
QM.pi_]

-----------------------
-- CONSTRAINT CHUNKS --
-----------------------
lenRodCons, pendDisplacementAngleOutCons, angAccelOutCons, initialPendAngleCons :: ConstrConcept

inConstraints :: [UncertQ]
inConstraints :: [UncertQ]
inConstraints = forall a b. (a -> b) -> [a] -> [b]
map (forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
`uq` Uncertainty
defaultUncrt) [ConstrConcept
lenRodCons, ConstrConcept
initialPendAngleCons]

outConstraints :: [UncertQ]
outConstraints :: [UncertQ]
outConstraints = forall a b. (a -> b) -> [a] -> [b]
map (forall c.
(Quantity c, Constrained c, Concept c, HasReasVal c,
 MayHaveUnit c) =>
c -> Uncertainty -> UncertQ
`uq` Uncertainty
defaultUncrt) [ConstrConcept
angAccelOutCons, ConstrConcept
pendDisplacementAngleOutCons]

lenRodCons :: ConstrConcept
lenRodCons                   = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' UnitalChunk
lenRod                [ConstraintE
gtZeroConstr] (forall r. LiteralC r => Double -> r
dbl Double
44.2)
initialPendAngleCons :: ConstrConcept
initialPendAngleCons         = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' UnitalChunk
initialPendAngle      [ConstraintE
gtZeroConstr] (forall r. LiteralC r => Double -> r
dbl Double
2.1)
pendDisplacementAngleOutCons :: ConstrConcept
pendDisplacementAngleOutCons = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' UnitalChunk
pendDisplacementAngle [ConstraintE
gtZeroConstr] (forall r. LiteralC r => Double -> r
dbl Double
2.1)
angAccelOutCons :: ConstrConcept
angAccelOutCons              = forall c.
(Concept c, MayHaveUnit c, Quantity c) =>
c -> [ConstraintE] -> Expr -> ConstrConcept
constrained' UnitalChunk
QP.angularAccel       [ConstraintE
gtZeroConstr] (forall r. LiteralC r => Integer -> r
exactDbl Integer
0)