module Drasil.GlassBR.IMods (symb, iMods, pbIsSafe, lrIsSafe, instModIntro,
  qDefns) where

import Control.Lens ((^.))
import Prelude hiding (exp)
import Language.Drasil
import Theory.Drasil (InstanceModel, imNoDeriv, qwC, qwUC, equationalModelN,
  output)
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Language.Drasil.Sentence.Combinators as S
import Drasil.SRSDocument (Block (Parallel))

import Data.Drasil.Citations (campidelli)
import Data.Drasil.Concepts.Documentation (goal, user, datum)
import Data.Drasil.SI_Units

import Drasil.GlassBR.DataDefs (aGrtrThanB, arRef, calofDemand, glaTyFac,
  glaTyFacQD, gtfRef, hFromtQD, hRef, loadDF, stdVals)
import Drasil.GlassBR.Figures (dimlessloadVsARFig)
import Drasil.GlassBR.Goals (willBreakGS)
import Drasil.GlassBR.References (astm2009, beasonEtAl1998)
import Drasil.GlassBR.Unitals

iMods :: [InstanceModel]
iMods :: [InstanceModel]
iMods = [InstanceModel
risk, InstanceModel
strDisFac, InstanceModel
nonFL, InstanceModel
dimLL, InstanceModel
tolPre, InstanceModel
tolStrDisFac, InstanceModel
probOfBreak,
  InstanceModel
calofCapacity, InstanceModel
pbIsSafe, InstanceModel
lrIsSafe]

symb :: [UnitalChunk]
symb :: [UnitalChunk]
symb =  [forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> UnitDefn -> UnitalChunk
ucuc UncertQ
plateLen UnitDefn
metre, forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> UnitDefn -> UnitalChunk
ucuc UncertQ
plateWidth UnitDefn
metre, forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> UnitDefn -> UnitalChunk
ucuc UncertQ
charWeight UnitDefn
kilogram,
  forall c.
(Quantity c, Concept c, MayHaveUnit c) =>
c -> UnitDefn -> UnitalChunk
ucuc UncertQ
standOffDist UnitDefn
metre, UnitalChunk
demand] -- this is temporary
-- ++
 -- [dqdQd (qw calofDemand) demandq]

qDefns :: [Block SimpleQDef]
qDefns :: [Block SimpleQDef]
qDefns = forall a. a -> [a] -> Block a
Parallel SimpleQDef
hFromtQD [SimpleQDef
glaTyFacQD] forall a. a -> [a] -> [a]
: --can be calculated on their own
  forall a b. (a -> b) -> [a] -> [b]
map (forall a. a -> [a] -> Block a
`Parallel` []) [SimpleQDef
dimLLQD, SimpleQDef
strDisFacQD, SimpleQDef
riskQD, SimpleQDef
tolStrDisFacQD, SimpleQDef
tolPreQD,
    SimpleQDef
nonFLQD]

abInputConstraints :: [(QuantityDict, Maybe (RealInterval Expr Expr))]
abInputConstraints :: [(QuantityDict, Maybe (RealInterval Expr Expr))]
abInputConstraints = [forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UncertQ
plateLen   forall a b. (a -> b) -> a -> b
$ forall b a. (Inclusive, b) -> RealInterval a b
UpFrom  (Inclusive
Exc, forall r. LiteralC r => Integer -> r
exactDbl Integer
0),
                      forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UncertQ
plateWidth forall a b. (a -> b) -> a -> b
$ forall a b. (Inclusive, a) -> (Inclusive, b) -> RealInterval a b
Bounded (Inclusive
Exc, forall r. LiteralC r => Integer -> r
exactDbl Integer
0) (Inclusive
Inc, forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateLen)]

aspectRatioConstraint :: RealInterval Expr Expr
aspectRatioConstraint :: RealInterval Expr Expr
aspectRatioConstraint = forall b a. (Inclusive, b) -> RealInterval a b
UpFrom (Inclusive
Inc, forall r. LiteralC r => Integer -> r
exactDbl Integer
1)

probConstraint :: RealInterval Expr Expr
probConstraint :: RealInterval Expr Expr
probConstraint = forall a b. (Inclusive, a) -> (Inclusive, b) -> RealInterval a b
Bounded (Inclusive
Inc, forall r. LiteralC r => Integer -> r
exactDbl Integer
0) (Inclusive
Inc, forall r. LiteralC r => Integer -> r
exactDbl Integer
1)

