Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWHS iMod components should have more meaningful names #1671

Open
danscime opened this issue Jul 5, 2019 · 3 comments
Open

SWHS iMod components should have more meaningful names #1671

danscime opened this issue Jul 5, 2019 · 3 comments
Labels
newcomers Good first issue to work on! verify-fixed When an issue seems fixed, but someone needs to check

Comments

@danscime
Copy link
Collaborator

danscime commented Jul 5, 2019

In SWHS Body, many components of iMods are created and have non-meaningful names.

iModSubpar :: NamedChunk -> UncertQ -> UncertQ -> UncertQ -> ConceptChunk
-> [Contents]
iModSubpar sol temw tempcm epcm pc = [foldlSP [S "The goals", foldlList Comma List $ map S
["GS1", "GS2", "GS3", "GS4"], S "are solved by" +:+. foldlList Comma List -- hardcoded GSs because Goals are not implemented yet
[makeRef2S eBalanceOnWtr, makeRef2S eBalanceOnPCM, makeRef2S heatEInWtr, makeRef2S heatEInPCM],
S "The", plural sol, S "for", makeRef2S eBalanceOnWtr `sAnd` makeRef2S eBalanceOnPCM,
S "are coupled since the", phrase sol, S "for", ch temw `sAnd` ch tempcm +:+. S "depend on one another",
makeRef2S heatEInWtr, S "can be solved once", makeRef2S eBalanceOnWtr, S "has been solved. The",
phrase sol `sOf` makeRef2S eBalanceOnPCM `sAnd` makeRef2S heatEInPCM, S "are also coupled, since the",
phrase tempcm `sAnd` phrase epcm, S "depend on the", phrase pc]]
iMod1Para :: UnitalChunk -> ConceptChunk -> [Contents]
iMod1Para en wa = [foldlSPCol [S "Derivation of the",
phrase en, S "balance on", phrase wa]]
iMod1Sent2 :: DataDefinition -> DataDefinition -> UnitalChunk ->
UnitalChunk -> [Sentence]
iMod1Sent2 d1hf d2hf hfc hfp = [S "Using", makeRef2S d1hf `sAnd`
makeRef2S d2hf, S "for", ch hfc `sAnd`
ch hfp, S "respectively, this can be written as"]
iMod1Sent3 :: UnitalChunk -> UncertQ -> [Sentence]
iMod1Sent3 wm hcw = [S "Dividing (3) by", ch wm :+: ch hcw `sC`
S "we obtain"]
iMod1Sent4 :: CI -> UncertQ -> UncertQ -> [Sentence]
iMod1Sent4 rs chtc csa = [S "Factoring the negative sign out of",
S "second term" `ofThe` short rs,
S "of", titleize equation,
S "(4) and multiplying it by",
ch chtc :+: ch csa :+: S "/" :+:
ch chtc :+: ch csa, S "yields"]
iMod1Sent5 :: [Sentence]
iMod1Sent5 = [S "Which simplifies to"]
iMod1Sent6 :: [Sentence]
iMod1Sent6 = [S "Setting",
(E $ sy tauW $= (sy wMass * sy htCapW) / (sy coilHTC * sy coilSA)) `sAnd`
(E $ sy eta $= (sy pcmHTC * sy pcmSA) / (sy coilHTC * sy coilSA)) `sC`
titleize equation, S "(5) can be written as"]
iMod1Sent7 :: [Sentence]
iMod1Sent7 = [S "Finally, factoring out", (E $ 1 / sy tauW) `sC`
S "we are left with the governing", short ode, S "for", makeRef2S eBalanceOnWtr]
iMod1Eqn1, iMod1Eqn2, iMod1Eqn3, iMod1Eqn4, iMod1Eqn5,
iMod1Eqn6, iMod1Eqn7 :: Expr
iMod1Eqn1 = sy wMass * sy htCapW * deriv (sy tempW) time $=
sy htFluxC * sy coilSA - sy htFluxP * sy pcmSA
iMod1Eqn2 = sy wMass * sy htCapW * deriv (sy tempW) time $=
sy coilHTC * sy coilSA * (sy tempC - sy tempW) -
sy pcmHTC * sy pcmSA * (sy tempW - sy tempPCM)
iMod1Eqn3 = deriv (sy tempW) time $= (sy coilHTC *
sy coilSA) / (sy wMass * sy htCapW) * (sy tempC -
sy tempW) - (sy pcmMass * sy pcmSA) / (sy wMass *
sy htCapW) * (sy tempW - sy tempPCM)
iMod1Eqn4 = deriv (sy tempW) time $= (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)
iMod1Eqn5 = deriv (sy tempW) time $= (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)
iMod1Eqn6 = deriv (sy tempW) time $= (1 / sy tauW) *
(sy tempC - sy tempW) + (sy eta / sy tauW) *
(sy tempPCM - sy tempW)
iMod1Eqn7 = deriv (sy tempW) time $= (1 / sy tauW) *
((sy tempC - sy tempW) + sy eta * (sy tempPCM -
sy tempW))
-- Should "energy balance" be a concept?
-- Add IM, GD, A, and EqnBlock references when available
-- Replace derivs with regular derivative when available
-- Fractions in paragraph?
iMod2Sent1 :: DataDefinition -> UnitalChunk -> [Sentence]
iMod2Sent1 d2hfp hfp = [S "Using", makeRef2S d2hfp, S "for",
ch hfp `sC` S "this", phrase equation, S "can be written as"]
iMod2Sent2 :: [Sentence]
iMod2Sent2 = [S "Dividing by", ch pcmMass :+: ch htCapSP,
S "we obtain"]
iMod2Sent3 :: [Sentence]
iMod2Sent3 = [S "Setting", ch tauSP :+: S "=" :+: ch pcmMass :+:
ch htCapSP :+: S "/" :+: ch pcmHTC :+: ch pcmSA `sC`
S "this can be written as"]
iMod2Eqn1, iMod2Eqn2, iMod2Eqn3, iMod2Eqn4 :: Expr
iMod2Eqn1 = sy pcmMass * sy htCapSP * deriv (sy tempPCM)
time $= sy htFluxP * sy pcmSA
iMod2Eqn2 = sy pcmMass * sy htCapSP * deriv (sy tempPCM)
time $= sy pcmHTC * sy pcmSA * (sy tempW - sy tempPCM)
iMod2Eqn3 = deriv (sy tempPCM) time $= (sy pcmHTC *
sy pcmSA) / (sy pcmMass * sy htCapSP) * (sy tempW - sy tempPCM)
iMod2Eqn4 = deriv (sy tempPCM) time $= (1 / sy tauSP) *
(sy tempW - sy tempPCM)

