diff --git a/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs b/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs index a2e71206e4..8cdc9da0a8 100644 --- a/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs +++ b/code/drasil-code/lib/Data/Drasil/ExternalLibraries/ODELibraries.hs @@ -72,11 +72,11 @@ scipyCall info = externalLibCall [ (returnExprListFill $ odeSyst info)], uncurry choiceStepFill (chooseMethod $ solveMethod $ odeOpts info), mandatoryStepsFill [callStepFill $ libCallFill $ map basicArgFill - [matrix[initVal info], tInit info], - initSolListWithValFill (depVar info) (matrix[initVal info]), + [matrix [initVal info], tInit info], + initSolListWithValFill (depVar info) (matrix [initVal info]), solveAndPopulateWhileFill (libCallFill []) (tFinal info) - (libCallFill [basicArgFill (addI (field r t) (stepSize (odeOpts info)))]) - (depVar info)]] + (libCallFill [basicArgFill (field r t $+ stepSize (odeOpts info))]) + (depVar info)]] where chooseMethod Adams = (0, solveMethodFill) chooseMethod BDF = (1, solveMethodFill) chooseMethod RK45 = (2, solveMethodFill) @@ -182,7 +182,7 @@ oslo = externalLib [ osloCall :: ODEInfo -> ExternalLibraryCall osloCall info = externalLibCall [ - mandatoryStepFill $ callStepFill $ libCallFill [basicArgFill $ matrix[initVal info]], + mandatoryStepFill $ callStepFill $ libCallFill [basicArgFill $ matrix [initVal info]], choiceStepFill (chooseMethod $ solveMethod $ odeOpts info) $ callStepFill $ libCallFill [basicArgFill $ tInit info, functionArgFill (map unnamedParamFill [indepVar info, vecDepVar info]) $ diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs index 55d57909b3..984e0b1cac 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/DrasilState.hs @@ -199,7 +199,7 @@ getConstantsCls chs cs = cnCls (constStructure $ dataInfo chs) (inputStructure $ where cnCls (Store Bundled) _ = zipCs Constants cnCls WithInputs Bundled = zipCs InputParameters cnCls _ _ = [] - zipCs ic = zip (map codeName cs) $ repeat (icNames chs ic) + zipCs ic = map ((, icNames chs ic) . codeName) cs -- | Get derived input functions (for @derived_values@). -- If there are no derived inputs, a derived inputs function is not generated. diff --git a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs index 645999bd5b..274d80d912 100644 --- a/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs +++ b/code/drasil-code/lib/Language/Drasil/Code/Imperative/Import.hs @@ -292,12 +292,10 @@ convExpr (Lit (Perc a b)) = do getLiteral Float = litFloat . realToFrac getLiteral _ = error "convExpr: Rational space matched to invalid CodeType; should be Double or Float" return $ getLiteral sm (fromIntegral a / (10 ** fromIntegral b)) -convExpr (AssocA AddI l) = foldl1 (#+) <$> mapM convExpr l -convExpr (AssocA AddRe l) = foldl1 (#+) <$> mapM convExpr l -convExpr (AssocA MulI l) = foldl1 (#*) <$> mapM convExpr l -convExpr (AssocA MulRe l) = foldl1 (#*) <$> mapM convExpr l -convExpr (AssocB And l) = foldl1 (?&&) <$> mapM convExpr l -convExpr (AssocB Or l) = foldl1 (?||) <$> mapM convExpr l +convExpr (AssocA Add l) = foldl1 (#+) <$> mapM convExpr l +convExpr (AssocA Mul l) = foldl1 (#*) <$> mapM convExpr l +convExpr (AssocB And l) = foldl1 (?&&) <$> mapM convExpr l +convExpr (AssocB Or l) = foldl1 (?||) <$> mapM convExpr l convExpr (C c) = do g <- get let v = quantvar (lookupC g c) diff --git a/code/drasil-data/lib/Data/Drasil/Equations/Defining/Derivations.hs b/code/drasil-data/lib/Data/Drasil/Equations/Defining/Derivations.hs index 7fe3bb5dc4..c2acfbe050 100644 --- a/code/drasil-data/lib/Data/Drasil/Equations/Defining/Derivations.hs +++ b/code/drasil-data/lib/Data/Drasil/Equations/Defining/Derivations.hs @@ -8,7 +8,7 @@ import qualified Data.Drasil.Quantities.PhysicalProperties as QPP (density, -- * Weight equation derivation weightDerivAccelEqn, weightDerivNewtonEqn, weightDerivReplaceMassEqn, weightDerivSpecWeightEqn :: ModelExpr -weightDerivNewtonEqn = sy QP.weight $= mulRe (sy QPP.mass) (sy QP.gravitationalAccel) -weightDerivReplaceMassEqn = sy QP.weight $= mulRe (sy QPP.density) (sy QPP.vol `mulRe` sy QP.gravitationalAccel) -weightDerivSpecWeightEqn = sy QP.weight $= mulRe (sy QPP.vol) (sy QPP.specWeight) -weightDerivAccelEqn = sy QP.acceleration $= vec2D (exactDbl 0) (sy QP.gravitationalAccel `mulRe` sy QM.unitVectj) +weightDerivNewtonEqn = sy QP.weight $= sy QPP.mass $* sy QP.gravitationalAccel +weightDerivReplaceMassEqn = sy QP.weight $= sy QPP.density $* sy QPP.vol $* sy QP.gravitationalAccel +weightDerivSpecWeightEqn = sy QP.weight $= sy QPP.vol $* sy QPP.specWeight +weightDerivAccelEqn = sy QP.acceleration $= vec2D (exactDbl 0) (sy QP.gravitationalAccel $* sy QM.unitVectj) diff --git a/code/drasil-data/lib/Data/Drasil/Equations/Defining/Physics.hs b/code/drasil-data/lib/Data/Drasil/Equations/Defining/Physics.hs index c9902218e5..605429fe9b 100644 --- a/code/drasil-data/lib/Data/Drasil/Equations/Defining/Physics.hs +++ b/code/drasil-data/lib/Data/Drasil/Equations/Defining/Physics.hs @@ -13,9 +13,9 @@ import Data.Drasil.Concepts.Documentation (body, constant) -- * Equations weightEqn, newtonSLEqn, hsPressureEqn, speedEqn :: ExprC r => r -newtonSLEqn = sy QPP.mass `mulRe` sy QP.acceleration -weightEqn = sy QPP.vol `mulRe` sy QPP.specWeight -hsPressureEqn = sy QPP.specWeight `mulRe` sy QP.height +newtonSLEqn = sy QPP.mass $* sy QP.acceleration +weightEqn = sy QPP.vol $* sy QPP.specWeight +hsPressureEqn = sy QPP.specWeight $* sy QP.height speedEqn = norm (sy QP.velocity) velocityEqn, accelerationEqn :: ModelExpr diff --git a/code/drasil-data/lib/Data/Drasil/Theories/Physics.hs b/code/drasil-data/lib/Data/Drasil/Theories/Physics.hs index f555713d69..b22a25ba8b 100644 --- a/code/drasil-data/lib/Data/Drasil/Theories/Physics.hs +++ b/code/drasil-data/lib/Data/Drasil/Theories/Physics.hs @@ -131,7 +131,7 @@ newtonSLRQD :: ModelQDef newtonSLRQD = mkQuantDef' QP.torque (nounPhraseSP "Newton's second law for rotational motion") newtonSLRExpr newtonSLRExpr :: ExprC r => r -newtonSLRExpr = sy QP.momentOfInertia `mulRe` sy QP.angularAccel +newtonSLRExpr = sy QP.momentOfInertia $* sy QP.angularAccel newtonSLRNotes :: [Sentence] newtonSLRNotes = [foldlSent diff --git a/code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs index 9f95a86c6e..7d6255b3f0 100644 --- a/code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/DataDefs.hs @@ -37,7 +37,7 @@ positionXQD_1 :: SimpleQDef positionXQD_1 = mkQuantDef xPos_1 positionXEqn_1 positionXEqn_1 :: PExpr -positionXEqn_1 = sy lenRod_1 `mulRe` sin (sy pendDisAngle_1) +positionXEqn_1 = sy lenRod_1 $* sin (sy pendDisAngle_1) positionXFigRef_1 :: Sentence positionXFigRef_1 = ch xPos_1 `S.is` S "shown in" +:+. refS figMotion @@ -55,7 +55,7 @@ positionYQD_1 :: SimpleQDef positionYQD_1 = mkQuantDef yPos_1 positionYEqn_1 positionYEqn_1 :: PExpr -positionYEqn_1 = neg (sy lenRod_1 `mulRe` cos (sy pendDisAngle_1)) +positionYEqn_1 = neg (sy lenRod_1 $* cos (sy pendDisAngle_1)) positionYFigRef_1 :: Sentence positionYFigRef_1 = ch yPos_1 `S.is` S "shown in" +:+. refS figMotion @@ -73,7 +73,7 @@ positionXQD_2 :: SimpleQDef positionXQD_2 = mkQuantDef xPos_2 positionXEqn_2 positionXEqn_2 :: PExpr -positionXEqn_2 = sy (positionXDD_1 ^. defLhs) `addRe` (sy lenRod_2 `mulRe` sin (sy pendDisAngle_2)) +positionXEqn_2 = sy (positionXDD_1 ^. defLhs) $+ (sy lenRod_2 $* sin (sy pendDisAngle_2)) positionXFigRef_2 :: Sentence positionXFigRef_2 = ch xPos_2 `S.is` S "shown in" +:+. refS figMotion @@ -91,7 +91,7 @@ positionYQD_2 :: SimpleQDef positionYQD_2 = mkQuantDef yPos_2 positionYEqn_2 positionYEqn_2 :: PExpr -positionYEqn_2 = sy (positionYDD_1 ^. defLhs) `addRe` neg (sy lenRod_2 `mulRe` cos (sy pendDisAngle_2)) +positionYEqn_2 = sy (positionYDD_1 ^. defLhs) $+ neg (sy lenRod_2 $* cos (sy pendDisAngle_2)) positionYFigRef_2 :: Sentence positionYFigRef_2 = ch yPos_2 `S.is` S "shown in" +:+. refS figMotion diff --git a/code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs index f716cf02e3..a2f5d33db8 100644 --- a/code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Derivations.hs @@ -19,12 +19,12 @@ velDerivEqn1, velXDerivEqn2_1, velXDerivEqn3_1, velXDerivEqn4_1 :: ModelExpr velDerivEqn1 = sy velocity $= positionGQD ^. defnExpr velXDerivEqn2_1 = sy xPos_1 $= positionXEqn_1 velXDerivEqn3_1 = sy xVel_1 $= deriv positionXEqn_1 time -velXDerivEqn4_1 = sy xVel_1 $= sy lenRod_1 `mulRe` deriv (sin (sy pendDisAngle_1)) time +velXDerivEqn4_1 = sy xVel_1 $= sy lenRod_1 $* deriv (sin (sy pendDisAngle_1)) time velYDerivEqn2_1,velYDerivEqn3_1,velYDerivEqn4_1 :: ModelExpr velYDerivEqn2_1 = sy yPos_1 $= express (positionYQD_1 ^. defnExpr) -velYDerivEqn3_1 = sy yVel_1 $= neg (deriv (sy lenRod_1 `mulRe` cos (sy pendDisAngle_1)) time) -velYDerivEqn4_1 = sy yVel_1 $= neg (sy lenRod_1 `mulRe` deriv (cos (sy pendDisAngle_1)) time) +velYDerivEqn3_1 = sy yVel_1 $= neg (deriv (sy lenRod_1 $* cos (sy pendDisAngle_1)) time) +velYDerivEqn4_1 = sy yVel_1 $= neg (sy lenRod_1 $* deriv (cos (sy pendDisAngle_1)) time) -- Velocity X/Y Second Object velXDerivEqn2_2, velXDerivEqn3_2 :: ModelExpr @@ -39,14 +39,14 @@ velYDerivEqn3_2 = sy yVel_2 $= neg (deriv positionYEqn_2 time) accelDerivEqn1, accelXDerivEqn3_1, accelXDerivEqn4_1 :: ModelExpr accelDerivEqn1 = sy acceleration $= accelGQD ^. defnExpr -accelXDerivEqn3_1 = sy xAccel_1 $= deriv (sy angularVel_1 `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1)) time -accelXDerivEqn4_1 = sy xAccel_1 $= deriv (sy angularVel_1) time `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1) - $- (sy angularVel_1 `mulRe` sy lenRod_1 `mulRe` sin (sy pendDisAngle_1) `mulRe` deriv (sy pendDisAngle_1) time) +accelXDerivEqn3_1 = sy xAccel_1 $= deriv (sy angularVel_1 $* sy lenRod_1 $* cos (sy pendDisAngle_1)) time +accelXDerivEqn4_1 = sy xAccel_1 $= deriv (sy angularVel_1) time $* sy lenRod_1 $* cos (sy pendDisAngle_1) + $- (sy angularVel_1 $* sy lenRod_1 $* sin (sy pendDisAngle_1) $* deriv (sy pendDisAngle_1) time) accelYDerivEqn3_1, accelYDerivEqn4_1 :: ModelExpr -accelYDerivEqn3_1 = sy yAccel_1 $= deriv (sy angularVel_1 `mulRe` sy lenRod_1 `mulRe` sin (sy pendDisAngle_1)) time -accelYDerivEqn4_1 = sy yAccel_1 $= deriv (sy angularVel_1) time `mulRe` sy lenRod_1 `mulRe` sin (sy pendDisAngle_1) - `addRe` (sy angularVel_1 `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1) `mulRe` deriv (sy pendDisAngle_1) time) +accelYDerivEqn3_1 = sy yAccel_1 $= deriv (sy angularVel_1 $* sy lenRod_1 $* sin (sy pendDisAngle_1)) time +accelYDerivEqn4_1 = sy yAccel_1 $= deriv (sy angularVel_1) time $* sy lenRod_1 $* sin (sy pendDisAngle_1) + $+ (sy angularVel_1 $* sy lenRod_1 $* cos (sy pendDisAngle_1) $* deriv (sy pendDisAngle_1) time) -- Acceleration X/Y Second Object accelXDerivEqn3_2 :: ModelExpr @@ -63,32 +63,32 @@ angularAccelDerivEqns = [angularAccelDerivEqn1, angularAccelDerivEqn2, angularAc angularAccelDerivEqn1, angularAccelDerivEqn2, angularAccelDerivEqn3, angularAccelDerivEqn4, angularAccelDerivEqn5, angularAccelDerivEqn6, angularAccelDerivEqn7, angularAccelDerivEqn8 :: ModelExpr -angularAccelDerivEqn1 = sy massObj_1 `mulRe` sy xAccel_1 $= - neg (sy tension_1) `mulRe` sin (sy pendDisAngle_1) $- (sy massObj_2 `mulRe` sy xAccel_2) -angularAccelDerivEqn2 = sy massObj_1 `mulRe` sy yAccel_1 $= - sy tension_1 `mulRe` cos (sy pendDisAngle_1) $- (sy massObj_2 `mulRe` sy yAccel_2) $- - (sy massObj_2 `mulRe` sy gravitationalMagnitude) $- (sy massObj_1 `mulRe` sy gravitationalMagnitude) -angularAccelDerivEqn3 = sy tension_1 `mulRe` sin (sy pendDisAngle_1) `mulRe` cos (sy pendDisAngle_1) $= - neg (cos (sy pendDisAngle_1)) `mulRe` - ((sy massObj_1 `mulRe` sy xAccel_1) `addRe` (sy massObj_2 `mulRe` sy xAccel_2)) -angularAccelDerivEqn4 = sy tension_1 `mulRe` sin (sy pendDisAngle_1) `mulRe` cos (sy pendDisAngle_1) $= - sin (sy pendDisAngle_1) `mulRe` +angularAccelDerivEqn1 = sy massObj_1 $* sy xAccel_1 $= + neg (sy tension_1) $* sin (sy pendDisAngle_1) $- (sy massObj_2 $* sy xAccel_2) +angularAccelDerivEqn2 = sy massObj_1 $* sy yAccel_1 $= + sy tension_1 $* cos (sy pendDisAngle_1) $- (sy massObj_2 $* sy yAccel_2) $- + (sy massObj_2 $* sy gravitationalMagnitude) $- (sy massObj_1 $* sy gravitationalMagnitude) +angularAccelDerivEqn3 = sy tension_1 $* sin (sy pendDisAngle_1) $* cos (sy pendDisAngle_1) $= + neg (cos (sy pendDisAngle_1)) $* + ((sy massObj_1 $* sy xAccel_1) $+ (sy massObj_2 $* sy xAccel_2)) +angularAccelDerivEqn4 = sy tension_1 $* sin (sy pendDisAngle_1) $* cos (sy pendDisAngle_1) $= + sin (sy pendDisAngle_1) $* ( - (sy massObj_1 `mulRe` sy yAccel_1) `addRe` (sy massObj_2 `mulRe` sy yAccel_2) `addRe` - (sy massObj_2 `mulRe` sy gravitationalMagnitude) `addRe` (sy massObj_1 `mulRe` sy gravitationalMagnitude) + (sy massObj_1 $* sy yAccel_1) $+ (sy massObj_2 $* sy yAccel_2) $+ + (sy massObj_2 $* sy gravitationalMagnitude) $+ (sy massObj_1 $* sy gravitationalMagnitude) ) -angularAccelDerivEqn5 = sin (sy pendDisAngle_1) `mulRe` +angularAccelDerivEqn5 = sin (sy pendDisAngle_1) $* ( - (sy massObj_1 `mulRe` sy yAccel_1) `addRe` (sy massObj_2 `mulRe` sy yAccel_2) `addRe` - (sy massObj_2 `mulRe` sy gravitationalMagnitude) `addRe` (sy massObj_1 `mulRe` sy gravitationalMagnitude) + (sy massObj_1 $* sy yAccel_1) $+ (sy massObj_2 $* sy yAccel_2) $+ + (sy massObj_2 $* sy gravitationalMagnitude) $+ (sy massObj_1 $* sy gravitationalMagnitude) ) $= - neg (cos (sy pendDisAngle_1)) `mulRe` - ((sy massObj_1 `mulRe` sy xAccel_1) `addRe` (sy massObj_2 `mulRe` sy xAccel_2)) -angularAccelDerivEqn6 = sy tension_2 `mulRe` sin(sy pendDisAngle_2) `mulRe` cos (sy pendDisAngle_2) $= - neg (cos (sy pendDisAngle_2)) `mulRe` sy massObj_2 `mulRe` sy xAccel_2 -angularAccelDerivEqn7 = sy tension_1 `mulRe` sin (sy pendDisAngle_2 ) `mulRe` cos (sy pendDisAngle_2) $= - sin (sy pendDisAngle_2) `mulRe` - ((sy massObj_2 `mulRe` sy yAccel_2) `addRe` (sy massObj_2 `mulRe` sy gravitationalMagnitude)) -angularAccelDerivEqn8 = sin (sy pendDisAngle_2) `mulRe` - ((sy massObj_2 `mulRe` sy yAccel_2) `addRe` (sy massObj_2 `mulRe` sy gravitationalMagnitude)) $= - neg (cos (sy pendDisAngle_2)) `mulRe` sy massObj_2 `mulRe` sy xAccel_2 + neg (cos (sy pendDisAngle_1)) $* + ((sy massObj_1 $* sy xAccel_1) $+ (sy massObj_2 $* sy xAccel_2)) +angularAccelDerivEqn6 = sy tension_2 $* sin(sy pendDisAngle_2) $* cos (sy pendDisAngle_2) $= + neg (cos (sy pendDisAngle_2)) $* sy massObj_2 $* sy xAccel_2 +angularAccelDerivEqn7 = sy tension_1 $* sin (sy pendDisAngle_2 ) $* cos (sy pendDisAngle_2) $= + sin (sy pendDisAngle_2) $* + ((sy massObj_2 $* sy yAccel_2) $+ (sy massObj_2 $* sy gravitationalMagnitude)) +angularAccelDerivEqn8 = sin (sy pendDisAngle_2) $* + ((sy massObj_2 $* sy yAccel_2) $+ (sy massObj_2 $* sy gravitationalMagnitude)) $= + neg (cos (sy pendDisAngle_2)) $* sy massObj_2 $* sy xAccel_2 diff --git a/code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs index de7923dd8c..0057c74377 100644 --- a/code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/Expressions.hs @@ -12,89 +12,89 @@ import Drasil.DblPend.Unitals (lenRod_1, lenRod_2, massObj_1, massObj_2, -- Velocity X/Y First Object velXExpr_1, velYExpr_1 :: PExpr -velXExpr_1 = sy angularVel_1 `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1) -velYExpr_1 = sy angularVel_1 `mulRe` positionXEqn_1 +velXExpr_1 = sy angularVel_1 $* sy lenRod_1 $* cos (sy pendDisAngle_1) +velYExpr_1 = sy angularVel_1 $* positionXEqn_1 -- Velocity X/Y Second Object velXExpr_2, velYExpr_2 :: PExpr -velXExpr_2 = sy xVel_1 `addRe` (sy angularVel_2 `mulRe` sy lenRod_2 `mulRe` cos (sy pendDisAngle_2)) -velYExpr_2 = sy yVel_1 `addRe` (sy angularVel_2 `mulRe` sy lenRod_2 `mulRe` sin (sy pendDisAngle_2)) +velXExpr_2 = sy xVel_1 $+ (sy angularVel_2 $* sy lenRod_2 $* cos (sy pendDisAngle_2)) +velYExpr_2 = sy yVel_1 $+ (sy angularVel_2 $* sy lenRod_2 $* sin (sy pendDisAngle_2)) -- Acceleration X/Y First Object accelXExpr_1, accelYExpr_1 :: PExpr -accelXExpr_1 = neg (square (sy angularVel_1) `mulRe` sy lenRod_1 `mulRe` sin (sy pendDisAngle_1)) - `addRe` (sy angularAccel_1 `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1)) -accelYExpr_1 = (square (sy angularVel_1) `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1)) - `addRe` (sy angularAccel_1 `mulRe` sy lenRod_1 `mulRe` sin (sy pendDisAngle_1)) +accelXExpr_1 = neg (square (sy angularVel_1) $* sy lenRod_1 $* sin (sy pendDisAngle_1)) + $+ (sy angularAccel_1 $* sy lenRod_1 $* cos (sy pendDisAngle_1)) +accelYExpr_1 = (square (sy angularVel_1) $* sy lenRod_1 $* cos (sy pendDisAngle_1)) + $+ (sy angularAccel_1 $* sy lenRod_1 $* sin (sy pendDisAngle_1)) -- Acceleration X/Y Second Object accelXExpr_2, accelYExpr_2 :: PExpr accelXExpr_2 = sy xAccel_1 $- - (square (sy angularVel_2) `mulRe` sy lenRod_2 `mulRe` sin (sy pendDisAngle_2)) - `addRe` (sy angularAccel_2 `mulRe` sy lenRod_2 `mulRe` cos (sy pendDisAngle_2)) -accelYExpr_2 = sy yAccel_1 `addRe` - (square (sy angularVel_2) `mulRe` sy lenRod_2 `mulRe` cos (sy pendDisAngle_2)) - `addRe` (sy angularAccel_2 `mulRe` sy lenRod_2 `mulRe` sin (sy pendDisAngle_2)) + (square (sy angularVel_2) $* sy lenRod_2 $* sin (sy pendDisAngle_2)) + $+ (sy angularAccel_2 $* sy lenRod_2 $* cos (sy pendDisAngle_2)) +accelYExpr_2 = sy yAccel_1 $+ + (square (sy angularVel_2) $* sy lenRod_2 $* cos (sy pendDisAngle_2)) + $+ (sy angularAccel_2 $* sy lenRod_2 $* sin (sy pendDisAngle_2)) -- Horizontal/Vertical force acting on the first object xForceWithAngle_1 :: PExpr -xForceWithAngle_1 = neg (sy tension_1 `mulRe` sin (sy pendDisAngle_1)) `addRe` - (sy tension_2 `mulRe` sin (sy pendDisAngle_2)) +xForceWithAngle_1 = neg (sy tension_1 $* sin (sy pendDisAngle_1)) $+ + (sy tension_2 $* sin (sy pendDisAngle_2)) yForceWithAngle_1 :: PExpr -yForceWithAngle_1 = sy tension_1 `mulRe` cos (sy pendDisAngle_1) $- - (sy tension_2 `mulRe` cos (sy pendDisAngle_2)) $- - (sy massObj_1 `mulRe` sy gravitationalAccel) +yForceWithAngle_1 = sy tension_1 $* cos (sy pendDisAngle_1) $- + (sy tension_2 $* cos (sy pendDisAngle_2)) $- + (sy massObj_1 $* sy gravitationalAccel) -- Horizontal/Vertical force acting on the second object xForceWithAngle_2 :: PExpr -xForceWithAngle_2 = neg (sy tension_2) `mulRe` sin (sy pendDisAngle_2) +xForceWithAngle_2 = neg (sy tension_2) $* sin (sy pendDisAngle_2) yForceWithAngle_2 :: PExpr -yForceWithAngle_2 = sy tension_2 `mulRe` cos (sy pendDisAngle_2) $- - (sy massObj_2 `mulRe` sy gravitationalAccel) +yForceWithAngle_2 = sy tension_2 $* cos (sy pendDisAngle_2) $- + (sy massObj_2 $* sy gravitationalAccel) -- Angular acceleration acting on the first object angularAccelExpr_1 :: PExpr -angularAccelExpr_1 = neg(sy gravitationalMagnitude) `mulRe` - (exactDbl 2 `mulRe` sy massObj_1 `addRe` sy massObj_2) `mulRe` sin (sy pendDisAngle_1 ) $- - (sy massObj_2 `mulRe` sy gravitationalMagnitude `mulRe` - sin (sy pendDisAngle_1 $- (exactDbl 2 `mulRe` sy pendDisAngle_2))) $- - ((exactDbl 2 `mulRe` sin (sy pendDisAngle_1 $- sy pendDisAngle_2 )) `mulRe` sy massObj_2 `mulRe` +angularAccelExpr_1 = neg(sy gravitationalMagnitude) $* + (exactDbl 2 $* sy massObj_1 $+ sy massObj_2) $* sin (sy pendDisAngle_1 ) $- + (sy massObj_2 $* sy gravitationalMagnitude $* + sin (sy pendDisAngle_1 $- (exactDbl 2 $* sy pendDisAngle_2))) $- + ((exactDbl 2 $* sin (sy pendDisAngle_1 $- sy pendDisAngle_2 )) $* sy massObj_2 $* ( - square (sy angularVel_2) `mulRe` sy lenRod_2 `addRe` - (square (sy angularVel_1) `mulRe` sy lenRod_1 `mulRe` cos (sy pendDisAngle_1 $- sy pendDisAngle_2)) + square (sy angularVel_2) $* sy lenRod_2 $+ + (square (sy angularVel_1) $* sy lenRod_1 $* cos (sy pendDisAngle_1 $- sy pendDisAngle_2)) )) $/ - sy lenRod_1 `mulRe` + sy lenRod_1 $* ( - exactDbl 2 `mulRe` sy massObj_1 `addRe` sy massObj_2 $- - (sy massObj_2 `mulRe` - cos (exactDbl 2 `mulRe` sy pendDisAngle_1 $- (exactDbl 2 `mulRe` sy pendDisAngle_2))) + exactDbl 2 $* sy massObj_1 $+ sy massObj_2 $- + (sy massObj_2 $* + cos (exactDbl 2 $* sy pendDisAngle_1 $- (exactDbl 2 $* sy pendDisAngle_2))) ) -- Angular acceleration acting on the first object angularAccelExpr_2 :: PExpr -angularAccelExpr_2 = exactDbl 2 `mulRe` sin (sy pendDisAngle_1 $- sy pendDisAngle_2) `mulRe` +angularAccelExpr_2 = exactDbl 2 $* sin (sy pendDisAngle_1 $- sy pendDisAngle_2) $* ( - square (sy angularVel_1) `mulRe` sy lenRod_1 `mulRe` (sy massObj_1 `addRe` sy massObj_2 ) `addRe` - (sy gravitationalMagnitude `mulRe` (sy massObj_1 `addRe` sy massObj_2 ) `mulRe` cos (sy pendDisAngle_1)) `addRe` - (square (sy angularVel_2) `mulRe` sy lenRod_2 `mulRe` sy massObj_2 `mulRe` + square (sy angularVel_1) $* sy lenRod_1 $* (sy massObj_1 $+ sy massObj_2 ) $+ + (sy gravitationalMagnitude $* (sy massObj_1 $+ sy massObj_2 ) $* cos (sy pendDisAngle_1)) $+ + (square (sy angularVel_2) $* sy lenRod_2 $* sy massObj_2 $* cos (sy pendDisAngle_1 $- sy pendDisAngle_2 )) ) $/ - sy lenRod_2 `mulRe` + sy lenRod_2 $* ( - exactDbl 2 `mulRe` sy massObj_1 `addRe` sy massObj_2 $- - (sy massObj_2 `mulRe` - cos (exactDbl 2 `mulRe` sy pendDisAngle_1 $- (exactDbl 2 `mulRe` sy pendDisAngle_2))) + exactDbl 2 $* sy massObj_1 $+ sy massObj_2 $- + (sy massObj_2 $* + cos (exactDbl 2 $* sy pendDisAngle_1 $- (exactDbl 2 $* sy pendDisAngle_2))) ) -- Angular acceleration support equations in IM forceDerivExpr1 :: PExpr -forceDerivExpr1 = sy tension_2 `mulRe` sin (sy pendDisAngle_2) +forceDerivExpr1 = sy tension_2 $* sin (sy pendDisAngle_2) forceDerivExpr2 :: PExpr -forceDerivExpr2 = sy tension_2 `mulRe` cos (sy pendDisAngle_2) +forceDerivExpr2 = sy tension_2 $* cos (sy pendDisAngle_2) cosAngleExpr1 :: PExpr cosAngleExpr1 = cos (sy pendDisAngle_1) diff --git a/code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs b/code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs index e0b20489fe..43e20043a7 100644 --- a/code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs +++ b/code/drasil-example/dblpend/lib/Drasil/DblPend/ODEs.hs @@ -21,23 +21,23 @@ dblPenODEInfo = odeInfo (exactDbl 20) -- final time [dbl 1.3463968515384828, exactDbl 0, dbl 2.356194490192345, exactDbl 0] -- unit in radian [3*pi/7, 0, 3*pi/4, 0] [ o1, - neg g `mulRe` - (two `mulRe` m1 `addRe` m2) `mulRe` sin t1 $- - (m2 `mulRe` g `mulRe` sin (t1 $- (two `mulRe` t2))) $- - ((two `mulRe` sin (t1 $- t2 )) `mulRe` m2 `mulRe` - (square o2 `mulRe` l2 `addRe` - (square o1 `mulRe` l1 `mulRe` cos (t1 $- t2)))) + neg g $* + (two $* m1 $+ m2) $* sin t1 $- + (m2 $* g $* sin (t1 $- (two $* t2))) $- + ((two $* sin (t1 $- t2 )) $* m2 $* + (square o2 $* l2 $+ + (square o1 $* l1 $* cos (t1 $- t2)))) $/ - l1 `mulRe`(two `mulRe` m1 `addRe` m2 $- - (m2 `mulRe` cos (two `mulRe` t1 $- (two `mulRe` t2)))), + l1 $* (two $* m1 $+ m2 $- + (m2 $* cos (two $* t1 $- (two $* t2)))), o2, - two `mulRe` sin (t1 $- t2) `mulRe` - (square o1 `mulRe` l1 `mulRe` (m1 `addRe` m2 ) `addRe` - (g `mulRe` (m1 `addRe` m2 ) `mulRe` cos t1) `addRe` - (square o2 `mulRe` l2 `mulRe` m2 `mulRe` cos (t1 $- t2 ))) + two $* sin (t1 $- t2) $* + (square o1 $* l1 $* (m1 $+ m2 ) $+ + (g $* (m1 $+ m2 ) $* cos t1) $+ + (square o2 $* l2 $* m2 $* cos (t1 $- t2 ))) $/ - l2 `mulRe`(two `mulRe` m1 `addRe` m2 $- - (m2 `mulRe` cos (two `mulRe` t1 $- (two `mulRe` t2)))) + l2 $* (two $* m1 $+ m2 $- + (m2 $* cos (two $* t1 $- (two $* t2)))) ] dblPenODEOpts where t1 = idx (sy pendDisAngle) (int 0) -- t1 is theta 1 diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/DataDefs.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/DataDefs.hs index 2bfb031654..c3d34dc42c 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/DataDefs.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/DataDefs.hs @@ -43,7 +43,7 @@ ctrOfMass = mkQuantDef posCM ctrOfMassEqn -- FIXME (variable "i") is a horrible hack ctrOfMassEqn :: ModelExpr -ctrOfMassEqn = sumAll (variable "j") (sy massj `mulRe` sy posj) $/ sy mTot +ctrOfMassEqn = sumAll (variable "j") (sy massj $* sy posj) $/ sy mTot -- DD2 : Linear displacement -- @@ -199,7 +199,7 @@ chasles = mkQuantDef' velB (nounPhraseSP "Chasles' theorem") chaslesEqn -- The last two terms in the denominator should be cross products. chaslesEqn :: Expr -chaslesEqn = sy velO `addRe` cross (sy QP.angularVelocity) (sy rOB) +chaslesEqn = sy velO $+ cross (sy QP.angularVelocity) (sy rOB) chaslesThmNote :: Sentence chaslesThmNote = foldlSent [atStartNP (the QP.linearVelocity), @@ -218,7 +218,7 @@ impulseV :: SimpleQDef impulseV = mkQuantDef QP.impulseV impulseVEqn impulseVEqn :: Expr -impulseVEqn = sy QPP.mass `mulRe` sy QP.chgInVelocity +impulseVEqn = sy QPP.mass $* sy QP.chgInVelocity impulseVDesc :: Sentence impulseVDesc = foldlSent [S "An", getTandS QP.impulseV, S "occurs when a", @@ -289,7 +289,7 @@ kEnergy :: SimpleQDef kEnergy = mkQuantDef QP.kEnergy kEnergyEqn kEnergyEqn :: Expr -kEnergyEqn = sy QPP.mass `mulRe` half (square (norm (sy QP.velocity))) +kEnergyEqn = sy QPP.mass $* half (square (norm (sy QP.velocity))) kEnergyDesc :: Sentence kEnergyDesc = foldlSent [atStart QP.kEnergy `S.is` (QP.kEnergy ^. defn)] @@ -303,7 +303,7 @@ momentOfInertia :: ModelQDef momentOfInertia = mkQuantDef QP.momentOfInertia momentOfInertiaEqn momentOfInertiaEqn :: ModelExpr -momentOfInertiaEqn = sumAll (variable "j") $ sy massj `mulRe` square (sy rRot) +momentOfInertiaEqn = sumAll (variable "j") $ sy massj $* square (sy rRot) momentOfInertiaDesc :: Sentence momentOfInertiaDesc = foldlSent [S "The", getTandS QP.momentOfInertia, @@ -320,7 +320,7 @@ potEnergy :: SimpleQDef potEnergy = mkQuantDef QP.potEnergy potEnergyEqn potEnergyEqn :: Expr -potEnergyEqn = sy QPP.mass `mulRe` sy QP.gravitationalAccel `mulRe` sy QP.height +potEnergyEqn = sy QPP.mass $* sy QP.gravitationalAccel $* sy QP.height potEnergyDesc :: Sentence potEnergyDesc = foldlSent [atStartNP (the QP.potEnergy) `S.of_` diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Derivations.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Derivations.hs index 68cbf11f0e..12473e0843 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Derivations.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Derivations.hs @@ -11,17 +11,17 @@ import qualified Data.Drasil.Quantities.PhysicalProperties as QPP (mass) impulseVDerivEqn1 :: ModelExpr -impulseVDerivEqn1 = sy QP.force $= sy QPP.mass `mulRe` sy QP.acceleration - $= sy QPP.mass `mulRe` deriv (sy QP.velocity) QP.time +impulseVDerivEqn1 = sy QP.force $= sy QPP.mass $* sy QP.acceleration + $= sy QPP.mass $* deriv (sy QP.velocity) QP.time impulseVDerivEqn2 :: ModelExpr -- TODO: Why does defint take a symbol as an argument? Shouldn't it be a UID? impulseVDerivEqn2 = defint (eqSymb timeT) (sy time_1) (sy time_2) (sy QP.force) $= - sy QPP.mass `mulRe` defint (eqSymb QP.velocity) (sy velo_1) (sy velo_2) (exactDbl 1) + sy QPP.mass $* defint (eqSymb QP.velocity) (sy velo_1) (sy velo_2) (exactDbl 1) impulseVDerivEqn3 :: ModelExpr impulseVDerivEqn3 = defint (eqSymb timeT) (sy time_1) (sy time_2) (sy QP.force) - $= (sy QPP.mass `mulRe` sy velo_2) $- (sy QPP.mass `mulRe` sy velo_1) - $= sy QPP.mass `mulRe` sy QP.chgInVelocity + $= (sy QPP.mass $* sy velo_2) $- (sy QPP.mass $* sy velo_1) + $= sy QPP.mass $* sy QP.chgInVelocity impulseVDerivEqns :: [ModelExpr] impulseVDerivEqns = [impulseVDerivEqn1, impulseVDerivEqn2, impulseVDerivEqn3] diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Expressions.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Expressions.hs index 58014bdd57..378b475f9f 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Expressions.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Expressions.hs @@ -7,7 +7,7 @@ import Data.Drasil.Quantities.Physics (time, momentOfInertia, gravitationalAccel, angularVelocity) transMotExpr :: PExpr -transMotExpr = sy gravitationalAccel `addRe` (apply1 forcej time $/ sy massj) +transMotExpr = sy gravitationalAccel $+ (apply1 forcej time $/ sy massj) transMotExprDeriv1 :: (ModelExprC r, ExprC r) => r transMotExprDeriv1 = defines (sy angAccj) $ deriv (apply1 velj time) time diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/GenDefs.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/GenDefs.hs index b65898e184..4e9159e8eb 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/GenDefs.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/GenDefs.hs @@ -75,8 +75,8 @@ accelGravityDesc = foldlSent [S "If one of the", plural QPP.mass, S "is much lar phrase QP.force] accelGravityExpr :: PExpr -accelGravityExpr = neg ((sy QP.gravitationalConst `mulRe` sy mLarger $/ - square (sy dispNorm)) `mulRe` sy dVect) +accelGravityExpr = neg ((sy QP.gravitationalConst $* sy mLarger $/ + square (sy dispNorm)) $* sy dVect) accelGravitySrc :: Reference accelGravitySrc = makeURI "accelGravitySrc" "https://en.wikipedia.org/wiki/Gravitational_acceleration" $ @@ -120,22 +120,22 @@ accelGravityDerivSentence5 = [S "and thus the negative sign indicates that the", S "an attractive", phrase QP.force] accelGravityDerivEqn1 :: PExpr -accelGravityDerivEqn1 = sy QP.force $= (sy QP.gravitationalConst `mulRe` (sy mass_1 `mulRe` sy mass_2) $/ - sy sqrDist) `mulRe` sy dVect +accelGravityDerivEqn1 = sy QP.force $= (sy QP.gravitationalConst $* (sy mass_1 $* sy mass_2) $/ + sy sqrDist) $* sy dVect accelGravityDerivEqn2 :: PExpr accelGravityDerivEqn2 = sy dVect $= (sy distMass $/ sy dispNorm) accelGravityDerivEqn3 :: PExpr -accelGravityDerivEqn3 = sy QP.fOfGravity $= sy QP.gravitationalConst `mulRe` - (sy mLarger `mulRe` sy QPP.mass $/ sy sqrDist) `mulRe` sy dVect - $= sy QPP.mass `mulRe` sy QP.gravitationalAccel +accelGravityDerivEqn3 = sy QP.fOfGravity $= sy QP.gravitationalConst $* + (sy mLarger $* sy QPP.mass $/ sy sqrDist) $* sy dVect + $= sy QPP.mass $* sy QP.gravitationalAccel accelGravityDerivEqn4 :: PExpr -accelGravityDerivEqn4 = sy QP.gravitationalConst `mulRe` (sy mLarger $/ sy sqrDist) `mulRe` sy dVect $= sy QP.gravitationalAccel +accelGravityDerivEqn4 = sy QP.gravitationalConst $* (sy mLarger $/ sy sqrDist) $* sy dVect $= sy QP.gravitationalAccel accelGravityDerivEqn5 :: PExpr -accelGravityDerivEqn5 = sy QP.gravitationalAccel $= neg (sy QP.gravitationalConst `mulRe` (sy mLarger $/ sy sqrDist)) `mulRe` sy dVect +accelGravityDerivEqn5 = sy QP.gravitationalAccel $= neg (sy QP.gravitationalConst $* (sy mLarger $/ sy sqrDist)) $* sy dVect accelGravityDerivEqns :: (ExprC r, LiteralC r) => [r] accelGravityDerivEqns = [accelGravityDerivEqn1, accelGravityDerivEqn2, accelGravityDerivEqn3, @@ -153,10 +153,10 @@ impulseQD :: ModelQDef impulseQD = mkQuantDef' QP.impulseS (nounPhraseSP "Impulse for Collision") impulseExpr impulseExpr :: PExpr -impulseExpr = (neg (exactDbl 1 `addRe` sy QP.restitutionCoef) `mulRe` sy initRelVel $. - sy normalVect) $/ ((recip_ (sy massA) `addRe` recip_ (sy massB)) `mulRe` - square (sy normalLen) `addRe` - (square (sy perpLenA) $/ sy momtInertA) `addRe` +impulseExpr = (neg (exactDbl 1 $+ sy QP.restitutionCoef) $* sy initRelVel $. + sy normalVect) $/ ((recip_ (sy massA) $+ recip_ (sy massB)) $* + square (sy normalLen) $+ + (square (sy perpLenA) $/ sy momtInertA) $+ (square (sy perpLenB) $/ sy momtInertB)) impulseSrc :: Reference diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/IMods.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/IMods.hs index 8259091390..0a8519236e 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/IMods.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/IMods.hs @@ -136,8 +136,8 @@ col2DNP :: NP col2DNP = nounPhraseSP "Collisions on 2D rigid bodies" col2DExpr {-, im3Rel2, im3Rel3, im3Rel4 -} :: Expr -- FIXME: add proper equation -col2DExpr = apply1 velA time `addRe` - ((sy impulseS $/ sy massA) `mulRe` sy normalVect) +col2DExpr = apply1 velA time $+ + ((sy impulseS $/ sy massA) $* sy normalVect) col2DOutputs, impulseNote :: Sentence diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/TMods.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/TMods.hs index 94e29f254c..ee113b3e10 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/TMods.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/TMods.hs @@ -48,8 +48,8 @@ newtonTLNote = foldlSent [(S "Every action has an equal and opposite reaction" ! -- FIXME: Missing ConceptDomain! newtonLUGModel :: ModelKind ModelExpr newtonLUGModel = equationalRealm' $ mkMultiDefnForQuant newtonForceQuant EmptyS $ NE.fromList [ - mkDefiningExpr "newtonLUGviaDeriv" [] EmptyS (sy gravitationalConst `mulRe` (sy mass_1 `mulRe` sy mass_2 $/ square (sy dispNorm)) `mulRe` sy dVect), - mkDefiningExpr "newtonLUGviaForm" [] EmptyS (sy gravitationalConst `mulRe` (sy mass_1 `mulRe` sy mass_2 $/ square (sy dispNorm)) `mulRe` (sy distMass $/ sy dispNorm)) + mkDefiningExpr "newtonLUGviaDeriv" [] EmptyS (sy gravitationalConst $* (sy mass_1 $* sy mass_2 $/ square (sy dispNorm)) $* sy dVect), + mkDefiningExpr "newtonLUGviaForm" [] EmptyS (sy gravitationalConst $* (sy mass_1 $* sy mass_2 $/ square (sy dispNorm)) $* (sy distMass $/ sy dispNorm)) ] newtonLUG :: TheoryModel @@ -66,7 +66,7 @@ newtonForceQuant = mkQuant' "force" (nounPhraseSP "Newton's law of universal gra -- verbal description instead. -- Can't properly include the gravitational constant in a sentence (in the last --- sentence, supposed to include "6.673 `mulRe` 10^{-11} m/kgs^2" (line 187)). +-- sentence, supposed to include "6.673 $* 10^{-11} m/kgs^2" (line 187)). newtonLUGNotes :: [Sentence] newtonLUGNotes = [foldlSent @@ -86,7 +86,7 @@ newtonSLRQD :: ModelQDef newtonSLRQD = mkQuantDef' torque (nounPhraseSP "Newton's second law for rotational motion") newtonSLRExpr newtonSLRExpr :: PExpr -newtonSLRExpr = sy momentOfInertia `mulRe` sy angularAccel +newtonSLRExpr = sy momentOfInertia $* sy angularAccel newtonSLRNotes :: [Sentence] newtonSLRNotes = map foldlSent [ diff --git a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Unitals.hs b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Unitals.hs index d9f015fee2..cb4f87b1e0 100644 --- a/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Unitals.hs +++ b/code/drasil-example/gamephysics/lib/Drasil/GamePhysics/Unitals.hs @@ -327,7 +327,7 @@ mmntOfInCons = constrained' QP.momentOfInertia [gtZeroConstr] (dbl 74.5) gravAccelCons = constrained' QP.gravitationalConst [] (lit $ QP.gravitationalConstValue ^. defnExpr) posCons = constrained' QP.position [] (dbl 0.412) --FIXME: should be (0.412, 0.502) vector veloCons = constrained' QP.velocity [] (dbl 2.51) -orientCons = constrained' QM.orientation [sfwrc $ Bounded (Inc, exactDbl 0) (Inc, exactDbl 2 `mulRe` sy QM.pi_)] (half $ sy QM.pi_) -- physical constraint not needed space is radians +orientCons = constrained' QM.orientation [sfwrc $ Bounded (Inc, exactDbl 0) (Inc, exactDbl 2 $* sy QM.pi_)] (half $ sy QM.pi_) -- physical constraint not needed space is radians angVeloCons = constrained' QP.angularVelocity [] (dbl 2.1) forceCons = constrained' QP.force [] (dbl 98.1) torqueCons = constrained' QP.torque [] (exactDbl 200) diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs index e328574d43..e704ba0a0b 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/DataDefs.hs @@ -27,7 +27,7 @@ dataDefs = [hFromt, loadDF, glaTyFac, standOffDis, aspRat, eqTNTWDD, calofDemand {--} hFromtEq :: Relation -hFromtEq = frac 1 1000 `mulRe` incompleteCase (zipWith hFromtHelper +hFromtEq = frac 1 1000 $* incompleteCase (zipWith hFromtHelper actualThicknesses nominalThicknesses) hFromtHelper :: Double -> Double -> (Expr, Relation) @@ -69,7 +69,7 @@ glaTyFac = ddE glaTyFacQD [dRef astm2009] Nothing "gTF" {--} standOffDisEq :: Expr -standOffDisEq = sqrt (square (sy sdx) `addRe` square (sy sdy) `addRe` square (sy sdz)) +standOffDisEq = sqrt (square (sy sdx) $+ square (sy sdy) $+ square (sy sdz)) standOffDisQD :: SimpleQDef standOffDisQD = mkQuantDef standOffDist standOffDisEq @@ -91,7 +91,7 @@ aspRat = ddE aspRatQD [dRef astm2009] Nothing "aspectRatio" [aGrtrThanB] {--} eqTNTWEq :: Expr -eqTNTWEq = mulRe (sy charWeight) (sy tNT) +eqTNTWEq = sy charWeight $* sy tNT eqTNTWQD :: SimpleQDef eqTNTWQD = mkQuantDef eqTNTWeight eqTNTWEq diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs index e34fae057a..d8768ebb4d 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/IMods.hs @@ -58,8 +58,8 @@ risk = imNoDeriv (equationalModelN (riskFun ^. term) riskQD) -- FIXME [4] !!! riskQD :: SimpleQDef riskQD = mkQuantDef riskFun ((sy sflawParamK $/ - (mulRe (sy plateLen) (sy plateWidth) $^ (sy sflawParamM $- exactDbl 1))) `mulRe` - ((sy modElas `mulRe` square (sy minThick)) $^ sy sflawParamM) `mulRe` sy lDurFac `mulRe` exp (sy stressDistFac)) + (sy plateLen $* sy plateWidth $^ (sy sflawParamM $- exactDbl 1))) $* + ((sy modElas $* square (sy minThick)) $^ sy sflawParamM) $* sy lDurFac $* exp (sy stressDistFac)) {--} @@ -87,8 +87,8 @@ nonFL = imNoDeriv (equationalModelN (nonFactorL ^. term) nonFLQD) [qHtTlTolRef, stdVals [modElas], hRef, aGrtrThanB] nonFLEq :: Expr -nonFLEq = mulRe (mulRe (sy tolLoad) (sy modElas)) (sy minThick $^ exactDbl 4) $/ - square (mulRe (sy plateLen) (sy plateWidth)) +nonFLEq = (sy tolLoad $* sy modElas) $* (sy minThick $^ exactDbl 4) $/ + square (sy plateLen $* sy plateWidth) nonFLQD :: SimpleQDef nonFLQD = mkQuantDef nonFactorL nonFLEq @@ -102,8 +102,8 @@ dimLL = imNoDeriv (equationalModelN (dimlessLoad ^. term) dimLLQD) "dimlessLoad" [qRef, aGrtrThanB, stdVals [modElas], hRef, gtfRef] dimLLEq :: Expr -dimLLEq = mulRe (sy demand) (square (mulRe (sy plateLen) (sy plateWidth))) - $/ mulRe (mulRe (sy modElas) (sy minThick $^ exactDbl 4)) (sy gTF) +dimLLEq = sy demand $* square (sy plateLen $* sy plateWidth) + $/ (sy modElas $* (sy minThick $^ exactDbl 4)) $* sy gTF dimLLQD :: SimpleQDef dimLLQD = mkQuantDef dimlessLoad dimLLEq @@ -134,9 +134,9 @@ tolStrDisFac = imNoDeriv (equationalModelN (sdfTol ^. term) tolStrDisFacQD) tolStrDisFacQD :: SimpleQDef tolStrDisFacQD = mkQuantDef sdfTol $ ln (ln (recip_ (exactDbl 1 $- sy pbTol)) - `mulRe` ((sy plateLen `mulRe` sy plateWidth) $^ (sy sflawParamM $- exactDbl 1) $/ - (sy sflawParamK `mulRe` ((sy modElas `mulRe` - square (sy minThick)) $^ sy sflawParamM) `mulRe` sy lDurFac))) + $* ((sy plateLen $* sy plateWidth) $^ (sy sflawParamM $- exactDbl 1) $/ + (sy sflawParamK $* ((sy modElas $* + square (sy minThick)) $^ sy sflawParamM) $* sy lDurFac))) {--} @@ -156,7 +156,7 @@ calofCapacity = imNoDeriv (equationalModelN (lRe ^. term) calofCapacityQD) [dRef astm2009] "calofCapacity" [lrCap, nonFLRef, gtfRef] calofCapacityQD :: SimpleQDef -calofCapacityQD = mkQuantDef lRe (sy (nonFL ^. output) `mulRe` sy (glaTyFac ^. defLhs) `mulRe` sy loadSF) +calofCapacityQD = mkQuantDef lRe (sy (nonFL ^. output) $* sy (glaTyFac ^. defLhs) $* sy loadSF) {--} diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/ModuleDefs.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/ModuleDefs.hs index 20f054198c..385e07caef 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/ModuleDefs.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/ModuleDefs.hs @@ -97,21 +97,21 @@ slope (x1, y1) (x2, y2) = (y2 $- y1) $/ (x2 $- x1) -- Given two points (x1,y1) and (x2,y2), and an x ordinate, return -- extrapoled y on the straight line in between onLine :: (CodeExpr, CodeExpr) -> (CodeExpr, CodeExpr) -> CodeExpr -> CodeExpr -onLine p1@(x1, y1) p2 x_ = (m `mulRe` (x_ $- x1)) `addRe` y1 +onLine p1@(x1, y1) p2 x_ = (m $* (x_ $- x1)) $+ y1 where m = slope p1 p2 ------------------------------------------------------------------------------------------ -- Code Template helper functions vLook :: (HasSymbol a, HasSymbol i, HasUID a, HasUID i) => a -> i -> CodeExpr -> CodeExpr -vLook a i_ p = idx (sy a) (sy i_ `addI` p) +vLook a i_ p = idx (sy a) (sy i_ $+ p) aLook :: (HasSymbol a, HasSymbol i, HasSymbol j, HasUID a, HasUID i, HasUID j) => a -> i -> j -> CodeExpr aLook a i_ j_ = idx (idx (sy a) (sy i_)) (sy j_) getCol :: (HasSymbol a, HasSymbol i, HasUID a, HasUID i) => a -> i -> CodeExpr -> CodeExpr -getCol a_ i_ p = apply (asVC extractColumnCT) [sy a_, sy i_ `addI` p] +getCol a_ i_ p = apply (asVC extractColumnCT) [sy a_, sy i_ $+ p] call :: Func -> [QuantityDict] -> FuncStmt call f l = FVal $ apply (asVC f) $ map sy l diff --git a/code/drasil-example/hghc/lib/Drasil/HGHC/HeatTransfer.hs b/code/drasil-example/hghc/lib/Drasil/HGHC/HeatTransfer.hs index 91d7a68713..559ae12ff6 100644 --- a/code/drasil-example/hghc/lib/Drasil/HGHC/HeatTransfer.hs +++ b/code/drasil-example/hghc/lib/Drasil/HGHC/HeatTransfer.hs @@ -47,8 +47,8 @@ htTransCladCool = fromEqn "htTransCladCool" (nounPhraseSP EmptyS (sub lH lClad) Real heatTransferCoef htTransCladCoolEq htTransCladCoolEq = - exactDbl 2 `mulRe` sy cladCond `mulRe` sy coolFilmCond $/ (exactDbl 2 `mulRe` sy cladCond `addRe` (sy cladThick - `mulRe` sy coolFilmCond)) + exactDbl 2 $* sy cladCond $* sy coolFilmCond $/ (exactDbl 2 $* sy cladCond $+ (sy cladThick + $* sy coolFilmCond)) --- @@ -60,8 +60,8 @@ htTransCladFuel = fromEqn "htTransCladFuel" (nounPhraseSP "effective heat transfer coefficient between clad and fuel surface") EmptyS (sub lH lEffective) Real heatTransferCoef htTransCladFuelEq -htTransCladFuelEq = (exactDbl 2 `mulRe` sy cladCond `mulRe` sy gapFilmCond) $/ (exactDbl 2 `mulRe` sy cladCond - `addRe` (sy cladThick `mulRe` sy gapFilmCond)) +htTransCladFuelEq = (exactDbl 2 $* sy cladCond $* sy gapFilmCond) $/ (exactDbl 2 $* sy cladCond + $+ (sy cladThick $* sy gapFilmCond)) --- diff --git a/code/drasil-example/pdcontroller/lib/Drasil/PDController/DataDefs.hs b/code/drasil-example/pdcontroller/lib/Drasil/PDController/DataDefs.hs index 074d533bdb..3750dc5ff0 100644 --- a/code/drasil-example/pdcontroller/lib/Drasil/PDController/DataDefs.hs +++ b/code/drasil-example/pdcontroller/lib/Drasil/PDController/DataDefs.hs @@ -51,7 +51,7 @@ ddPropCtrlDefn :: SimpleQDef ddPropCtrlDefn = mkQuantDef qdPropControlFD ddPropCtrlEqn ddPropCtrlEqn :: Expr -ddPropCtrlEqn = sy qdPropGain `mulRe` sy qdProcessErrorFD +ddPropCtrlEqn = sy qdPropGain $* sy qdProcessErrorFD ddPropCtrlNote :: Sentence ddPropCtrlNote @@ -73,7 +73,7 @@ ddDerivCtrlDefn = mkQuantDef qdDerivativeControlFD ddDerivCtrlEqn ddDerivCtrlEqn :: Expr ddDerivCtrlEqn - = sy qdDerivGain `mulRe` sy qdProcessErrorFD `mulRe` sy qdFreqDomain + = sy qdDerivGain $* sy qdProcessErrorFD $* sy qdFreqDomain ddDerivCtrlNote :: Sentence ddDerivCtrlNote @@ -96,8 +96,8 @@ ddCtrlVarDefn = mkQuantDef qdCtrlVarFD ddCtrlEqn ddCtrlEqn :: Expr ddCtrlEqn - = sy qdProcessErrorFD `mulRe` (sy qdPropGain `addRe` - (sy qdDerivGain `mulRe` sy qdFreqDomain)) + = sy qdProcessErrorFD $* (sy qdPropGain $+ + (sy qdDerivGain $* sy qdFreqDomain)) ddCtrlNote :: Sentence ddCtrlNote diff --git a/code/drasil-example/pdcontroller/lib/Drasil/PDController/GenDefs.hs b/code/drasil-example/pdcontroller/lib/Drasil/PDController/GenDefs.hs index da84c066de..785b4da26c 100644 --- a/code/drasil-example/pdcontroller/lib/Drasil/PDController/GenDefs.hs +++ b/code/drasil-example/pdcontroller/lib/Drasil/PDController/GenDefs.hs @@ -35,7 +35,7 @@ gdPowerPlantRC gdPowerPlantEqn :: Expr gdPowerPlantEqn - = recip_ (square (sy qdFreqDomain) `addRe` sy qdFreqDomain `addRe` exactDbl 20) + = recip_ (square (sy qdFreqDomain) $+ sy qdFreqDomain $+ exactDbl 20) gdPowerPlantNote :: Sentence gdPowerPlantNote diff --git a/code/drasil-example/pdcontroller/lib/Drasil/PDController/IModel.hs b/code/drasil-example/pdcontroller/lib/Drasil/PDController/IModel.hs index 5c914d2d27..9e44384afd 100644 --- a/code/drasil-example/pdcontroller/lib/Drasil/PDController/IModel.hs +++ b/code/drasil-example/pdcontroller/lib/Drasil/PDController/IModel.hs @@ -42,14 +42,14 @@ imPDRC "imPDRC" (nounPhraseSP "Computation of the Process Variable as a function of time") EmptyS - where lhs = [exactDbl 1 `addRe` sy qdDerivGain $* (opProcessVariable $^^ 1)] - $+ (exactDbl 1 $* (opProcessVariable $^^ 2)) - $+ (exactDbl 20 `addRe` sy qdPropGain $* (opProcessVariable $^^ 0)) - rhs = sy qdSetPointTD `mulRe` sy qdPropGain + where lhs = [exactDbl 1 $+ sy qdDerivGain $** (opProcessVariable $^^ 1)] + $++ (exactDbl 1 $** (opProcessVariable $^^ 2)) + $++ (exactDbl 20 $+ sy qdPropGain $** (opProcessVariable $^^ 0)) + rhs = sy qdSetPointTD $* sy qdPropGain -- Matrix form: - -- coeffs = [[exactDbl 1, exactDbl 1 `addRe` sy qdDerivGain, exactDbl 20 `addRe` sy qdPropGain]] + -- coeffs = [[exactDbl 1, exactDbl 1 $+ sy qdDerivGain, exactDbl 20 $+ sy qdPropGain]] -- unknowns = [2, 1, 0] - -- constants = [sy qdSetPointTD `mulRe` sy qdPropGain] + -- constants = [sy qdSetPointTD $* sy qdPropGain] imDeriv :: Derivation imDeriv @@ -74,19 +74,19 @@ derivEqn1 :: ModelExpr derivEqn1 = sy qdProcessVariableFD $= (sy qdSetPointFD $- sy qdProcessVariableFD) - `mulRe` (sy qdPropGain `addRe` (sy qdDerivGain `mulRe` sy qdFreqDomain)) - `mulRe` recip_ (square (sy qdFreqDomain) `addRe` sy qdFreqDomain `addRe` exactDbl 20) + $* (sy qdPropGain $+ (sy qdDerivGain $* sy qdFreqDomain)) + $* recip_ (square (sy qdFreqDomain) $+ sy qdFreqDomain $+ exactDbl 20) derivStmt2 :: Sentence derivStmt2 = (S "Substituting the values and rearranging the equation" !.) derivEqn2 :: ModelExpr derivEqn2 - = square (sy qdFreqDomain) `mulRe` sy qdProcessVariableFD - `addRe` ((exactDbl 1 `addRe` sy qdDerivGain) `mulRe` sy qdProcessVariableFD `mulRe` sy qdFreqDomain) - `addRe` ((exactDbl 20 `addRe` sy qdPropGain) `mulRe` sy qdProcessVariableFD) - $- (sy qdSetPointFD `mulRe` sy qdFreqDomain `mulRe` sy qdDerivGain) - $- (sy qdSetPointFD `mulRe` sy qdPropGain) $= exactDbl 0 + = square (sy qdFreqDomain) $* sy qdProcessVariableFD + $+ ((exactDbl 1 $+ sy qdDerivGain) $* sy qdProcessVariableFD $* sy qdFreqDomain) + $+ ((exactDbl 20 $+ sy qdPropGain) $* sy qdProcessVariableFD) + $- (sy qdSetPointFD $* sy qdFreqDomain $* sy qdDerivGain) + $- (sy qdSetPointFD $* sy qdPropGain) $= exactDbl 0 derivStmt3 :: Sentence derivStmt3 @@ -95,11 +95,11 @@ derivStmt3 derivEqn3 :: ModelExpr derivEqn3 - = deriv (deriv (sy qdProcessVariableTD) time) time `addRe` - (((exactDbl 1 `addRe` sy qdDerivGain) `mulRe` deriv (sy qdProcessVariableTD) time) - `addRe` ((exactDbl 20 `addRe` sy qdPropGain) `mulRe` sy qdProcessVariableTD)) - $- (sy qdDerivGain `mulRe` deriv (sy qdSetPointTD) time) - $- (sy qdSetPointTD `mulRe` sy qdPropGain) $= exactDbl 0 + = deriv (deriv (sy qdProcessVariableTD) time) time $+ + (((exactDbl 1 $+ sy qdDerivGain) $* deriv (sy qdProcessVariableTD) time) + $+ ((exactDbl 20 $+ sy qdPropGain) $* sy qdProcessVariableTD)) + $- (sy qdDerivGain $* deriv (sy qdSetPointTD) time) + $- (sy qdSetPointTD $* sy qdPropGain) $= exactDbl 0 derivStmt4 :: Sentence derivStmt4 @@ -112,7 +112,7 @@ derivStmt4 derivEqn4 :: ModelExpr derivEqn4 - = deriv (deriv (sy qdProcessVariableTD) time) time `addRe` - ((exactDbl 1 `addRe` sy qdDerivGain) `mulRe` deriv (sy qdProcessVariableTD) time) - `addRe` ((exactDbl 20 `addRe` sy qdPropGain) `mulRe` sy qdProcessVariableTD) - $- (sy qdSetPointTD `mulRe` sy qdPropGain) $= exactDbl 0 + = deriv (deriv (sy qdProcessVariableTD) time) time $+ + ((exactDbl 1 $+ sy qdDerivGain) $* deriv (sy qdProcessVariableTD) time) + $+ ((exactDbl 20 $+ sy qdPropGain) $* sy qdProcessVariableTD) + $- (sy qdSetPointTD $* sy qdPropGain) $= exactDbl 0 diff --git a/code/drasil-example/pdcontroller/lib/Drasil/PDController/TModel.hs b/code/drasil-example/pdcontroller/lib/Drasil/PDController/TModel.hs index 37d4c8694b..73516814f5 100644 --- a/code/drasil-example/pdcontroller/lib/Drasil/PDController/TModel.hs +++ b/code/drasil-example/pdcontroller/lib/Drasil/PDController/TModel.hs @@ -38,7 +38,7 @@ laplaceRel :: Relation laplaceRel = sy qdLaplaceTransform $= defint (eqSymb time) (sy negInf) (sy posInf) (sy qdFxnTDomain - `mulRe` DrasilLang.exp (neg (sy qdFreqDomain) `mulRe` sy time)) + $* DrasilLang.exp (neg (sy qdFreqDomain) $* sy time)) laplaceDesc :: Sentence laplaceDesc @@ -100,9 +100,9 @@ tmSOSystemRC soSystemRel :: Relation soSystemRel = exactDbl 1 - $/ (sy mass `mulRe` square (sy qdFreqDomain) - `addRe` (sy qdDampingCoeff `mulRe` sy qdFreqDomain) - `addRe` sy qdStiffnessCoeff) + $/ (sy mass $* square (sy qdFreqDomain) + $+ (sy qdDampingCoeff $* sy qdFreqDomain) + $+ sy qdStiffnessCoeff) soSystemDesc :: Sentence soSystemDesc diff --git a/code/drasil-example/projectile/lib/Drasil/Projectile/DataDefs.hs b/code/drasil-example/projectile/lib/Drasil/Projectile/DataDefs.hs index bcf12d17f6..8f0da0a51e 100644 --- a/code/drasil-example/projectile/lib/Drasil/Projectile/DataDefs.hs +++ b/code/drasil-example/projectile/lib/Drasil/Projectile/DataDefs.hs @@ -21,8 +21,8 @@ speedIX = ddENoRefs speedIXQD Nothing "speedIX" [speedRef, figRef] speedIY = ddENoRefs speedIYQD Nothing "speedIY" [speedRef, figRef] speedIXQD, speedIYQD :: SimpleQDef -speedIXQD = mkQuantDef ixVel $ sy iSpeed `mulRe` cos (sy launAngle) -speedIYQD = mkQuantDef iyVel $ sy iSpeed `mulRe` sin (sy launAngle) +speedIXQD = mkQuantDef ixVel $ sy iSpeed $* cos (sy launAngle) +speedIYQD = mkQuantDef iyVel $ sy iSpeed $* sin (sy launAngle) ---------- speedRef :: Sentence diff --git a/code/drasil-example/projectile/lib/Drasil/Projectile/Derivations.hs b/code/drasil-example/projectile/lib/Drasil/Projectile/Derivations.hs index 5ddd792ec1..2012f45a92 100644 --- a/code/drasil-example/projectile/lib/Drasil/Projectile/Derivations.hs +++ b/code/drasil-example/projectile/lib/Drasil/Projectile/Derivations.hs @@ -19,19 +19,19 @@ timeDeriv :: [ModelExpr] timeDeriv = [timeDerivEqn1, timeDerivEqn2, timeDerivEqn3, timeDerivEqn4] timeDerivEqn1, timeDerivEqn2, timeDerivEqn3, timeDerivEqn4 :: ModelExpr -timeDerivEqn1 = sy yPos $= (sy iyVel `mulRe` sy time) $- half (sy gravitationalAccelConst `mulRe` square (sy time)) -timeDerivEqn2 = (sy iyVel `mulRe` sy flightDur) $- half (sy gravitationalAccelConst `mulRe` square (sy flightDur)) $= exactDbl 0 -timeDerivEqn3 = sy iyVel $- half (sy gravitationalAccelConst `mulRe` sy flightDur) $= exactDbl 0 -timeDerivEqn4 = sy flightDur $= exactDbl 2 `mulRe` sy iyVel $/ sy gravitationalAccelConst +timeDerivEqn1 = sy yPos $= (sy iyVel $* sy time) $- half (sy gravitationalAccelConst $* square (sy time)) +timeDerivEqn2 = (sy iyVel $* sy flightDur) $- half (sy gravitationalAccelConst $* square (sy flightDur)) $= exactDbl 0 +timeDerivEqn3 = sy iyVel $- half (sy gravitationalAccelConst $* sy flightDur) $= exactDbl 0 +timeDerivEqn4 = sy flightDur $= exactDbl 2 $* sy iyVel $/ sy gravitationalAccelConst -- landPosDeriv :: [ModelExpr] landPosDeriv = [landPosDerivEqn1, landPosDerivEqn2, landPosDerivEqn3] landPosDerivEqn1, landPosDerivEqn2, landPosDerivEqn3 :: ModelExpr -landPosDerivEqn1 = sy xPos $= sy ixVel `mulRe` sy time -landPosDerivEqn2 = sy landPos $= sy ixVel `mulRe` exactDbl 2 `mulRe` sy launSpeed `mulRe` sin (sy launAngle) $/ sy gravitationalAccelConst -landPosDerivEqn3 = sy landPos $= sy launSpeed `mulRe` cos (sy launAngle) `mulRe` exactDbl 2 `mulRe` sy launSpeed `mulRe` sin (sy launAngle) $/ sy gravitationalAccelConst +landPosDerivEqn1 = sy xPos $= sy ixVel $* sy time +landPosDerivEqn2 = sy landPos $= sy ixVel $* exactDbl 2 $* sy launSpeed $* sin (sy launAngle) $/ sy gravitationalAccelConst +landPosDerivEqn3 = sy landPos $= sy launSpeed $* cos (sy launAngle) $* exactDbl 2 $* sy launSpeed $* sin (sy launAngle) $/ sy gravitationalAccelConst -- @@ -52,4 +52,4 @@ rectPosDerivEqn1 = sy speed $= deriv (sy scalarPos) time rectPosDerivEqn2 = defint (eqSymb scalarPos) (sy iPos) (sy scalarPos) (exactDbl 1) $= defint (eqSymb time) (exactDbl 0) (sy time) (sy speed) rectPosDerivEqn3 = defint (eqSymb scalarPos) (sy iPos) (sy scalarPos) (exactDbl 1) $= - defint (eqSymb time) (exactDbl 0) (sy time) (sy QP.iSpeed `addRe` (sy QP.constAccel `mulRe` sy time)) + defint (eqSymb time) (exactDbl 0) (sy time) (sy QP.iSpeed $+ (sy QP.constAccel $* sy time)) diff --git a/code/drasil-example/projectile/lib/Drasil/Projectile/Expressions.hs b/code/drasil-example/projectile/lib/Drasil/Projectile/Expressions.hs index b78f5e74a6..1993b5191e 100644 --- a/code/drasil-example/projectile/lib/Drasil/Projectile/Expressions.hs +++ b/code/drasil-example/projectile/lib/Drasil/Projectile/Expressions.hs @@ -15,7 +15,7 @@ import Data.Drasil.Quantities.Physics (gravitationalAccel, gravitationalAccelCon import Drasil.Projectile.Unitals (launAngle, launSpeed, targPos, tol, landPos, offset) flightDur', iyPos, yConstAccel, iSpeed :: PExpr -flightDur' = exactDbl 2 `mulRe` sy launSpeed `mulRe` sin (sy launAngle) $/ sy gravitationalAccelConst +flightDur' = exactDbl 2 $* sy launSpeed $* sin (sy launAngle) $/ sy gravitationalAccelConst iyPos = exactDbl 0 -- launchOrigin yConstAccel = neg $ sy gravitationalAccelConst -- accelYGravity iSpeed = sy launSpeed @@ -31,27 +31,27 @@ message = completeCase [case1, case2, case3] -- speed' :: PExpr -speed' = sy QP.iSpeed `addRe` (sy QP.constAccel `mulRe` sy time) +speed' = sy QP.iSpeed $+ (sy QP.constAccel $* sy time) scalarPos' :: PExpr -scalarPos' = sy iPos `addRe` (sy QP.iSpeed `mulRe` sy time `addRe` half (sy QP.constAccel `mulRe` square (sy time))) +scalarPos' = sy iPos $+ (sy QP.iSpeed $* sy time $+ half (sy QP.constAccel $* square (sy time))) rectNoTime :: PExpr -rectNoTime = square (sy speed) $= square (sy QP.iSpeed) `addRe` (exactDbl 2 `mulRe` sy QP.constAccel `mulRe` (sy scalarPos $- sy iPos)) +rectNoTime = square (sy speed) $= square (sy QP.iSpeed) $+ (exactDbl 2 $* sy QP.constAccel $* (sy scalarPos $- sy iPos)) -- velVecExpr :: PExpr -velVecExpr = vec2D (sy ixVel `addRe` (sy QP.xConstAccel `mulRe` sy time)) (sy iyVel `addRe` (sy QP.yConstAccel `mulRe` sy time)) +velVecExpr = vec2D (sy ixVel $+ (sy QP.xConstAccel $* sy time)) (sy iyVel $+ (sy QP.yConstAccel $* sy time)) -- posVecExpr :: PExpr posVecExpr = vec2D - (sy QP.ixPos `addRe` (sy ixVel `mulRe` sy time) `addRe` half (sy QP.xConstAccel `mulRe` square (sy time))) - (sy QP.iyPos `addRe` (sy iyVel `mulRe` sy time) `addRe` half (sy QP.yConstAccel `mulRe` square (sy time))) + (sy QP.ixPos $+ (sy ixVel $* sy time) $+ half (sy QP.xConstAccel $* square (sy time))) + (sy QP.iyPos $+ (sy iyVel $* sy time) $+ half (sy QP.yConstAccel $* square (sy time))) -- landPosExpr :: PExpr -landPosExpr = exactDbl 2 `mulRe` square (sy launSpeed) `mulRe` sin (sy launAngle) `mulRe` cos (sy launAngle) $/ sy gravitationalAccelConst +landPosExpr = exactDbl 2 $* square (sy launSpeed) $* sin (sy launAngle) $* cos (sy launAngle) $/ sy gravitationalAccelConst -- Helper expressions that represent the vectors of quantities as components positionXY, velocityXY, accelerationXY, constAccelXY :: PExpr @@ -63,12 +63,12 @@ constAccelXY = sy constAccelV $= vec2D (sy QP.xConstAccel) (sy QP.yConstAccel -- Expressions for Lesson horizVel, horizPos :: PExpr horizVel = sy xVel $= sy ixVel -horizPos = sy xPos $= sy QP.ixPos `addRe` (sy ixVel `mulRe` sy time) +horizPos = sy xPos $= sy QP.ixPos $+ (sy ixVel $* sy time) vertVel, vertPos, vertNoTime :: PExpr -vertVel = sy yVel $= sy iyVel $- (sy gravitationalAccel `mulRe` sy time) -vertPos = sy yPos $= sy QP.iyPos `addRe` (sy iyVel `mulRe` sy time) $- (sy gravitationalAccel `mulRe` square (sy time) $/ exactDbl 2) -vertNoTime = square (sy yVel) $= square (sy iyVel) $- (exactDbl 2 `mulRe` sy gravitationalAccel `mulRe` (sy yPos $- sy QP.iyPos)) +vertVel = sy yVel $= sy iyVel $- (sy gravitationalAccel $* sy time) +vertPos = sy yPos $= sy QP.iyPos $+ (sy iyVel $* sy time) $- (sy gravitationalAccel $* square (sy time) $/ exactDbl 2) +vertNoTime = square (sy yVel) $= square (sy iyVel) $- (exactDbl 2 $* sy gravitationalAccel $* (sy yPos $- sy QP.iyPos)) lcrectVel, lcrectPos, lcrectNoTime, lchorizVel, lchorizPos, lcvertVel, lcvertPos, lcvertNoTime :: LabelledContent lcrectVel = lbldExpr (sy speed $= speed') (makeEqnRef "rectVel") diff --git a/code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs index cfc6b3b0f2..7cfc8aa99f 100644 --- a/code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/DataDefs.hs @@ -27,7 +27,7 @@ positionIXQD :: SimpleQDef positionIXQD = mkQuantDef QP.ixPos positionIXEqn positionIXEqn :: Expr -positionIXEqn = sy lenRod `mulRe` sin (sy initialPendAngle) +positionIXEqn = sy lenRod $* sin (sy initialPendAngle) figRef :: Sentence figRef = ch QP.ixPos `S.is` S "shown in" +:+. refS figMotion @@ -43,7 +43,7 @@ positionIYQD :: SimpleQDef positionIYQD = mkQuantDef QP.iyPos positionIYEqn positionIYEqn :: Expr -positionIYEqn = neg (sy lenRod `mulRe` cos (sy initialPendAngle)) +positionIYEqn = neg (sy lenRod $* cos (sy initialPendAngle)) figReff :: Sentence figReff = ch QP.iyPos `S.is` S "shown in" +:+. refS figMotion @@ -75,7 +75,7 @@ angFrequencyDDQD :: SimpleQDef angFrequencyDDQD = mkQuantDef QP.angularFrequency angFrequencyDDEqn angFrequencyDDEqn :: Expr -angFrequencyDDEqn = exactDbl 2 `mulRe` sy QM.pi_ $/ sy QP.period +angFrequencyDDEqn = exactDbl 2 $* sy QM.pi_ $/ sy QP.period angFrequencyRef :: Sentence angFrequencyRef = ch QP.period `S.is` S "from" +:+ refS periodSHMDD diff --git a/code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs index 7bdbb901be..2db9576d0a 100644 --- a/code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Derivations.hs @@ -14,17 +14,17 @@ import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) -- Velocity IX/IY velocityIDerivEqn1, velocityIXDerivEqn2, velocityIXDerivEqn3, velocityIXDerivEqn4 :: ModelExpr velocityIDerivEqn1 = sy velocity $= deriv (sy position) time -velocityIXDerivEqn2 = sy xPos $= sy lenRod `mulRe` sin (sy pendDisplacementAngle) -velocityIXDerivEqn3 = sy xVel $= deriv (sy lenRod `mulRe` sin (sy pendDisplacementAngle)) time -velocityIXDerivEqn4 = sy xVel $= sy lenRod `mulRe` deriv (sin (sy pendDisplacementAngle)) time +velocityIXDerivEqn2 = sy xPos $= sy lenRod $* sin (sy pendDisplacementAngle) +velocityIXDerivEqn3 = sy xVel $= deriv (sy lenRod $* sin (sy pendDisplacementAngle)) time +velocityIXDerivEqn4 = sy xVel $= sy lenRod $* deriv (sin (sy pendDisplacementAngle)) time velocityIXDerivEqns :: [ModelExpr] velocityIXDerivEqns = [velocityIDerivEqn1, velocityIXDerivEqn2, velocityIXDerivEqn3, velocityIXDerivEqn4] velocityIYDerivEqn2,velocityIYDerivEqn3,velocityIYDerivEqn4 :: ModelExpr -velocityIYDerivEqn2 = sy yPos $= neg (sy lenRod `mulRe` cos (sy pendDisplacementAngle)) -velocityIYDerivEqn3 = sy yVel $= neg (deriv (sy lenRod `mulRe` cos (sy pendDisplacementAngle)) time) -velocityIYDerivEqn4 = sy yVel $= neg (sy lenRod `mulRe` deriv (cos (sy pendDisplacementAngle)) time) +velocityIYDerivEqn2 = sy yPos $= neg (sy lenRod $* cos (sy pendDisplacementAngle)) +velocityIYDerivEqn3 = sy yVel $= neg (deriv (sy lenRod $* cos (sy pendDisplacementAngle)) time) +velocityIYDerivEqn4 = sy yVel $= neg (sy lenRod $* deriv (cos (sy pendDisplacementAngle)) time) velocityIYDerivEqns :: [ModelExpr] velocityIYDerivEqns = [velocityIDerivEqn1, velocityIYDerivEqn2, velocityIYDerivEqn3, velocityIYDerivEqn4] @@ -32,14 +32,14 @@ velocityIYDerivEqns = [velocityIDerivEqn1, velocityIYDerivEqn2, velocityIYDerivE -- Acceleration IX/IY accelerationIDerivEqn1, accelerationIXDerivEqn3, accelerationIXDerivEqn4 :: ModelExpr accelerationIDerivEqn1 = sy acceleration $= deriv (sy velocity) time -accelerationIXDerivEqn3 = sy xAccel $= deriv (sy angularVelocity `mulRe` sy lenRod `mulRe` cos (sy pendDisplacementAngle)) time -accelerationIXDerivEqn4 = sy xAccel $= deriv (sy angularVelocity) time `mulRe` sy lenRod `mulRe` cos (sy pendDisplacementAngle) - $- (sy angularVelocity `mulRe` sy lenRod `mulRe` sin (sy pendDisplacementAngle) `mulRe` deriv (sy pendDisplacementAngle) time) +accelerationIXDerivEqn3 = sy xAccel $= deriv (sy angularVelocity $* sy lenRod $* cos (sy pendDisplacementAngle)) time +accelerationIXDerivEqn4 = sy xAccel $= deriv (sy angularVelocity) time $* sy lenRod $* cos (sy pendDisplacementAngle) + $- (sy angularVelocity $* sy lenRod $* sin (sy pendDisplacementAngle) $* deriv (sy pendDisplacementAngle) time) accelerationIYDerivEqn3, accelerationIYDerivEqn4 :: ModelExpr -accelerationIYDerivEqn3 = sy yAccel $= deriv (sy angularVelocity `mulRe` sy lenRod `mulRe` sin (sy pendDisplacementAngle)) time -accelerationIYDerivEqn4 = sy yAccel $= deriv (sy angularVelocity) time `mulRe` sy lenRod `mulRe` sin (sy pendDisplacementAngle) - `addRe` (sy angularVelocity `mulRe` sy lenRod `mulRe` cos (sy pendDisplacementAngle) `mulRe` deriv (sy pendDisplacementAngle) time) +accelerationIYDerivEqn3 = sy yAccel $= deriv (sy angularVelocity $* sy lenRod $* sin (sy pendDisplacementAngle)) time +accelerationIYDerivEqn4 = sy yAccel $= deriv (sy angularVelocity) time $* sy lenRod $* sin (sy pendDisplacementAngle) + $+ (sy angularVelocity $* sy lenRod $* cos (sy pendDisplacementAngle) $* deriv (sy pendDisplacementAngle) time) -- Angular Frequency Of Pendulum angFrequencyDerivEqns :: [ModelExpr] @@ -49,14 +49,14 @@ angFrequencyDerivEqns = [angFrequencyDerivEqn1, angFrequencyDerivEqn2, angFreque angFrequencyDerivEqn1, angFrequencyDerivEqn2, angFrequencyDerivEqn3, angFrequencyDerivEqn4, angFrequencyDerivEqn5, angFrequencyDerivEqn6, angFrequencyDerivEqn7 :: ModelExpr -angFrequencyDerivEqn1 = sy torque $= neg (sy lenRod) `mulRe` (sy mass `mulRe` sy gravitationalAccel `mulRe` sin (sy pendDisplacementAngle)) -angFrequencyDerivEqn2 = sy momentOfInertia `mulRe` sy angularAccel $= neg (sy lenRod) `mulRe` (sy mass `mulRe` sy gravitationalAccel `mulRe` sin (sy pendDisplacementAngle)) -angFrequencyDerivEqn3 = sy momentOfInertia `mulRe` deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy lenRod) - `mulRe` sy mass `mulRe` sy gravitationalAccel `mulRe` sin (sy pendDisplacementAngle) -angFrequencyDerivEqn4 = (sy mass `mulRe` square (sy lenRod)) `mulRe` deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy lenRod) - `mulRe` sy mass `mulRe` sy gravitationalAccel `mulRe` sin (sy pendDisplacementAngle) -angFrequencyDerivEqn5 = deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy gravitationalAccel $/ sy lenRod) `mulRe` sin (sy pendDisplacementAngle) -angFrequencyDerivEqn6 = deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy gravitationalAccel $/ sy lenRod) `mulRe` sy pendDisplacementAngle +angFrequencyDerivEqn1 = sy torque $= neg (sy lenRod) $* (sy mass $* sy gravitationalAccel $* sin (sy pendDisplacementAngle)) +angFrequencyDerivEqn2 = sy momentOfInertia $* sy angularAccel $= neg (sy lenRod) $* (sy mass $* sy gravitationalAccel $* sin (sy pendDisplacementAngle)) +angFrequencyDerivEqn3 = sy momentOfInertia $* deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy lenRod) + $* sy mass $* sy gravitationalAccel $* sin (sy pendDisplacementAngle) +angFrequencyDerivEqn4 = (sy mass $* square (sy lenRod)) $* deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy lenRod) + $* sy mass $* sy gravitationalAccel $* sin (sy pendDisplacementAngle) +angFrequencyDerivEqn5 = deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy gravitationalAccel $/ sy lenRod) $* sin (sy pendDisplacementAngle) +angFrequencyDerivEqn6 = deriv (deriv (sy pendDisplacementAngle) time) time $= neg (sy gravitationalAccel $/ sy lenRod) $* sy pendDisplacementAngle angFrequencyDerivEqn7 = sy angularFrequency $= sqrt (sy gravitationalAccel $/ sy lenRod) -- Period of Pendulum Motion @@ -65,7 +65,7 @@ periodPendDerivEqns = [periodPendDerivEqn1, periodPendDerivEqn2] periodPendDerivEqn1, periodPendDerivEqn2 :: ModelExpr periodPendDerivEqn1 = sy angularFrequency $= sqrt (sy gravitationalAccel $/ sy lenRod) -periodPendDerivEqn2 = sy period $= exactDbl 2 `mulRe` sy QM.pi_ `mulRe` sqrt (sy lenRod $/ sy gravitationalAccel) +periodPendDerivEqn2 = sy period $= exactDbl 2 $* sy QM.pi_ $* sqrt (sy lenRod $/ sy gravitationalAccel) -- Angular Displacement angularDisplacementDerivEqns :: [ModelExpr] @@ -74,9 +74,9 @@ angularDisplacementDerivEqns = [angularDisplacementDerivEqn1, angularDisplacemen angularDisplacementDerivEqn1, angularDisplacementDerivEqn2, angularDisplacementDerivEqn3, angularDisplacementDerivEqn4, angularDisplacementDerivEqn5 :: ModelExpr -angularDisplacementDerivEqn1 = sy torque $= sy momentOfInertia `mulRe` sy angularAccel -angularDisplacementDerivEqn2 = neg (sy mass `mulRe` sy gravitationalAccel `mulRe` sin (sy pendDisplacementAngle) `mulRe` sy lenRod) $= (sy mass `mulRe` square (sy lenRod)) - `mulRe` deriv (deriv (sy pendDisplacementAngle) time) time -angularDisplacementDerivEqn3 = deriv (deriv (sy pendDisplacementAngle) time) time `addRe` ((sy gravitationalAccel $/ sy lenRod) `mulRe` sin (sy pendDisplacementAngle)) $= exactDbl 0 -angularDisplacementDerivEqn4 = deriv (deriv (sy pendDisplacementAngle) time) time `addRe` ((sy gravitationalAccel $/ sy lenRod) `mulRe` sy pendDisplacementAngle) $= exactDbl 0 -angularDisplacementDerivEqn5 = apply1 pendDisplacementAngle time $= sy initialPendAngle `mulRe` cos ( sy angularFrequency `mulRe` sy time) +angularDisplacementDerivEqn1 = sy torque $= sy momentOfInertia $* sy angularAccel +angularDisplacementDerivEqn2 = neg (sy mass $* sy gravitationalAccel $* sin (sy pendDisplacementAngle) $* sy lenRod) $= (sy mass $* square (sy lenRod)) + $* deriv (deriv (sy pendDisplacementAngle) time) time +angularDisplacementDerivEqn3 = deriv (deriv (sy pendDisplacementAngle) time) time $+ ((sy gravitationalAccel $/ sy lenRod) $* sin (sy pendDisplacementAngle)) $= exactDbl 0 +angularDisplacementDerivEqn4 = deriv (deriv (sy pendDisplacementAngle) time) time $+ ((sy gravitationalAccel $/ sy lenRod) $* sy pendDisplacementAngle) $= exactDbl 0 +angularDisplacementDerivEqn5 = apply1 pendDisplacementAngle time $= sy initialPendAngle $* cos ( sy angularFrequency $* sy time) diff --git a/code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs b/code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs index 515dbadefa..052d375815 100644 --- a/code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs +++ b/code/drasil-example/sglpend/lib/Drasil/SglPend/Expressions.hs @@ -11,25 +11,25 @@ import Drasil.SglPend.Unitals (lenRod, pendDisplacementAngle, initialPendAngle) -- Velocity IX/IY velocityIXExpr, velocityIYExpr :: Expr -velocityIXExpr = sy angularVelocity `mulRe` sy lenRod `mulRe` cos (sy pendDisplacementAngle) -velocityIYExpr = sy angularVelocity `mulRe` sy lenRod `mulRe` sin (sy pendDisplacementAngle) +velocityIXExpr = sy angularVelocity $* sy lenRod $* cos (sy pendDisplacementAngle) +velocityIYExpr = sy angularVelocity $* sy lenRod $* sin (sy pendDisplacementAngle) -- Acceleration IX/IY accelerationIXExpr, accelerationIYExpr :: Expr -accelerationIXExpr = neg (square (sy angularVelocity) `mulRe` sy lenRod `mulRe` sin (sy pendDisplacementAngle)) - `addRe` (sy angularAccel `mulRe` sy lenRod `mulRe` cos (sy pendDisplacementAngle)) -accelerationIYExpr = (square (sy angularVelocity) `mulRe` sy lenRod `mulRe` cos (sy pendDisplacementAngle)) - `addRe` (sy angularAccel `mulRe` sy lenRod `mulRe` sin (sy pendDisplacementAngle)) +accelerationIXExpr = neg (square (sy angularVelocity) $* sy lenRod $* sin (sy pendDisplacementAngle)) + $+ (sy angularAccel $* sy lenRod $* cos (sy pendDisplacementAngle)) +accelerationIYExpr = (square (sy angularVelocity) $* sy lenRod $* cos (sy pendDisplacementAngle)) + $+ (sy angularAccel $* sy lenRod $* sin (sy pendDisplacementAngle)) -- Horizontal/Vertical force acting on the pendulum hForceOnPendulumViaComponent, hForceOnPendulumViaAngle :: Expr -hForceOnPendulumViaComponent = sy mass `mulRe` sy xAccel -hForceOnPendulumViaAngle = neg (sy tension `mulRe` sin (sy pendDisplacementAngle)) +hForceOnPendulumViaComponent = sy mass $* sy xAccel +hForceOnPendulumViaAngle = neg (sy tension $* sin (sy pendDisplacementAngle)) vForceOnPendulumViaComponent, vForceOnPendulumViaAngle :: Expr -vForceOnPendulumViaComponent = sy mass `mulRe` sy yAccel -vForceOnPendulumViaAngle = sy tension `mulRe` cos (sy pendDisplacementAngle) - $- (sy mass `mulRe` sy gravitationalAccel) +vForceOnPendulumViaComponent = sy mass $* sy yAccel +vForceOnPendulumViaAngle = sy tension $* cos (sy pendDisplacementAngle) + $- (sy mass $* sy gravitationalAccel) -- Angular Frequency Of Pendulum angFrequencyExpr :: Expr @@ -37,8 +37,8 @@ angFrequencyExpr = sqrt (sy gravitationalAccel $/ sy lenRod) -- Period of Pendulum Motion periodPendExpr :: Expr -periodPendExpr = exactDbl 2 `mulRe` sy QM.pi_ `mulRe` sqrt (sy lenRod $/ sy gravitationalAccel) +periodPendExpr = exactDbl 2 $* sy QM.pi_ $* sqrt (sy lenRod $/ sy gravitationalAccel) -- Angular Displacement angularDisplacementExpr :: Expr -angularDisplacementExpr = sy initialPendAngle `mulRe` cos (sy angularFrequency `mulRe` sy time) +angularDisplacementExpr = sy initialPendAngle $* cos (sy angularFrequency $* sy time) diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/BasicExprs.hs b/code/drasil-example/ssp/lib/Drasil/SSP/BasicExprs.hs index 71dcd079cb..cbcdf26bbd 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/BasicExprs.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/BasicExprs.hs @@ -10,76 +10,76 @@ import Drasil.SSP.Unitals (baseAngle, baseWthX, earthqkLoadFctr, fs, eqlExpr :: (ExprC r, LiteralC r) => (r -> r) -> (r -> r) -> (r -> r -> r) -> r eqlExpr f1_ f2_ _e_ = (inxi slcWght `_e_` - (inxi surfHydroForce `mulRe` cos (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` cos (inxi impLoadAngle))) `mulRe` f1_ (inxi baseAngle) $- - (((neg (sy earthqkLoadFctr) `mulRe` inxi slcWght) $- inxi intNormForce `addRe` - inxiM1 intNormForce $- inxi watrForce `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` sin (inxi impLoadAngle))) `mulRe` f2_ (inxi baseAngle)) + (inxi surfHydroForce $* cos (inxi surfAngle)) $+ + (inxi surfLoad $* cos (inxi impLoadAngle))) $* f1_ (inxi baseAngle) $- + (((neg (sy earthqkLoadFctr) $* inxi slcWght) $- inxi intNormForce $+ + inxiM1 intNormForce $- inxi watrForce $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle)) $+ + (inxi surfLoad $* sin (inxi impLoadAngle))) $* f2_ (inxi baseAngle)) eqlExprN :: (ExprC r, LiteralC r) => (r -> r) -> (r -> r) -> (r -> r -> r) -> r eqlExprN f1_ f2_ _e_ = (inxi slcWght `_e_` - (inxi surfHydroForce `mulRe` cos (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` cos (inxi impLoadAngle)) `mulRe` f1_ (inxi baseAngle)) `addRe` - (((neg (sy earthqkLoadFctr) `mulRe` inxi slcWght $- inxi intNormForce `addRe` - inxiM1 intNormForce $- inxi watrForce `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle))) `addRe` - (inxi surfLoad `mulRe` sin (inxi impLoadAngle))) `mulRe` f2_ (inxi baseAngle)) + (inxi surfHydroForce $* cos (inxi surfAngle)) $+ + (inxi surfLoad $* cos (inxi impLoadAngle)) $* f1_ (inxi baseAngle)) $+ + (((neg (sy earthqkLoadFctr) $* inxi slcWght $- inxi intNormForce $+ + inxiM1 intNormForce $- inxi watrForce $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle))) $+ + (inxi surfLoad $* sin (inxi impLoadAngle))) $* f2_ (inxi baseAngle)) eqlExprSepG :: (ExprC r, LiteralC r) => (r -> r) -> (r -> r) -> (r -> r -> r) -> r eqlExprSepG f1_ f2_ _e_ = (inxi slcWght `_e_` - (inxi surfHydroForce `mulRe` cos (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` cos (inxi impLoadAngle)) `mulRe` f1_ (inxi baseAngle)) $- - ((neg (sy earthqkLoadFctr) `mulRe` inxi slcWght $- inxi watrForce `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` sin (inxi impLoadAngle))) `mulRe` f2_ (inxi baseAngle)) $- - ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) `mulRe` f2_ (inxi baseAngle)) + (inxi surfHydroForce $* cos (inxi surfAngle)) $+ + (inxi surfLoad $* cos (inxi impLoadAngle)) $* f1_ (inxi baseAngle)) $- + ((neg (sy earthqkLoadFctr) $* inxi slcWght $- inxi watrForce $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle)) $+ + (inxi surfLoad $* sin (inxi impLoadAngle))) $* f2_ (inxi baseAngle)) $- + ((neg (inxi intNormForce) $+ inxiM1 intNormForce) $* f2_ (inxi baseAngle)) eqlExprNSepG :: (ExprC r, LiteralC r) => (r -> r) -> (r -> r) -> (r -> r -> r) -> r eqlExprNSepG f1_ f2_ _e_ = (inxi slcWght `_e_` - (inxi surfHydroForce `mulRe` cos (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` cos (inxi impLoadAngle))) `mulRe` f1_ (inxi baseAngle) `addRe` - ((neg (sy earthqkLoadFctr) `mulRe` inxi slcWght $- inxi watrForce `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle)) `addRe` - (inxi surfLoad `mulRe` sin (inxi impLoadAngle))) `mulRe` f2_ (inxi baseAngle)) `addRe` - ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) `mulRe` f2_ (inxi baseAngle)) + (inxi surfHydroForce $* cos (inxi surfAngle)) $+ + (inxi surfLoad $* cos (inxi impLoadAngle))) $* f1_ (inxi baseAngle) $+ + ((neg (sy earthqkLoadFctr) $* inxi slcWght $- inxi watrForce $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle)) $+ + (inxi surfLoad $* sin (inxi impLoadAngle))) $* f2_ (inxi baseAngle)) $+ + ((neg (inxi intNormForce) $+ inxiM1 intNormForce) $* f2_ (inxi baseAngle)) eqlExprNoKQ :: (ExprC r, LiteralC r) => (r -> r) -> (r -> r) -> (r -> r -> r) -> r eqlExprNoKQ f1_ f2_ _e_ = (inxi slcWght `_e_` - (inxi surfHydroForce `mulRe` cos (inxi surfAngle))) `mulRe` f1_ (inxi baseAngle) $- - ((neg (inxi watrForce) `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle))) `mulRe` f2_ (inxi baseAngle)) $- - ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) `mulRe` f2_ (inxi baseAngle)) + (inxi surfHydroForce $* cos (inxi surfAngle))) $* f1_ (inxi baseAngle) $- + ((neg (inxi watrForce) $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle))) $* f2_ (inxi baseAngle)) $- + ((neg (inxi intNormForce) $+ inxiM1 intNormForce) $* f2_ (inxi baseAngle)) eqlExprNNoKQ :: (ExprC r, LiteralC r) => (r -> r) -> (r -> r) -> (r -> r -> r) -> r eqlExprNNoKQ f1_ f2_ _e_ = (inxi slcWght `_e_` - (inxi surfHydroForce `mulRe` cos (inxi surfAngle))) `mulRe` f1_ (inxi baseAngle) `addRe` - ((neg (inxi watrForce) `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle))) `mulRe` f2_ (inxi baseAngle)) `addRe` - ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) `mulRe` f2_ (inxi baseAngle)) + (inxi surfHydroForce $* cos (inxi surfAngle))) $* f1_ (inxi baseAngle) $+ + ((neg (inxi watrForce) $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle))) $* f2_ (inxi baseAngle)) $+ + ((neg (inxi intNormForce) $+ inxiM1 intNormForce) $* f2_ (inxi baseAngle)) sliceExpr :: (ExprC r, LiteralC r) => Integer -> r -sliceExpr n = idx (sy intNormForce) (int n) `mulRe` idx (sy shrResC) (int n) $= - (idx (sy mobShrC) (int (n-1)) `mulRe` idx (sy intNormForce) (int (n-1)) `mulRe` - idx (sy shrResC) (int (n-1)) `addRe` (sy fs `mulRe` idx (sy shearFNoIntsl) (int n)) $- +sliceExpr n = idx (sy intNormForce) (int n) $* idx (sy shrResC) (int n) $= + (idx (sy mobShrC) (int (n-1)) $* idx (sy intNormForce) (int (n-1)) $* + idx (sy shrResC) (int (n-1)) $+ (sy fs $* idx (sy shearFNoIntsl) (int n)) $- idx (sy shearRNoIntsl) (int n)) momExpr :: (ExprC r, LiteralC r) => (r -> r -> r) -> r -momExpr _e_ = (neg (inxi intNormForce) `mulRe` (inxi sliceHght `addRe`(half (inxi baseWthX) - `mulRe` tan (inxi baseAngle))) `addRe` (inxiM1 intNormForce `mulRe` (inxiM1 sliceHght $- - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle)))) $- - (inxi watrForce `mulRe` (oneThird `mulRe` inxi sliceHghtW `addRe` (half (inxi baseWthX) `mulRe` - tan (inxi baseAngle)))) `addRe` (inxiM1 watrForce `mulRe` (oneThird `mulRe` inxiM1 sliceHghtW $- - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle))))) `_e_` - (half (neg (sy earthqkLoadFctr) `mulRe` inxi slcWght `mulRe` inxi midpntHght) `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle) `mulRe` inxi midpntHght `addRe` - (inxi surfLoad `mulRe` sin (inxi impLoadAngle) `mulRe` inxi midpntHght))) +momExpr _e_ = (neg (inxi intNormForce) $* (inxi sliceHght $+(half (inxi baseWthX) + $* tan (inxi baseAngle))) $+ (inxiM1 intNormForce $* (inxiM1 sliceHght $- + (half (inxi baseWthX) $* tan (inxi baseAngle)))) $- + (inxi watrForce $* (oneThird $* inxi sliceHghtW $+ (half (inxi baseWthX) $* + tan (inxi baseAngle)))) $+ (inxiM1 watrForce $* (oneThird $* inxiM1 sliceHghtW $- + (half (inxi baseWthX) $* tan (inxi baseAngle))))) `_e_` + (half (neg (sy earthqkLoadFctr) $* inxi slcWght $* inxi midpntHght) $+ + (inxi surfHydroForce $* sin (inxi surfAngle) $* inxi midpntHght $+ + (inxi surfLoad $* sin (inxi impLoadAngle) $* inxi midpntHght))) momExprNoKQ :: (ExprC r, LiteralC r) => (r -> r -> r) -> r -momExprNoKQ _e_ = (neg (inxi intNormForce) `mulRe` (inxi sliceHght `addRe`(half (inxi baseWthX) - `mulRe` tan (inxi baseAngle))) `addRe` (inxiM1 intNormForce `mulRe` (inxiM1 sliceHght $- - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle)))) $- - (inxi watrForce `mulRe` (oneThird `mulRe` inxi sliceHghtW `addRe` (half (inxi baseWthX) `mulRe` - tan (inxi baseAngle)))) `addRe` (inxiM1 watrForce `mulRe` (oneThird `mulRe` inxiM1 sliceHghtW $- - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle))))) `_e_` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle) `mulRe` inxi midpntHght) +momExprNoKQ _e_ = (neg (inxi intNormForce) $* (inxi sliceHght $+(half (inxi baseWthX) + $* tan (inxi baseAngle))) $+ (inxiM1 intNormForce $* (inxiM1 sliceHght $- + (half (inxi baseWthX) $* tan (inxi baseAngle)))) $- + (inxi watrForce $* (oneThird $* inxi sliceHghtW $+ (half (inxi baseWthX) $* + tan (inxi baseAngle)))) $+ (inxiM1 watrForce $* (oneThird $* inxiM1 sliceHghtW $- + (half (inxi baseWthX) $* tan (inxi baseAngle))))) `_e_` + (inxi surfHydroForce $* sin (inxi surfAngle) $* inxi midpntHght) diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs b/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs index 93e456a177..90f7f1719f 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/Body.hs @@ -354,7 +354,7 @@ physSysConv = foldlSP [atStart morPrice, phrase analysis, refS morgenstern1965 phrase value, S "for a single", phrase slice `sC` S "and an", phrase intrslce, phrase value, S "at a given", phrase index, ch index, S "refers to the", phrase value, S "between", phrase slice, ch index `S.and_` S "adjacent", phrase slice, - eS $ sy index `addI` int 1] + eS $ sy index $+ int 1] figIndexConv :: LabelledContent figIndexConv = llcc (makeFigRef "IndexConvention") $ diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/DataDefs.hs b/code/drasil-example/ssp/lib/Drasil/SSP/DataDefs.hs index 3b9d9e42a8..5259b6d788 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/DataDefs.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/DataDefs.hs @@ -43,11 +43,11 @@ intersliceWtrFQD = mkQuantDef watrForce intersliceWtrFEqn intersliceWtrFEqn :: Expr intersliceWtrFEqn = completeCase [case1,case2,case3] - where case1 = (half (square (inxi slopeHght $- inxi slipHght)) `mulRe` - sy waterWeight `addRe` (square (inxi waterHght $- inxi slopeHght) `mulRe` + where case1 = (half (square (inxi slopeHght $- inxi slipHght)) $* + sy waterWeight $+ (square (inxi waterHght $- inxi slopeHght) $* sy waterWeight), inxi waterHght $>= inxi slopeHght) - case2 = (half (square (inxi waterHght $- inxi slipHght)) `mulRe` sy waterWeight, + case2 = (half (square (inxi waterHght $- inxi slipHght)) $* sy waterWeight, (inxi slopeHght $> inxi waterHght) $&& (inxi waterHght $> inxi slipHght)) @@ -115,7 +115,7 @@ lengthLbQD :: SimpleQDef lengthLbQD = mkQuantDef baseLngth lengthLbEqn lengthLbEqn :: Expr -lengthLbEqn = inxi baseWthX `mulRe` sec (inxi baseAngle) +lengthLbEqn = inxi baseWthX $* sec (inxi baseAngle) lengthLbNotes :: Sentence lengthLbNotes = foldlSent [baseWthX `definedIn'''` @@ -132,7 +132,7 @@ lengthLsQD :: SimpleQDef lengthLsQD = mkQuantDef surfLngth lengthLsEqn lengthLsEqn :: Expr -lengthLsEqn = inxi baseWthX `mulRe` sec (inxi surfAngle) +lengthLsEqn = inxi baseWthX $* sec (inxi surfAngle) lengthLsNotes :: Sentence lengthLsNotes = foldlSent [baseWthX `definedIn'''` @@ -149,7 +149,7 @@ slcHeightQD :: SimpleQDef slcHeightQD = mkQuantDef midpntHght slcHeightEqn slcHeightEqn :: Expr -slcHeightEqn = oneHalf `mulRe` (inxi sliceHghtRight `addRe` inxi sliceHghtLeft) +slcHeightEqn = oneHalf $* (inxi sliceHghtRight $+ inxi sliceHghtLeft) slcHeightNotes :: [Sentence] slcHeightNotes = [S "This" +:+ phrase equation +:+ S "is based on the" +:+ @@ -194,7 +194,7 @@ ratioVarEqn :: Expr ratioVarEqn = completeCase [case1, case2] where case1 = (exactDbl 1, sy constF) - case2 = (sin (sy QM.pi_ `mulRe` ((inxi slipDist $- idx (sy slipDist) (int 0)) $/ + case2 = (sin (sy QM.pi_ $* ((inxi slipDist $- idx (sy slipDist) (int 0)) $/ (indxn slipDist $- idx (sy slipDist) (int 0)))), not_ (sy constF)) --DD convertFunc1: first function for incorporating interslice forces into shear force @@ -207,10 +207,10 @@ convertFunc1QD :: SimpleQDef convertFunc1QD = mkQuantDef shrResC convertFunc1Eqn convertFunc1Eqn :: Expr -convertFunc1Eqn = (sy normToShear `mulRe` inxi scalFunc `mulRe` - cos (inxi baseAngle) $- sin (inxi baseAngle)) `mulRe` tan (sy fricAngle) $- - ((sy normToShear `mulRe` inxi scalFunc `mulRe` sin (inxi baseAngle) `addRe` - cos (inxi baseAngle)) `mulRe` sy fs) +convertFunc1Eqn = (sy normToShear $* inxi scalFunc $* + cos (inxi baseAngle) $- sin (inxi baseAngle)) $* tan (sy fricAngle) $- + ((sy normToShear $* inxi scalFunc $* sin (inxi baseAngle) $+ + cos (inxi baseAngle)) $* sy fs) convertFunc1Notes :: Sentence convertFunc1Notes = foldlSent [scalFunc `definedIn'''` ratioVariation `S.and_` (baseAngle `definedIn'''` angleA)] @@ -225,10 +225,10 @@ convertFunc2QD :: SimpleQDef convertFunc2QD = mkQuantDef mobShrC convertFunc2Eqn convertFunc2Eqn :: Expr -convertFunc2Eqn = ((sy normToShear `mulRe` inxi scalFunc `mulRe` - cos (inxi baseAngle) $- sin (inxi baseAngle)) `mulRe` tan (sy fricAngle) $- - ((sy normToShear `mulRe` inxi scalFunc `mulRe` sin (inxi baseAngle) `addRe` - cos (inxi baseAngle)) `mulRe` sy fs)) $/ +convertFunc2Eqn = ((sy normToShear $* inxi scalFunc $* + cos (inxi baseAngle) $- sin (inxi baseAngle)) $* tan (sy fricAngle) $- + ((sy normToShear $* inxi scalFunc $* sin (inxi baseAngle) $+ + cos (inxi baseAngle)) $* sy fs)) $/ inxiM1 shrResC convertFunc2Notes :: Sentence @@ -247,13 +247,13 @@ resShearWOQD :: QDefinition resShearWOQD = mkQuantDef shearRNoIntsl resShearWOEqn resShearWOEqn :: Expr -resShearWOEqn = (((inxi slcWght) `addRe` (inxi surfHydroForce) * - (cos (inxi surfAngle)) `addRe` (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) * - (cos (inxi baseAngle)) `addRe` (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - - (inxi watrForceDif) `addRe` (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) + - (inxi surfLoad) `mulRe` (sin (inxi impLoadAngle))) `mulRe` (sin (inxi baseAngle)) - - (inxi baseHydroForce)) `mulRe` tan (inxi fricAngle) `addRe` (inxi effCohesion) * - (inxi baseWthX) `mulRe` sec (inxi baseAngle) +resShearWOEqn = (((inxi slcWght) $+ (inxi surfHydroForce) * + (cos (inxi surfAngle)) $+ (inxi surfLoad) $* (cos (inxi impLoadAngle))) * + (cos (inxi baseAngle)) $+ (negate (sy earthqkLoadFctr) $* (inxi slcWght) - + (inxi watrForceDif) $+ (inxi surfHydroForce) $* sin (inxi surfAngle) + + (inxi surfLoad) $* (sin (inxi impLoadAngle))) $* (sin (inxi baseAngle)) - + (inxi baseHydroForce)) $* tan (inxi fricAngle) $+ (inxi effCohesion) * + (inxi baseWthX) $* sec (inxi baseAngle) resShr_deriv_ssp :: Derivation resShr_deriv_ssp = weave [resShrDerivation_sentence, map E resShr_deriv_eqns_ssp] @@ -269,11 +269,11 @@ mobShearWOQD :: QDefinition mobShearWOQD = mkQuantDef shearFNoIntsl mobShearWOEqn mobShearWOEqn :: Expr -mobShearWOEqn = ((inxi slcWght) `addRe` (inxi surfHydroForce) * - (cos (inxi surfAngle)) `addRe` (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) * - (sin (inxi baseAngle)) - (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - - (inxi watrForceDif) `addRe` (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) + - (inxi surfLoad) `mulRe` (sin (inxi impLoadAngle))) `mulRe` (cos (inxi baseAngle)) +mobShearWOEqn = ((inxi slcWght) $+ (inxi surfHydroForce) * + (cos (inxi surfAngle)) $+ (inxi surfLoad) $* (cos (inxi impLoadAngle))) * + (sin (inxi baseAngle)) - (negate (sy earthqkLoadFctr) $* (inxi slcWght) - + (inxi watrForceDif) $+ (inxi surfHydroForce) $* sin (inxi surfAngle) + + (inxi surfLoad) $* (sin (inxi impLoadAngle))) $* (cos (inxi baseAngle)) mobShr_deriv_ssp :: Derivation mobShr_deriv_ssp = (weave [mobShrDerivation_sentence, map E mobShr_deriv_eqns_ssp])-} @@ -294,10 +294,10 @@ sliceHghtLeftDD = ddE sliceHghtLeftQD [dRef fredlund1977] Nothing "sliceHghtLeftDD" []--Notes nrmForceSumQD :: SimpleQDef -nrmForceSumQD = ec nrmForceSum (inxi intNormForce `addRe` inxiM1 intNormForce) +nrmForceSumQD = ec nrmForceSum (inxi intNormForce $+ inxiM1 intNormForce) watForceSumQD :: SimpleQDef -watForceSumQD = ec watForceSum (inxi watrForce `addRe` inxiM1 watrForce) +watForceSumQD = ec watForceSum (inxi watrForce $+ inxiM1 watrForce) sliceHghtRightQD :: SimpleQDef sliceHghtRightQD = ec sliceHghtRight (inxi slopeHght $- inxi slipHght) @@ -348,32 +348,32 @@ resShr_deriv_eqns_ssp = [eq1, eq2, eq3, eq8] eq1, eq2, eq3, eq8 :: Expr eq1 = (inxi nrmFSubWat) $= eqlExpr cos sin (\x y -> x - - inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) - inxi baseHydroForce + inxiM1 intShrForce $+ inxi intShrForce $+ y) - inxi baseHydroForce -eq2 = (inxi nrmFNoIntsl) $= (((inxi slcWght) `addRe` (inxi surfHydroForce) * - (cos (inxi surfAngle)) `addRe` (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) * - (cos (inxi baseAngle)) `addRe` (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - - (inxi watrForce) `addRe` (inxiM1 watrForce) `addRe` (inxi surfHydroForce) * - sin (inxi surfAngle) `addRe` (inxi surfLoad) `mulRe` (sin (inxi impLoadAngle))) * +eq2 = (inxi nrmFNoIntsl) $= (((inxi slcWght) $+ (inxi surfHydroForce) * + (cos (inxi surfAngle)) $+ (inxi surfLoad) $* (cos (inxi impLoadAngle))) * + (cos (inxi baseAngle)) $+ (negate (sy earthqkLoadFctr) $* (inxi slcWght) - + (inxi watrForce) $+ (inxiM1 watrForce) $+ (inxi surfHydroForce) * + sin (inxi surfAngle) $+ (inxi surfLoad) $* (sin (inxi impLoadAngle))) * (sin (inxi baseAngle)) - (inxi baseHydroForce)) -eq3 = inxi shearRNoIntsl $= (inxi nrmFNoIntsl) `mulRe` tan (inxi fricAngle) + - (inxi effCohesion) `mulRe` (inxi baseWthX) `mulRe` sec (inxi baseAngle) $= - (((inxi slcWght) `addRe` (inxi surfHydroForce) `mulRe` (cos (inxi surfAngle)) + - (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) `mulRe` (cos (inxi baseAngle)) + - (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - (inxi watrForceDif) + - (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) `addRe` (inxi surfLoad) * - (sin (inxi impLoadAngle))) `mulRe` (sin (inxi baseAngle)) - - (inxi baseHydroForce)) `mulRe` tan (inxi fricAngle) `addRe` (inxi effCohesion) * - (inxi baseWthX) `mulRe` sec (inxi baseAngle) +eq3 = inxi shearRNoIntsl $= (inxi nrmFNoIntsl) $* tan (inxi fricAngle) + + (inxi effCohesion) $* (inxi baseWthX) $* sec (inxi baseAngle) $= + (((inxi slcWght) $+ (inxi surfHydroForce) $* (cos (inxi surfAngle)) + + (inxi surfLoad) $* (cos (inxi impLoadAngle))) $* (cos (inxi baseAngle)) + + (negate (sy earthqkLoadFctr) $* (inxi slcWght) - (inxi watrForceDif) + + (inxi surfHydroForce) $* sin (inxi surfAngle) $+ (inxi surfLoad) * + (sin (inxi impLoadAngle))) $* (sin (inxi baseAngle)) - + (inxi baseHydroForce)) $* tan (inxi fricAngle) $+ (inxi effCohesion) * + (inxi baseWthX) $* sec (inxi baseAngle) eq8 = inxi shearRNoIntsl $= - (((inxi slcWght) `addRe` (inxi surfHydroForce) `mulRe` (cos (inxi surfAngle))) `mulRe` (cos (inxi baseAngle)) + + (((inxi slcWght) $+ (inxi surfHydroForce) $* (cos (inxi surfAngle))) $* (cos (inxi baseAngle)) + (- (inxi watrForceDif) + - (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) `addRe` (inxi surfLoad) * - (sin (inxi impLoadAngle))) `mulRe` (sin (inxi baseAngle)) - - (inxi baseHydroForce)) `mulRe` tan (inxi fricAngle) `addRe` (inxi effCohesion) * - (inxi baseWthX) `mulRe` sec (inxi baseAngle) + (inxi surfHydroForce) $* sin (inxi surfAngle) $+ (inxi surfLoad) * + (sin (inxi impLoadAngle))) $* (sin (inxi baseAngle)) - + (inxi baseHydroForce)) $* tan (inxi fricAngle) $+ (inxi effCohesion) * + (inxi baseWthX) $* sec (inxi baseAngle) -------old chunk--------- @@ -388,7 +388,7 @@ resShrDerivation = [ S "of", refS effStress, S "shown in", eqN 5], eqUnR' $ (inxi nrmFSubWat) $= eqlExpr cos sin (\x y -> x - - inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) - inxi baseHydroForce, + inxiM1 intShrForce $+ inxi intShrForce $+ y) - inxi baseHydroForce, foldlSP [plural value `the_ofThe'` S "interslice forces", ch intNormForce `S.and_` ch intShrForce, S "in the", phrase equation, @@ -399,11 +399,11 @@ resShrDerivation = [ S "to obtain a solvable value as done for", ch nrmFNoIntsl, S "in", eqN 2], eqUnR' $ - (inxi nrmFNoIntsl) $= (((inxi slcWght) `addRe` (inxi surfHydroForce) * - (cos (inxi surfAngle)) `addRe` (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) * - (cos (inxi baseAngle)) `addRe` (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - - (inxi watrForce) `addRe` (inxiM1 watrForce) `addRe` (inxi surfHydroForce) * - sin (inxi surfAngle) `addRe` (inxi surfLoad) `mulRe` (sin (inxi impLoadAngle))) * + (inxi nrmFNoIntsl) $= (((inxi slcWght) $+ (inxi surfHydroForce) * + (cos (inxi surfAngle)) $+ (inxi surfLoad) $* (cos (inxi impLoadAngle))) * + (cos (inxi baseAngle)) $+ (negate (sy earthqkLoadFctr) $* (inxi slcWght) - + (inxi watrForce) $+ (inxiM1 watrForce) $+ (inxi surfHydroForce) * + sin (inxi surfAngle) $+ (inxi surfLoad) $* (sin (inxi impLoadAngle))) * (sin (inxi baseAngle)) - (inxi baseHydroForce)), foldlSP [S "Using", ch nrmFNoIntsl `sC` S "a", phrase shearRNoIntsl, @@ -411,15 +411,15 @@ resShrDerivation = [ plural value, S "as done in", eqN 3], eqUnR' $ - inxi shearRNoIntsl $= (inxi nrmFNoIntsl) `mulRe` tan (inxi fricAngle) + - (inxi effCohesion) `mulRe` (inxi baseWthX) `mulRe` sec (inxi baseAngle) $= - (((inxi slcWght) `addRe` (inxi surfHydroForce) `mulRe` (cos (inxi surfAngle)) + - (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) `mulRe` (cos (inxi baseAngle)) + - (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - (inxi watrForceDif) + - (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) `addRe` (inxi surfLoad) * - (sin (inxi impLoadAngle))) `mulRe` (sin (inxi baseAngle)) - - (inxi baseHydroForce)) `mulRe` tan (inxi fricAngle) `addRe` (inxi effCohesion) * - (inxi baseWthX) `mulRe` sec (inxi baseAngle) + inxi shearRNoIntsl $= (inxi nrmFNoIntsl) $* tan (inxi fricAngle) + + (inxi effCohesion) $* (inxi baseWthX) $* sec (inxi baseAngle) $= + (((inxi slcWght) $+ (inxi surfHydroForce) $* (cos (inxi surfAngle)) + + (inxi surfLoad) $* (cos (inxi impLoadAngle))) $* (cos (inxi baseAngle)) + + (negate (sy earthqkLoadFctr) $* (inxi slcWght) - (inxi watrForceDif) + + (inxi surfHydroForce) $* sin (inxi surfAngle) $+ (inxi surfLoad) * + (sin (inxi impLoadAngle))) $* (sin (inxi baseAngle)) - + (inxi baseHydroForce)) $* tan (inxi fricAngle) $+ (inxi effCohesion) * + (inxi baseWthX) $* sec (inxi baseAngle) ] @@ -454,18 +454,18 @@ mobShr_deriv_eqns_ssp = [eq4, eq5, eq6] eq4, eq5, eq6:: Expr eq4 = inxi mobShrI $= eqlExpr sin cos - (\x y -> x - inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) + (\x y -> x - inxiM1 intShrForce $+ inxi intShrForce $+ y) -eq5 = inxi shearFNoIntsl $= ((inxi slcWght) `addRe` (inxi surfHydroForce) * - (cos (inxi surfAngle)) `addRe` (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) * - (sin (inxi baseAngle)) - (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - - (inxi watrForceDif) `addRe` (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) + - (inxi surfLoad) `mulRe` (sin (inxi impLoadAngle))) `mulRe` (cos (inxi baseAngle)) +eq5 = inxi shearFNoIntsl $= ((inxi slcWght) $+ (inxi surfHydroForce) * + (cos (inxi surfAngle)) $+ (inxi surfLoad) $* (cos (inxi impLoadAngle))) * + (sin (inxi baseAngle)) - (negate (sy earthqkLoadFctr) $* (inxi slcWght) - + (inxi watrForceDif) $+ (inxi surfHydroForce) $* sin (inxi surfAngle) + + (inxi surfLoad) $* (sin (inxi impLoadAngle))) $* (cos (inxi baseAngle)) -eq6 = inxi shearFNoIntsl $= ((inxi slcWght) `addRe` (inxi surfHydroForce) * +eq6 = inxi shearFNoIntsl $= ((inxi slcWght) $+ (inxi surfHydroForce) * (cos (inxi surfAngle))) * (sin (inxi baseAngle)) - - ((inxi watrForceDif) `addRe` (inxi surfHydroForce) `mulRe` sin (inxi surfAngle)) `mulRe` (cos (inxi baseAngle)) + ((inxi watrForceDif) $+ (inxi surfHydroForce) $* sin (inxi surfAngle)) $* (cos (inxi baseAngle)) ------old chunk----- mobShrDerivation :: [Contents] @@ -476,7 +476,7 @@ mobShrDerivation = [ S "also shown in", eqN 4], eqUnR' $ inxi mobShrI $= eqlExpr sin cos - (\x y -> x - inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y), + (\x y -> x - inxiM1 intShrForce $+ inxi intShrForce $+ y), foldlSP [S "The", phrase equation, S "is unsolvable, containing the unknown", getTandS intNormForce, S "and" +:+. getTandS intShrForce, @@ -484,11 +484,11 @@ mobShrDerivation = [ getTandS shearFNoIntsl `sC` S "as done in", eqN 5], eqUnR' $ - inxi shearFNoIntsl $= ((inxi slcWght) `addRe` (inxi surfHydroForce) * - (cos (inxi surfAngle)) `addRe` (inxi surfLoad) `mulRe` (cos (inxi impLoadAngle))) * - (sin (inxi baseAngle)) - (negate (sy earthqkLoadFctr) `mulRe` (inxi slcWght) - - (inxi watrForceDif) `addRe` (inxi surfHydroForce) `mulRe` sin (inxi surfAngle) + - (inxi surfLoad) `mulRe` (sin (inxi impLoadAngle))) `mulRe` (cos (inxi baseAngle)), + inxi shearFNoIntsl $= ((inxi slcWght) $+ (inxi surfHydroForce) * + (cos (inxi surfAngle)) $+ (inxi surfLoad) $* (cos (inxi impLoadAngle))) * + (sin (inxi baseAngle)) - (negate (sy earthqkLoadFctr) $* (inxi slcWght) - + (inxi watrForceDif) $+ (inxi surfHydroForce) $* sin (inxi surfAngle) + + (inxi surfLoad) $* (sin (inxi impLoadAngle))) $* (cos (inxi baseAngle)), foldlSP [S "The", plural value, S "of", ch shearRNoIntsl `S.and_` ch shearFNoIntsl, S "are now defined completely in terms of the", diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/GenDefs.hs b/code/drasil-example/ssp/lib/Drasil/SSP/GenDefs.hs index 4692cfbb32..0c2649934d 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/GenDefs.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/GenDefs.hs @@ -86,7 +86,7 @@ normForcEq = makeRC "normForcEq" (nounPhraseSP "normal force equilibrium") nmFEqRel :: Relation nmFEqRel = inxi totNrmForce $= eqlExprN cos sin - (\x y -> x $- inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) + (\x y -> x $- inxiM1 intShrForce $+ inxi intShrForce $+ y) nmFEqDesc :: Sentence nmFEqDesc = foldlSent [S "This equation satisfies", refS equilibrium +:+. @@ -106,7 +106,7 @@ bsShrFEq = makeRC "bsShrFEq" (nounPhraseSP "base shear force equilibrium") bShFEqRel :: Relation bShFEqRel = inxi mobShrI $= eqlExpr sin cos - (\x y -> x $- inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) + (\x y -> x $- inxiM1 intShrForce $+ inxi intShrForce $+ y) bShFEqDesc :: Sentence bShFEqDesc = foldlSent [S "This equation satisfies", refS equilibrium +:+. @@ -120,7 +120,7 @@ bShFEqDeriv = mkDerivNoHeader [foldlSent [atStart bsShrFEq `S.is` (refS figForceActing `S.in_` refS (SRS.physSyst [] []))]] -- shrResEqn :: Expr -shrResEqn = inxi nrmFSubWat `mulRe` tan (inxi fricAngle) `addRe` (inxi effCohesion `mulRe` +shrResEqn = inxi nrmFSubWat $* tan (inxi fricAngle) $+ (inxi effCohesion $* inxi baseLngth) resShr :: RelationConcept @@ -193,7 +193,7 @@ normShrR :: ModelQDef normShrR = mkQuantDef intShrForce nmShrRExpr nmShrRExpr :: PExpr -nmShrRExpr = sy normToShear `mulRe` sy scalFunc `mulRe` sy intNormForce +nmShrRExpr = sy normToShear $* sy scalFunc $* sy intNormForce nmShrRDesc :: Sentence nmShrRDesc = foldlSent [S "Mathematical representation of the primary", @@ -207,10 +207,10 @@ resShearWO = makeRC "resShearWO" resShearWORel :: Relation resShearWORel = inxi shearRNoIntsl $= - ((inxi slcWght `addRe` (inxi surfHydroForce `mulRe` cos (inxi surfAngle))) `mulRe` - cos (inxi baseAngle) `addRe` (neg (inxi watrForce) `addRe` inxiM1 watrForce `addRe` - (inxi surfHydroForce `mulRe` sin (inxi surfAngle)) `mulRe` sin (inxi baseAngle) $- - inxi baseHydroForce) `mulRe` tan (inxi fricAngle) `addRe` (inxi effCohesion `mulRe` + ((inxi slcWght $+ (inxi surfHydroForce $* cos (inxi surfAngle))) $* + cos (inxi baseAngle) $+ (neg (inxi watrForce) $+ inxiM1 watrForce $+ + (inxi surfHydroForce $* sin (inxi surfAngle)) $* sin (inxi baseAngle) $- + inxi baseHydroForce) $* tan (inxi fricAngle) $+ (inxi effCohesion $* inxi baseLngth)) resShearWODesc :: Sentence @@ -229,9 +229,9 @@ mobShearWO = makeRC "mobShearWO" (nounPhraseSP "mobilized shear force, without interslice normal and shear forces") mobShearWODesc mobShearWORel mobShearWORel :: Relation -mobShearWORel = inxi shearFNoIntsl $= ((inxi slcWght `addRe` (inxi surfHydroForce `mulRe` - cos (inxi surfAngle))) `mulRe` sin (inxi baseAngle) $- ((neg (inxi watrForce) `addRe` - inxiM1 watrForce `addRe` (inxi surfHydroForce `mulRe` sin (inxi surfAngle))) `mulRe` cos (inxi baseAngle))) +mobShearWORel = inxi shearFNoIntsl $= ((inxi slcWght $+ (inxi surfHydroForce $* + cos (inxi surfAngle))) $* sin (inxi baseAngle) $- ((neg (inxi watrForce) $+ + inxiM1 watrForce $+ (inxi surfHydroForce $* sin (inxi surfAngle))) $* cos (inxi baseAngle))) mobShearWODesc :: Sentence mobShearWODesc = (foldlList Comma List [slcWght `definedIn'''` sliceWghtGD, @@ -247,8 +247,8 @@ momentEqlModel = equationalConstraints' $ NE.fromList [express momEqlExpr] momEqlExpr :: Expr -momEqlExpr = exactDbl 0 $= momExpr (\ x y -> x `addRe` - (half (inxi baseWthX) `mulRe` (inxi intShrForce `addRe` inxiM1 intShrForce)) `addRe` y) +momEqlExpr = exactDbl 0 $= momExpr (\ x y -> x $+ + (half (inxi baseWthX) $* (inxi intShrForce $+ inxiM1 intShrForce)) $+ y) momEqlDesc :: Sentence momEqlDesc = foldlSent [S "This", phrase equation, S "satisfies", @@ -361,8 +361,8 @@ momEqlDerivSheariM1Sentence = [atStartNP (NP.the (combineNINI intrslce shearForc momEqlDerivSeismicIntSentence = [S "Seismic", plural force, S "act over the", S "entire height of the" +:+. phrase slice, S "For each horizontal segment" `S.ofThe` phrase slice `sC` S "the seismic", phrase force `S.is` - eS (sy earthqkLoadFctr `mulRe` inxi slcWght), S "where", eS (inxi slcWght), - S "can be expressed as", eS (sy genericSpWght `mulRe` inxi baseWthX `mulRe` sy yi), + eS (sy earthqkLoadFctr $* inxi slcWght), S "where", eS (inxi slcWght), + S "can be expressed as", eS (sy genericSpWght $* inxi baseWthX $* sy yi), S "using", refS weightGD, S "where", eS' yi, S "is the height of" +:+. S "the segment under consideration", S "The corresponding", phrase momntArm `S.is` ch yi `sC` S "the height from the base of", phraseNP (the slice) +:+. @@ -379,7 +379,7 @@ momEqlDerivSeismicIntSentence = [S "Seismic", plural force, S "act over the", momEqlDerivSeismicSentence = [S "Solving the definite integral yields"] momEqlDerivSeismicWSentence = [S "Using", refS weightGD, - S "again to express", eS (sy genericSpWght `mulRe` inxi baseWthX `mulRe` inxi midpntHght), + S "again to express", eS (sy genericSpWght $* inxi baseWthX $* inxi midpntHght), S "as", eS (inxi slcWght) `sC` phraseNP (the genericM), S "is"] momEqlDerivHydroSentence = [S "The surface hydrostatic", phrase force, @@ -407,40 +407,40 @@ momEqlDerivFinalSentence = [S "The base hydrostatic", phraseNP (force `and_` momEqlDerivTorqueEqn = sy torque $= cross (sy displacement) (sy force) -momEqlDerivMomentEqn = sy genericM $= sy rotForce `mulRe` sy momntArm +momEqlDerivMomentEqn = sy genericM $= sy rotForce $* sy momntArm -momEqlDerivNormaliEqn = neg (inxi intNormForce) `mulRe` (inxi sliceHght `addRe` - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle))) +momEqlDerivNormaliEqn = neg (inxi intNormForce) $* (inxi sliceHght $+ + (half (inxi baseWthX) $* tan (inxi baseAngle))) -momEqlDerivNormaliM1Eqn = inxiM1 intNormForce `mulRe` (inxiM1 sliceHght $- - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle))) +momEqlDerivNormaliM1Eqn = inxiM1 intNormForce $* (inxiM1 sliceHght $- + (half (inxi baseWthX) $* tan (inxi baseAngle))) -momEqlDerivWateriEqn = neg (inxi watrForce) `mulRe` (frac 1 3 `mulRe` inxi sliceHghtW `addRe` - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle))) +momEqlDerivWateriEqn = neg (inxi watrForce) $* (frac 1 3 $* inxi sliceHghtW $+ + (half (inxi baseWthX) $* tan (inxi baseAngle))) -momEqlDerivWateriM1Eqn = inxiM1 watrForce `mulRe` (frac 1 3 `mulRe` inxiM1 sliceHghtW `addRe` - (half (inxi baseWthX) `mulRe` tan (inxi baseAngle))) +momEqlDerivWateriM1Eqn = inxiM1 watrForce $* (frac 1 3 $* inxiM1 sliceHghtW $+ + (half (inxi baseWthX) $* tan (inxi baseAngle))) -momEqlDerivSheariEqn = inxi intShrForce `mulRe` half (inxi baseWthX) +momEqlDerivSheariEqn = inxi intShrForce $* half (inxi baseWthX) -momEqlDerivSheariM1Eqn = inxiM1 intShrForce `mulRe` half (inxi baseWthX) +momEqlDerivSheariM1Eqn = inxiM1 intShrForce $* half (inxi baseWthX) momEqlDerivSeismicIntEqn = neg $ defint (eqSymb yi) (exactDbl 0) (inxi midpntHght) - (sy earthqkLoadFctr `mulRe` sy genericSpWght `mulRe` inxi baseWthX `mulRe` sy yi) + (sy earthqkLoadFctr $* sy genericSpWght $* inxi baseWthX $* sy yi) -momEqlDerivSeismicEqn = neg $ sy earthqkLoadFctr `mulRe` sy genericSpWght `mulRe` - inxi baseWthX `mulRe` half (square (inxi midpntHght)) +momEqlDerivSeismicEqn = neg $ sy earthqkLoadFctr $* sy genericSpWght $* + inxi baseWthX $* half (square (inxi midpntHght)) -momEqlDerivSeismicWEqn = neg $ sy earthqkLoadFctr `mulRe` inxi slcWght `mulRe` +momEqlDerivSeismicWEqn = neg $ sy earthqkLoadFctr $* inxi slcWght $* half (inxi midpntHght) -momEqlDerivHydroEqn = inxi surfHydroForce `mulRe` sin (inxi surfAngle) `mulRe` +momEqlDerivHydroEqn = inxi surfHydroForce $* sin (inxi surfAngle) $* inxi midpntHght -momEqlDerivExtEqn = inxi surfLoad `mulRe` sin (inxi impLoadAngle) `mulRe` inxi midpntHght +momEqlDerivExtEqn = inxi surfLoad $* sin (inxi impLoadAngle) $* inxi midpntHght -momEqlDerivFinalEqn = exactDbl 0 $= momExpr (\ x y -> x `addRe` - (half (inxi baseWthX) `mulRe` (inxi intShrForce `addRe` inxiM1 intShrForce)) `addRe` y) +momEqlDerivFinalEqn = exactDbl 0 $= momExpr (\ x y -> x $+ + (half (inxi baseWthX) $* (inxi intShrForce $+ inxiM1 intShrForce)) $+ y) -- @@ -449,19 +449,19 @@ sliceWght = makeRC "sliceWght" (nounPhraseSP "slice weight") sliceWghtNotes sliceWghtEqn sliceWghtEqn :: Expr -sliceWghtEqn = inxi slcWght $= inxi baseWthX `mulRe` oneHalf `mulRe` completeCase [case1, case2, case3] - where case1 = (((inxi slopeHght $- inxi slipHght) `addRe` - (inxiM1 slopeHght $- inxiM1 slipHght)) `mulRe` sy satWeight, +sliceWghtEqn = inxi slcWght $= inxi baseWthX $* oneHalf $* completeCase [case1, case2, case3] + where case1 = (((inxi slopeHght $- inxi slipHght) $+ + (inxiM1 slopeHght $- inxiM1 slipHght)) $* sy satWeight, (inxi waterHght $> inxi slopeHght) $|| (inxiM1 waterHght $> inxiM1 slopeHght)) - case2 = (((inxi slopeHght $- inxi waterHght) `addRe` - (inxiM1 slopeHght $- inxiM1 waterHght)) `mulRe` sy dryWeight `addRe` - (((inxi waterHght $- inxi slipHght) `addRe` - (inxiM1 waterHght $- inxiM1 slipHght)) `mulRe` sy satWeight), + case2 = (((inxi slopeHght $- inxi waterHght) $+ + (inxiM1 slopeHght $- inxiM1 waterHght)) $* sy dryWeight $+ + (((inxi waterHght $- inxi slipHght) $+ + (inxiM1 waterHght $- inxiM1 slipHght)) $* sy satWeight), (inxi slopeHght $>= inxi waterHght $>= inxi slipHght) $&& (inxiM1 slopeHght $>= inxiM1 waterHght $>= inxiM1 slipHght)) - case3 = (((inxi slopeHght $- inxi slipHght) `addRe` - (inxiM1 slopeHght $- inxiM1 slipHght)) `mulRe` sy dryWeight, + case3 = (((inxi slopeHght $- inxi slipHght) $+ + (inxiM1 slopeHght $- inxiM1 slipHght)) $* sy dryWeight, (inxi waterHght $< inxi slipHght) $|| (inxiM1 waterHght $< inxiM1 slipHght)) @@ -518,10 +518,10 @@ sliceWghtDerivSatCase2DSentence = [S "Due to", refS assumpPSC `sC` S "width of the" +:+. phrase slice, S "Thus" `sC` phraseNP (the slcWght), S "are defined as"] -sliceWghtDerivSatCaseWeightEqn = inxi slcWght $= inxi satVol `mulRe` sy satWeight +sliceWghtDerivSatCaseWeightEqn = inxi slcWght $= inxi satVol $* sy satWeight -sliceWghtDerivSatCaseSliceEqn = inxi slcWght $= inxi baseWthX `mulRe` oneHalf `mulRe` - ((inxi slopeHght $- inxi slipHght) `addRe` (inxiM1 slopeHght $- inxiM1 slipHght)) `mulRe` sy satWeight +sliceWghtDerivSatCaseSliceEqn = inxi slcWght $= inxi baseWthX $* oneHalf $* + ((inxi slopeHght $- inxi slipHght) $+ (inxiM1 slopeHght $- inxiM1 slipHght)) $* sy satWeight sliceWghtDerivDryCaseIntroSentence = [S "For the case where the", phrase waterTable, S "is below", phraseNP (the slpSrf) `sC` @@ -537,10 +537,10 @@ sliceWghtDerivDryCase2DSentence = [refS assumpPSC, S "again allows for", S "shape is the same as in the previous case" `sC` S "so", phraseNP (the slcWght), S "are defined as"] -sliceWghtDerivDryCaseWeightEqn = inxi slcWght $= inxi dryVol `mulRe` sy dryWeight +sliceWghtDerivDryCaseWeightEqn = inxi slcWght $= inxi dryVol $* sy dryWeight -sliceWghtDerivDryCaseSliceEqn = inxi slcWght $= inxi baseWthX `mulRe` oneHalf `mulRe` - ((inxi slopeHght $- inxi slipHght) `addRe` (inxiM1 slopeHght $- inxiM1 slipHght)) `mulRe` sy dryWeight +sliceWghtDerivDryCaseSliceEqn = inxi slcWght $= inxi baseWthX $* oneHalf $* + ((inxi slopeHght $- inxi slipHght) $+ (inxiM1 slopeHght $- inxiM1 slipHght)) $* sy dryWeight sliceWghtDerivMixCaseIntroSentence = [S "For the case where the", phrase waterTable, S "is between", phraseNP (NP.the (slopeSrf `and_` @@ -566,14 +566,14 @@ sliceWghtDerivMixCase2DSentence = [refS assumpPSC, S "again allows for", phraseNP (waterTable `and_` slpSrf), S "at", phraseNP (the slice) +:+. S "edges", S "Thus" `sC` phraseNP (the slcWght), S "are defined as"] -sliceWghtDerivMixCaseWeightEqn = inxi slcWght $= inxi dryVol `mulRe` sy dryWeight `addRe` - (inxi satVol `mulRe` sy satWeight) +sliceWghtDerivMixCaseWeightEqn = inxi slcWght $= inxi dryVol $* sy dryWeight $+ + (inxi satVol $* sy satWeight) -sliceWghtDerivMixCaseSliceEqn = inxi slcWght $= (inxi baseWthX `mulRe` oneHalf `mulRe` - (((inxi slopeHght $- inxi waterHght) `addRe` - (inxiM1 slopeHght $- inxiM1 waterHght)) `mulRe` sy dryWeight `addRe` - (((inxi waterHght $- inxi slipHght) `addRe` - (inxiM1 waterHght $- inxiM1 slipHght)) `mulRe` sy satWeight))) +sliceWghtDerivMixCaseSliceEqn = inxi slcWght $= (inxi baseWthX $* oneHalf $* + (((inxi slopeHght $- inxi waterHght) $+ + (inxiM1 slopeHght $- inxiM1 waterHght)) $* sy dryWeight $+ + (((inxi waterHght $- inxi slipHght) $+ + (inxiM1 waterHght $- inxiM1 slipHght)) $* sy satWeight))) -- @@ -582,9 +582,9 @@ baseWtrF = makeRC "baseWtrF" (nounPhraseSP "base hydrostatic force") bsWtrFNotes bsWtrFEqn bsWtrFEqn :: Expr -bsWtrFEqn = inxi baseHydroForce $= inxi baseLngth `mulRe` sy waterWeight `mulRe` oneHalf `mulRe` +bsWtrFEqn = inxi baseHydroForce $= inxi baseLngth $* sy waterWeight $* oneHalf $* completeCase [case1, case2] - where case1 = ((inxi waterHght $- inxi slipHght) `addRe` + where case1 = ((inxi waterHght $- inxi slipHght) $+ (inxiM1 waterHght $- inxiM1 slipHght), (inxi waterHght $> inxi slipHght) $|| (inxiM1 waterHght $> inxiM1 slipHght)) @@ -651,11 +651,11 @@ bsWtrFDerivEndSentence = [foldlSent [S "This", phrase equation `S.is` S "is below", phraseNP (height `the_ofThe` slpSrf) `sC` S "so there is no", S "hydrostatic", phrase force]] -bsWtrFDerivWeightEqn = sy pressure $= sy specWeight `mulRe` sy height +bsWtrFDerivWeightEqn = sy pressure $= sy specWeight $* sy height -bsWtrFDerivHeightEqn = oneHalf `mulRe` ((inxi waterHght $- inxi slipHght) `addRe` (inxiM1 waterHght $- inxiM1 slipHght)) +bsWtrFDerivHeightEqn = oneHalf $* ((inxi waterHght $- inxi slipHght) $+ (inxiM1 waterHght $- inxiM1 slipHght)) -bsWtrFDerivSliceEqn = inxi baseHydroForce $= inxi baseLngth `mulRe` sy waterWeight `mulRe` +bsWtrFDerivSliceEqn = inxi baseHydroForce $= inxi baseLngth $* sy waterWeight $* bsWtrFDerivHeightEqn -- @@ -665,9 +665,9 @@ srfWtrF = makeRC "srfWtrF" (nounPhraseSP "surface hydrostatic force") srfWtrFNotes srfWtrFEqn srfWtrFEqn :: Relation -srfWtrFEqn = inxi surfHydroForce $= inxi surfLngth `mulRe` sy waterWeight `mulRe` oneHalf `mulRe` +srfWtrFEqn = inxi surfHydroForce $= inxi surfLngth $* sy waterWeight $* oneHalf $* completeCase [case1, case2] - where case1 = ((inxi waterHght $- inxi slopeHght) `addRe` + where case1 = ((inxi waterHght $- inxi slopeHght) $+ (inxiM1 waterHght $- inxiM1 slopeHght), (inxi waterHght $> inxi slopeHght) $|| (inxiM1 waterHght $> inxiM1 slopeHght)) @@ -734,9 +734,9 @@ srfWtrFDerivEndSentence = [foldlSent [S "This" +:+ phrase equation `S.is` S "is below", phraseNP (height `the_ofThe` slopeSrf) `sC` S "so there is no", S "hydrostatic", phrase force]] -srfWtrFDerivWeightEqn = sy pressure $= sy specWeight `mulRe` sy height +srfWtrFDerivWeightEqn = sy pressure $= sy specWeight $* sy height -srfWtrFDerivHeightEqn = oneHalf `mulRe` ((inxi waterHght $- inxi slopeHght) `addRe` (inxiM1 waterHght $- inxiM1 slopeHght)) +srfWtrFDerivHeightEqn = oneHalf $* ((inxi waterHght $- inxi slopeHght) $+ (inxiM1 waterHght $- inxiM1 slopeHght)) -srfWtrFDerivSliceEqn = inxi surfHydroForce $= inxi surfLngth `mulRe` sy waterWeight `mulRe` +srfWtrFDerivSliceEqn = inxi surfHydroForce $= inxi surfLngth $* sy waterWeight $* srfWtrFDerivHeightEqn \ No newline at end of file diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/IMods.hs b/code/drasil-example/ssp/lib/Drasil/SSP/IMods.hs index b6dfaa51ef..c1c01a461f 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/IMods.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/IMods.hs @@ -65,7 +65,7 @@ fctSftyExpr = sumOp shearRNoIntsl $/ sumOp shearFNoIntsl where prodOp = defprod (eqSymb varblV) (sy index) (sy numbSlices $- int 1) (idx (sy mobShrC) (sy varblV)) sumOp sym = defsum (eqSymb index) (int 1) (sy numbSlices $- int 1) - (idx (sy sym) (sy index) `mulRe` prodOp) `addRe` idx (sy sym) (sy numbSlices) + (idx (sy sym) (sy index) $* prodOp) $+ idx (sy sym) (sy numbSlices) fctSftyDesc :: Sentence fctSftyDesc = foldlList Comma List [shearRNoIntsl `definedIn'''` resShearWOGD, @@ -205,66 +205,66 @@ fctSftyDerivSentence20 = [ch fs +:+ S "depends on the unknowns" +:+ fctSftyDerivEqn1 :: PExpr fctSftyDerivEqn1 = --FIXME: pull the right side of this from GD4 - eqlExpr sin cos (\x y -> x $- inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) - $= (inxi nrmFSubWat `mulRe` tan (sy fricAngle) `addRe` (sy effCohesion `mulRe` + eqlExpr sin cos (\x y -> x $- inxiM1 intShrForce $+ inxi intShrForce $+ y) + $= (inxi nrmFSubWat $* tan (sy fricAngle) $+ (sy effCohesion $* inxi baseLngth)) $/ sy fs fctSftyDerivEqn2 :: PExpr fctSftyDerivEqn2 = inxi nrmFSubWat $= eqlExprN cos sin (\x y -> x $- - inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) $- inxi baseHydroForce + inxiM1 intShrForce $+ inxi intShrForce $+ y) $- inxi baseHydroForce fctSftyDerivEqn3 :: PExpr -fctSftyDerivEqn3 = eqlExpr sin cos (\x y -> x $- inxiM1 intShrForce `addRe` - inxi intShrForce `addRe` y) $= ((eqlExprN cos sin (\x y -> x $- - inxiM1 intShrForce `addRe` inxi intShrForce `addRe` y) $- inxi baseHydroForce) `mulRe` - tan (sy fricAngle) `addRe` (sy effCohesion `mulRe` inxi baseLngth)) $/ sy fs +fctSftyDerivEqn3 = eqlExpr sin cos (\x y -> x $- inxiM1 intShrForce $+ + inxi intShrForce $+ y) $= ((eqlExprN cos sin (\x y -> x $- + inxiM1 intShrForce $+ inxi intShrForce $+ y) $- inxi baseHydroForce) $* + tan (sy fricAngle) $+ (sy effCohesion $* inxi baseLngth)) $/ sy fs fctSftyDerivEqn4 :: PExpr -fctSftyDerivEqn4 = eqlExprSepG sin cos addRe `addRe` - ((neg (inxiM1 intShrForce) `addRe` inxi intShrForce) `mulRe` sin (inxi baseAngle)) $= - ((eqlExprNSepG cos sin addRe `addRe` - (((neg (inxiM1 intShrForce) `addRe` inxi intShrForce) `mulRe` cos (inxi baseAngle)) $- - inxi baseHydroForce) `mulRe` - tan (sy fricAngle)) `addRe` (sy effCohesion `mulRe` inxi baseLngth)) $/ sy fs +fctSftyDerivEqn4 = eqlExprSepG sin cos ($+) $+ + ((neg (inxiM1 intShrForce) $+ inxi intShrForce) $* sin (inxi baseAngle)) $= + ((eqlExprNSepG cos sin ($+) $+ + (((neg (inxiM1 intShrForce) $+ inxi intShrForce) $* cos (inxi baseAngle)) $- + inxi baseHydroForce) $* + tan (sy fricAngle)) $+ (sy effCohesion $* inxi baseLngth)) $/ sy fs fctSftyDerivEqn5 :: PExpr -fctSftyDerivEqn5 = eqlExprNoKQ sin cos addRe `addRe` - ((neg (inxiM1 intShrForce) `addRe` inxi intShrForce) `mulRe` sin (inxi baseAngle)) $= - ((eqlExprNNoKQ cos sin addRe `addRe` - ((neg (inxiM1 intShrForce) `addRe` inxi intShrForce) `mulRe` cos (inxi baseAngle)) $- - inxi baseHydroForce) `mulRe` - tan (sy fricAngle) `addRe` (sy effCohesion `mulRe` inxi baseLngth)) $/ sy fs +fctSftyDerivEqn5 = eqlExprNoKQ sin cos ($+) $+ + ((neg (inxiM1 intShrForce) $+ inxi intShrForce) $* sin (inxi baseAngle)) $= + ((eqlExprNNoKQ cos sin ($+) $+ + ((neg (inxiM1 intShrForce) $+ inxi intShrForce) $* cos (inxi baseAngle)) $- + inxi baseHydroForce) $* + tan (sy fricAngle) $+ (sy effCohesion $* inxi baseLngth)) $/ sy fs fctSftyDerivEqn6 :: PExpr -fctSftyDerivEqn6 = (inxi shearFNoIntsl `addRe` ((neg (inxiM1 intShrForce) `addRe` - inxi intShrForce) `mulRe` sin (inxi baseAngle)) $- ((neg (inxi intNormForce) `addRe` - inxiM1 intNormForce) `mulRe` cos (inxi baseAngle))) $= (inxi shearRNoIntsl `addRe` - (((neg (inxiM1 intShrForce) `addRe` inxi intShrForce) `mulRe` cos (inxi baseAngle) `addRe` - ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) `mulRe` sin (inxi baseAngle))) `mulRe` +fctSftyDerivEqn6 = (inxi shearFNoIntsl $+ ((neg (inxiM1 intShrForce) $+ + inxi intShrForce) $* sin (inxi baseAngle)) $- ((neg (inxi intNormForce) $+ + inxiM1 intNormForce) $* cos (inxi baseAngle))) $= (inxi shearRNoIntsl $+ + (((neg (inxiM1 intShrForce) $+ inxi intShrForce) $* cos (inxi baseAngle) $+ + ((neg (inxi intNormForce) $+ inxiM1 intNormForce) $* sin (inxi baseAngle))) $* tan (sy fricAngle))) $/ sy fs fctSftyDerivEqn7 :: PExpr -fctSftyDerivEqn7 = (inxi shearFNoIntsl `addRe` ((neg (sy normToShear) `mulRe` inxiM1 scalFunc `mulRe` - inxiM1 intNormForce `addRe` (sy normToShear `mulRe` inxi scalFunc `mulRe` inxi intNormForce)) `mulRe` - sin (inxi baseAngle)) $- ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) `mulRe` cos (inxi baseAngle))) - $= (inxi shearRNoIntsl `addRe` (((neg (sy normToShear) `mulRe` - inxiM1 scalFunc `mulRe` inxiM1 intNormForce `addRe` (sy normToShear `mulRe` inxi scalFunc `mulRe` - inxi intNormForce)) `mulRe` cos (inxi baseAngle) `addRe` ((neg (inxi intNormForce) `addRe` inxiM1 intNormForce) - `mulRe` sin (inxi baseAngle))) `mulRe` tan (sy fricAngle))) $/ sy fs +fctSftyDerivEqn7 = (inxi shearFNoIntsl $+ ((neg (sy normToShear) $* inxiM1 scalFunc $* + inxiM1 intNormForce $+ (sy normToShear $* inxi scalFunc $* inxi intNormForce)) $* + sin (inxi baseAngle)) $- ((neg (inxi intNormForce) $+ inxiM1 intNormForce) $* cos (inxi baseAngle))) + $= (inxi shearRNoIntsl $+ (((neg (sy normToShear) $* + inxiM1 scalFunc $* inxiM1 intNormForce $+ (sy normToShear $* inxi scalFunc $* + inxi intNormForce)) $* cos (inxi baseAngle) $+ ((neg (inxi intNormForce) $+ inxiM1 intNormForce) + $* sin (inxi baseAngle))) $* tan (sy fricAngle))) $/ sy fs fctSftyDerivEqn8 :: PExpr -fctSftyDerivEqn8 = (inxi intNormForce `mulRe` ((sy normToShear `mulRe` inxi scalFunc `mulRe` - cos (inxi baseAngle) $- sin (inxi baseAngle)) `mulRe` tan (sy fricAngle) $- - ((sy normToShear `mulRe` inxi scalFunc `mulRe` sin (inxi baseAngle) `addRe` - cos (inxi baseAngle)) `mulRe` sy fs))) $= (inxiM1 intNormForce `mulRe` - ((sy normToShear `mulRe` inxiM1 scalFunc `mulRe` cos (inxi baseAngle) $- - sin (inxi baseAngle)) `mulRe` tan (sy fricAngle) $- ((sy normToShear `mulRe` - inxiM1 scalFunc `mulRe` sin (inxi baseAngle) `addRe` cos (inxi baseAngle)) `mulRe` - sy fs)) `addRe` (sy fs `mulRe` inxi shearFNoIntsl) $- inxi shearRNoIntsl) +fctSftyDerivEqn8 = (inxi intNormForce $* ((sy normToShear $* inxi scalFunc $* + cos (inxi baseAngle) $- sin (inxi baseAngle)) $* tan (sy fricAngle) $- + ((sy normToShear $* inxi scalFunc $* sin (inxi baseAngle) $+ + cos (inxi baseAngle)) $* sy fs))) $= (inxiM1 intNormForce $* + ((sy normToShear $* inxiM1 scalFunc $* cos (inxi baseAngle) $- + sin (inxi baseAngle)) $* tan (sy fricAngle) $- ((sy normToShear $* + inxiM1 scalFunc $* sin (inxi baseAngle) $+ cos (inxi baseAngle)) $* + sy fs)) $+ (sy fs $* inxi shearFNoIntsl) $- inxi shearRNoIntsl) fctSftyDerivEqn9 :: PExpr -fctSftyDerivEqn9 = (inxi intNormForce `mulRe` inxi shrResC) $= (inxiM1 mobShrC `mulRe` - inxiM1 intNormForce `mulRe` inxiM1 shrResC `addRe` (sy fs `mulRe` inxi shearFNoIntsl) $- +fctSftyDerivEqn9 = (inxi intNormForce $* inxi shrResC) $= (inxiM1 mobShrC $* + inxiM1 intNormForce $* inxiM1 shrResC $+ (sy fs $* inxi shearFNoIntsl) $- inxi shearRNoIntsl) fctSftyDerivEqn10a :: PExpr @@ -277,97 +277,97 @@ fctSftyDerivEqn10c :: PExpr fctSftyDerivEqn10c = sliceExpr 3 fctSftyDerivEqn10d :: PExpr -fctSftyDerivEqn10d = idx (sy intNormForce) (sy numbSlices $- int 2) `mulRe` - idx (sy shrResC) (sy numbSlices $- int 2) $= (idx (sy mobShrC) (sy numbSlices $- int 3) `mulRe` idx (sy intNormForce) (sy numbSlices $- int 3) `mulRe` - idx (sy shrResC) (sy numbSlices $- int 3) `addRe` (sy fs `mulRe` +fctSftyDerivEqn10d = idx (sy intNormForce) (sy numbSlices $- int 2) $* + idx (sy shrResC) (sy numbSlices $- int 2) $= (idx (sy mobShrC) (sy numbSlices $- int 3) $* idx (sy intNormForce) (sy numbSlices $- int 3) $* + idx (sy shrResC) (sy numbSlices $- int 3) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 2)) $- idx (sy shearRNoIntsl) (sy numbSlices $- int 2)) fctSftyDerivEqn10e :: PExpr -fctSftyDerivEqn10e = idx (sy intNormForce) (sy numbSlices $- int 1) `mulRe` - idx (sy shrResC) (sy numbSlices $- int 1) $= (idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy intNormForce) (sy numbSlices $- int 2) `mulRe` - idx (sy shrResC) (sy numbSlices $- int 2) `addRe` (sy fs `mulRe` +fctSftyDerivEqn10e = idx (sy intNormForce) (sy numbSlices $- int 1) $* + idx (sy shrResC) (sy numbSlices $- int 1) $= (idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy intNormForce) (sy numbSlices $- int 2) $* + idx (sy shrResC) (sy numbSlices $- int 2) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 1)) $- idx (sy shearRNoIntsl) (sy numbSlices $- int 1)) fctSftyDerivEqn10f :: PExpr -fctSftyDerivEqn10f = idx (sy intNormForce) (sy numbSlices) `mulRe` - idx (sy shrResC) (sy numbSlices) $= (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` idx (sy intNormForce) (sy numbSlices $- int 1) `mulRe` - idx (sy shrResC) (sy numbSlices $- int 1) `addRe` (sy fs `mulRe` +fctSftyDerivEqn10f = idx (sy intNormForce) (sy numbSlices) $* + idx (sy shrResC) (sy numbSlices) $= (idx (sy mobShrC) (sy numbSlices $- int 1) $* idx (sy intNormForce) (sy numbSlices $- int 1) $* + idx (sy shrResC) (sy numbSlices $- int 1) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices)) $- idx (sy shearRNoIntsl) (sy numbSlices)) fctSftyDerivEqn11 :: PExpr -fctSftyDerivEqn11 = (indx1 intNormForce `mulRe` indx1 shrResC) $= - (sy fs `mulRe` indx1 shearFNoIntsl $- indx1 shearRNoIntsl) +fctSftyDerivEqn11 = (indx1 intNormForce $* indx1 shrResC) $= + (sy fs $* indx1 shearFNoIntsl $- indx1 shearRNoIntsl) fctSftyDerivEqn12 :: PExpr -fctSftyDerivEqn12 = neg ((sy fs `mulRe` indxn shearFNoIntsl $- indxn shearRNoIntsl) $/ +fctSftyDerivEqn12 = neg ((sy fs $* indxn shearFNoIntsl $- indxn shearRNoIntsl) $/ idx (sy mobShrC) (sy numbSlices $- int 1)) $= - (idx (sy intNormForce) (sy numbSlices $- int 1) `mulRe` + (idx (sy intNormForce) (sy numbSlices $- int 1) $* idx (sy shrResC) (sy numbSlices $- int 1)) fctSftyDerivEqn13 :: PExpr -fctSftyDerivEqn13 = idx (sy intNormForce) (int 2) `mulRe` idx (sy shrResC) (int 2) $= - (idx (sy mobShrC) (int 1) `mulRe` (sy fs `mulRe` idx (sy shearFNoIntsl) (int 1) $- - idx (sy shearRNoIntsl) (int 1)) `addRe` (sy fs `mulRe` idx (sy shearFNoIntsl) (int 2)) $- +fctSftyDerivEqn13 = idx (sy intNormForce) (int 2) $* idx (sy shrResC) (int 2) $= + (idx (sy mobShrC) (int 1) $* (sy fs $* idx (sy shearFNoIntsl) (int 1) $- + idx (sy shearRNoIntsl) (int 1)) $+ (sy fs $* idx (sy shearFNoIntsl) (int 2)) $- idx (sy shearRNoIntsl) (int 2)) fctSftyDerivEqn14 :: PExpr -fctSftyDerivEqn14 = idx (sy intNormForce) (int 3) `mulRe` idx (sy shrResC) (int 3) $= - (idx (sy mobShrC) (int 2) `mulRe` (idx (sy mobShrC) (int 1) `mulRe` (sy fs `mulRe` idx (sy shearFNoIntsl) (int 1) $- - idx (sy shearRNoIntsl) (int 1)) `addRe` (sy fs `mulRe` idx (sy shearFNoIntsl) (int 2)) $- - idx (sy shearRNoIntsl) (int 2)) `addRe` (sy fs `mulRe` idx (sy shearFNoIntsl) (int 3)) $- +fctSftyDerivEqn14 = idx (sy intNormForce) (int 3) $* idx (sy shrResC) (int 3) $= + (idx (sy mobShrC) (int 2) $* (idx (sy mobShrC) (int 1) $* (sy fs $* idx (sy shearFNoIntsl) (int 1) $- + idx (sy shearRNoIntsl) (int 1)) $+ (sy fs $* idx (sy shearFNoIntsl) (int 2)) $- + idx (sy shearRNoIntsl) (int 2)) $+ (sy fs $* idx (sy shearFNoIntsl) (int 3)) $- idx (sy shearRNoIntsl) (int 3)) --- Need to add ellipses where appropriate +-- Need to ($+) ellipses where appropriate fctSftyDerivEqn15 :: PExpr -fctSftyDerivEqn15 = idx (sy intNormForce) (sy numbSlices $- int 1) `mulRe` - idx (sy shrResC) (sy numbSlices $- int 1) $= (idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` - (idx (sy mobShrC) (sy numbSlices $- int 3) `mulRe` (idx (sy mobShrC) (int 1) `mulRe` - (sy fs `mulRe` idx (sy shearFNoIntsl) (int 1) $- idx (sy shearRNoIntsl) (int 1)) `addRe` (sy fs `mulRe` - idx (sy shearFNoIntsl) (int 2)) $- idx (sy shearRNoIntsl) (int 2)) `addRe` (sy fs `mulRe` +fctSftyDerivEqn15 = idx (sy intNormForce) (sy numbSlices $- int 1) $* + idx (sy shrResC) (sy numbSlices $- int 1) $= (idx (sy mobShrC) (sy numbSlices $- int 2) $* + (idx (sy mobShrC) (sy numbSlices $- int 3) $* (idx (sy mobShrC) (int 1) $* + (sy fs $* idx (sy shearFNoIntsl) (int 1) $- idx (sy shearRNoIntsl) (int 1)) $+ (sy fs $* + idx (sy shearFNoIntsl) (int 2)) $- idx (sy shearRNoIntsl) (int 2)) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 2)) $- - idx (sy shearRNoIntsl) (sy numbSlices $- int 2)) `addRe` (sy fs `mulRe` + idx (sy shearRNoIntsl) (sy numbSlices $- int 2)) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 1)) $- idx (sy shearRNoIntsl) (sy numbSlices $- int 1)) -- Ellipses needed here too fctSftyDerivEqn16 :: PExpr -fctSftyDerivEqn16 = neg ((sy fs `mulRe` indxn shearFNoIntsl $- indxn shearRNoIntsl) $/ +fctSftyDerivEqn16 = neg ((sy fs $* indxn shearFNoIntsl $- indxn shearRNoIntsl) $/ idx (sy mobShrC) (sy numbSlices $- int 1)) $= (idx (sy mobShrC) (sy numbSlices $- - int 2) `mulRe` (idx (sy mobShrC) (sy numbSlices $- int 3) `mulRe` (idx (sy mobShrC) (int 1) `mulRe` - (sy fs `mulRe` idx (sy shearFNoIntsl) (int 1) $- idx (sy shearRNoIntsl) (int 1)) `addRe` (sy fs `mulRe` - idx (sy shearFNoIntsl) (int 2)) $- idx (sy shearRNoIntsl) (int 2)) `addRe` (sy fs `mulRe` + int 2) $* (idx (sy mobShrC) (sy numbSlices $- int 3) $* (idx (sy mobShrC) (int 1) $* + (sy fs $* idx (sy shearFNoIntsl) (int 1) $- idx (sy shearRNoIntsl) (int 1)) $+ (sy fs $* + idx (sy shearFNoIntsl) (int 2)) $- idx (sy shearRNoIntsl) (int 2)) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 2)) $- - idx (sy shearRNoIntsl) (sy numbSlices $- int 2)) `addRe` (sy fs `mulRe` + idx (sy shearRNoIntsl) (sy numbSlices $- int 2)) $+ (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 1)) $- idx (sy shearRNoIntsl) (sy numbSlices $- int 1)) -- Ellipses needed here too fctSftyDerivEqn17 :: PExpr -fctSftyDerivEqn17 = neg (sy fs `mulRe` indxn shearFNoIntsl $- indxn shearRNoIntsl) $= - (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy mobShrC) (int 1) `mulRe` (sy fs `mulRe` indx1 shearFNoIntsl $- - indx1 shearRNoIntsl) `addRe` (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy mobShrC) (int 2) `mulRe` (sy fs `mulRe` - idx (sy shearFNoIntsl) (int 2) $- idx (sy shearRNoIntsl) (int 2))) `addRe` - (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` (sy fs `mulRe` +fctSftyDerivEqn17 = neg (sy fs $* indxn shearFNoIntsl $- indxn shearRNoIntsl) $= + (idx (sy mobShrC) (sy numbSlices $- int 1) $* idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy mobShrC) (int 1) $* (sy fs $* indx1 shearFNoIntsl $- + indx1 shearRNoIntsl) $+ (idx (sy mobShrC) (sy numbSlices $- int 1) $* idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy mobShrC) (int 2) $* (sy fs $* + idx (sy shearFNoIntsl) (int 2) $- idx (sy shearRNoIntsl) (int 2))) $+ + (idx (sy mobShrC) (sy numbSlices $- int 1) $* (sy fs $* idx (sy shearFNoIntsl) (sy numbSlices $- int 1) $- idx (sy shearRNoIntsl) (sy numbSlices $- int 1)))) -- Ellipses needed here too fctSftyDerivEqn18 :: PExpr -fctSftyDerivEqn18 = sy fs `mulRe` (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` - idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy mobShrC) (int 1) `mulRe` - idx (sy shearFNoIntsl) (int 1) `addRe` (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` - idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy mobShrC) (int 2) `mulRe` - idx (sy shearFNoIntsl) (int 2)) `addRe` (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` - idx (sy shearFNoIntsl) (sy numbSlices $- int 1)) `addRe` indxn shearFNoIntsl) $= - (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` - idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy mobShrC) (int 1) `mulRe` - idx (sy shearRNoIntsl) (int 1) `addRe` (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` - idx (sy mobShrC) (sy numbSlices $- int 2) `mulRe` idx (sy mobShrC) (int 2) `mulRe` - idx (sy shearRNoIntsl) (int 2)) `addRe` (idx (sy mobShrC) (sy numbSlices $- int 1) `mulRe` - idx (sy shearRNoIntsl) (sy numbSlices $- int 1)) `addRe` indxn shearRNoIntsl) +fctSftyDerivEqn18 = sy fs $* (idx (sy mobShrC) (sy numbSlices $- int 1) $* + idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy mobShrC) (int 1) $* + idx (sy shearFNoIntsl) (int 1) $+ (idx (sy mobShrC) (sy numbSlices $- int 1) $* + idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy mobShrC) (int 2) $* + idx (sy shearFNoIntsl) (int 2)) $+ (idx (sy mobShrC) (sy numbSlices $- int 1) $* + idx (sy shearFNoIntsl) (sy numbSlices $- int 1)) $+ indxn shearFNoIntsl) $= + (idx (sy mobShrC) (sy numbSlices $- int 1) $* + idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy mobShrC) (int 1) $* + idx (sy shearRNoIntsl) (int 1) $+ (idx (sy mobShrC) (sy numbSlices $- int 1) $* + idx (sy mobShrC) (sy numbSlices $- int 2) $* idx (sy mobShrC) (int 2) $* + idx (sy shearRNoIntsl) (int 2)) $+ (idx (sy mobShrC) (sy numbSlices $- int 1) $* + idx (sy shearRNoIntsl) (sy numbSlices $- int 1)) $+ indxn shearRNoIntsl) ------------------------------------------------------------------------ @@ -438,24 +438,24 @@ nrmShrDerivEqns = [nrmShrDerivEqn1, nrmShrDerivEqn2, nrmShrDerivEqn3, nrmShrDerivEqn1, nrmShrDerivEqn2, nrmShrDerivEqn3, nrmShrDerivEqn4 :: PExpr nrmShrDerivEqn1 = exactDbl 0 $= - momExpr (\ x y -> x `addRe` (sy normToShear `mulRe` half (inxi baseWthX) `mulRe` - (inxi intNormForce `mulRe` inxi scalFunc `addRe` (inxiM1 intNormForce `mulRe` - inxiM1 scalFunc))) `addRe` y) + momExpr (\ x y -> x $+ (sy normToShear $* half (inxi baseWthX) $* + (inxi intNormForce $* inxi scalFunc $+ (inxiM1 intNormForce $* + inxiM1 scalFunc))) $+ y) -nrmShrDerivEqn2 = sy normToShear $= momExpr addRe - $/ neg (half (inxi baseWthX) `mulRe` (inxi intNormForce `mulRe` inxi scalFunc `addRe` - (inxiM1 intNormForce `mulRe` inxiM1 scalFunc))) +nrmShrDerivEqn2 = sy normToShear $= momExpr ($+) + $/ neg (half (inxi baseWthX) $* (inxi intNormForce $* inxi scalFunc $+ + (inxiM1 intNormForce $* inxiM1 scalFunc))) -nrmShrDerivEqn3 = sy normToShear $= momExprNoKQ addRe - $/ neg (half (inxi baseWthX) `mulRe` (inxi intNormForce `mulRe` inxi scalFunc `addRe` - (inxiM1 intNormForce `mulRe` inxiM1 scalFunc))) +nrmShrDerivEqn3 = sy normToShear $= momExprNoKQ ($+) + $/ neg (half (inxi baseWthX) $* (inxi intNormForce $* inxi scalFunc $+ + (inxiM1 intNormForce $* inxiM1 scalFunc))) nrmShrDerivEqn4 = sy normToShear $= sum1toN - (inxi baseWthX `mulRe` (sy nrmForceSum `addRe` sy watForceSum) `mulRe` tan (inxi baseAngle) `addRe` - (inxi midpntHght `mulRe` neg (exactDbl 2 `mulRe` inxi surfHydroForce `mulRe` sin (inxi surfAngle)))) + (inxi baseWthX $* (sy nrmForceSum $+ sy watForceSum) $* tan (inxi baseAngle) $+ + (inxi midpntHght $* neg (exactDbl 2 $* inxi surfHydroForce $* sin (inxi surfAngle)))) $/ sum1toN - (inxi baseWthX `mulRe` (inxi intNormForce `mulRe` inxi scalFunc `addRe` - (inxiM1 intNormForce `mulRe` inxiM1 scalFunc))) + (inxi baseWthX $* (inxi intNormForce $* inxi scalFunc $+ + (inxiM1 intNormForce $* inxiM1 scalFunc))) --------------------------------------------------------------------- @@ -471,16 +471,16 @@ nrmShrForNumRC = makeRC "nrmShrForNumRC" (nounPhraseSP "normal and shear force p nrmShrFNumRel :: Relation nrmShrFNumRel = inxi nrmShearNum $= incompleteCase [case1,case2,case3] - where case1 = (indx1 baseWthX `mulRe` (indx1 intNormForce `addRe` indx1 watrForce) `mulRe` + where case1 = (indx1 baseWthX $* (indx1 intNormForce $+ indx1 watrForce) $* tan (indx1 baseAngle), sy index $= int 1) - case2 = ((inxi baseWthX `mulRe` - (sy nrmForceSum `addRe` sy watForceSum) - `mulRe` tan (inxi baseAngle)) `addRe` (sy midpntHght `mulRe` (neg - (exactDbl 2) `mulRe` inxi surfHydroForce `mulRe` sin (inxi surfAngle))), + case2 = ((inxi baseWthX $* + (sy nrmForceSum $+ sy watForceSum) + $* tan (inxi baseAngle)) $+ (sy midpntHght $* (neg + (exactDbl 2) $* inxi surfHydroForce $* sin (inxi surfAngle))), int 2 $<= sy index $<= (sy numbSlices $- int 1)) - case3 = (indxn baseWthX `mulRe` (idx (sy intNormForce) - (sy numbSlices $- int 1) `addRe` idx (sy watrForce) - (sy numbSlices $- int 1)) `mulRe` tan (idx (sy baseAngle) + case3 = (indxn baseWthX $* (idx (sy intNormForce) + (sy numbSlices $- int 1) $+ idx (sy watrForce) + (sy numbSlices $- int 1)) $* tan (idx (sy baseAngle) (sy numbSlices $- int 1)), sy index $= sy numbSlices) nrmShrFNumDeriv :: Derivation @@ -508,11 +508,11 @@ nrmShrForDenRC = makeRC "nrmShrForDenRC" (nounPhraseSP "normal and shear force p nrmShrFDenRel :: Relation nrmShrFDenRel = inxi nrmShearDen $= incompleteCase [ - (indx1 baseWthX `mulRe` indx1 scalFunc `mulRe` indx1 intNormForce, sy index $= int 1), - (inxi baseWthX `mulRe` (inxi scalFunc `mulRe` inxi intNormForce `addRe` - (inxiM1 scalFunc `mulRe` inxiM1 intNormForce)), + (indx1 baseWthX $* indx1 scalFunc $* indx1 intNormForce, sy index $= int 1), + (inxi baseWthX $* (inxi scalFunc $* inxi intNormForce $+ + (inxiM1 scalFunc $* inxiM1 intNormForce)), int 2 $<= sy index $<= (sy numbSlices $- int 1)), - (indxn baseWthX `mulRe` idx (sy intNormForce) (sy numbSlices $- int 1) `mulRe` + (indxn baseWthX $* idx (sy intNormForce) (sy numbSlices $- int 1) $* idx (sy scalFunc) (sy numbSlices $- int 1), sy index $= sy numbSlices) ] @@ -539,10 +539,10 @@ intsliceFsRC = makeRC "intsliceFsRC" (nounPhraseSP "interslice normal forces") sliceFsRel :: Relation sliceFsRel = inxi intNormForce $= incompleteCase [ - ((sy fs `mulRe` indx1 shearFNoIntsl $- indx1 shearRNoIntsl) $/ indx1 shrResC, + ((sy fs $* indx1 shearFNoIntsl $- indx1 shearRNoIntsl) $/ indx1 shrResC, sy index $= int 1), - ((inxiM1 mobShrC `mulRe` inxiM1 intNormForce `addRe` - (sy fs `mulRe` inxi shearFNoIntsl $- inxi shearRNoIntsl)) $/ inxi shrResC, + ((inxiM1 mobShrC $* inxiM1 intNormForce $+ + (sy fs $* inxi shearFNoIntsl $- inxi shearRNoIntsl)) $/ inxi shrResC, int 2 $<= sy index $<= (sy numbSlices $- int 1)), (int 0, sy index $= int 0 $|| sy index $= sy numbSlices)] -- FIXME: Use index i as part of condition @@ -583,8 +583,8 @@ intrSlcDerivEqns = [fctSftyDerivEqn9, intrSlcDerivEqn] intrSlcDerivEqn :: PExpr intrSlcDerivEqn = inxi intNormForce $= - (inxiM1 mobShrC `mulRe` inxiM1 intNormForce `addRe` - (sy fs `mulRe` inxi shearFNoIntsl) $- inxi shearRNoIntsl) $/ inxi shrResC + (inxiM1 mobShrC $* inxiM1 intNormForce $+ + (sy fs $* inxi shearFNoIntsl) $- inxi shearRNoIntsl) $/ inxi shrResC -------------------------------------------------------------------------- crtSlpId :: InstanceModel diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/TMods.hs b/code/drasil-example/ssp/lib/Drasil/SSP/TMods.hs index 2f63badd21..b84ea64b69 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/TMods.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/TMods.hs @@ -85,7 +85,7 @@ mcShrStrgthQD = fromEqnSt' (shrStress ^. uid) (nounPhraseSP "Mohr-Coulumb shear mcShrStrgthDesc (symbol shrStress) Real mcShrStrgthExpr mcShrStrgthExpr :: PExpr -mcShrStrgthExpr = sy effNormStress `mulRe` tan (sy fricAngle) `addRe` sy effCohesion +mcShrStrgthExpr = sy effNormStress $* tan (sy fricAngle) $+ sy effCohesion mcShrStrgthDesc :: Sentence mcShrStrgthDesc = foldlSent [S "In this", phrase model, S "the", diff --git a/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs b/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs index eec6f478ab..e683bd3b63 100644 --- a/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs +++ b/code/drasil-example/ssp/lib/Drasil/SSP/Unitals.hs @@ -514,7 +514,7 @@ inx :: (ExprC r, LiteralC r, Quantity e) => e -> Integer -> r inx e n | n < 0 = idx (sy e) (sy index $- int (-n)) | n == 0 = idx (sy e) (sy index) - | otherwise = idx (sy e) (sy index `addI` int n) + | otherwise = idx (sy e) (sy index $+ int n) sum1toN :: (ExprC r, LiteralC r) => r -> r sum1toN = defsum (eqSymb index) (int 1) (sy numbSlices) diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs index 476e7a3990..88c0e6375f 100755 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/Body.hs @@ -533,9 +533,9 @@ propCorSolDeriv1 lce ewat en co pcmat g1hfc g2hfp su ht = propCorSolDeriv2 :: Contents propCorSolDeriv2 = unlbldExpr (sy watE $= defint (eqSymb time) (exactDbl 0) (sy time) - (sy coilHTC `mulRe` sy coilSA `mulRe` (sy tempC $- apply1 tempW time)) + (sy coilHTC $* sy coilSA $* (sy tempC $- apply1 tempW time)) $- defint (eqSymb time) (exactDbl 0) (sy time) - (sy pcmHTC `mulRe` sy pcmSA `mulRe` (apply1 tempW time $- + (sy pcmHTC $* sy pcmSA $* (apply1 tempW time $- apply1 tempPCM time))) propCorSolDeriv3 :: NamedIdea a => a -> UnitalChunk -> CI -> ConceptChunk -> Contents @@ -547,7 +547,7 @@ propCorSolDeriv3 epcm en pcmat wa = propCorSolDeriv4 :: Contents propCorSolDeriv4 = unlbldExpr (sy pcmE $= defint (eqSymb time) (exactDbl 0) (sy time) - (sy pcmHTC `mulRe` sy pcmSA `mulRe` (apply1 tempW time $- + (sy pcmHTC $* sy pcmSA $* (apply1 tempW time $- apply1 tempPCM time))) propCorSolDeriv5 :: ConceptChunk -> CI -> CI -> Contents diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/DataDefs.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/DataDefs.hs index e5c2b219d1..73556ac669 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/DataDefs.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/DataDefs.hs @@ -37,7 +37,7 @@ waterMassQD :: SimpleQDef waterMassQD = mkQuantDef wMass waterMassEqn waterMassEqn :: Expr -waterMassEqn = sy wVol `mulRe` sy wDensity +waterMassEqn = sy wVol $* sy wDensity waterMassNotes :: Sentence waterMassNotes = foldlSent [ch wVol, S "is defined in", refS waterVolume] @@ -67,7 +67,7 @@ tankVolumeQD :: SimpleQDef tankVolumeQD = mkQuantDef tankVol tankVolumeEqn tankVolumeEqn :: Expr -tankVolumeEqn = sy pi_ `mulRe` square (half $ sy diam) `mulRe` sy tankLength +tankVolumeEqn = sy pi_ $* square (half $ sy diam) $* sy tankLength tankVolume :: DataDefinition tankVolume = ddENoRefs tankVolumeQD Nothing "tankVolume" [] @@ -78,7 +78,7 @@ balanceDecayRateQD :: SimpleQDef balanceDecayRateQD = mkQuantDef tauW balanceDecayRateEqn balanceDecayRateEqn :: Expr -balanceDecayRateEqn = sy wMass `mulRe` sy htCapW $/ (sy coilHTC `mulRe` sy coilSA) +balanceDecayRateEqn = sy wMass $* sy htCapW $/ (sy coilHTC $* sy coilSA) balanceDecayRateNotes :: Sentence balanceDecayRateNotes = foldlSent [ch wMass, S "is defined in", @@ -94,7 +94,7 @@ balanceDecayTimeQD :: SimpleQDef balanceDecayTimeQD = mkQuantDef eta balanceDecayTimeEqn balanceDecayTimeEqn :: Expr -balanceDecayTimeEqn = sy pcmHTC `mulRe` sy pcmSA $/ (sy coilHTC `mulRe` sy coilSA) +balanceDecayTimeEqn = sy pcmHTC $* sy pcmSA $/ (sy coilHTC $* sy coilSA) balanceDecayTime :: DataDefinition balanceDecayTime = ddE balanceDecayTimeQD [dRef koothoor2013] @@ -106,8 +106,8 @@ balanceSolidPCMQD :: SimpleQDef balanceSolidPCMQD = mkQuantDef tauSP balanceSolidPCMEqn balanceSolidPCMEqn :: Expr -balanceSolidPCMEqn = (sy pcmMass `mulRe` sy htCapSP) $/ - (sy pcmHTC `mulRe` sy pcmSA) +balanceSolidPCMEqn = (sy pcmMass $* sy htCapSP) $/ + (sy pcmHTC $* sy pcmSA) balanceSolidPCM :: DataDefinition balanceSolidPCM = ddE balanceSolidPCMQD [dRef lightstone2012] @@ -119,8 +119,8 @@ balanceLiquidPCMQD :: SimpleQDef balanceLiquidPCMQD = mkQuantDef tauLP balanceLiquidPCMEqn balanceLiquidPCMEqn :: Expr -balanceLiquidPCMEqn = (sy pcmMass `mulRe` sy htCapLP) $/ - (sy pcmHTC `mulRe` sy pcmSA) +balanceLiquidPCMEqn = (sy pcmMass $* sy htCapLP) $/ + (sy pcmHTC $* sy pcmSA) balanceLiquidPCM :: DataDefinition balanceLiquidPCM = ddE balanceLiquidPCMQD [dRef lightstone2012] @@ -155,7 +155,7 @@ ddMeltFracQD = mkQuantDef meltFrac meltFracEqn -- produced according to CaseStudies' original meltFracEqn :: Expr -meltFracEqn = sy latentEP $/ (sy htFusion `mulRe` sy pcmMass) +meltFracEqn = sy latentEP $/ (sy htFusion $* sy pcmMass) ddMeltFrac :: DataDefinition ddMeltFrac = ddE ddMeltFracQD [dRef koothoor2013] diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/Derivations.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/Derivations.hs index f25e68179e..2286f69684 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/Derivations.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/Derivations.hs @@ -12,38 +12,38 @@ import Language.Drasil (ModelExprC(deriv), ExprC(..), ModelExpr, recip_) eBalanceOnWtrDerivEqn1, eBalanceOnWtrDerivEqn2, eBalanceOnWtrDerivEqn3, eBalanceOnWtrDerivEqn4, eBalanceOnWtrDerivEqn5, eBalanceOnWtrDerivEqn6, eBalanceOnWtrDerivEqn7 :: ModelExpr -eBalanceOnWtrDerivEqn1 = sy wMass `mulRe` sy htCapW `mulRe` deriv (sy tempW) time $= - sy htFluxC `mulRe` sy coilSA $- (sy htFluxP `mulRe` sy pcmSA) +eBalanceOnWtrDerivEqn1 = sy wMass $* sy htCapW $* deriv (sy tempW) time $= + sy htFluxC $* sy coilSA $- (sy htFluxP $* sy pcmSA) -eBalanceOnWtrDerivEqn2 = sy wMass `mulRe` sy htCapW `mulRe` deriv (sy tempW) time $= - sy coilHTC `mulRe` sy coilSA `mulRe` (sy tempC $- sy tempW) $- - (sy pcmHTC `mulRe` sy pcmSA `mulRe` (sy tempW $- sy tempPCM)) +eBalanceOnWtrDerivEqn2 = sy wMass $* sy htCapW $* deriv (sy tempW) time $= + sy coilHTC $* sy coilSA $* (sy tempC $- sy tempW) $- + (sy pcmHTC $* sy pcmSA $* (sy tempW $- sy tempPCM)) eBalanceOnWtrDerivEqn3 = deriv (sy tempW) time $= - (sy coilHTC `mulRe` sy coilSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempC $- sy tempW) $- - ((sy pcmHTC `mulRe` sy pcmSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempW $- sy tempPCM)) + (sy coilHTC $* sy coilSA $/ + (sy wMass $* sy htCapW)) $* (sy tempC $- sy tempW) $- + ((sy pcmHTC $* sy pcmSA $/ + (sy wMass $* sy htCapW)) $* (sy tempW $- sy tempPCM)) eBalanceOnWtrDerivEqn4 = deriv (sy tempW) time $= - (sy coilHTC `mulRe` sy coilSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempC $- sy tempW) `addRe` - ((sy coilHTC `mulRe` sy coilSA $/ - (sy coilHTC `mulRe` sy coilSA)) `mulRe` (sy pcmHTC `mulRe` sy pcmSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempPCM $- sy tempW)) + (sy coilHTC $* sy coilSA $/ + (sy wMass $* sy htCapW)) $* (sy tempC $- sy tempW) $+ + ((sy coilHTC $* sy coilSA $/ + (sy coilHTC $* sy coilSA)) $* (sy pcmHTC $* sy pcmSA $/ + (sy wMass $* sy htCapW)) $* (sy tempPCM $- sy tempW)) eBalanceOnWtrDerivEqn5 = deriv (sy tempW) time $= - (sy coilHTC `mulRe` sy coilSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempC $- sy tempW) `addRe` - ((sy pcmHTC `mulRe` sy pcmSA $/ - (sy coilHTC `mulRe` sy coilSA)) `mulRe` (sy coilHTC `mulRe` sy coilSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempPCM $- sy tempW)) + (sy coilHTC $* sy coilSA $/ + (sy wMass $* sy htCapW)) $* (sy tempC $- sy tempW) $+ + ((sy pcmHTC $* sy pcmSA $/ + (sy coilHTC $* sy coilSA)) $* (sy coilHTC $* sy coilSA $/ + (sy wMass $* sy htCapW)) $* (sy tempPCM $- sy tempW)) eBalanceOnWtrDerivEqn6 = deriv (sy tempW) time $= - recip_ (sy tauW) `mulRe` (sy tempC $- sy tempW) `addRe` ((sy eta $/ sy tauW) `mulRe` (sy tempPCM $- sy tempW)) + recip_ (sy tauW) $* (sy tempC $- sy tempW) $+ ((sy eta $/ sy tauW) $* (sy tempPCM $- sy tempW)) eBalanceOnWtrDerivEqn7 = deriv (sy tempW) time $= - recip_ (sy tauW) `mulRe` ((sy tempC $- sy tempW) `addRe` (sy eta `mulRe` (sy tempPCM $- sy tempW))) + recip_ (sy tauW) $* ((sy tempC $- sy tempW) $+ (sy eta $* (sy tempPCM $- sy tempW))) eBalanceOnWtrDerivEqnsIM1 :: [ModelExpr] eBalanceOnWtrDerivEqnsIM1 = [eBalanceOnWtrDerivEqn1, eBalanceOnWtrDerivEqn2, @@ -52,14 +52,14 @@ eBalanceOnWtrDerivEqnsIM1 = [eBalanceOnWtrDerivEqn1, eBalanceOnWtrDerivEqn2, -- eBalanceOnPCMEqn1, eBalanceOnPCMEqn2, eBalanceOnPCMEqn3, eBalanceOnPCMEqn4 :: ModelExpr -eBalanceOnPCMEqn1 = sy pcmMass `mulRe` sy htCapSP `mulRe` deriv (sy tempPCM) time $= - sy htFluxP `mulRe` sy pcmSA -eBalanceOnPCMEqn2 = sy pcmMass `mulRe` sy htCapSP `mulRe` deriv (sy tempPCM) time $= - sy pcmHTC `mulRe` sy pcmSA `mulRe` (sy tempW $- sy tempPCM) +eBalanceOnPCMEqn1 = sy pcmMass $* sy htCapSP $* deriv (sy tempPCM) time $= + sy htFluxP $* sy pcmSA +eBalanceOnPCMEqn2 = sy pcmMass $* sy htCapSP $* deriv (sy tempPCM) time $= + sy pcmHTC $* sy pcmSA $* (sy tempW $- sy tempPCM) eBalanceOnPCMEqn3 = deriv (sy tempPCM) time $= - ((sy pcmHTC `mulRe` sy pcmSA) $/ (sy pcmMass `mulRe` sy htCapSP)) `mulRe` (sy tempW $- sy tempPCM) + ((sy pcmHTC $* sy pcmSA) $/ (sy pcmMass $* sy htCapSP)) $* (sy tempW $- sy tempPCM) eBalanceOnPCMEqn4 = deriv (sy tempPCM) time $= - recip_ (sy tauSP) `mulRe` (sy tempW $- sy tempPCM) + recip_ (sy tauSP) $* (sy tempW $- sy tempPCM) eBalanceOnPCMDerivEqnsIM2 :: [ModelExpr] eBalanceOnPCMDerivEqnsIM2 = [eBalanceOnPCMEqn1, eBalanceOnPCMEqn2, eBalanceOnPCMEqn3, eBalanceOnPCMEqn4] diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/GenDefs.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/GenDefs.hs index cb2ddedbfe..98c31eeaec 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/GenDefs.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/GenDefs.hs @@ -45,9 +45,9 @@ rocTempSimpRC = makeRC "rocTempSimpRC" (nounPhraseSP $ "Simplified rate " ++ "of change of temperature") EmptyS rocTempSimpRel rocTempSimpRel :: ModelExpr -rocTempSimpRel = sy QPP.mass `mulRe` sy QT.heatCapSpec `mulRe` - deriv (sy QT.temp) QP.time $= (sy htFluxIn `mulRe` sy inSA $- - (sy htFluxOut `mulRe` sy outSA)) `addRe` (sy volHtGen `mulRe` sy QPP.vol) +rocTempSimpRel = sy QPP.mass $* sy QT.heatCapSpec $* + deriv (sy QT.temp) QP.time $= (sy htFluxIn $* sy inSA $- + (sy htFluxOut $* sy outSA)) $+ (sy volHtGen $* sy QPP.vol) ---- @@ -60,7 +60,7 @@ htFluxWaterFromCoilQD :: ModelQDef htFluxWaterFromCoilQD = mkQuantDef htFluxC htFluxWaterFromCoilExpr htFluxWaterFromCoilExpr :: ModelExpr -htFluxWaterFromCoilExpr = sy coilHTC `mulRe` (sy tempC $- apply1 tempW time) +htFluxWaterFromCoilExpr = sy coilHTC $* (sy tempC $- apply1 tempW time) --Can't include info in description beyond definition of variables? ---- @@ -74,7 +74,7 @@ htFluxPCMFromWaterQD :: ModelQDef htFluxPCMFromWaterQD = mkQuantDef htFluxP htFluxPCMFromWaterExpr htFluxPCMFromWaterExpr :: ModelExpr -htFluxPCMFromWaterExpr = sy pcmHTC `mulRe` (apply1 tempW time $- apply1 tempPCM time) +htFluxPCMFromWaterExpr = sy pcmHTC $* (apply1 tempW time $- apply1 tempPCM time) newtonLawNote :: UnitalChunk -> ConceptInstance -> ConceptChunk -> Sentence newtonLawNote u a c = foldlSent [ch u `S.is` S "found by assuming that", @@ -132,27 +132,27 @@ rocTempDerivDens = [S "Using the fact that", ch density :+: S "=" :+: ch mass :+ rocTempDerivIntegEq, rocTempDerivGaussEq, rocTempDerivArbVolEq, rocTempDerivConsFlxEq, rocTempDerivDensEq :: ModelExpr -rocTempDerivIntegEq = neg (intAll (eqSymb vol) (sy gradient $. sy thFluxVect)) `addRe` +rocTempDerivIntegEq = neg (intAll (eqSymb vol) (sy gradient $. sy thFluxVect)) $+ intAll (eqSymb vol) (sy volHtGen) $= intAll (eqSymb vol) (sy density - `mulRe` sy QT.heatCapSpec `mulRe` pderiv (sy QT.temp) time) + $* sy QT.heatCapSpec $* pderiv (sy QT.temp) time) -rocTempDerivGaussEq = neg (intAll (eqSymb surface) (sy thFluxVect $. sy uNormalVect)) `addRe` +rocTempDerivGaussEq = neg (intAll (eqSymb surface) (sy thFluxVect $. sy uNormalVect)) $+ intAll (eqSymb vol) (sy volHtGen) $= intAll (eqSymb vol) - (sy density `mulRe` sy QT.heatCapSpec `mulRe` pderiv (sy QT.temp) time) + (sy density $* sy QT.heatCapSpec $* pderiv (sy QT.temp) time) -rocTempDerivArbVolEq = (sy htFluxIn `mulRe` sy inSA $- (sy htFluxOut `mulRe` - sy outSA)) `addRe` (sy volHtGen `mulRe` sy vol) $= - intAll (eqSymb vol) (sy density `mulRe` sy QT.heatCapSpec `mulRe` pderiv (sy QT.temp) time) +rocTempDerivArbVolEq = (sy htFluxIn $* sy inSA $- (sy htFluxOut $* + sy outSA)) $+ (sy volHtGen $* sy vol) $= + intAll (eqSymb vol) (sy density $* sy QT.heatCapSpec $* pderiv (sy QT.temp) time) -rocTempDerivConsFlxEq = sy density `mulRe` sy QT.heatCapSpec `mulRe` sy vol `mulRe` deriv - (sy QT.temp) time $= (sy htFluxIn `mulRe` sy inSA $- (sy htFluxOut `mulRe` - sy outSA)) `addRe` (sy volHtGen `mulRe` sy vol) +rocTempDerivConsFlxEq = sy density $* sy QT.heatCapSpec $* sy vol $* deriv + (sy QT.temp) time $= (sy htFluxIn $* sy inSA $- (sy htFluxOut $* + sy outSA)) $+ (sy volHtGen $* sy vol) -rocTempDerivDensEq = sy mass `mulRe` sy QT.heatCapSpec `mulRe` deriv (sy QT.temp) - time $= (sy htFluxIn `mulRe` sy inSA $- (sy htFluxOut - `mulRe` sy outSA)) `addRe` (sy volHtGen `mulRe` sy vol) +rocTempDerivDensEq = sy mass $* sy QT.heatCapSpec $* deriv (sy QT.temp) + time $= (sy htFluxIn $* sy inSA $- (sy htFluxOut + $* sy outSA)) $+ (sy volHtGen $* sy vol) rocTempSimpDerivEqns :: [ModelExpr] rocTempSimpDerivEqns = [rocTempDerivIntegEq, rocTempDerivGaussEq, rocTempDerivArbVolEq, rocTempDerivConsFlxEq, diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/IMods.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/IMods.hs index 60a897dddc..59f66c3062 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/IMods.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/IMods.hs @@ -60,8 +60,8 @@ balWtrRel :: ModelExpr balWtrRel = deriv (sy tempW) time $= express balWtrExpr balWtrExpr :: Expr -balWtrExpr = recip_ (sy tauW) `mulRe` ((sy tempC $- apply1 tempW time) `addRe` - (sy eta `mulRe` (apply1 tempPCM time $- apply1 tempW time))) +balWtrExpr = recip_ (sy tauW) $* ((sy tempC $- apply1 tempW time) $+ + (sy eta $* (apply1 tempPCM time $- apply1 tempW time))) balWtrDesc :: [Sentence] balWtrDesc = map foldlSent [ @@ -147,7 +147,7 @@ eBalanceOnWtrDerivDesc7 eq22 = foldlSentCol [S "Finally, factoring out", eS' eq2 S "we are left with the governing", getAcc ode `S.for` refS eBalanceOnWtr] eq1, eq2 :: Expr -eq1 = sy wMass `mulRe` sy htCapW +eq1 = sy wMass $* sy htCapW eq2 = recip_ $ sy tauW --------- @@ -170,9 +170,9 @@ balPCMRel = deriv (sy tempPCM) time $= balPCMExpr balPCMExpr :: PExpr balPCMExpr = completeCase [case1, case2, case3] - where case1 = (recip_ (sy tauSP) `mulRe` (apply1 tempW time $- + where case1 = (recip_ (sy tauSP) $* (apply1 tempW time $- apply1 tempPCM time), realInterval tempPCM (UpTo (Exc, sy tempMeltP))) - case2 = (recip_ (sy tauLP) `mulRe` (apply1 tempW time $- + case2 = (recip_ (sy tauLP) $* (apply1 tempW time $- apply1 tempPCM time), realInterval tempPCM (UpFrom (Exc,sy tempMeltP))) case3 = (exactDbl 0, sy tempPCM $= sy tempMeltP $&& realInterval meltFrac (Bounded (Exc, exactDbl 0) (Exc, exactDbl 1))) @@ -280,7 +280,7 @@ heatEInWtrFD :: SimpleQDef heatEInWtrFD = mkFuncDefByQ watE [time] htWtrExpr htWtrExpr :: Expr -htWtrExpr = sy htCapW `mulRe` sy wMass `mulRe` +htWtrExpr = sy htCapW $* sy wMass $* (apply1 tempW time $- sy tempInit) htWtrNotes :: [Sentence] @@ -310,14 +310,14 @@ heatEInPCMRC = makeRC "heatEInPCMRC" (nounPhraseSP "Heat energy in the PCM") htPCMRel :: Relation htPCMRel = sy pcmE $= completeCase [case1, case2, case3] - where case1 = (sy htCapSP `mulRe` sy pcmMass `mulRe` (apply1 tempPCM time $- + where case1 = (sy htCapSP $* sy pcmMass $* (apply1 tempPCM time $- sy tempInit), realInterval tempPCM (UpTo (Exc, sy tempMeltP))) - case2 = (sy pcmInitMltE `addRe` (sy htFusion `mulRe` sy pcmMass) `addRe` - (sy htCapLP `mulRe` sy pcmMass `mulRe` (apply1 tempPCM time $- + case2 = (sy pcmInitMltE $+ (sy htFusion $* sy pcmMass) $+ + (sy htCapLP $* sy pcmMass $* (apply1 tempPCM time $- sy tempMeltP)), realInterval tempPCM (UpFrom (Exc, sy tempMeltP))) - case3 = (sy pcmInitMltE `addRe` apply1 latentEP time, + case3 = (sy pcmInitMltE $+ apply1 latentEP time, sy tempPCM $= sy tempMeltP $&& realInterval meltFrac (Bounded (Exc, exactDbl 0) (Exc, exactDbl 1))) htPCMNotes :: [Sentence] @@ -334,7 +334,7 @@ htPCMNotes = map foldlSent [ short phsChgMtrl, S "plus the", phrase energy, S "when", phrase melting, S "starts" `sC` S "plus", (phrase energy +:+ S "required to melt all") `S.the_ofThe` short phsChgMtrl], [atStartNP (the energy), S "required to melt all of the", short phsChgMtrl `S.is` - eS (sy htFusion `mulRe` sy pcmMass), sParen (unwrap $ getUnit pcmInitMltE), + eS (sy htFusion $* sy pcmMass), sParen (unwrap $ getUnit pcmInitMltE), fromSource ddHtFusion], [atStartNP (NP.the (change `in_` temp)) `S.is` eS (sy tempPCM $- sy tempMeltP), sParen (unwrap $ getUnit tempMeltP)], diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/TMods.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/TMods.hs index c375ceb043..3112d7dd1d 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/TMods.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/TMods.hs @@ -50,8 +50,8 @@ consThermECS = mkConstraintSet consCC rels rels = NE.fromList [consThermERel] consThermERel :: ModelExpr -consThermERel = negVec (sy gradient) $. sy thFluxVect `addRe` sy volHtGen $= - sy density `mulRe` sy heatCapSpec `mulRe` pderiv (sy temp) time +consThermERel = negVec (sy gradient) $. sy thFluxVect $+ sy volHtGen $= + sy density $* sy heatCapSpec $* pderiv (sy temp) time -- the second argument is a 'ShortName'... consThemESrc :: Reference @@ -100,12 +100,12 @@ sensHtESrc = makeURI "sensHtESrc" sensHtEEqn :: PhaseChange -> ModelExpr sensHtEEqn pChange = case pChange of Liquid -> liquidFormula - AllPhases -> incompleteCase [(sy htCapS `mulRe` sy mass `mulRe` sy deltaT, + AllPhases -> incompleteCase [(sy htCapS $* sy mass $* sy deltaT, sy temp $< sy meltPt), (liquidFormula, sy meltPt $< sy temp $< - sy boilPt), (sy htCapV `mulRe` sy mass `mulRe` + sy boilPt), (sy htCapV $* sy mass $* sy deltaT, sy boilPt $< sy temp)] where - liquidFormula = sy htCapL `mulRe` sy mass `mulRe` sy deltaT + liquidFormula = sy htCapL $* sy mass $* sy deltaT --When to call with C? When to call with U, S, Sy, etc? Sometimes confusing. @@ -178,7 +178,7 @@ nwtnCoolingFD :: ModelQDef nwtnCoolingFD = mkFuncDefByQ htFlux [time] nwtnCoolingExpr nwtnCoolingExpr :: ModelExpr -nwtnCoolingExpr = sy htTransCoeff `mulRe` apply1 deltaT time +nwtnCoolingExpr = sy htTransCoeff $* apply1 deltaT time nwtnCoolingNotes :: [Sentence] nwtnCoolingNotes = map foldlSent [ diff --git a/code/drasil-example/swhs/lib/Drasil/SWHS/Unitals.hs b/code/drasil-example/swhs/lib/Drasil/SWHS/Unitals.hs index dde43bc609..f520ebcc6b 100644 --- a/code/drasil-example/swhs/lib/Drasil/SWHS/Unitals.hs +++ b/code/drasil-example/swhs/lib/Drasil/SWHS/Unitals.hs @@ -278,7 +278,7 @@ pcmVol = uqc "pcmVol" (nounPhraseSP "volume of PCM") "the amount of space occupied by a given quantity of phase change material" (sub (eqSymb vol) lPCM) m_3 Real [physc $ Bounded (Exc, exactDbl 0) (Exc, sy tankVol), - sfwrc $ UpFrom (Inc, sy fracMin `mulRe` sy tankVol)] + sfwrc $ UpFrom (Inc, sy fracMin $* sy tankVol)] (dbl 0.05) defaultUncrt -- needs to add (D,L)*minfract to end of last constraint @@ -292,7 +292,7 @@ pcmSA = uqc "pcmSA" "area covered by the outermost layer of the phase change material" (sub cA lPCM) m_2 Real [gtZeroConstr, - sfwrc $ Bounded (Inc, sy pcmVol) (Inc, (exactDbl 2 $/ sy thickness) `mulRe` sy tankVol)] + sfwrc $ Bounded (Inc, sy pcmVol) (Inc, (exactDbl 2 $/ sy thickness) $* sy tankVol)] (dbl 1.2) defaultUncrt -- Constraint 5 diff --git a/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs index 2f9d46da92..11d283fbb2 100644 --- a/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/Derivations.hs @@ -13,18 +13,18 @@ import Drasil.SWHS.Unitals (coilHTC, coilSA, htCapW, htFluxC, tauW, tempC, ---------------------------------------------- eBalanceOnWtrDerivEqn1, eBalanceOnWtrDerivEqn2, eBalanceOnWtrDerivEqn3, eBalanceOnWtrDerivEqn4 :: ModelExpr -eBalanceOnWtrDerivEqn1 = sy wMass `mulRe` sy htCapW `mulRe` deriv (sy tempW) time $= - sy htFluxC `mulRe` sy coilSA +eBalanceOnWtrDerivEqn1 = sy wMass $* sy htCapW $* deriv (sy tempW) time $= + sy htFluxC $* sy coilSA -eBalanceOnWtrDerivEqn2 = sy wMass `mulRe` sy htCapW `mulRe` deriv (sy tempW) time $= - sy coilHTC `mulRe` sy coilSA `mulRe` (sy tempC $- sy tempW) +eBalanceOnWtrDerivEqn2 = sy wMass $* sy htCapW $* deriv (sy tempW) time $= + sy coilHTC $* sy coilSA $* (sy tempC $- sy tempW) eBalanceOnWtrDerivEqn3 = deriv (sy tempW) time $= - (sy coilHTC `mulRe` sy coilSA $/ - (sy wMass `mulRe` sy htCapW)) `mulRe` (sy tempC $- sy tempW) + (sy coilHTC $* sy coilSA $/ + (sy wMass $* sy htCapW)) $* (sy tempC $- sy tempW) eBalanceOnWtrDerivEqn4 = - deriv (sy tempW) time $= recip_ (sy tauW) `mulRe` (sy tempC $- sy tempW) + deriv (sy tempW) time $= recip_ (sy tauW) $* (sy tempC $- sy tempW) eBalanceOnWtrDerivEqns :: [ModelExpr] eBalanceOnWtrDerivEqns = [eBalanceOnWtrDerivEqn1, eBalanceOnWtrDerivEqn2, eBalanceOnWtrDerivEqn3, eBalanceOnWtrDerivEqn4] diff --git a/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs index ab4acbdec2..14b59d0dbf 100644 --- a/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs +++ b/code/drasil-example/swhsnopcm/lib/Drasil/SWHSNoPCM/IMods.hs @@ -55,7 +55,7 @@ eBalanceOnWtrRC = (tempW ^. defn) where coeffs = [[exactDbl 1, recip_ (sy tauW)]] unknowns = [1, 0] - constants = [recip_ (sy tauW) `mulRe` sy tempC] + constants = [recip_ (sy tauW) $* sy tempC] balWtrNotes :: [Sentence] balWtrNotes = map foldlSent [ diff --git a/code/drasil-lang/lib/Language/Drasil.hs b/code/drasil-lang/lib/Language/Drasil.hs index e294d9191b..93073b3d99 100644 --- a/code/drasil-lang/lib/Language/Drasil.hs +++ b/code/drasil-lang/lib/Language/Drasil.hs @@ -100,7 +100,7 @@ module Language.Drasil ( -- Language.Drasil.Chunk.Relation , RelationConcept, makeRC, addRelToCC -- Language.Drasil.Chunk.DifferentialModel - , DifferentialModel(..), ODESolverFormat(..), InitialValueProblem(..), ($^^),($*), ($+) + , DifferentialModel(..), ODESolverFormat(..), InitialValueProblem(..), ($^^),($**), ($++) , makeAODESolverFormat, makeAIVP, formEquations, makeASystemDE, makeASingleDE -- *** Quantities and Units @@ -361,7 +361,7 @@ import Language.Drasil.Chunk.NamedIdea import Language.Drasil.Chunk.Quantity import Language.Drasil.Chunk.Relation(RelationConcept, makeRC, addRelToCC) import Language.Drasil.Chunk.DifferentialModel(DifferentialModel(..), ODESolverFormat(..), - InitialValueProblem(..), ($^^), ($*), ($+), makeAODESolverFormat, makeAIVP, makeASystemDE, + InitialValueProblem(..), ($^^), ($**), ($++), makeAODESolverFormat, makeAIVP, makeASystemDE, makeASingleDE, formEquations) import Language.Drasil.Chunk.UncertainQuantity import Language.Drasil.Chunk.Unital(UnitalChunk(..), uc, uc', ucStaged, ucStaged', diff --git a/code/drasil-lang/lib/Language/Drasil/Chunk/DifferentialModel.hs b/code/drasil-lang/lib/Language/Drasil/Chunk/DifferentialModel.hs index c776e40789..d0d1f6ac95 100644 --- a/code/drasil-lang/lib/Language/Drasil/Chunk/DifferentialModel.hs +++ b/code/drasil-lang/lib/Language/Drasil/Chunk/DifferentialModel.hs @@ -5,7 +5,7 @@ module Language.Drasil.Chunk.DifferentialModel ( -- * Export Data Type DifferentialModel(..), ODESolverFormat(..), InitialValueProblem(..), -- * Input Language - ($^^), ($*), ($+), + ($^^), ($**), ($++), -- * Constructors makeAODESolverFormat, makeAIVP, makeASystemDE, makeASingleDE, formEquations @@ -59,18 +59,18 @@ type LHS = [Term] exactDbl 1 is the the coefficient, (opProcessVariable $^^ 2) is the 2rd order of opProcessVariable -} -($*) :: Expr -> Unknown -> Term -($*) = T +($**) :: Expr -> Unknown -> Term +($**) = T -- | Operation represent plus (collection Terms) {- e.g. [exactDbl 1 $* (opProcessVariable $^^ 2)] - $+ (exactDbl 1 `addRe` sy qdDerivGain $* (opProcessVariable $^^ 1)) + $+ (exactDbl 1 $+ sy qdDerivGain $* (opProcessVariable $^^ 1)) [exactDbl 1 $* (opProcessVariable $^^ 2)] is a collection with a single Term, - (exactDbl 1 `addRe` sy qdDerivGain $* (opProcessVariable $^^ 1)) is the appended element + (exactDbl 1 $+ sy qdDerivGain $* (opProcessVariable $^^ 1)) is the appended element -} -($+) :: [Term] -> Term -> LHS -($+) xs x = xs ++ [x] +($++) :: [Term] -> Term -> LHS +($++) xs x = xs ++ [x] -- | Describe the structural content of a system of linear ODEs with six necessary fields data DifferentialModel = SystemOfLinearODEs { @@ -142,7 +142,7 @@ formStdODE d -- | Set the single ODE to a flat equation form, "left hand side" = "right hand side" formASingleODE :: [Expr] -> [ModelExpr] -> [Expr] -> ModelExpr formASingleODE coeffs unks consts = equiv (lhs : rhs) - where lhs = foldl1 addRe (map (\x-> express (fst x) `mulRe` snd x) $ filterZeroCoeff coeffs unks) + where lhs = foldl1 ($+) (map (\x-> express (fst x) $* snd x) $ filterZeroCoeff coeffs unks) rhs = map express consts -- | Remove zero coefficients for the displaying purpose @@ -297,11 +297,11 @@ formEquations [] _ _ _ = [] formEquations _ [] _ _ = [] formEquations _ _ [] _ = [] formEquations (ex:exs) unks (y:ys) depVa = - (if y == exactDbl 0 then finalExpr else finalExpr `addRe` y) : formEquations exs unks ys depVa + (if y == exactDbl 0 then finalExpr else finalExpr $+ y) : formEquations exs unks ys depVa where indexUnks = map (idx (sy depVa) . int) unks -- create X filteredExprs = filter (\x -> fst x /= exactDbl 0) (zip ex indexUnks) -- remove zero coefficients - termExprs = map (uncurry mulRe) filteredExprs -- multiple coefficient with depend variables - finalExpr = foldl1 addRe termExprs -- add terms together + termExprs = map (uncurry ($*)) filteredExprs -- multiple coefficient with depend variables + finalExpr = foldl1 ($+) termExprs -- add terms together -- Construct an InitialValueProblem. {- diff --git a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Convert.hs b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Convert.hs index a18c08fd26..90ee3c4a0a 100644 --- a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Convert.hs +++ b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Convert.hs @@ -95,10 +95,8 @@ nvvBinOp :: LD.NVVBinOp -> NVVBinOp nvvBinOp LD.Scale = Scale assocArithOp :: LD.AssocArithOper -> AssocArithOper -assocArithOp LD.AddI = AddI -- TODO: These L.'s should be exported through L.D.Development -assocArithOp LD.AddRe = AddRe -assocArithOp LD.MulI = MulI -assocArithOp LD.MulRe = MulRe +assocArithOp LD.Add = Add -- TODO: These L.'s should be exported through L.D.Development +assocArithOp LD.Mul = Mul assocBoolOp :: LD.AssocBoolOper -> AssocBoolOper assocBoolOp LD.And = And -- TODO: These L.'s should be exported through L.D.Development diff --git a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Lang.hs b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Lang.hs index e66a034c0e..283dc1719d 100644 --- a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Lang.hs +++ b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Lang.hs @@ -46,7 +46,7 @@ data NVVBinOp = Scale deriving Eq -- | Associative operators (adding and multiplication). Also specifies whether it is for integers or for real numbers. -data AssocArithOper = AddI | AddRe | MulI | MulRe +data AssocArithOper = Add | Mul deriving Eq -- | Associative boolean operators (and, or). diff --git a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Precedence.hs b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Precedence.hs index 2f4f4f0196..ff96ef4f00 100644 --- a/code/drasil-lang/lib/Language/Drasil/CodeExpr/Precedence.hs +++ b/code/drasil-lang/lib/Language/Drasil/CodeExpr/Precedence.hs @@ -44,10 +44,8 @@ prec2NVV _ = 190 -- | precA - precedence for arithmetic-related Binary-Associative (Commutative) operators. precA :: AssocArithOper -> Int -precA MulI = 190 -precA MulRe = 190 -precA AddI = 180 -precA AddRe = 180 +precA Mul = 190 +precA Add = 180 -- | precB - precedence for boolean-related Binary-Associative (Commutative) operators. precB :: AssocBoolOper -> Int diff --git a/code/drasil-lang/lib/Language/Drasil/Expr/Class.hs b/code/drasil-lang/lib/Language/Drasil/Expr/Class.hs index b971cec647..0772ede25e 100644 --- a/code/drasil-lang/lib/Language/Drasil/Expr/Class.hs +++ b/code/drasil-lang/lib/Language/Drasil/Expr/Class.hs @@ -103,18 +103,12 @@ class ExprC r where -- | Smart constructor for the dot product of two equations. ($.) :: r -> r -> r - -- | Add two expressions (Integers). - addI :: r -> r -> r - - -- | Add two expressions (Real numbers). - addRe :: r -> r -> r - - -- | Multiply two expressions (Integers). - mulI :: r -> r -> r - - -- | Multiply two expressions (Real numbers). - mulRe :: r -> r -> r + -- | Add two expressions. + ($+) :: r -> r -> r + -- | Multiply two expressions. + ($*) :: r -> r -> r + ($-), ($/), ($^) :: r -> r -> r ($=>), ($<=>) :: r -> r -> r @@ -239,42 +233,30 @@ instance ExprC Expr where -- | Smart constructor for the dot product of two equations. ($.) = VVNBinaryOp Dot - -- | Add two expressions (Integers). - addI l (Lit (Int 0)) = l - addI (Lit (Int 0)) r = r - addI (AssocA AddI l) (AssocA AddI r) = AssocA AddI (l ++ r) - addI (AssocA AddI l) r = AssocA AddI (l ++ [r]) - addI l (AssocA AddI r) = AssocA AddI (l : r) - addI l r = AssocA AddI [l, r] - - -- | Add two expressions (Real numbers). - addRe l (Lit (Dbl 0))= l - addRe (Lit(Dbl 0)) r = r - addRe l (Lit (ExactDbl 0)) = l - addRe (Lit (ExactDbl 0)) r = r - addRe (AssocA AddRe l) (AssocA AddRe r) = AssocA AddRe (l ++ r) - addRe (AssocA AddRe l) r = AssocA AddRe (l ++ [r]) - addRe l (AssocA AddRe r) = AssocA AddRe (l : r) - addRe l r = AssocA AddRe [l, r] - - -- | Multiply two expressions (Integers). - mulI l (Lit (Int 1)) = l - mulI (Lit (Int 1)) r = r - mulI (AssocA MulI l) (AssocA MulI r) = AssocA MulI (l ++ r) - mulI (AssocA MulI l) r = AssocA MulI (l ++ [r]) - mulI l (AssocA MulI r) = AssocA MulI (l : r) - mulI l r = AssocA MulI [l, r] - - -- | Multiply two expressions (Real numbers). - mulRe l (Lit (Dbl 1)) = l - mulRe (Lit (Dbl 1)) r = r - mulRe l (Lit (ExactDbl 1)) = l - mulRe (Lit (ExactDbl 1)) r = r - mulRe (AssocA MulRe l) (AssocA MulRe r) = AssocA MulRe (l ++ r) - mulRe (AssocA MulRe l) r = AssocA MulRe (l ++ [r]) - mulRe l (AssocA MulRe r) = AssocA MulRe (l : r) - mulRe l r = AssocA MulRe [l, r] - + -- | Add two expressions. + ($+) (Lit (Int 0)) r = r + ($+) l (Lit (Int 0)) = l + ($+) (Lit (Dbl 0)) r = r + ($+) l (Lit (Dbl 0)) = l + ($+) l (Lit (ExactDbl 0)) = l + ($+) (Lit (ExactDbl 0)) r = r + ($+) (AssocA Add l) (AssocA Add r) = AssocA Add (l ++ r) + ($+) (AssocA Add l) r = AssocA Add (l ++ [r]) + ($+) l (AssocA Add r) = AssocA Add (l : r) + ($+) l r = AssocA Add [l, r] + + -- | Multiply two expressions. + ($*) (Lit (Int 1)) r = r + ($*) l (Lit (Int 1)) = l + ($*) (Lit (Dbl 1.0)) r = r + ($*) l (Lit (Dbl 1.0)) = l + ($*) l (Lit (ExactDbl 1)) = l + ($*) (Lit (ExactDbl 1)) r = r + ($*) (AssocA Mul l) (AssocA Mul r) = AssocA Mul (l ++ r) + ($*) (AssocA Mul l) r = AssocA Mul (l ++ [r]) + ($*) l (AssocA Mul r) = AssocA Mul (l : r) + ($*) l r = AssocA Mul [l, r] + -- | Smart constructor for subtracting two expressions. ($-) = ArithBinaryOp Subt -- | Smart constructor for dividing two expressions. @@ -355,20 +337,20 @@ instance ExprC Expr where idx = LABinaryOp Index -- | Integrate over some expression with bounds (∫). - defint v low high = Operator AddRe (BoundedDD v Continuous low high) + defint v low high = Operator Add (BoundedDD v Continuous low high) -- | Sum over some expression with bounds (∑). - defsum v low high = Operator AddRe (BoundedDD v Discrete low high) + defsum v low high = Operator Add (BoundedDD v Discrete low high) -- | Product over some expression with bounds (∏). - defprod v low high = Operator MulRe (BoundedDD v Discrete low high) + defprod v low high = Operator Mul (BoundedDD v Discrete low high) -- | Smart constructor for 'real interval' membership. realInterval c = RealI (c ^. uid) -- TODO: Move euclidean to smart constructor -- | Euclidean function : takes a vector and returns the sqrt of the sum-of-squares. - euclidean = sqrt . foldr1 addRe . map square + euclidean = sqrt . foldr1 ($+) . map square -- | Smart constructor to cross product two expressions. cross = VVVBinaryOp Cross @@ -413,42 +395,29 @@ instance ExprC M.ModelExpr where -- | Smart constructor for the dot product of two equations. ($.) = M.VVNBinaryOp M.Dot - -- | Add two expressions (Integers). - addI l (M.Lit (Int 0)) = l - addI (M.Lit (Int 0)) r = r - addI (M.AssocA M.AddI l) (M.AssocA M.AddI r) = M.AssocA M.AddI (l ++ r) - addI (M.AssocA M.AddI l) r = M.AssocA M.AddI (l ++ [r]) - addI l (M.AssocA M.AddI r) = M.AssocA M.AddI (l : r) - addI l r = M.AssocA M.AddI [l, r] - - -- | Add two expressions (Real numbers). - addRe l (M.Lit (Dbl 0)) = l - addRe (M.Lit (Dbl 0)) r = r - addRe l (M.Lit (ExactDbl 0)) = l - addRe (M.Lit (ExactDbl 0)) r = r - addRe (M.AssocA M.AddRe l) (M.AssocA M.AddRe r) = M.AssocA M.AddRe (l ++ r) - addRe (M.AssocA M.AddRe l) r = M.AssocA M.AddRe (l ++ [r]) - addRe l (M.AssocA M.AddRe r) = M.AssocA M.AddRe (l : r) - addRe l r = M.AssocA M.AddRe [l, r] - - -- | Multiply two expressions (Integers). - mulI l (M.Lit (Int 1)) = l - mulI (M.Lit (Int 1)) r = r - mulI (M.AssocA M.MulI l) (M.AssocA M.MulI r) = M.AssocA M.MulI (l ++ r) - mulI (M.AssocA M.MulI l) r = M.AssocA M.MulI (l ++ [r]) - mulI l (M.AssocA M.MulI r) = M.AssocA M.MulI (l : r) - mulI l r = M.AssocA M.MulI [l, r] - - -- | Multiply two expressions (Real numbers). - mulRe l (M.Lit (Dbl 1)) = l - mulRe (M.Lit (Dbl 1)) r = r - mulRe l (M.Lit (ExactDbl 1)) = l - mulRe (M.Lit (ExactDbl 1)) r = r - mulRe (M.AssocA M.MulRe l) (M.AssocA M.MulRe r) = M.AssocA M.MulRe (l ++ r) - mulRe (M.AssocA M.MulRe l) r = M.AssocA M.MulRe (l ++ [r]) - mulRe l (M.AssocA M.MulRe r) = M.AssocA M.MulRe (l : r) - mulRe l r = M.AssocA M.MulRe [l, r] - + -- | Add two expressions. + ($+) (M.Lit (Int 0)) r = r + ($+) l (M.Lit (Int 0)) = l + ($+) (M.Lit (Dbl 0)) r = r + ($+) l (M.Lit (Dbl 0)) = l + ($+) l (M.Lit (ExactDbl 0)) = l + ($+) (M.Lit (ExactDbl 0)) r = r + ($+) (M.AssocA M.Add l) (M.AssocA M.Add r) = M.AssocA M.Add (l ++ r) + ($+) (M.AssocA M.Add l) r = M.AssocA M.Add (l ++ [r]) + ($+) l (M.AssocA M.Add r) = M.AssocA M.Add (l : r) + ($+) l r = M.AssocA M.Add [l, r] + + -- | Multiply two expressions. + ($*) (M.Lit (Int 1)) r = r + ($*) l (M.Lit (Int 1)) = l + ($*) (M.Lit (Dbl 1.0)) r = r + ($*) l (M.Lit (Dbl 1.0)) = l + ($*) l (M.Lit (ExactDbl 1)) = l + ($*) (M.Lit (ExactDbl 1)) r = r + ($*) (M.AssocA M.Mul l) (M.AssocA M.Mul r) = M.AssocA M.Mul (l ++ r) + ($*) (M.AssocA M.Mul l) r = M.AssocA M.Mul (l ++ [r]) + ($*) l (M.AssocA M.Mul r) = M.AssocA M.Mul (l : r) + ($*) l r = M.AssocA M.Mul [l,r] -- | Smart constructor for subtracting two expressions. ($-) = M.ArithBinaryOp M.Subt -- | Smart constructor for dividing two expressions. @@ -529,19 +498,19 @@ instance ExprC M.ModelExpr where idx = M.LABinaryOp M.Index -- | Integrate over some expression with bounds (∫). - defint v low high = M.Operator M.AddRe (BoundedDD v Continuous low high) + defint v low high = M.Operator M.Add (BoundedDD v Continuous low high) -- | Sum over some expression with bounds (∑). - defsum v low high = M.Operator M.AddRe (BoundedDD v Discrete low high) + defsum v low high = M.Operator M.Add (BoundedDD v Discrete low high) -- | Product over some expression with bounds (∏). - defprod v low high = M.Operator M.MulRe (BoundedDD v Discrete low high) + defprod v low high = M.Operator M.Mul (BoundedDD v Discrete low high) -- | Smart constructor for 'real interval' membership. realInterval c = M.RealI (c ^. uid) -- | Euclidean function : takes a vector and returns the sqrt of the sum-of-squares. - euclidean = sqrt . foldr1 addRe . map square + euclidean = sqrt . foldr1 ($+) . map square -- | Smart constructor to cross product two expressions. cross = M.VVVBinaryOp M.Cross @@ -588,41 +557,29 @@ instance ExprC C.CodeExpr where -- | Smart constructor for the dot product of two equations. ($.) = C.VVNBinaryOp C.Dot - -- | Add two expressions (Integers). - addI l (C.Lit (Int 0)) = l - addI (C.Lit (Int 0)) r = r - addI (C.AssocA C.AddI l) (C.AssocA C.AddI r) = C.AssocA C.AddI (l ++ r) - addI (C.AssocA C.AddI l) r = C.AssocA C.AddI (l ++ [r]) - addI l (C.AssocA C.AddI r) = C.AssocA C.AddI (l : r) - addI l r = C.AssocA C.AddI [l, r] - - -- | Add two expressions (Real numbers). - addRe l (C.Lit (Dbl 0))= l - addRe (C.Lit(Dbl 0)) r = r - addRe l (C.Lit (ExactDbl 0)) = l - addRe (C.Lit (ExactDbl 0)) r = r - addRe (C.AssocA C.AddRe l) (C.AssocA C.AddRe r) = C.AssocA C.AddRe (l ++ r) - addRe (C.AssocA C.AddRe l) r = C.AssocA C.AddRe (l ++ [r]) - addRe l (C.AssocA C.AddRe r) = C.AssocA C.AddRe (l : r) - addRe l r = C.AssocA C.AddRe [l, r] - - -- | Multiply two expressions (Integers). - mulI l (C.Lit (Int 1)) = l - mulI (C.Lit (Int 1)) r = r - mulI (C.AssocA C.MulI l) (C.AssocA C.MulI r) = C.AssocA C.MulI (l ++ r) - mulI (C.AssocA C.MulI l) r = C.AssocA C.MulI (l ++ [r]) - mulI l (C.AssocA C.MulI r) = C.AssocA C.MulI (l : r) - mulI l r = C.AssocA C.MulI [l, r] - - -- | Multiply two expressions (Real numbers). - mulRe l (C.Lit (Dbl 1)) = l - mulRe (C.Lit (Dbl 1)) r = r - mulRe l (C.Lit (ExactDbl 1)) = l - mulRe (C.Lit (ExactDbl 1)) r = r - mulRe (C.AssocA C.MulRe l) (C.AssocA C.MulRe r) = C.AssocA C.MulRe (l ++ r) - mulRe (C.AssocA C.MulRe l) r = C.AssocA C.MulRe (l ++ [r]) - mulRe l (C.AssocA C.MulRe r) = C.AssocA C.MulRe (l : r) - mulRe l r = C.AssocA C.MulRe [l, r] + -- | Add two expressions. + ($+) (C.Lit (Int 0)) r = r + ($+) l (C.Lit (Int 0)) = l + ($+) (C.Lit (Dbl 0)) r = r + ($+) l (C.Lit (Dbl 0)) = l + ($+) l (C.Lit (ExactDbl 0)) = l + ($+) (C.Lit (ExactDbl 0)) r = r + ($+) (C.AssocA C.Add l) (C.AssocA C.Add r) = C.AssocA C.Add (l ++ r) + ($+) (C.AssocA C.Add l) r = C.AssocA C.Add (l ++ [r]) + ($+) l (C.AssocA C.Add r) = C.AssocA C.Add (l : r) + ($+) l r = C.AssocA C.Add [l, r] + + -- | Multiply two expressions. + ($*) (C.Lit (Int 1)) r = r + ($*) l (C.Lit (Int 1)) = l + ($*) (C.Lit (Dbl 1.0)) r = r + ($*) l (C.Lit (Dbl 1.0)) = l + ($*) l (C.Lit (ExactDbl 1)) = l + ($*) (C.Lit (ExactDbl 1)) r = r + ($*) (C.AssocA C.Mul l) (C.AssocA C.Mul r) = C.AssocA C.Mul (l ++ r) + ($*) (C.AssocA C.Mul l) r = C.AssocA C.Mul (l ++ [r]) + ($*) l (C.AssocA C.Mul r) = C.AssocA C.Mul (l : r) + ($*) l r = C.AssocA C.Mul [l,r] -- | Smart constructor for subtracting two expressions. ($-) = C.ArithBinaryOp C.Subt @@ -704,19 +661,19 @@ instance ExprC C.CodeExpr where idx = C.LABinaryOp C.Index -- | Integrate over some expression with bounds (∫). - defint v low high = C.Operator C.AddRe (BoundedDD v Continuous low high) + defint v low high = C.Operator C.Add (BoundedDD v Continuous low high) -- | Sum over some expression with bounds (∑). - defsum v low high = C.Operator C.AddRe (BoundedDD v Discrete low high) + defsum v low high = C.Operator C.Add (BoundedDD v Discrete low high) -- | Product over some expression with bounds (∏). - defprod v low high = C.Operator C.MulRe (BoundedDD v Discrete low high) + defprod v low high = C.Operator C.Mul (BoundedDD v Discrete low high) -- | Smart constructor for 'real interval' membership. realInterval c = C.RealI (c ^. uid) -- | Euclidean function : takes a vector and returns the sqrt of the sum-of-squares. - euclidean = sqrt . foldr1 addRe . map square + euclidean = sqrt . foldr1 ($+) . map square -- | Smart constructor to cross product two expressions. cross = C.VVVBinaryOp C.Cross diff --git a/code/drasil-lang/lib/Language/Drasil/Expr/Lang.hs b/code/drasil-lang/lib/Language/Drasil/Expr/Lang.hs index 84f3541dee..ef86f11008 100644 --- a/code/drasil-lang/lib/Language/Drasil/Expr/Lang.hs +++ b/code/drasil-lang/lib/Language/Drasil/Expr/Lang.hs @@ -60,7 +60,7 @@ data NVVBinOp = Scale -- TODO: I suppose these can be merged to just Add and Mul? -- | Associative operators (adding and multiplication). Also specifies whether it is for integers or for real numbers. -data AssocArithOper = AddI | AddRe | MulI | MulRe +data AssocArithOper = Add | Mul deriving Eq -- | Associative boolean operators (and, or). @@ -210,16 +210,11 @@ instance LiteralC Expr where exactDbl = Lit . exactDbl perc l r = Lit $ perc l r -assocArithOperToTy :: AssocArithOper -> Space -assocArithOperToTy AddI = S.Integer -assocArithOperToTy MulI = S.Integer -assocArithOperToTy AddRe = S.Real -assocArithOperToTy MulRe = S.Real -- helper function for typechecking to help reduce duplication vvvInfer :: TypingContext Space -> VVVBinOp -> Expr -> Expr -> Either Space TypeError vvvInfer ctx op l r = case (infer ctx l, infer ctx r) of - (Left lt@(S.Vect lsp), Left (S.Vect rsp)) -> + (Left lt@(S.Vect lsp), Left (S.Vect rsp)) -> if lsp == rsp && S.isBasicNumSpace lsp then if op == VSub && (lsp == S.Natural || rsp == S.Natural) then Right $ "Vector subtraction expects both operands to be vectors of non-natural numbers. Received `" ++ show lsp ++ "` and `" ++ show rsp ++ "`." @@ -229,6 +224,7 @@ vvvInfer ctx op l r = case (infer ctx l, infer ctx r) of (_ , Right re) -> Right re (Right le, _ ) -> Right le + instance Typed Expr Space where check :: TypingContext Space -> Expr -> Space -> Either Space TypeError check = typeCheckByInfer @@ -236,10 +232,20 @@ instance Typed Expr Space where infer :: TypingContext Space -> Expr -> Either Space TypeError infer cxt (Lit lit) = infer cxt lit - infer cxt (AssocA op exs) = allOfType cxt exs sp sp - $ "Associative arithmetic operation expects all operands to be of the same expected type (" ++ show sp ++ ")." - where - sp = assocArithOperToTy op + infer cxt (AssocA _ (e:exs)) = + case infer cxt e of + Left spaceValue | S.isBasicNumSpace spaceValue -> + -- If the inferred type of e is a valid Space, call allOfType with spaceValue + allOfType cxt exs spaceValue spaceValue + "Associative arithmetic operation expects all operands to be of the same expected type." + Left l -> + -- Handle the case when sp is a Left value but spaceValue is invalid + Right ("Expected all operands in addition/multiplication to be numeric, but found " ++ show l) + Right r -> + -- If sp is a Right value containing a TypeError + Right r + infer _ (AssocA Add _) = Right "Associative addition requires at least one operand." + infer _ (AssocA Mul _) = Right "Associative multiplication requires at least one operand." infer cxt (AssocB _ exs) = allOfType cxt exs S.Boolean S.Boolean $ "Associative boolean operation expects all operands to be of the same type (" ++ show S.Boolean ++ ")." @@ -391,8 +397,8 @@ instance Typed Expr Space where (_, Right rx) -> Right rx (Right lx, _) -> Right lx - infer cxt (Operator aao (S.BoundedDD _ _ bot top) body) = - let expTy = assocArithOperToTy aao in + infer cxt (Operator _ (S.BoundedDD _ _ bot top) body) = + let expTy = S.Integer in case (infer cxt bot, infer cxt top, infer cxt body) of (Left botTy, Left topTy, Left bodyTy) -> if botTy == S.Integer then if topTy == S.Integer @@ -405,7 +411,7 @@ instance Typed Expr Space where (_ , Right x , _ ) -> Right x (Right x , _ , _ ) -> Right x - infer cxt (RealI uid ri) = + infer cxt (RealI uid ri) = case (inferFromContext cxt uid, riTy ri) of (Left S.Real, Left riSp) -> if riSp == S.Real then Left S.Boolean diff --git a/code/drasil-lang/lib/Language/Drasil/Expr/Precedence.hs b/code/drasil-lang/lib/Language/Drasil/Expr/Precedence.hs index d6af61d36d..ddea00edac 100644 --- a/code/drasil-lang/lib/Language/Drasil/Expr/Precedence.hs +++ b/code/drasil-lang/lib/Language/Drasil/Expr/Precedence.hs @@ -46,10 +46,8 @@ prec2NVV _ = 190 -- | precA - precedence for arithmetic-related Binary-Associative (Commutative) operators. precA :: AssocArithOper -> Int -precA MulI = 190 -precA MulRe = 190 -precA AddI = 180 -precA AddRe = 180 +precA Mul = 190 +precA Add = 180 -- | precB - precedence for boolean-related Binary-Associative (Commutative) operators. precB :: AssocBoolOper -> Int diff --git a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Class.hs b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Class.hs index 0880fbdb09..dae695cd71 100644 --- a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Class.hs +++ b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Class.hs @@ -75,8 +75,8 @@ instance ModelExprC ModelExpr where -- TODO: All of the below only allow for Reals! Will be easier to fix while we add typing. -- | Integrate over some expression (∫). - intAll v = Operator AddRe (AllDD v Continuous) + intAll v = Operator Add (AllDD v Continuous) -- | Sum over some expression (∑). - sumAll v = Operator AddRe (AllDD v Discrete) + sumAll v = Operator Add (AllDD v Discrete) -- | Product over some expression (∏). - prodAll v = Operator MulRe (AllDD v Discrete) + prodAll v = Operator Mul (AllDD v Discrete) diff --git a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Convert.hs b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Convert.hs index 31fbff4ac8..15de833c07 100644 --- a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Convert.hs +++ b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Convert.hs @@ -10,10 +10,8 @@ import qualified Language.Drasil.Expr.Lang as E import Language.Drasil.ModelExpr.Lang assocArithOper :: E.AssocArithOper -> AssocArithOper -assocArithOper E.AddI = AddI -assocArithOper E.AddRe = AddRe -assocArithOper E.MulI = MulI -assocArithOper E.MulRe = MulRe +assocArithOper E.Add = Add +assocArithOper E.Mul = Mul assocBoolOper :: E.AssocBoolOper -> AssocBoolOper assocBoolOper E.And = And diff --git a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Lang.hs b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Lang.hs index 5072392058..62695a7f29 100644 --- a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Lang.hs +++ b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Lang.hs @@ -47,7 +47,7 @@ data NVVBinOp = Scale deriving Eq -- | Associative operators (adding and multiplication). Also specifies whether it is for integers or for real numbers. -data AssocArithOper = AddI | AddRe | MulI | MulRe +data AssocArithOper = Add | Mul deriving Eq -- | Associative boolean operators (and, or). diff --git a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Precedence.hs b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Precedence.hs index 4c4885f4d2..92bc48528f 100644 --- a/code/drasil-lang/lib/Language/Drasil/ModelExpr/Precedence.hs +++ b/code/drasil-lang/lib/Language/Drasil/ModelExpr/Precedence.hs @@ -49,10 +49,8 @@ prec2NVV _ = 190 -- | precA - precedence for arithmetic-related Binary-Associative (Commutative) operators. precA :: AssocArithOper -> Int -precA MulI = 190 -precA MulRe = 190 -precA AddI = 180 -precA AddRe = 180 +precA Mul = 190 +precA Add = 180 -- | precB - precedence for boolean-related Binary-Associative (Commutative) operators. precB :: AssocBoolOper -> Int diff --git a/code/drasil-printers/lib/Language/Drasil/Printing/Import/CodeExpr.hs b/code/drasil-printers/lib/Language/Drasil/Printing/Import/CodeExpr.hs index 6bd7e87a6b..acaf4dba7b 100644 --- a/code/drasil-printers/lib/Language/Drasil/Printing/Import/CodeExpr.hs +++ b/code/drasil-printers/lib/Language/Drasil/Printing/Import/CodeExpr.hs @@ -40,8 +40,7 @@ neg' (Lit (Dbl _)) = True neg' (Lit (Int _)) = True neg' (Lit (ExactDbl _)) = True neg' Operator{} = True -neg' (AssocA MulI _) = True -neg' (AssocA MulRe _) = True +neg' (AssocA Mul _) = True neg' (LABinaryOp Index _ _) = True neg' (UnaryOp _ _) = True neg' (UnaryOpB _ _) = True @@ -101,20 +100,16 @@ eopMuls _ (BoundedDD _ Continuous _ _) _ = error "Printing/Import.hs Product-Int -- | Helper function for translating 'EOperator's. eop :: PrintingInformation -> AssocArithOper -> DomainDesc t CodeExpr CodeExpr -> CodeExpr -> P.Expr -eop sm AddI = eopAdds sm -eop sm AddRe = eopAdds sm -eop sm MulI = eopMuls sm -eop sm MulRe = eopMuls sm +eop sm Add = eopAdds sm +eop sm Mul = eopMuls sm -- | Translate 'CodeExpr's to printable layout AST 'Expr's. codeExpr :: CodeExpr -> PrintingInformation -> P.Expr codeExpr (Lit l) sm = literal l sm codeExpr (AssocB And l) sm = assocExpr P.And (precB And) l sm codeExpr (AssocB Or l) sm = assocExpr P.Or (precB Or) l sm -codeExpr (AssocA AddI l) sm = P.Row $ addExpr l AddI sm -codeExpr (AssocA AddRe l) sm = P.Row $ addExpr l AddRe sm -codeExpr (AssocA MulI l) sm = P.Row $ mulExpr l MulI sm -codeExpr (AssocA MulRe l) sm = P.Row $ mulExpr l MulRe sm +codeExpr (AssocA Add l) sm = P.Row $ addExpr l Add sm +codeExpr (AssocA Mul l) sm = P.Row $ mulExpr l Mul sm codeExpr (C c) sm = symbol $ lookupC (sm ^. stg) (sm ^. ckdb) c codeExpr (FCall f [x] []) sm = P.Row [symbol $ lookupC (sm ^. stg) (sm ^. ckdb) f, parens $ codeExpr x sm] @@ -202,10 +197,8 @@ withParens prI a b = P.Row [parens (codeExpr a prI), P.Sup (codeExpr b prI)] -- | Helper for properly rendering exponents. pow :: PrintingInformation -> CodeExpr -> CodeExpr -> P.Expr -pow prI a@(AssocA AddI _) b = withParens prI a b -pow prI a@(AssocA AddRe _) b = withParens prI a b -pow prI a@(AssocA MulI _) b = withParens prI a b -pow prI a@(AssocA MulRe _) b = withParens prI a b +pow prI a@(AssocA Add _) b = withParens prI a b +pow prI a@(AssocA Mul _) b = withParens prI a b pow prI a@(ArithBinaryOp Subt _ _) b = withParens prI a b pow prI a@(ArithBinaryOp Frac _ _) b = withParens prI a b pow prI a@(ArithBinaryOp Pow _ _) b = withParens prI a b diff --git a/code/drasil-printers/lib/Language/Drasil/Printing/Import/Expr.hs b/code/drasil-printers/lib/Language/Drasil/Printing/Import/Expr.hs index b794e8d500..54883c6701 100644 --- a/code/drasil-printers/lib/Language/Drasil/Printing/Import/Expr.hs +++ b/code/drasil-printers/lib/Language/Drasil/Printing/Import/Expr.hs @@ -41,8 +41,7 @@ neg' (Lit (Dbl _)) = True neg' (Lit (Int _)) = True neg' (Lit (ExactDbl _)) = True neg' Operator{} = True -neg' (AssocA MulI _) = True -neg' (AssocA MulRe _) = True +neg' (AssocA Mul _) = True neg' (LABinaryOp Index _ _) = True neg' (UnaryOp _ _) = True neg' (UnaryOpB _ _) = True @@ -102,10 +101,8 @@ eopMuls _ (BoundedDD _ Continuous _ _) _ = error "Printing/Import.hs Product-Int -- | Helper function for translating 'EOperator's. eop :: PrintingInformation -> AssocArithOper -> DomainDesc t Expr Expr -> Expr -> P.Expr -eop sm AddI = eopAdds sm -eop sm AddRe = eopAdds sm -eop sm MulI = eopMuls sm -eop sm MulRe = eopMuls sm +eop sm Add = eopAdds sm +eop sm Mul = eopMuls sm -- | Translate Exprs to printable layout AST. @@ -113,10 +110,8 @@ expr :: Expr -> PrintingInformation -> P.Expr expr (Lit l) sm = literal l sm expr (AssocB And l) sm = assocExpr P.And (precB And) l sm expr (AssocB Or l) sm = assocExpr P.Or (precB Or) l sm -expr (AssocA AddI l) sm = P.Row $ addExpr l AddI sm -expr (AssocA AddRe l) sm = P.Row $ addExpr l AddRe sm -expr (AssocA MulI l) sm = P.Row $ mulExpr l MulI sm -expr (AssocA MulRe l) sm = P.Row $ mulExpr l MulRe sm +expr (AssocA Add l) sm = P.Row $ addExpr l Add sm +expr (AssocA Mul l) sm = P.Row $ mulExpr l Mul sm expr (C c) sm = symbol $ lookupC (sm ^. stg) (sm ^. ckdb) c expr (FCall f [x]) sm = P.Row [symbol $ lookupC (sm ^. stg) (sm ^. ckdb) f, parens $ expr x sm] @@ -199,10 +194,8 @@ withParens prI a b = P.Row [parens (expr a prI), P.Sup (expr b prI)] -- | Helper for properly rendering exponents. pow :: PrintingInformation -> Expr -> Expr -> P.Expr -pow prI a@(AssocA AddI _) b = withParens prI a b -pow prI a@(AssocA AddRe _) b = withParens prI a b -pow prI a@(AssocA MulI _) b = withParens prI a b -pow prI a@(AssocA MulRe _) b = withParens prI a b +pow prI a@(AssocA Add _) b = withParens prI a b +pow prI a@(AssocA Mul _) b = withParens prI a b pow prI a@(ArithBinaryOp Subt _ _) b = withParens prI a b pow prI a@(ArithBinaryOp Frac _ _) b = withParens prI a b pow prI a@(ArithBinaryOp Pow _ _) b = withParens prI a b diff --git a/code/drasil-printers/lib/Language/Drasil/Printing/Import/ModelExpr.hs b/code/drasil-printers/lib/Language/Drasil/Printing/Import/ModelExpr.hs index 630e39ce8a..369c712757 100644 --- a/code/drasil-printers/lib/Language/Drasil/Printing/Import/ModelExpr.hs +++ b/code/drasil-printers/lib/Language/Drasil/Printing/Import/ModelExpr.hs @@ -40,8 +40,7 @@ neg' (Lit (Dbl _)) = True neg' (Lit (Int _)) = True neg' (Lit (ExactDbl _)) = True neg' Operator{} = True -neg' (AssocA MulI _) = True -neg' (AssocA MulRe _) = True +neg' (AssocA Mul _) = True neg' (LABinaryOp Index _ _) = True neg' (UnaryOp _ _) = True neg' (UnaryOpB _ _) = True @@ -101,10 +100,8 @@ eopMuls _ (BoundedDD _ Continuous _ _) _ = error "Printing/Import.hs Product-Int -- | Helper function for translating 'EOperator's. eop :: PrintingInformation -> AssocArithOper -> DomainDesc t ModelExpr ModelExpr -> ModelExpr -> P.Expr -eop sm AddI = eopAdds sm -eop sm AddRe = eopAdds sm -eop sm MulI = eopMuls sm -eop sm MulRe = eopMuls sm +eop sm Add = eopAdds sm +eop sm Mul = eopMuls sm -- | Helper function for display nth derivative sup :: Integer -> [P.Expr] @@ -118,10 +115,8 @@ modelExpr (Lit l) sm = literal l sm modelExpr (AssocB And l) sm = assocExpr P.And (precB And) l sm modelExpr (AssocB Or l) sm = assocExpr P.Or (precB Or) l sm modelExpr (AssocB Equivalence l) sm = assocExpr P.Eq (precB Equivalence) l sm -modelExpr (AssocA AddI l) sm = P.Row $ addExpr l AddI sm -modelExpr (AssocA AddRe l) sm = P.Row $ addExpr l AddRe sm -modelExpr (AssocA MulI l) sm = P.Row $ mulExpr l MulI sm -modelExpr (AssocA MulRe l) sm = P.Row $ mulExpr l MulRe sm +modelExpr (AssocA Add l) sm = P.Row $ addExpr l Add sm +modelExpr (AssocA Mul l) sm = P.Row $ mulExpr l Mul sm modelExpr (Deriv 0 Part a _) sm = P.Row [modelExpr a sm] modelExpr (Deriv 0 Total a _) sm = P.Row [modelExpr a sm] modelExpr (Deriv n Part a b) sm = @@ -217,10 +212,8 @@ withParens prI a b = P.Row [parens (modelExpr a prI), P.Sup (modelExpr b prI)] -- | Helper for properly rendering exponents. pow :: PrintingInformation -> ModelExpr -> ModelExpr -> P.Expr -pow prI a@(AssocA AddI _) b = withParens prI a b -pow prI a@(AssocA AddRe _) b = withParens prI a b -pow prI a@(AssocA MulI _) b = withParens prI a b -pow prI a@(AssocA MulRe _) b = withParens prI a b +pow prI a@(AssocA Add _) b = withParens prI a b +pow prI a@(AssocA Mul _) b = withParens prI a b pow prI a@(ArithBinaryOp Subt _ _) b = withParens prI a b pow prI a@(ArithBinaryOp Frac _ _) b = withParens prI a b pow prI a@(ArithBinaryOp Pow _ _) b = withParens prI a b