{--}

risk :: InstanceModel
risk :: InstanceModel
risk = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (QuantityDict
riskFun forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
riskQD)
  (forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitalChunk
modElas forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC QuantityDict
lDurFac forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC ConstrainedChunk
stressDistFac forall a. a -> [a] -> [a]
:
    forall a b. (a -> b) -> [a] -> [b]
map forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC [UnitaryChunk
sflawParamK, UnitaryChunk
sflawParamM, UnitaryChunk
minThick] forall a. [a] -> [a] -> [a]
++ [(QuantityDict, Maybe (RealInterval Expr Expr))]
abInputConstraints)
  (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
riskFun) [] [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009, forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> RefInfo -> DecRef
dRefInfo Citation
beasonEtAl1998 forall a b. (a -> b) -> a -> b
$ [Int] -> RefInfo
Equation [Int
4, Int
5],
    forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> RefInfo -> DecRef
dRefInfo Citation
campidelli forall a b. (a -> b) -> a -> b
$ [Int] -> RefInfo
Equation [Int
14]] String
"riskFun" [Sentence
aGrtrThanB, Sentence
hRef, Sentence
ldfRef, Sentence
jRef]

-- FIXME [4] !!!
riskQD :: SimpleQDef
riskQD :: SimpleQDef
riskQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
riskFun ((forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
sflawParamK forall r. ExprC r => r -> r -> r
$/
  (forall r. ExprC r => r -> r -> r
mulRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateLen) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateWidth) forall r. ExprC r => r -> r -> r
$^ (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
sflawParamM forall r. ExprC r => r -> r -> r
$- forall r. LiteralC r => Integer -> r
exactDbl Integer
1))) forall r. ExprC r => r -> r -> r
`mulRe`
  ((forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
modElas forall r. ExprC r => r -> r -> r
`mulRe` forall r. (ExprC r, LiteralC r) => r -> r
square (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
minThick)) forall r. ExprC r => r -> r -> r
$^ forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
sflawParamM) forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
lDurFac forall r. ExprC r => r -> r -> r
`mulRe` forall r. ExprC r => r -> r
exp (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstrainedChunk
stressDistFac))

{--}

strDisFac :: InstanceModel
strDisFac :: InstanceModel
strDisFac = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (ConstrainedChunk
stressDistFac forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
strDisFacQD)
  (forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UncertQ
aspectRatio RealInterval Expr Expr
aspectRatioConstraint forall a. a -> [a] -> [a]
: [forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC QuantityDict
dimlessLoad]) (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw ConstrainedChunk
stressDistFac)
  [forall a b. (Inclusive, a) -> (Inclusive, b) -> RealInterval a b
Bounded (Inclusive
Inc, forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstQDef
stressDistFacMin) (Inclusive
Inc, forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstQDef
stressDistFacMax)]
  [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"stressDistFac"
  [forall s f.
(HasUID s, HasSymbol s, Referable f, HasShortName f) =>
s -> f -> Sentence
interpolating ConstrainedChunk
stressDistFac LabelledContent
dimlessloadVsARFig, Sentence
arRef, Sentence
qHtRef]

strDisFacQD :: SimpleQDef
strDisFacQD :: SimpleQDef
strDisFacQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef ConstrainedChunk
stressDistFac Expr
strDisFacEq

strDisFacEq :: Expr
-- strDisFacEq = apply (sy stressDistFac)
--   [sy dimlessLoad, sy aspectRatio]
strDisFacEq :: Expr
strDisFacEq = forall r f. (ExprC r, HasUID f, HasSymbol f) => f -> [r] -> r
apply QuantityDict
interpZ [forall r. LiteralC r => String -> r
str String
"SDF.txt", forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
aspectRatio, forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
dimlessLoad]

{--}

nonFL :: InstanceModel
nonFL :: InstanceModel
nonFL = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (UnitalChunk
nonFactorL forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
nonFLQD)
  (forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC QuantityDict
tolLoad forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitalChunk
modElas forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitaryChunk
minThick forall a. a -> [a] -> [a]
: [(QuantityDict, Maybe (RealInterval Expr Expr))]
abInputConstraints)
  (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw UnitalChunk
nonFactorL) [] [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"nFL"
  [Sentence
qHtTlTolRef, forall s. (HasSymbol s, HasUID s) => [s] -> Sentence
stdVals [UnitalChunk
modElas], Sentence
hRef, Sentence
aGrtrThanB]

nonFLEq :: Expr
nonFLEq :: Expr
nonFLEq = forall r. ExprC r => r -> r -> r
mulRe (forall r. ExprC r => r -> r -> r
mulRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
tolLoad) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
modElas)) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
minThick forall r. ExprC r => r -> r -> r
$^ forall r. LiteralC r => Integer -> r
exactDbl Integer
4) forall r. ExprC r => r -> r -> r
$/
  forall r. (ExprC r, LiteralC r) => r -> r