@danscime danscime self-assigned this Jul 5, 2019
@danscime danscime removed their assignment Sep 1, 2019
@JacquesCarette JacquesCarette mentioned this issue May 14, 2020
2 tasks
@balacij balacij added verify-fixed When an issue seems fixed, but someone needs to check newcomers Good first issue to work on! labels Apr 26, 2023
@daijingz
Copy link
Contributor

Have selected this issue and started working.

@daijingz
Copy link
Contributor

@balacij I believe this issue has become out-of-date on its path, because:

  1. At first, I inspected the file Drasil\code\drasil-example\swhs\lib\Drasil\SWHS\Body.hs, and I found these lines did not exist (this file only has 606 lines, but the improvement place starts at line 802). But this should be the correct equivalent corresponding body.hs file.
  2. Then I guess it should be moved to somewhere else, so I searched all keywords in this definition, but none of them targeted at a new definition.
  3. Then I remembered this code section represents the SWHS example's instance models, so I looked at section 4.2.5, However, this section's code body in the body.hs is empty.
  4. I remember that all instance models are stored in an independent file IMods.hs, so I looked at them and I found some places for this issue's improvement.

Current Path: D:\Drasil\code\drasil-example\swhs\lib\Drasil\SWHS\IMods.hs
If you feel this is incorrect, please inform me.

@daijingz
Copy link
Contributor

daijingz commented Sep 14, 2024

@balacij I feel this file has no place for such meaningful naming improvements. Up to now, all definitions in the SWHS IMods.hs file have meaningful names, except derivation sentences and equations. However, using numbers inside their names is reasonable. So seems like all definition namings are reasonable. (No need to change anything)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
newcomers Good first issue to work on! verify-fixed When an issue seems fixed, but someone needs to check
Projects
None yet
Development

No branches or pull requests

3 participants