<commit_before>module Drasil.SWHS.Requirements where --all of this file is exported

import Language.Drasil

import Drasil.DocLang (inDataConstTbl)
import Drasil.DocLang.SRS (propCorSol) 

import Data.Drasil.Concepts.Documentation (assumption, code, condition, corSol,
  dataDefn, funcReqDom, genDefn, inModel, input_, likelyChg, mg, mis, module_,
  nonFuncReqDom, output_, physicalConstraint, property, quantity, requirement, 
  simulation, solution, srs, thModel, traceyMatrix, unlikelyChg, vavPlan)
import Data.Drasil.Concepts.Math (equation, parameter, surface)
import Data.Drasil.Concepts.Thermodynamics as CT (heatTrans, law_cons_energy, melting)

import Data.Drasil.Quantities.PhysicalProperties (mass)
import Data.Drasil.Quantities.Physics (energy, time)

import Data.Drasil.SentenceStructures (FoldType(List), SepType(Comma), foldlList, 
  foldlSent, foldlSP, foldlSP_, foldlSPCol, isThe, ofThe', sAnd)
import Data.Drasil.Utils (eqUnR')

import Drasil.SWHS.Assumptions (assumpVCN)
import Drasil.SWHS.Concepts (coil, phsChgMtrl, progName, rightSide, tank, water)
import Drasil.SWHS.DataDefs (dd1HtFluxC, dd2HtFluxP)
import Drasil.SWHS.IMods (eBalanceOnWtr, eBalanceOnPCM, heatEInWtr, heatEInPCM, swhsIMods)
import Drasil.SWHS.Tables (inputInitQuantsTblabled)
import Drasil.SWHS.Unitals (coil_HTC, coil_SA, diam, eta, htCap_L_P, htCap_S_P,
  htCap_W, htFusion, pcm_E, pcm_HTC, pcm_SA, pcm_density, pcm_mass, pcm_vol,
  sim_time, t_final_melt, t_init_melt, tank_length, tank_vol, tau_L_P, tau_S_P,
  tau_W, temp_C, temp_PCM, temp_W, temp_init, temp_melt_P, time_final, w_E,
  w_density, w_mass, w_vol)

------------------------------
-- Data Constraint: Table 1 --
------------------------------

-- FIXME: This probably shouldn't be here.
dataConTable1 :: LabelledContent
dataConTable1 = inDataConstTbl inputConstraints

inputConstraints :: [UncertQ]
inputConstraints = [tank_length, diam, pcm_vol, pcm_SA, pcm_density,
  temp_melt_P, htCap_S_P, htCap_L_P, htFusion, coil_SA,
  temp_C, w_density, htCap_W, coil_HTC, pcm_HTC, temp_init, time_final]

------------------------------
-- Section 5 : REQUIREMENTS --
------------------------------
-----------------------------------
-- 5.1 : Functional Requirements --
-----------------------------------

funcReqs :: [ConceptInstance]
funcReqs = [inputInitQuants, findMass, checkWithPhysConsts, outputInputDerivQuants,
  calcTempWtrOverTime, calcTempPCMOverTime, calcChgHeatEnergyWtrOverTime,
  calcChgHeatEnergyPCMOverTime, verifyEnergyOutput, calcPCMMeltBegin, calcPCMMeltEnd]

inputInitQuants, findMass, checkWithPhysConsts, outputInputDerivQuants,
  calcTempWtrOverTime, calcTempPCMOverTime, calcChgHeatEnergyWtrOverTime,
  calcChgHeatEnergyPCMOverTime, verifyEnergyOutput, calcPCMMeltBegin,
  calcPCMMeltEnd :: ConceptInstance

inputInitQuantsEqn, findMassEqn :: Expr --Fixme: rename labels

inputInitQuants = cic "inputInitQuants" ( foldlSent [
  titleize input_, S "the following", plural quantity, S "described in",
  makeRef2S inputInitQuantsTblabled `sC` S "which define the", phrase tank,
  plural parameter `sC` S "material", plural property, S "and initial",
  plural condition]) "Input-Initial-Quantities" funcReqDom
--
findMass = cic "findMass" ( foldlSent [
  S "Use the", plural input_, S "in", makeRef2S inputInitQuants,
  S "to find the", phrase mass, S "needed for",
  (foldlList Comma List $ map makeRef2S swhsIMods) `sC`
  S "using", E inputInitQuantsEqn, S "and", E findMassEqn `sC` S "where",
  ch w_vol `isThe` phrase w_vol, S "and" +:+. (ch tank_vol `isThe`
  phrase tank_vol), makeRef2S assumpVCN])
  "Find-Mass" funcReqDom -- FIXME: Equations shouldn't be inline

inputInitQuantsEqn = (sy w_mass) $= (sy w_vol) * (sy w_density) $=
  ((sy tank_vol) - (sy pcm_vol)) * (sy w_density) $=
  ((((sy diam) / 2) $^ 2) * (sy tank_length) - (sy pcm_vol)) * (sy w_density) -- FIXME: Ref Hack

findMassEqn = (sy pcm_mass) $= (sy pcm_vol) * (sy pcm_density) -- FIXME: Ref Hack
--
checkWithPhysConsts = cic "checkWithPhysConsts" ( foldlSent [
  S "Verify that the", plural input_, S "satisfy the required",
  plural physicalConstraint , S "shown in", makeRef2S dataConTable1] )
  "Check-Input-with-Physical_Constraints" funcReqDom
--
outputInputDerivQuants = cic "outputInputDerivQuants" ( foldlSent [
  titleize output_, S "the", phrase input_, plural quantity `sAnd`
  S "derived", plural quantity +: S "in the following list",
  S "the", plural quantity, S "from", makeRef2S inputInitQuants `sC` S "the",
  plural mass, S "from", makeRef2S findMass `sC` ch tau_W,
  sParen (S "from" +:+ makeRef2S eBalanceOnWtr) `sC` ch eta,
  sParen (S "from" +:+ makeRef2S eBalanceOnWtr) `sC` ch tau_S_P,
  sParen (S "from" +:+ makeRef2S eBalanceOnPCM) `sAnd` ch tau_L_P,
  sParen (S "from" +:+ makeRef2S eBalanceOnPCM)] )
  "Output-Input-Derived-Quantities" funcReqDom
--
calcTempWtrOverTime = cic "calcTempWtrOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase temp_W,
  sParen(ch temp_W :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S eBalanceOnWtr)] )
  "Calculate-Temperature-Water-Over-Time" funcReqDom
