JacquesCarette / Drasil

Generate all the things (focusing on research software)
https://jacquescarette.github.io/Drasil
BSD 2-Clause "Simplified" License
142 stars 26 forks source link

Convert SSP's GenDefn normShrR into EquationalModel #2582

Closed balacij closed 3 years ago

balacij commented 3 years ago

Similar to #2580

https://jacquescarette.github.io/Drasil/examples/SSP/srs/SSP_SRS.html#GD:normShrR

Awurama-N commented 3 years ago

@balacij this one seemse a bit different from the others in the sense that it's "on its own"

normShrR :: RelationConcept
normShrR = makeRC "normShrR"
  (nounPhraseSP "interslice normal and shear force proportionality")
  nmShrRDesc nmShrRRel

with the others i usually had to edit both things to make it work

offsetIM :: InstanceModeloffsetIM = imNoDerivNoRefs (OthModel offsetRC)
  [qwC landPos $ UpFrom (Exc, exactDbl 0)  
  ,qwC targPos $ UpFrom (Exc, exactDbl 0)]  
  (qw offset) [] "offsetIM" [landPosNote, landAndTargPosConsNote]

offsetRC :: RelationConcept
offsetRC = makeRC "offsetRC" (nounPhraseSP "offset") EmptyS $ sy offset $= E.offset

I initially thought it would be:

normShrR :: QDefinition 
normShrR = mkQuantDef nmShrRDesc nmShrRRel

But there's an error reading that there are "no instances of (Quantity Sentence)"

Awurama-N commented 3 years ago

also after this is figured out, i see other Relationship concepts in this file similar to this one, would you like me to create issues and change them to equational models as well?

balacij commented 3 years ago
normShrR :: QDefinition 
normShrR = mkQuantDef nmShrRDesc nmShrRRel

The issue here is that nmShrRDesc is a Sentence. You should be converting the RelationConcept nmShrRRel (similar to your example sy offset $= E.offset) into a QDefinition using mkQuantDef/any of the other QDefinition constructors (if you CMD+click on mkQuantDef, it should bring you to the file containing mkQuantDef, showing other constructors -- namely, mkQuantDef', fromEqnSt', fromEqnSet, etc). Specifically, with your offset example, we are defining the offset using the expression E.offset. You will need to look into what nmShrRRel (CMD+click is helpful again here) is to create this connection too, so you can find what quantity we're defining, and using which expression.

Thank you, the other RelationConcepts in the file are slightly different unfortunately however, they need a new kind of model to assist in defining them. We wouldn't be able to jig them into any of the existing ModelKinds, I think it will need to be some sort of forall/discrete/ranged model. I'm not quite sure yet how we can define them.

Awurama-N commented 3 years ago

is there something i could do to fix this issue now? I see Dr. Carette said the code changes were fine but it still breaking stable in ways that it shouldn't. I'm not quite sure what the next steps should be. @balacij

balacij commented 3 years ago