square (forall r. ExprC r => r -> r -> r
mulRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateLen) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateWidth))

nonFLQD :: SimpleQDef
nonFLQD :: SimpleQDef
nonFLQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef UnitalChunk
nonFactorL Expr
nonFLEq

{--}

dimLL :: InstanceModel
dimLL :: InstanceModel
dimLL = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (QuantityDict
dimlessLoad forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
dimLLQD)
  (forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitalChunk
demand forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitalChunk
modElas forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitaryChunk
minThick forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC DefinedQuantityDict
gTF forall a. a -> [a] -> [a]
: [(QuantityDict, Maybe (RealInterval Expr Expr))]
abInputConstraints)
  (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
dimlessLoad) [] [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009, forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> RefInfo -> DecRef
dRefInfo Citation
campidelli forall a b. (a -> b) -> a -> b
$ [Int] -> RefInfo
Equation [Int
7]]
  String
"dimlessLoad" [Sentence
qRef, Sentence
aGrtrThanB, forall s. (HasSymbol s, HasUID s) => [s] -> Sentence
stdVals [UnitalChunk
modElas], Sentence
hRef, Sentence
gtfRef]

dimLLEq :: Expr
dimLLEq :: Expr
dimLLEq = forall r. ExprC r => r -> r -> r
mulRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
demand) (forall r. (ExprC r, LiteralC r) => r -> r
square (forall r. ExprC r => r -> r -> r
mulRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateLen) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateWidth)))
  forall r. ExprC r => r -> r -> r
$/ forall r. ExprC r => r -> r -> r
mulRe (forall r. ExprC r => r -> r -> r
mulRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
modElas) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
minThick forall r. ExprC r => r -> r -> r
$^ forall r. LiteralC r => Integer -> r
exactDbl Integer
4)) (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy DefinedQuantityDict
gTF)

dimLLQD :: SimpleQDef
dimLLQD :: SimpleQDef
dimLLQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
dimlessLoad Expr
dimLLEq

{--}