--
calcTempPCMOverTime = cic "calcTempPCMOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase temp_PCM,
  sParen (ch temp_PCM :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S eBalanceOnPCM)] )
  "Calculate-Temperature-PCM-Over-Time" funcReqDom
--
calcChgHeatEnergyWtrOverTime = cic "calcChgHeatEnergyWtrOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase w_E,
  sParen (ch w_E :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S heatEInWtr)] )
  "Calculate-Change-Heat_Energy-Water-Over-Time" funcReqDom
--
calcChgHeatEnergyPCMOverTime = cic "calcChgHeatEnergyPCMOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase pcm_E,
  sParen (ch pcm_E :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S heatEInPCM)] )
  "Calculate-Change-Heat_Energy-PCM-Over-Time" funcReqDom
--<commit_msg>Split outputInputDerivQuants into a constructor<commit_after>module Drasil.SWHS.Requirements where --all of this file is exported

import Language.Drasil

import Drasil.DocLang (inDataConstTbl)
import Drasil.DocLang.SRS (propCorSol) 

import Data.Drasil.Concepts.Documentation (assumption, code, condition, corSol,
  dataDefn, funcReqDom, genDefn, inModel, input_, likelyChg, mg, mis, module_,
  nonFuncReqDom, output_, physicalConstraint, property, quantity, requirement, 
  simulation, solution, srs, thModel, traceyMatrix, unlikelyChg, vavPlan)
import Data.Drasil.Concepts.Math (equation, parameter, surface)
import Data.Drasil.Concepts.Thermodynamics as CT (heatTrans, law_cons_energy, melting)

import Data.Drasil.Quantities.PhysicalProperties (mass)
import Data.Drasil.Quantities.Physics (energy, time)