Yeah, there's a few things we can try, but ultimately we may just need to add a custom "term" to the GDs. Where is the breakage located if you don't give the mkQuantDef a custom term (e.g., using mkQuantDef instead of mkQuantDef')?

Awurama-N commented 3 years ago

when i change it i have to take out the noun phrase, so everything in the stable logs is a bit different. All the definitions slightly change. for example:

659c659
<               \item{$\mathbf{X}$ is the interslice normal and shear force proportionality ($\frac{\text{N}}{\text{m}}$)}
---
>               \item{$\mathbf{X}$ is the interslice shear forces ($\frac{\text{N}}{\text{m}}$)}
707c707
<               \item{$\mathbf{X}$ is the interslice normal and shear force proportionality ($\frac{\text{N}}{\text{m}}$)}
---
>               \item{$\mathbf{X}$ is the interslice shear forces ($\frac{\text{N}}{\text{m}}$)}

443c443
< \item[Determine-Shear-Forces:\phantomsection\label{determineShearF}]{Determine the interslice normal and shear force proportionality between each pair of vertical slices of the slope.}
---
> \item[Determine-Shear-Forces:\phantomsection\label{determineShearF}]{Determine the interslice shear forces between each pair of vertical slices of the slope.}
459c459
< \item[Interslice-Norm-Shear-Forces-Linear:\phantomsection\label{assumpINSFL}]{Following the assumption of Morgenstern and Price (\cite{morgenstern1965}), interslice normal forces and interslice normal and shear force proportionality have a proportional relationship, depending on a proportionality constant ($λ$) and a function ($\mathbf{f}$) describing variation depending on $x$ position. (RefBy: \hyperref[IM:nrmShrFor]{IM: nrmShrFor}, \hyperref[IM:fctSfty]{IM: fctSfty}, \hyperref[GD:normShrR]{GD: normShrR}, and \hyperref[UC_normshearlinear]{UC: Normal-And-Shear-Linear-Only}.)}
---
> \item[Interslice-Norm-Shear-Forces-Linear:\phantomsection\label{assumpINSFL}]{Following the assumption of Morgenstern and Price (\cite{morgenstern1965}), interslice normal forces and interslice shear forces have a proportional relationship, depending on a proportionality constant ($λ$) and a function ($\mathbf{f}$) describing variation depending on $x$ position. (RefBy: \hyperref[IM:nrmShrFor]{IM: nrmShrFor}, \hyperref[IM:fctSfty]{IM: fctSfty}, \hyperref[GD:normShrR]
balacij commented 3 years ago

Commented on the PR, thank you for the logs!

JacquesCarette commented 3 years ago

The deeper issue is that there is 'normal force' and 'shear force' and they are different, although there are times where you want to talk about both of them.

So we need to make sure the models are tagged with the correct information - I think that's the source of the problem that @smiths spotted. That will likely still result in changes to stable, quite likely the ones that @Awurama-N is showing above. Then we'll need to understand if stable was even correct. If it was, then it's possible that the example used a hack to get there. In other words, we need a much deeper understanding of the source of this bug. We need to not only get the expected answer, we also need to get it via the desired computational path.

balacij commented 3 years ago

Ah, ok. In that case, @Awurama-N, is that the full logs? It sounds like we need @smiths to give it a look to answer @JacquesCarette's above discussion questions.

Awurama-N commented 3 years ago

full logs @smiths

diff --strip-trailing-cr -r -X ../.gitignore -x '*.txt' stable/ssp/SRS/SSP_SRS.tex build/SSP/SRS/SSP_SRS.tex
443c443
< \item[Determine-Shear-Forces:\phantomsection\label{determineShearF}]{Determine the interslice normal and shear force proportionality between each pair of vertical slices of the slope.}
---
> \item[Determine-Shear-Forces:\phantomsection\label{determineShearF}]{Determine the interslice shear forces between each pair of vertical slices of the slope.}
459c459
< \item[Interslice-Norm-Shear-Forces-Linear:\phantomsection\label{assumpINSFL}]{Following the assumption of Morgenstern and Price (\cite{morgenstern1965}), interslice normal forces and interslice normal and shear force proportionality have a proportional relationship, depending on a proportionality constant ($λ$) and a function ($\mathbf{f}$) describing variation depending on $x$ position. (RefBy: \hyperref[IM:nrmShrFor]{IM: nrmShrFor}, \hyperref[IM:fctSfty]{IM: fctSfty}, \hyperref[GD:normShrR]{GD: normShrR}, and \hyperref[UC_normshearlinear]{UC: Normal-And-Shear-Linear-Only}.)}
---
> \item[Interslice-Norm-Shear-Forces-Linear:\phantomsection\label{assumpINSFL}]{Following the assumption of Morgenstern and Price (\cite{morgenstern1965}), interslice normal forces and interslice shear forces have a proportional relationship, depending on a proportionality constant ($λ$) and a function ($\mathbf{f}$) describing variation depending on $x$ position. (RefBy: \hyperref[IM:nrmShrFor]{IM: nrmShrFor}, \hyperref[IM:fctSfty]{IM: fctSfty}, \hyperref[GD:normShrR]{GD: normShrR}, and \hyperref[UC_normshearlinear]{UC: Normal-And-Shear-Linear-Only}.)}
659c659
<               \item{$\mathbf{X}$ is the interslice normal and shear force proportionality ($\frac{\text{N}}{\text{m}}$)}
---
>               \item{$\mathbf{X}$ is the interslice shear forces ($\frac{\text{N}}{\text{m}}$)}
707c707
<               \item{$\mathbf{X}$ is the interslice normal and shear force proportionality ($\frac{\text{N}}{\text{m}}$)}
---
>               \item{$\mathbf{X}$ is the interslice shear forces ($\frac{\text{N}}{\text{m}}$)}
950c950
< Label & Interslice normal and shear force proportionality
---
> Label & Interslice shear forces
961c961
<               \item{$\mathbf{X}$ is the interslice normal and shear force proportionality ($\frac{\text{N}}{\text{m}}$)}
---
>               \item{$\mathbf{X}$ is the interslice shear forces ($\frac{\text{N}}{\text{m}}$)}
1005c1005
<               \item{$\mathbf{X}$ is the interslice normal and shear force proportionality ($\frac{\text{N}}{\text{m}}$)}
---
>               \item{$\mathbf{X}$ is the interslice shear forces ($\frac{\text{N}}{\text{m}}$)}
2126c2126
< Since the interslice normal and shear force proportionality $\mathbf{X}$ and interslice normal forces $\mathbf{G}$ are unknown, they are separated from the other terms as follows:
---
> Since the interslice shear forces $\mathbf{X}$ and interslice normal forces $\mathbf{G}$ are unknown, they are separated from the other terms as follows:
2141c2141
< The interslice normal and shear force proportionality $\mathbf{X}$ can be expressed in terms of the interslice normal forces $\mathbf{G}$ using \hyperref[assumpINSFL]{A: Interslice-Norm-Shear-Forces-Linear} and \hyperref[GD:normShrR]{GD: normShrR}, resulting in:
---
> The interslice shear forces $\mathbf{X}$ can be expressed in terms of the interslice normal forces $\mathbf{G}$ using \hyperref[assumpINSFL]{A: Interslice-Norm-Shear-Forces-Linear} and \hyperref[GD:normShrR]{GD: normShrR}, resulting in:
2600c2600
< \item[Display-Interslice-Shear-Forces:\phantomsection\label{displayShear}]{Using \hyperref[IM:fctSfty]{IM: fctSfty}, \hyperref[IM:nrmShrFor]{IM: nrmShrFor}, and \hyperref[IM:intsliceFs]{IM: intsliceFs}, calculate and graphically display the interslice normal and shear force proportionality.}
---
> \item[Display-Interslice-Shear-Forces:\phantomsection\label{displayShear}]{Using \hyperref[IM:fctSfty]{IM: fctSfty}, \hyperref[IM:nrmShrFor]{IM: nrmShrFor}, and \hyperref[IM:intsliceFs]{IM: intsliceFs}, calculate and graphically display the interslice shear forces.}
2695c2695
< \item[Normal-And-Shear-Linear-Only:\phantomsection\label{UC_normshearlinear}]{Changes related to \hyperref[assumpINSFL]{A: Interslice-Norm-Shear-Forces-Linear} are not possible due to the dependency of the calculations on the linear relationship between interslice normal forces and interslice normal and shear force proportionality.}
---
> \item[Normal-And-Shear-Linear-Only:\phantomsection\label{UC_normshearlinear}]{Changes related to \hyperref[assumpINSFL]{A: Interslice-Norm-Shear-Forces-Linear} are not possible due to the dependency of the calculations on the linear relationship between interslice normal forces and interslice shear forces.}
diff --strip-trailing-cr -r -X ../.gitignore -x '*.txt' stable/ssp/Website/SSP_SRS.html build/SSP/Website/SSP_SRS.html
1058c1058
<                       Determine-Shear-Forces: Determine the interslice normal and shear force proportionality between each pair of vertical slices of the slope.
---
>                       Determine-Shear-Forces: Determine the interslice shear forces between each pair of vertical slices of the slope.
1106c1106
<                       Interslice-Norm-Shear-Forces-Linear: Following the assumption of Morgenstern and Price (<a href=#morgenstern1965>morgenstern1965</a>), interslice normal forces and interslice normal and shear force proportionality have a proportional relationship, depending on a proportionality constant (<em>λ</em>) and a function (<em><b>f</b></em>) describing variation depending on <em>x</em> position. (RefBy: <a href=#IM:nrmShrFor>IM: nrmShrFor</a>, <a href=#IM:fctSfty>IM: fctSfty</a>, <a href=#GD:normShrR>GD: normShrR</a>, and <a href=#UC_normshearlinear>UC: Normal-And-Shear-Linear-Only</a>.)
---
>                       Interslice-Norm-Shear-Forces-Linear: Following the assumption of Morgenstern and Price (<a href=#morgenstern1965>morgenstern1965</a>), interslice normal forces and interslice shear forces have a proportional relationship, depending on a proportionality constant (<em>λ</em>) and a function (<em><b>f</b></em>) describing variation depending on <em>x</em> position. (RefBy: <a href=#IM:nrmShrFor>IM: nrmShrFor</a>, <a href=#IM:fctSfty>IM: fctSfty</a>, <a href=#GD:normShrR>GD: normShrR</a>, and <a href=#UC_normshearlinear>UC: Normal-And-Shear-Linear-Only</a>.)
1439c1439
<                             <em><b>X</b></em> is the interslice normal and shear force proportionality (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
---
>                             <em><b>X</b></em> is the interslice shear forces (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
1526c1526
<                             <em><b>X</b></em> is the interslice normal and shear force proportionality (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
---
>                             <em><b>X</b></em> is the interslice shear forces (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
1956,1960c1956
<                       <td>
<                         <p class="paragraph">
<                           Interslice normal and shear force proportionality
<                         </p>
<                       </td>
---
>                       <td><p class="paragraph">Interslice shear forces</p></td>
1977c1973
<                             <em><b>X</b></em> is the interslice normal and shear force proportionality (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
---
>                             <em><b>X</b></em> is the interslice shear forces (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
2052c2048
<                             <em><b>X</b></em> is the interslice normal and shear force proportionality (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
---
>                             <em><b>X</b></em> is the interslice shear forces (<em>\(\frac{\text{N}}{\text{m}}\)</em>)
3734c3730
<                       Since the interslice normal and shear force proportionality <em><b>X</b></em> and interslice normal forces <em><b>G</b></em> are unknown, they are separated from the other terms as follows:
---
>                       Since the interslice shear forces <em><b>X</b></em> and interslice normal forces <em><b>G</b></em> are unknown, they are separated from the other terms as follows:
3746c3742
<                       The interslice normal and shear force proportionality <em><b>X</b></em> can be expressed in terms of the interslice normal forces <em><b>G</b></em> using <a href=#assumpINSFL>A: Interslice-Norm-Shear-Forces-Linear</a> and <a href=#GD:normShrR>GD: normShrR</a>, resulting in:
---
>                       The interslice shear forces <em><b>X</b></em> can be expressed in terms of the interslice normal forces <em><b>G</b></em> using <a href=#assumpINSFL>A: Interslice-Norm-Shear-Forces-Linear</a> and <a href=#GD:normShrR>GD: normShrR</a>, resulting in:
4515c4511
<                   Display-Interslice-Shear-Forces: Using <a href=#IM:fctSfty>IM: fctSfty</a>, <a href=#IM:nrmShrFor>IM: nrmShrFor</a>, and <a href=#IM:intsliceFs>IM: intsliceFs</a>, calculate and graphically display the interslice normal and shear force proportionality.
---
>                   Display-Interslice-Shear-Forces: Using <a href=#IM:fctSfty>IM: fctSfty</a>, <a href=#IM:nrmShrFor>IM: nrmShrFor</a>, and <a href=#IM:intsliceFs>IM: intsliceFs</a>, calculate and graphically display the interslice shear forces.
4722c4718
<               Normal-And-Shear-Linear-Only: Changes related to <a href=#assumpINSFL>A: Interslice-Norm-Shear-Forces-Linear</a> are not possible due to the dependency of the calculations on the linear relationship between interslice normal forces and interslice normal and shear force proportionality.
---
>               Normal-And-Shear-Linear-Only: Changes related to <a href=#assumpINSFL>A: Interslice-Norm-Shear-Forces-Linear</a> are not possible due to the dependency of the calculations on the linear relationship between interslice normal forces and interslice shear forces.
smiths commented 3 years ago

@Awurama-N, I prefer to look at the diffs through GitHub's interface. The GitHub interface has nice colour coding. :smile: @Awurama-N, have you made a change that restores stable to something similar to what it was? As @JacquesCarette said there are times when we can talk about normal and shear forces together, but most of the time they should be discussed separately.

Please let me know when there is a specific version of the new stable that you would like me to look at.

balacij commented 3 years ago

This is fixed with #2584