tolPre :: InstanceModel
tolPre :: InstanceModel
tolPre = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (QuantityDict
tolLoad forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
tolPreQD)
  [forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UncertQ
aspectRatio RealInterval Expr Expr
aspectRatioConstraint, forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC forall a b. (a -> b) -> a -> b
$ InstanceModel
tolStrDisFac forall s a. s -> Getting a s a -> a
^. forall c. HasOutput c => Getter c QuantityDict
output] (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
tolLoad) []
  [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"tolLoad" [forall s f.
(HasUID s, HasSymbol s, Referable f, HasShortName f) =>
s -> f -> Sentence
interpolating QuantityDict
tolLoad LabelledContent
dimlessloadVsARFig, Sentence
arRef,
    Sentence
jtolRef]

tolPreEq :: Expr
--tolPreEq = apply (sy tolLoad) [sy sdfTol, (sy plateLen) / (sy plateWidth)]
tolPreEq :: Expr
tolPreEq = forall r f. (ExprC r, HasUID f, HasSymbol f) => f -> [r] -> r
apply QuantityDict
interpY [forall r. LiteralC r => String -> r
str String
"SDF.txt", forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
aspectRatio, forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
sdfTol]

tolPreQD :: SimpleQDef
tolPreQD :: SimpleQDef
tolPreQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
tolLoad Expr
tolPreEq

{--}

tolStrDisFac :: InstanceModel
tolStrDisFac :: InstanceModel
tolStrDisFac = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (QuantityDict
sdfTol forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
tolStrDisFacQD)
  ((QuantityDict
lDurFac, forall a. Maybe a
Nothing) forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UncertainChunk
pbTol RealInterval Expr Expr
probConstraint forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC UnitalChunk
modElas forall a. a -> [a] -> [a]
: [(QuantityDict, Maybe (RealInterval Expr Expr))]
abInputConstraints forall a. [a] -> [a] -> [a]
++
    forall a b. (a -> b) -> [a] -> [b]
map forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC [UnitaryChunk
sflawParamM, UnitaryChunk
sflawParamK, UnitaryChunk
minThick]) (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
sdfTol) []
  [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"sdfTol" [Sentence
pbTolUsr, Sentence
aGrtrThanB, forall s. (HasSymbol s, HasUID s) => [s] -> Sentence
stdVals [UnitaryChunk
sflawParamM,
      UnitaryChunk
sflawParamK, forall u. (Unitary u, MayHaveUnit u) => u -> UnitaryChunk
mkUnitary UnitalChunk
modElas], Sentence
hRef, Sentence
ldfRef]  

tolStrDisFacQD :: SimpleQDef
tolStrDisFacQD :: SimpleQDef
tolStrDisFacQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
sdfTol forall a b. (a -> b) -> a -> b
$ forall r. ExprC r => r -> r
ln (forall r. ExprC r => r -> r
ln (forall r. (ExprC r, LiteralC r) => r -> r
recip_ (forall r. LiteralC r => Integer -> r
exactDbl Integer
1 forall r. ExprC r => r -> r -> r
$- forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertainChunk
pbTol))
  forall r. ExprC r => r -> r -> r
`mulRe` ((forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateLen forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertQ
plateWidth) forall r. ExprC r => r -> r -> r
$^ (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
sflawParamM forall r. ExprC r => r -> r -> r
$- forall r. LiteralC r => Integer -> r
exactDbl Integer
1) forall r. ExprC r => r -> r -> r
$/
    (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
sflawParamK forall r. ExprC r => r -> r -> r
`mulRe` ((forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
modElas forall r. ExprC r => r -> r -> r
`mulRe`
    forall r. (ExprC r, LiteralC r) => r -> r
square (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
minThick)) forall r. ExprC r => r -> r -> r
$^ forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitaryChunk
sflawParamM) forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
lDurFac)))

{--}

probOfBreak :: InstanceModel
probOfBreak :: InstanceModel
probOfBreak = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (ConstrainedChunk
probBr forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
probOfBreakQD)
  [forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC forall a b. (a -> b) -> a -> b
$ InstanceModel
risk forall s a. s -> Getting a s a -> a
^. forall c. HasOutput c => Getter c QuantityDict
output] (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw ConstrainedChunk
probBr) [RealInterval Expr Expr
probConstraint] (forall a b. (a -> b) -> [a] -> [b]
map forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef [Citation
astm2009, Citation
beasonEtAl1998]) String
"probOfBreak"
  [Sentence
riskRef]

probOfBreakQD :: SimpleQDef
probOfBreakQD :: SimpleQDef
probOfBreakQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef ConstrainedChunk
probBr (forall r. LiteralC r => Integer -> r
exactDbl Integer
1 forall r. ExprC r => r -> r -> r
$- forall r. ExprC r => r -> r
exp (forall r. ExprC r => r -> r
neg forall a b. (a -> b) -> a -> b
$ forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy forall a b. (a -> b) -> a -> b
$ InstanceModel
risk forall s a. s -> Getting a s a -> a
^. forall c. HasOutput c => Getter c QuantityDict
output))

{--}

calofCapacity :: InstanceModel
calofCapacity :: InstanceModel
calofCapacity = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (UnitalChunk
lRe forall s a. s -> Getting a s a -> a
^. forall c. NamedIdea c => Lens' c NP
term) SimpleQDef
calofCapacityQD)
  (forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC (InstanceModel
nonFL forall s a. s -> Getting a s a -> a
^. forall c. HasOutput c => Getter c QuantityDict
output) forall a. a -> [a] -> [a]
: forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC (DataDefinition
glaTyFac forall s a. s -> Getting a s a -> a
^. forall c. HasOutput c => Getter c QuantityDict
output) forall a. a -> [a] -> [a]
: [forall q.
(Quantity q, MayHaveUnit q) =>
q -> (QuantityDict, Maybe (RealInterval Expr Expr))
qwUC DefinedQuantityDict
loadSF]) (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw UnitalChunk
lRe) []
  [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"calofCapacity" [Sentence
lrCap, Sentence
nonFLRef, Sentence
gtfRef]

calofCapacityQD :: SimpleQDef
calofCapacityQD :: SimpleQDef
calofCapacityQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef UnitalChunk
lRe (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy (InstanceModel
nonFL forall s a. s -> Getting a s a -> a
^. forall c. HasOutput c => Getter c QuantityDict
output) forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy (DataDefinition
glaTyFac forall s a. s -> Getting a s a -> a
^. forall d. DefinesQuantity d => Getter d QuantityDict
defLhs) forall r. ExprC r => r -> r -> r
`mulRe` forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy DefinedQuantityDict
loadSF)

{--}

pbIsSafe :: InstanceModel
pbIsSafe :: InstanceModel
pbIsSafe = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (String -> NP
nounPhraseSP String
"Safety Req-Pb") SimpleQDef
pbIsSafeQD)
  [forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC ConstrainedChunk
probBr RealInterval Expr Expr
probConstraint, forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UncertainChunk
pbTol RealInterval Expr Expr
probConstraint] (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
isSafePb) []
  [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"isSafePb" [Sentence
pbIsSafeDesc, Sentence
probBRRef, Sentence
pbTolUsr]

pbIsSafeQD :: SimpleQDef
pbIsSafeQD :: SimpleQDef
pbIsSafeQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
isSafePb (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy ConstrainedChunk
probBr forall r. ExprC r => r -> r -> r
$< forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UncertainChunk
pbTol)

{--}

lrIsSafe :: InstanceModel
lrIsSafe :: InstanceModel
lrIsSafe = ModelKind Expr
-> [(QuantityDict, Maybe (RealInterval Expr Expr))]
-> QuantityDict
-> OutputConstraints
-> [DecRef]
-> String
-> [Sentence]
-> InstanceModel
imNoDeriv (forall e. NP -> QDefinition e -> ModelKind e
equationalModelN (String -> NP
nounPhraseSP String
"Safety Req-LR") SimpleQDef
lrIsSafeQD)
  [forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UnitalChunk
lRe forall a b. (a -> b) -> a -> b
$ forall b a. (Inclusive, b) -> RealInterval a b
UpFrom (Inclusive
Exc, forall r. LiteralC r => Integer -> r
exactDbl Integer
0), forall q.
(Quantity q, MayHaveUnit q) =>
q
-> RealInterval Expr Expr
-> (QuantityDict, Maybe (RealInterval Expr Expr))
qwC UnitalChunk
demand forall a b. (a -> b) -> a -> b
$ forall b a. (Inclusive, b) -> RealInterval a b
UpFrom (Inclusive
Exc, forall r. LiteralC r => Integer -> r
exactDbl Integer
0)]
  (forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw QuantityDict
isSafeLR) []
  [forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> DecRef
dRef Citation
astm2009] String
"isSafeLR"
  [Sentence
lrIsSafeDesc, Sentence
capRef, Sentence
qRef]

lrIsSafeQD :: SimpleQDef 
lrIsSafeQD :: SimpleQDef
lrIsSafeQD = forall c e. (Quantity c, MayHaveUnit c) => c -> e -> QDefinition e
mkQuantDef QuantityDict
isSafeLR (forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
lRe forall r. ExprC r => r -> r -> r
$> forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy UnitalChunk
demand)

iModDesc :: QuantityDict -> Sentence -> Sentence
iModDesc :: QuantityDict -> Sentence -> Sentence
iModDesc QuantityDict
main Sentence
s = [Sentence] -> Sentence
foldlSent [String -> Sentence
S String
"If", forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch QuantityDict
main Sentence -> Sentence -> Sentence
`sC` String -> Sentence
S String
"the glass is" Sentence -> Sentence -> Sentence
+:+.
    String -> Sentence
S String
"considered safe", Sentence
s Sentence -> Sentence -> Sentence
`S.are` String -> Sentence
S String
"either both True or both False"]
  
-- Intro --

instModIntro :: Sentence
instModIntro :: Sentence
instModIntro = [Sentence] -> Sentence
foldlSent [forall n. NounPhrase n => n -> Sentence
atStartNP (forall t. NamedIdea t => t -> NP
the IdeaDict
goal), forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS ConceptInstance
willBreakGS, 
  String -> Sentence
S String
"is met by", forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS InstanceModel
pbIsSafe Sentence -> Sentence -> Sentence
`sC` forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS InstanceModel
lrIsSafe]

-- Notes --
lrCap :: Sentence
lrCap :: Sentence
lrCap = forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch UnitalChunk
lRe Sentence -> Sentence -> Sentence
+:+. String -> Sentence
S String
"is also called capacity"

pbTolUsr :: Sentence
pbTolUsr :: Sentence
pbTolUsr = forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch UncertainChunk
pbTol Sentence -> Sentence -> Sentence
`S.is` String -> Sentence
S String
"entered by the" Sentence -> Sentence -> Sentence
+:+. forall n. NamedIdea n => n -> Sentence
phrase IdeaDict
user

qRef :: Sentence
qRef :: Sentence
qRef = forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch UnitalChunk
demand Sentence -> Sentence -> Sentence
`S.isThe` (ConceptChunk
demandq forall s a. s -> Getting a s a -> a
^. forall c. Definition c => Lens' c Sentence
defn) Sentence -> Sentence -> Sentence
`sC` String -> Sentence
S String
"as given in" Sentence -> Sentence -> Sentence
+:+. forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS DataDefinition
calofDemand

lrIsSafeDesc :: Sentence
lrIsSafeDesc :: Sentence
lrIsSafeDesc = QuantityDict -> Sentence -> Sentence
iModDesc QuantityDict
isSafeLR
  (forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch QuantityDict
isSafePb Sentence -> Sentence -> Sentence
+:+ forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource InstanceModel
pbIsSafe Sentence -> Sentence -> Sentence
`S.and_` forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch QuantityDict
isSafeLR)

pbIsSafeDesc :: Sentence
pbIsSafeDesc :: Sentence
pbIsSafeDesc = QuantityDict -> Sentence -> Sentence
iModDesc QuantityDict
isSafePb
  (forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch QuantityDict
isSafePb Sentence -> Sentence -> Sentence
`S.and_` forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch QuantityDict
isSafeLR Sentence -> Sentence -> Sentence
+:+ forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource InstanceModel
lrIsSafe)

capRef, jRef, jtolRef, ldfRef, nonFLRef, probBRRef, qHtRef, qHtTlTolRef,
  riskRef :: Sentence
capRef :: Sentence
capRef      = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence -> Sentence
definedIn' InstanceModel
calofCapacity (String -> Sentence
S String
"and is also called capacity")
jRef :: Sentence
jRef        = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
strDisFac
jtolRef :: Sentence
jtolRef     = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
tolStrDisFac
ldfRef :: Sentence
ldfRef      = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  DataDefinition
loadDF
nonFLRef :: Sentence
nonFLRef    = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
nonFL
probBRRef :: Sentence
probBRRef   = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
probOfBreak
qHtRef :: Sentence
qHtRef      = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
dimLL
qHtTlTolRef :: Sentence
qHtTlTolRef = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
tolPre
riskRef :: Sentence
riskRef     = forall r.
(Referable r, HasShortName r, DefinesQuantity r) =>
r -> Sentence
definedIn  InstanceModel
risk

-- Helper --
interpolating :: (HasUID s, HasSymbol s, Referable f, HasShortName f) => s -> f -> Sentence
interpolating :: forall s f.
(HasUID s, HasSymbol s, Referable f, HasShortName f) =>
s -> f -> Sentence
interpolating s
s f
f = [Sentence] -> Sentence
foldlSent [forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch s
s Sentence -> Sentence -> Sentence
`S.is` String -> Sentence
S String
"obtained by interpolating from",
  forall n. NamedIdea n => n -> Sentence
plural IdeaDict
datum, String -> Sentence
S String
"shown" Sentence -> Sentence -> Sentence
`S.in_` forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS f
f]