import Data.Drasil.SentenceStructures (FoldType(List), SepType(Comma), foldlList, 
  foldlSent, foldlSent_, foldlSP, foldlSP_, foldlSPCol, isThe, ofThe', sAnd)
import Data.Drasil.Utils (eqUnR')

import Drasil.SWHS.Assumptions (assumpVCN)
import Drasil.SWHS.Concepts (coil, phsChgMtrl, progName, rightSide, tank, water)
import Drasil.SWHS.DataDefs (dd1HtFluxC, dd2HtFluxP)
import Drasil.SWHS.IMods (eBalanceOnWtr, eBalanceOnPCM, heatEInWtr, heatEInPCM, swhsIMods)
import Drasil.SWHS.Tables (inputInitQuantsTblabled)
import Drasil.SWHS.Unitals (coil_HTC, coil_SA, diam, eta, htCap_L_P, htCap_S_P,
  htCap_W, htFusion, pcm_E, pcm_HTC, pcm_SA, pcm_density, pcm_mass, pcm_vol,
  sim_time, t_final_melt, t_init_melt, tank_length, tank_vol, tau_L_P, tau_S_P,
  tau_W, temp_C, temp_PCM, temp_W, temp_init, temp_melt_P, time_final, w_E,
  w_density, w_mass, w_vol)

------------------------------
-- Data Constraint: Table 1 --
------------------------------

-- FIXME: This probably shouldn't be here.
dataConTable1 :: LabelledContent
dataConTable1 = inDataConstTbl inputConstraints

inputConstraints :: [UncertQ]
inputConstraints = [tank_length, diam, pcm_vol, pcm_SA, pcm_density,
  temp_melt_P, htCap_S_P, htCap_L_P, htFusion, coil_SA,
  temp_C, w_density, htCap_W, coil_HTC, pcm_HTC, temp_init, time_final]

------------------------------
-- Section 5 : REQUIREMENTS --
------------------------------
-----------------------------------
-- 5.1 : Functional Requirements --
-----------------------------------

funcReqs :: [ConceptInstance]
funcReqs = [inputInitQuants, findMass, checkWithPhysConsts, outputInputDerivQuants,
  calcTempWtrOverTime, calcTempPCMOverTime, calcChgHeatEnergyWtrOverTime,
  calcChgHeatEnergyPCMOverTime, verifyEnergyOutput, calcPCMMeltBegin, calcPCMMeltEnd]

inputInitQuants, findMass, checkWithPhysConsts, outputInputDerivQuants,
  calcTempWtrOverTime, calcTempPCMOverTime, calcChgHeatEnergyWtrOverTime,
  calcChgHeatEnergyPCMOverTime, verifyEnergyOutput, calcPCMMeltBegin,
  calcPCMMeltEnd :: ConceptInstance

inputInitQuantsEqn, findMassEqn :: Expr --Fixme: rename labels

inputInitQuants = cic "inputInitQuants" ( foldlSent [
  titleize input_, S "the following", plural quantity, S "described in",
  makeRef2S inputInitQuantsTblabled `sC` S "which define the", phrase tank,
  plural parameter `sC` S "material", plural property, S "and initial",
  plural condition]) "Input-Initial-Quantities" funcReqDom
--
findMass = cic "findMass" ( foldlSent [
  S "Use the", plural input_, S "in", makeRef2S inputInitQuants,
  S "to find the", phrase mass, S "needed for",
  (foldlList Comma List $ map makeRef2S swhsIMods) `sC`
  S "using", E inputInitQuantsEqn, S "and", E findMassEqn `sC` S "where",
  ch w_vol `isThe` phrase w_vol, S "and" +:+. (ch tank_vol `isThe`
  phrase tank_vol), makeRef2S assumpVCN])
  "Find-Mass" funcReqDom -- FIXME: Equations shouldn't be inline

inputInitQuantsEqn = (sy w_mass) $= (sy w_vol) * (sy w_density) $=
  ((sy tank_vol) - (sy pcm_vol)) * (sy w_density) $=
  ((((sy diam) / 2) $^ 2) * (sy tank_length) - (sy pcm_vol)) * (sy w_density) -- FIXME: Ref Hack

findMassEqn = (sy pcm_mass) $= (sy pcm_vol) * (sy pcm_density) -- FIXME: Ref Hack
--
checkWithPhysConsts = cic "checkWithPhysConsts" ( foldlSent [
  S "Verify that the", plural input_, S "satisfy the required",
  plural physicalConstraint , S "shown in", makeRef2S dataConTable1] )
  "Check-Input-with-Physical_Constraints" funcReqDom
--
outputInputDerivQuants = oIDQConstruct oIDQQuants

oIDQConstruct :: Sentence -> ConceptInstance
oIDQConstruct x = cic "outputInputDerivQuants" ( foldlSent_ [
  titleize output_, S "the", phrase input_, plural quantity `sAnd`
  S "derived", plural quantity +: S "in the following list"] +:+ x)
  "Output-Input-Derived-Quantities" funcReqDom

oIDQQuants :: Sentence
oIDQQuants = foldlSent [
  S "the", plural quantity, S "from", makeRef2S inputInitQuants `sC` S "the",
  plural mass, S "from", makeRef2S findMass `sC` ch tau_W,
  sParen (S "from" +:+ makeRef2S eBalanceOnWtr) `sC` ch eta,
  sParen (S "from" +:+ makeRef2S eBalanceOnWtr) `sC` ch tau_S_P,
  sParen (S "from" +:+ makeRef2S eBalanceOnPCM) `sAnd` ch tau_L_P,
  sParen (S "from" +:+ makeRef2S eBalanceOnPCM)]
  
--
calcTempWtrOverTime = cic "calcTempWtrOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase temp_W,
  sParen(ch temp_W :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S eBalanceOnWtr)] )
  "Calculate-Temperature-Water-Over-Time" funcReqDom
--
calcTempPCMOverTime = cic "calcTempPCMOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase temp_PCM,
  sParen (ch temp_PCM :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S eBalanceOnPCM)] )
  "Calculate-Temperature-PCM-Over-Time" funcReqDom
--
calcChgHeatEnergyWtrOverTime = cic "calcChgHeatEnergyWtrOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase w_E,
  sParen (ch w_E :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S heatEInWtr)] )
  "Calculate-Change-Heat_Energy-Water-Over-Time" funcReqDom
--
calcChgHeatEnergyPCMOverTime = cic "calcChgHeatEnergyPCMOverTime" ( foldlSent [
  S "Calculate and", phrase output_, S "the", phrase pcm_E,
  sParen (ch pcm_E :+: sParen (ch time)), S "over the",
  phrase simulation, phrase time, sParen (S "from" +:+ makeRef2S heatEInPCM)] )
  "Calculate-Change-Heat_Energy-PCM-Over-Time" funcReqDom
--
{'fraction_non_alphanumeric': 0.14063875770431442, 'fraction_numerical': 0.004162330905306972, 'mean_word_length': 4.6178057553956835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2643219', 'n_tokens_mistral': 4693, 'n_tokens_neox': 4561, 'n_words': 1161}